CS331 Compilers Project---Phase 4

CS331 Compilers Project

Phase 4

SEMANTIC ACTIONS

 

With the integration of semantic routines into the project as it exists so far, the project will be complete, and you should have a working generator for an Intermediate Code representation of any valid program written in the subset of Pascal outlined in Appendix B of your text.

Error handling Semantic errors are detected by the semantic action routines, and include such things as mismatches in number and type of actual and formal parameters in a procedure call, any of the various kinds-of-objects used in the wrong context, array without subscripts (or simple variable with subscripts), type clashes in arithmetic statements. etc. Each of these should generate an appropriate error message, but the parse should continue thereafter.

Note that undeclared and multiply declared variables are detected when a semantic routine calls the symbol table routines. You can avoid printing a message every time the undeclared variable is encountered in the source---i.e., print the message only the first time the variable is encountered by adding a flag to the symbol table entries that can be used to indicate that the variable was entered into the table as the result of an error condition. Similarly, when a simple variable is referenced as if it were an array, you can set a flag to indicate this in the symbol table entry for that name so that subsequent illegal references do not generate the same error over and over again.

Output

Instructions for submission are in submission instructions.