Presentation is loading. Please wait.

Presentation is loading. Please wait.

Honors Compilers The Course Project Feb 28th 2002.

Similar presentations


Presentation on theme: "Honors Compilers The Course Project Feb 28th 2002."— Presentation transcript:

1 Honors Compilers The Course Project Feb 28th 2002

2 The Goal Write a compiler for a subset of Algol-68 Write a compiler for a subset of Algol-68 The compiler to be written in its own language (i.e. in the chosen subset) The compiler to be written in its own language (i.e. in the chosen subset) Targetted to MMIX Targetted to MMIX Bootstrapped (Compiler can compile itself) Bootstrapped (Compiler can compile itself)

3 The Language to be Compiled A subset of Algol-68 (roughly Algol-68S) A subset of Algol-68 (roughly Algol-68S) You get to choose the exact subset You get to choose the exact subset Required elements Required elements int, bool, char primitive modes int, bool, char primitive modes ref, [], struct, proc modes ref, [], struct, proc modes Normal declaration and statement forms Normal declaration and statement forms Including if/endif and do/od loops Including if/endif and do/od loops All ordinary expression forms All ordinary expression forms Compile a single procedure (acts as main) Compile a single procedure (acts as main)

4 Optional Language Elements 1-d arrays required, 2-d etc optional 1-d arrays required, 2-d etc optional Union modes optional Union modes optional Floating-point processing optional Floating-point processing optional Garbage collection optional Garbage collection optional Case/esac optional Case/esac optional Implement separately compiled modules Implement separately compiled modules Good error messages Good error messages

5 Optimization Aim for a reasonable level of code quality Aim for a reasonable level of code quality At least minimal register allocation At least minimal register allocation Preferably attempt at least some global optimization Preferably attempt at least some global optimization

6 Input/Output You must be able to read and write files (treated as a sequence of char) You must be able to read and write files (treated as a sequence of char) Exact provision of facilities is up to you Exact provision of facilities is up to you

7 Lexical Structure Standard Algol-68 lexical elements Standard Algol-68 lexical elements Use upper case for bold, lower case for non-bold. Use upper case for bold, lower case for non-bold. Lexical structure to be defined by your second assignment. Lexical structure to be defined by your second assignment.

8 Third assignment Due right after the break Due right after the break Exact description of subset you will implement Exact description of subset you will implement Indicate possible optional additions Indicate possible optional additions Provide BNF of language grammar Provide BNF of language grammar

9 Fourth Assignment Take grammar you devised for your subset. Take grammar you devised for your subset. Modify grammar to be acceptable as bison input, and use output bison to parse a small program. Modify grammar to be acceptable as bison input, and use output bison to parse a small program.

10 Fifth Assignment Provide complete design document for compiler Provide complete design document for compiler Exact details of what is to be implemented Exact details of what is to be implemented Internal data structures Internal data structures Format of intermediate files Format of intermediate files Details of algorithms used Details of algorithms used

11 Implementation Language To be implemented in its own language To be implemented in its own language Final version must be able to compile itself Final version must be able to compile itself So you define the implementation language as well as the language to be compiled. So you define the implementation language as well as the language to be compiled.

12 The Target Language Generate MMIX assembly language Generate MMIX assembly language To be assembled and run on MMIX assembler To be assembled and run on MMIX assembler

13 Compiler Organization Organize compiler as set of separate programs, e.g. parser, semantic analyzer, optimizer, code generator. Organize compiler as set of separate programs, e.g. parser, semantic analyzer, optimizer, code generator. Programs communicate by means of files Programs communicate by means of files Carefully define format of these files Carefully define format of these files

14 Bootstrapping Some different methods Some different methods Write crude translator from Algol-68 subset to C (e.g. PERL script) Write crude translator from Algol-68 subset to C (e.g. PERL script) Write crude translator from C to Algol-68 Write crude translator from C to Algol-68 Write in Algol-68 and use some existing A68 compiler or translator Write in Algol-68 and use some existing A68 compiler or translator

15 What to Hand In Commented source code Commented source code Set of sample programs used to test compiler, with output from MMIX run, and MMIX assembly language. Set of sample programs used to test compiler, with output from MMIX run, and MMIX assembly language. Standard class bench mark (to be supplied later) run on instrumented MMIX simulator. Standard class bench mark (to be supplied later) run on instrumented MMIX simulator.

16 Due Date Last Day of the Exam Period Last Day of the Exam Period Extensions possible Extensions possible But not if you want to use grade to avoid exam! But not if you want to use grade to avoid exam!


Download ppt "Honors Compilers The Course Project Feb 28th 2002."

Similar presentations


Ads by Google