Notes For Compiler Techonology Experiments
刘欣欣,彭绍武
swpeng@scut.edu.cn
2008 Fall
Contents
1 Arrangement of Experiment Course 2
1.1 Schedule of Program . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Time for the Lab . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Due Date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Introduction to TINY+ 4
2.1 Lexical Conventions of TINY+ . . . . . . . . . . . . . . . . . 4
2.2 Syntax of TINY+ . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Main semantics description of TINY+ . . . . . . . . . . . . . 6
2.4 Sample programs in TINY+ . . . . . . . . . . . . . . . . . . . 6
3 Experiment 1: Scanner 7
3.1 Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3 Example output for some TINY+ programs . . . . . . . . . . 8
4 Experiment 2: Parser, Analyzer and Code Generator 9
4.1 Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.2 Requirement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.3 Example output for some TINY+ programs . . . . . . . . . . 10
4.4 Appendix: Attribute grammar . . . . . . . . . . . . . . . . . . 11
1
1 Arrangement of Experiment Course
1.1 Schedule of Program
• Week 14 (11.30-12.6):
- The TINY sample language and it’s compiler
- The TINY+ extension of TINY
• Week 15 (12.7-12.13):
- The lexical of TINY+
- Implement of TINY+ scanner
• Week 16 (12.14-12.20):
- Syntax of TINY+
- Implement the parser of TINY+
• Week 17 (12.21-12.27):
- Semantic of TINY+
- Implement of semantic analyzer and intermediate code generator
for TINY+
1.2 Time for the Lab
• Week 14,15
Monday morning: section 1∼4 (8:50-12:00)
•
Week 16,17
Tuesday afternoon: section 5∼8 (14:00-17:00)
• Venue
Software 06(3∼6): B3-138 (about 180 seats);
Rest people: Second floor of B3, room to be determined.
1.3 Due Date
• Experiment 1 – Implementing a Scanner for TINY+: by the end of
week 16(12.20)
If finish and hand in by the end of week 13(11.29), you will get 10 bonus
points.
2
• Experiment 2 – Implementing a Parser, Semantic Analyzer and Inter-
mediate Code Generator for TINY+: by the end of week 18(1.3)
3