CST 8152 - Assignment Seven (Bonus/Optional)
Topic: The Symbol Table
This page last updated: Sunday September 27, 1998 01:07
Bonus Assignment
This assignment serves as a make-up/bonus assignment for those people who lost marks on
earlier assignments but managed to get things working correctly later in the term.
Deliverables for this assignment:
Due: 6pm, Thursday April 30. This is the final date for marked
submissions of this assignment.
To get credit for this bonus assignment, I must have your complete source code
available on a diskette. The code must compile and run. Do not use
absolute pathnames such as "A:\stack.h" or "N:\stack.h" in your
#include statements, since I will not have an A: drive or an N: drive when I build your
programs. Use only relative pathnames, e.g. "stack.h". If you don't
know how to make this work, ask someone.
Your program must be able to read the sample input
file and generate output that is similar (not necessarily identical) to the sample output.
Hand in on paper and diskette:
- on paper, submit:
- a description of your testing strategy -- what did you test and why
- the output (including all the error messages) from processing the entire sample
input file a7test.txt; you may need
to modify your error printing function to send error output to standard output instead of
to standard error to enable it to be captured using DOS command line redirection
- any other test output that demonstrates the good features of your parser, such as
ability to do panic-mode error recovery, good error messages, etc.
- on a properly labelled diskette, submit:
- Your complete source code, object files, and executable for your assignment, ready to
run, with only relative pathnames for the #include files.
- 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 course submission
standards, including an Assignment Submission Label for both the paper and the
diskette submissions.
Purpose:
This assignment adds a symbol table to the interpreter,
allowing it to store values in variables using assignment
statements and retrieve the values of those variables from the symbol table.
You may use the main() program from the previous assignment to test
your Parser (or, you may write your own driver).
Instructions:
- Here is a suggested order to tackle this assignment.
- Be sure you take advantage of any code that I write for you!
- Read the frequently asked questions file.
- 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
- Make the item_free()
and item_value()
functions visible by removing the static keyword from their definitions.
Add prototypes for these public functions to the parser.h file.
You will find these two functions useful in implementing the symbol table.
- Part 2
- Using the new fixme-symtab.c
source file template, implement the functions that make up the symbol
table.
- Part 3
- Enhance your scanner to handle Program Grammar #3 that
includes the dump statement.
Insert the appropriate semantic action symbols
into the production for the dump command to serve as a guide in
implementing the parsing function. Write the dump function. Use the
method described in class to write code for the
pseudocode symbols you inserted in the dump command productions.
Use the appropriate functions from the symbol table to do the work. You may
find the updated fixme-parser.c
source file template helpful.
- Part 4
- Modify the execute()
function to handle the assignment statement
using the functions from the symbol table. You may find the updated fixme-parser.c source file template
helpful. Remember to free the memory of the popped operands. Test that
assignment statements work using the dump command to dump the symbol
table.
- Part 5
- Modify the factor --> TT_ID production to get the type and
value of the identifier from the symbol table and push them on the stack as an item.
You may find the updated fixme-parser.c
source file template helpful.
- Part 6
- 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 a7test.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 error messages give enough detail to locate
the error.
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 a7test.txt
file as input is in the output.txt
file. The input file contains many errors, to test the error handling in your
parser. Be sure you hand in your error messages when you submit your
parser's output.
Testing
- Develop a testing strategy. Decide what you will test, and design input
that tests it. Examples of things you could test:
- Write test input that demonstrates every error message in your code, so you are sure
that all the messages are clear and correct.
- Test borderline cases: empty files, files with no newlines, files with identifiers that
end at EOF, files with strings that have no closing quote, etc.
- Include a description or listing of your input test file(s) (and output, if appropriate)
showing how you tested your program. Don't kill a hundred trees; print descriptions
and short excerpts of your testing input and output if the files are large.
The intent of your test submissions is to convince me that your program works. Short
excerpts of actual program output are usually more convincing than mere words, so give me
at least some sample output.
- No demonstration is required for this Lab; however, I am always pleased to see working
code during lab hours.
Ian D. Allen CST8152 Home Page
This page last updated: Sunday September 27, 1998 01:07