How to execute programs in lex tool ubuntu?
Answers
Answer:
Running a Lex and Yacc program
write the lex program in a file and save it as file. l (where file is the name of the file).
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.
Ubuntu does not come installed with a lex and yacc compiler to do so install it first by
1. Opening the terminal
2. type sudo apt-get install flex
3. enter your password
after installation of flex finishes
4. type sudo apt-get install bison
5. enter your pasword.
Successfully Lex and Yacc have been installed on your system.
Running a Lex and Yacc program
1. write the lex program in a file and save it as file.l (where file is the name of the file).
2. open the terminal and navigate to the directory where you have saved the file.l (e.x CD Desktop)
3. type lex filename.l
4. then type cc lex.yy.c -lfl
5. then type ./a.out
Your lex progam will be running now (comment should be correct).
or compiling lex and yacc together
1. write lex program in a file file.l and yacc in a file file.y
2. open the terminal and navigate to the directory where you have saved the files.
3. type lex filename.l
4. type yacc filename.y
5. type cc lex.yy.c y.tab.h -lfl
6. type ./a.out
The lex and yacc will run succesfully now send me your