Design and implement a lexical analyzer for given language using C and the lexical analyzer should ignore redundant spaces, tabs and new lines.
- Save file as
pgm_name.c. - Compile it using gcc by typing
gcc pgm_name.c. - Execute the
./a.outfile.
Write a program to design lexical analyzer using LEX
i) Write a program to check whether the given string is valid according to the regular definition 0(10|01)*.
ii) Write a program to list the identifiers from a given C program.
- Save file as
lexical-lextool.l. - Run
lex lexical-lextool.l. - Then a file
lex.yy.cwill be generated. - Compile it using gcc by typing
gcc lex.yy.c -lfl - Execute the
./a.outfile.
Write a program to design a parser for arithmetic expressions using YACC
i) Write a program to check the syntax of switch statement in C.
ii) Write a program to recognize a valid arithmetic expression that uses operator +, β , * and /.
iii) Program to recognize a valid variable which starts with a letter followed by any number of letters or digits.
iv) Write a program to implement arithmetic calculator.
- Save lex file as
YourFileName.land YACC file asYourFileName.y. - Run
lex YourFileName.l. (Here this command creates acfilelex.yy.c) - Compile YACC by using
yacc -d YourFileName.yandy.tab.cfile is generated. (Here the tokens are generated and stored intoy.tab.c) - Now Compile it together using gcc by typing
gcc y.tab.c lex.yy.corgcc y.tab.c -ll -ly. - Execute the
./a.outfile.
Write a program to design a recursive descent parser
- Save file as
pgm_name.c. - Compile it using gcc by typing
gcc pgm_name.c. - Execute the
./a.outfile.
Write a program to simulate FIRST and FOLLOW of any given grammar
- Save file as
pgm_name.c. - Compile it using gcc by typing
gcc pgm_name.c. - Execute the
./a.outfile.
-
Write a program to implement LL (1) parser.
-
Write a program to implementation of Operator precedence parsing.
-
Write a program to perform constant propagation.
-
Write a program to generate Intermediate Code for arithmetic expressions.
-
Write a program to design a code generator for arithmetic expressions.
-
Write a program to find Ξ΅ β closure of all states of any given NFA with Ξ΅ transition.
