You are here

Laboratory 6

 Laboratory 6 is an introduction to the csym compiler framework. Begin the laboratory by downloading the csym source code and compile the source code by issuing "make" in your console. This should build an executable named "csym" that can be tested by issuing "make test" in your console. At this point the executable will fail with an error because you have not finished the laboratory yet.

The purpose of this laboratory is to build and print out a symbol table for the C-like language that the csym compiler framework parses. Much of the source code for the project has already been written. To complete the project you will need to modify the following:

  1. The enterblock, leaveblock, and dump functions in the file "sym.c" are stubs and must be completed.
  2. The fname, fhead, ftail, blockdecl, and btail functions in the file "sem_sym.c" are stubs and must be completed.

Completing these functions means that you will need to build up the symbol table correctly and print out the symbol table at the correct time. Complete instructions and more details on the support functions will be given at the beginning of the laboratory.

Reference Output

The reference output for the test input file "temp.c", which is distributed with the project template, is shown below. In the output the first column is the name of the declared variable, the second column is the block level, the third column is the type value, and the fourth column is the defined boolean. The variable name and the block level are the most important elements of the output.

Dumping identifier table
bd_loc2	 5	4	1
b_loc1	 5	1	1
Dumping identifier table
loc1	 4	1	1
loc2	 4	1	1
d_arr	 4	20	1
d_loc	 4	4	1
Dumping identifier table
Dumping identifier table
int_glob 2	1	1
d_glob	 2	4	1

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer