| start | ::= | program ID ; block . | |||||||||||||||||||||||||||||||||||||||
| block | ::= | variables cmpdstmt | |||||||||||||||||||||||||||||||||||||||
| variables | ::= | var vardcls | empty string | |||||||||||||||||||||||||||||||||||||||
| vardcls | ::= | vardcls vardcl ; | vardcl ; | |||||||||||||||||||||||||||||||||||||||
| vardcl | ::= | IDlist : type | |||||||||||||||||||||||||||||||||||||||
| type | ::= | integer |
array[ ICONST ] of integer |
array[ ICONST, ICONST ] of integer
| IDlist
| ::=
| IDlist , ID | ID
| stmtlist
| ::=
| stmtlist ; stmt | stmt
| stmt
| ::=
| ifstmt | fstmt | astmt | writestmt | cmpdstmt
| cmpdstmt
| ::=
| begin stmtlist end
| writestmt
| ::=
| writeln ( exp )
| ifstmt
| ::=
| ifhead then stmt else stmt | ifhead then stmt
| ifhead
| ::=
| if condexp
| fstmt
| ::=
| for ctrlexp do stmt
| ctrlexp
| ::=
| ID := ICONST, ICONST
| astmt
| ::=
| lhs := exp
| lhs
| ::=
| ID |
ID [ exp ] |
ID [ exp, exp ]
| exp
| ::=
| exp + exp |
exp - exp |
exp * exp |
ID |
ID [ exp ] |
ID [ exp, exp ] |
ICONST
| condexp
| ::=
| exp != exp | exp == exp | exp <
exp | exp <= exp
| |
You may assume that the program is correct in terms of static
semantics, i.e., no semantic analysis (type checking) is required.
You will write a syntax directed translation scheme that will generate
ILOC code for the above language. You may test the correctness of your
generated ILOC code by running it on the ILOC simulator sim provided in
directory ~uli/cs515/projects/proj1/ILOCsimulator/src on the
ilab machines . This directory
also contains the source code of the ILOC simulator.
If you have specific, overriding,
personal reasons why these dates are unreasonable, you should discuss
them directly with the instructor before the deadline.