Next: The Assignment
Up: Compiler Theory: Assignment 2
Previous: Guidelines
You will also learn a lot by studying last year's project
(the MOOL language) which was proposed as Assignment 3.
Observe that the archive yacc.tar.gz contains samples
of different steps in the development of a MOOL compiler.
- mool-0.y
- generates a parser
for MOOL programs restricted to classes declarations,
themselves restricted to attributes declarations.
- mool-1.y
- generates a parser
similar to mool-0.y but provides animation to figure out
in which order YACC actions are performed.
- mool-2.y
- generates a parser
similar to mool-1.y. In addition, stores the names of the defined classes.
Hence, this is a preliminary stage for symbol table computations.
- mool-3.y
- generates a parser
similar to mool-2.y. In addition, stores the names of the defined attributes.
It performs also some little checks.
- mool-4.y
- is similar to mool-3.y except that it uses
an external C file mool-aux.c for C code.
You are strongly suggested to proceed in the same way,
carefully step by step:
- Realize a first parser that will parse only category
definitions
(i.e. no domain definitions, no main definitions).
- Realize a second parser from the previous one that will parse category and domain
definitions with very limited statements, say just assignments
(i.e. no alternatives, no loops, no arithmetic/boolean expressions, ...).
- Your third parser will recognize arithmetic/boolean expressions.
- The fourth will add statements,
- Finally, enhance this parser with the construction of symbol tables.
Here again, you can proceed step by step:
- a symbol table for the whole program that will only store category
and domain names,
- a symbol table for each category that will store function declarations,
- a symbol table for each domain that will store its category and its attributes,
- a symbol table for each function definition that will store the domain it belongs to,
its local variables, ...
Next: The Assignment
Up: Compiler Theory: Assignment 2
Previous: Guidelines
Marc Moreno Maza
2004-12-01