HINTS TO START PROJECT 2

Once project 1 is coded and runs correctly you can start on project 2.

  1. The grammar for project 2 is the "upper part" of the main project grammar: all nonterminals from program down to expr but with the productions for expr changed to:

    expr --> NUM | BCONST

    Modify the project 2 grammar to eliminate left recursion and also to left-factor it.

  2. Use the lexical analyzer, symbol table manager, and symbol table initializer from project 1.

  3. Code a match function as described in section 2.4 of these notes and the text.

  4. Document your modified grammar with a large comment in your code.

  5. Code a function for each nonterminal of your modified grammar as described in section 2.4 of these notes and the text. For the moment, each function has no arguments and no returned value. To help you code the functions start each of them with a comment showing the productions for the nonterminal.

  6. Code the main program of project 2 to initialize the symbol table; open the I/O files; call the lexical analyzer once to put the first token in lookahead (and its attribute pointer in attributes ); call the function for the program nonterminal once; close the I/O files; and exit.

  7. Debug your code with the test file for project 2. Since there are no syntax errors in the test file your code should never report an error.

  8. Later on we will give hints for adding semantic actions and code generation operations to complete project 2.

Kenneth E. Batcher - 9/17/2001