Reference no: EM133141578
Question:
Project you are going to generate code in C language.
How the code generation takes place.
B. You will also implement symbol table. I am uploading a small write up on symbol table. Also I did explain it in the class how symbol table works
C. After symbol table implementation, your compiler can catch errors.
Implement catching at least 3 errors - for example using undeclared variable, type mismtach etc etc.
Submit all the files .....Y, .c files (.c and .h written by you and npot generated by bison or flex)
Finally, signup to demo your project. I will ask the grader to prepare a signup sheet on google.
Please read the following before you run the program
1. List of files
================
Filename Description
--------------------------------------------------------------------------------------------------------------------
lexer.l => code for lexical analyzer
semantic.y => code for semantic analysis
types.h => C header (interface) for type checking
types.c => C source for type checking
symbol_table.h => C header (interface) for symbol table
symbol_table.c => C source for symbol table
makefile => a make file for compiling the sources
Tests/test_success => test for success case
Tests/test_error => test for error case
2. Running the parser
=======================
Fire the following commands from terminal:
make
Optionally, you can build the source by executing
bison -d parser.y // generates parser.tab.c and parser.tab.h for use in lexer.l
flex lexer.l // this creates a lex.yy.c file
gcc parser.tab.c lex.yy.c symbol_table.c hash_table.c -o parser // links lex.yy.c, symbol_table.c and hash_table.c to parser.tab.c and generates a parser
You can then run the parser as follows:
./parser
Alternatively, run the scanner with given test cases:
make test_success // for success case
make test_error // for error case
3. NOTES
========
The program is designed using Flex 2.5.35 and bison 3.0.2 on Ubuntu 14.04 machine.
To install both flex and bison run:
sudo apt-get install flex
sudo apt-get install bison
N0te: Need help on part A. not able to generate C code. B & C working fine.
Attachment:- Symbol table-Compiler Design.rar