2020 Compiler Design Lab Programs
Ubuntu does not come installed with a lex and yacc compiler to do so install it first by
- Opening the terminal
- type
sudo apt-get install flex - enter your password
after installation of flex finishes
- type
sudo apt-get install bison - enter your password.
Lex and Yacc have been Successfully installed on your system.
Running a Lex and Yacc program
- write the lex program in a file and save it as
file.l - open the terminal and navigate to the directory where you have saved the file.l (e.x
cd Desktop) - type
lex filename.l - then type
cc lex.yy.c -lfl - then type
./a.out
Your lex program will be running now (comment should be correct). or compiling lex and yacc together
- write lex program in a file
file.land yacc in a filefile.y - open the terminal and navigate to the directory where you have saved the files.
- type
lex filename.l - type
yacc -d filename.y - type
cc lex.yy.c y.tab.c -lfl - type
./a.out
The lex and yacc will run succesfully now