Professional Documents
Culture Documents
Compiler Design Assignment 2021 Department of Computer Science Page 1 Assignment
Compiler Design Assignment 2021 Department of Computer Science Page 1 Assignment
1. Assume you have the following C++ source program to be analyzed by C++ compiler lexical analyzer.
Identify and list down all possible tokens and their lexemes.(4pts)
Use the following table to write your answers. Token Matching Lexeme
2. Consider the following grammar and remove left-recursion and left-factoring from the grammar if any.(4pts)
A → Ba | C
B → AA
C→B|b
3. Consider the grammar from which you have eliminated both problems and the following questions.
a. Parse the string bbbb using recursive-decent parsing to check that the string belongs to the language defined
by the grammar.(2pts)
b. Parse the string bbbb using non-recursive predictive parsing.(2pts) Don’t forget to construct the LL(1)
parsing table of the parser by yourself .(3pts) #include int Add(int op1, int op2) ( return op1+op2; ) int main()
{ int x=7,y=9; cout<<<x<<<y<<