Simulation of the front end phase of a C compiler involving the If-Else and While constructs.
This includes:
- Lexical Analysis- Scanning the input and formation of the symbol table.
- Syntactic Analysis- Creation of an Abstract Syntax Tree.
- Semantic Analysis- Verifying Type compatability and generating the Intermediate Code.
- Machine Independent Code Optimization- Constant Folding, Common Sub-Expression Elimination.
To Run Program:
- Place all files in the same directory.
- lex lexer.l
- yacc -d -v parser.y
ss4) gcc y.tab.c -ll - ./a.out<input.txt
Here lexer.l is the lexical analyzer, yacc -d -v parser.y runs parser.y written in YACC and -d creates y.tab.h and -v creates y.output (debugger for parser).