Wednesday, December 1, 2010

Lex, Yacc Installation and Compilation Shell Script

If you don't have lex and yacc install them using the following command.
Fedora Core

# yum -y install flex bison


$ sudo aptitude install flex bison
This script will be very useful for compiling lex and yacc files. Here is the script:

 1 echo SA-OS Script []
 2 echo Generating lex
 3 lex $1
 4 echo compling using yet another compiler compiler
 5 yacc -d $2
 6 echo Creating objects for c files
 7 gcc -c lex.yy.c
 8 echo Creating executable
 9 gcc -o p.out lex.yy.o -ll
10 echo Running executable
11 ./p.out

After saving this in file named

You have to apply the following command to make it executable script.

$ chmod a+x

Now you can run the script like this:

$ ./ lexfilename.l yaccfilename.y

No comments:

Post a Comment