Semantic Actions Phase 1

The first phase of the semantic action part of the project is due Wednesday, April 23.

The semantic actions are the biggest part of the compiler, in part because this is where all the pieces you have developed finally start working together.

If you are using C++ before starting this phase, please consult Compiler File Organization in C++, which provides the overall structure of the files in your compiler.

Once your file structure is set up correctly, do the following in this order:

  1. Set up the semantic action class, including the declarations for the Execute method and the semantic stack. For the time being you do not need to set up the Quadruple array--leave it to a later phase.
  2. Add the following private data members to the class and initialize them as indicated. All of these are boolean variables:
  3. Do not concern yourself with any of the other variables and methods described in the semantic action routines for now.

  4. Implement and test the Execute method, which simply consults the action number passed to it and calls the appropriate semantic action routine. In this phase you will implement only the following actions: 1, 2, 3, 4, 6, 7, 13. Therefore, you need only provide a switch statement that calls these routines (and of course does something meaningful if passed any other action number).
  5. Implement and test the semantic actions listed below, in this order:

    Action 3 is the most involved. Before you start on action 3, make sure the others work, your semantic stack behaves as it should etc.

  6. Implement a "semantic stack dump" routine that prints the stack contents.

A sample header file for C++ is here.

A sample skeleton file for Java is here.