Write an operator-precedence parser for expressions. The parser should handle the following productions:
expr --> | expr MULOP expr |
expr --> | expr ADDOP expr |
expr --> | expr RELOP expr |
expr --> | expr ANDOP expr |
expr --> | expr OROP expr |
expr --> | UNARYOP expr |
expr --> | NOTOP expr |
expr --> | ID LBRK expr RBRK |
expr --> | LPAR expr RPAR |
expr --> | NUM |
expr --> | BCONST |
expr --> | ID |
expr --> | ID LPAR expr_list RPAR |
where expr_list is one or more expressions separated by commas. Click here for a table of the precedence relations.
Write the parser as a function of no arguments that generates quadruples to evaluate an expression and returns a pointer to the symbol table entry for the expression. This function replaces the function in project 2 that evaluates constant expressions so give it the same name. The code in project 2 will call this parser each time it expects to see an expression; this parser will generate quadruples and return a pointer to the caller when it reaches an accept state.
Testing: You can de-bug your project using test3pas as a source file: the output file should look like test3code. To help you de-bug the project test3sym is a listing of the symbol table.
Follow these guidelines when submitting the project. Click here for some hints about the project.