CSc 553 : Programming Assignment 0 (Syntax Tree Traversal)
Mon Aug 27, 2018
Due: 11:59 PM on Mon Sept 3, 2018
This assignment is for your benefit only, to get acquainted with the
syntax tree code: it will not be graded for credit.
You don't have to turn in your code.
You are to take the front end of a compiler for
C--, provided in
the file FrontEnd.tar.gz, and write your own
code to traverse it and print out the syntax tree and symbol table for
each function (some example inputs are given in the file
ExampleInputs.tar.gz).
The point of this exercise is to get you familiar with the
symbol table and syntax tree code, so that you can use it to write your
own final code generator. (Also, it gives us an opportunity to find
any bugs in my code before we start the real project.)
The files can be unpacked using the Linux command tar. See
man tar for details.
After you have unpacked this archive, see the file README for a
high-level overview of the system. Look through the code after this for
details of the data structures.
If the symbol DEBUG is defined when compiling the code (e.g., by
adding "-DDEBUG" to the variable CFLAGS in
Makefile), it will invoke a syntax tree print routine that I have written.
This code is defined in print.c.
The file protos.h defines prototypes for a number of accessor
functions for syntax tree nodes. You can use these to traverse the tree.
Call your print routines from the file parser.y, at the place
where my print routine is called:
#ifdef DEBUG
printf("@@FUN: %s\n", $3);
printf("@@BODY:\n");
printSyntaxTree(currfnbodyTree, 4, 0);
printf("-----\n");
#endif
I am happy to answer questions about the
code, but want you to make at least some effort to understand the code
first.