CST 8152 Compilers - Assignment #6 Demonstration required in Labs April 16-17
This assignment builds on Assignment #5. It enhances your recursive-descent parser to recognize expressions, including unary minus and nested parentheses. You are required to code the interpreter in a modular fashion, using only one global token structure.
Given this enhanced version of the familiar Toy Grammar:
<_parser> =>
( <_assignment> | <_print> | <_dump> ) ;
<_assignment> => ID = <_expression>
<_print> =>
PRINT <_expression> ( , <_expresssion> )*
<_dump> => DUMP ( INTEGER )*
<_expression> =><_term> ( (+|-) <_term> )*
<_term> =><_factor> ( (*|/) <_factor> )*
<_factor> =>IDENTIFIER | STRING | INTEGER
| ( <> ) | - <_factor>
1. Turn this grammar into a translation scheme by inserting brief semantic action symbols.
2. Explain (and hand in) the actions associated with each brief action symbol you added.
3. Enhance your scanner to recognize parentheses and commas: ( , )
4. Enhance your interpreter to parse your translation scheme. Follow the Notes carefully.
total = - ( -50 + ( -2 * -10 ) ) * cost + 23 ;
print The cost is , cost, and the total is , total ;
print \n\nThat is , cost * 100, pennies\n ;