CST 8152 - Assignment Six

Topic: The interpreter Value Stack

This page last updated: Sunday September 27, 1998 01:07

Deliverables for this assignment:

Due: 6pm, Thursday April 30.  This is the final date for marked submissions of this assignment.

Hand in on paper and diskette:

  1. on paper, submit:
    • a description of your testing strategy -- what did you test and why
    • the error-free output (or the best you can do!) from processing the entire sample input file a5test.txt
    • any other test output that demonstrates the features of your parser, such as ability to do panic-mode error recovery, good error messages, etc.
  2. on a properly labelled diskette, submit:
    • Your complete source code, object files, and executable for your assignment, ready to run.
    • All your input test files, labelled test1.txt, test2.txt, etc.
    • All the output files from your testing, labelled test1.out, test2.out, etc. to correspond with the input test file names.  You may choose any file names as long as the input files end in ".txt" and the corresponding output files end in ".out".

The submission must follow the online course submission standards, including an Assignment Submission Label for both the paper and the diskette submissions, and a Table of Contents for the paper submission. (The Label and Contents may be on the same exterior cover page.)

Purpose:

This assignment generates the arithmetic output missing from the previous assignment, using a semantic actions value stack.

You may use the main() program from the previous assignment to test your Parser (or, you may write your own driver).

Instructions:

Part 0 (optional but highly recommended)
Get the MEM package and install it in a simple program.  Learn how it works.   Then install it in this assignment, and use it all subsequent assignments.  It will save you a lot of debugging time.
Part 1
Enhance your scanner to handle the new Token structure definition containing the union.   Your scanner must convert an unsigned integer into its numeric value (using the C library function sscanf()) and store it in the numeric part of the Token union before returning.   (Optional: Make sure the conversion works and does not overflow.)  You may want to use the fixme-scanner.h and fixme-scanner.c source files as a model.
Part 2
Refer to the semantic action symbols  you inserted into the translation scheme based on Program Grammar #2 last assignment.  Use the method described in class to write code for the pseudocode symbols you inserted.   Take advantage of the utility functions and the execute() function supplied in the new fixme-parser.c source file and of the stack functions supplied in the fixme-stack.c source file.

Since handling identifiers requires a symbol table, and we don't yet have one, we can't yet implement the correct semantic actions for the two productions that involve identifier tokens.  Here are some debugging substitute actions you should use until you have a working symbol table:

       factor --> TT_ID {push an integer zero Item on the stack}
   asst --> TT_ID {eval;push} '=' expr {pop;pop;print debug message}


The debug message would say something like "Parser would store value '%s' into identifier '%s'.", using the two popped operands from the stack.  Remember to free the memory of the popped operands.  The a5test.txt file contains no identifiers, so these substitute productions will not be used when processing that input file; but, other files that do contain assignment statements will work.
Part 3
Test your program on every different type of input you can think of.  Document your testing strategy and submit a summary of what you did and why.  Try your program on the a5test.txt input file in the source directory and submit it as part of your suite of test output. Your output should resemble my sample output.

For incorrect input, make sure your Parser's semantic error messages give enough detail to locate the error.  See my sample error messages for guidance.

Source and Sample Output directory

Copy these source files and modify them according to the assignment instructions.  The header files are examples only; you are not obligated to use them.  The only places you need to insert code are flagged with "//FIXME" in the source files.

The output of running the Parser using the a5test.txt file as input is in the output.txt file.  Sample semantic error messages are in the errors.txt file.

Testing


Ian D. Allen CST8152 Home Page

This page last updated: Sunday September 27, 1998 01:07