This is a compiler for the PL\0 language.
program = block "." .
block = [ "const" ident "=" number {"," ident "=" number}* ";"]
[ "var" ident {"," ident} ";"]
{ "procedure" ident ";" block ";" }* statement .
statement = [ ident ":=" expression
| "call" ident
| "?" ident | "!" expression
| "begin" statement {";" statement }* "end"
| "if" condition "then" statement ["else" statement]
| "while" condition "do" statement ].
condition = "odd" expression |
expression ("="|"#"|"<"|"<="|">"|">=") expression .
expression = [ "+"|"-"] term { ("+"|"-") term}*.
term = factor {("*"|"/") factor}*.
factor = ident | number | "(" expression ")".
- translate x := y
- constant folding
- calls cannot be the first instruciton in a BB
- problem with useless variables that might be assigned to the same register as one useful variable
- InputStat
- Test functions
- Functions can call only other functions that have been previously defined (FEATURE)
- at least one instruction after begin-end blocks
- In the construction of the CFG if we have 2 omonymous functions one will overwrite the CFG of the other one (only the graph because of the name)
- Test the for loop