Next: Computing symbol tables
Up: Writing a MOOL compiler
Previous: Writing a MOOL compiler
A first step is probably to write a flex/lex program and yacc program
in order to obtain a parser for a MOOL program.
The only goal of this parser is
to check whether an input text file is a valid MOOL program or not,
that is a program which can be generated by the above grammar.
- So the flex/lex program and the yacc program implements
the grammar of MOOL described above.
- And the actions of the yacc program are limited
to message printing.
Since the grammar of a true programming language like MOOL is more
complicated than the little examples of a lecture, one should divide
this task into subtasks.
- First one could write a parser for the top level
of the grammar only.
To do so one can add the following dummy rules.
ArithmeticExpression |
|
1 |
Body |
|
id |
- Second for the middle level (bodies) by adding dummy rule like
BooleanExpression |
|
true |
- Lastly for the low level (arithmetic and boolean expressions).
Next: Computing symbol tables
Up: Writing a MOOL compiler
Previous: Writing a MOOL compiler
Marc Moreno Maza
2004-12-01