12.9 Testing

Testing of the complete compiler was a long process. The following general steps were taken in the order shown:

The Scanner: yylex() within the yacc input file miniC.y was separately tested in three steps:

  1. First, without any Symbol Table activity, just to check if it did scan and detect required Lexical atoms.
  2. The Symbol Table routines were tested separately for creation insertion and access to the Symbol Table. This was simplified to some extent because we used well-tested Tree-base Tree-ADT functions.
  3. The Symbol Table access statements in the Scanner were activated and Scanner plus Symbol Table were tested together.

Parser: The Parser generated by yacc from the attributed grammar was tested in the following steps:

  1. The grammar was tested by inserting “stubs” as action terms in the basic grammar.
    1. The basic grammar for expr and stmt was tested first. All conflict resolutions done by yacc were checked and adjusted where necessary in a couple of cases.
    2. The aggregating constructs like stmtlist, arglist, etc. were tested
    3. The control constructs like IF-THEN-ELSE, WHILE-DO, etc. were tested.
    4. The remaining grammar was tested.
  2. The stubs were replaced by actual action statements for the raw assembly output. No attempt at any kind of optimization was done, but correct instruction sequences for control constructs and function calling conventions were achieved.
  3. The generated assembly code was tested by assembling and linking it via as and ld. This exercise would provide inputs for later implementations of code generators.
  4. As the FPU is used extensively, gdb was used to check and debug the floating-point instruction sequences. See Section 12.10 for further details.

Semantic analysis: The stubs were replaced by actual action statements and tested again in the same order as above, but this time, the emphasis was on achieving correct RPN, 4-tuple and raw assembly outputs.

Code generation: The support libraries macros.S and builtinsa.S were tested. The code generators for RPN (i.e., *.AST to *.S) and 4-tuple (i.e., *.MAT to *.S) were tested.

Type checking and Optimization: Only a few of the optimization possibilities are actually implemented and they were checked the last.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.181.36