Hello folks, This time we'll let you know how to configure Lex and Yacc. Sorry its off topic but just came across it so thought of sharing with you. Talking about Lex , "Lex is a computer program that generates lexical analyzers "- wikipedia . Lex and yacc are tools
used to generate lexical analyzers and parsers for more information you visit Lex and Yacc Tutorials.
This tools are not shipped in Any version Ubuntu . So we'll show you how to can get them working in your ubuntu laced machine.
What You will need ?
Steps to Get Lex and Yacc :
Hope you find it usefull , Stay Tuned to The Tech Addas.
This tools are not shipped in Any version Ubuntu . So we'll show you how to can get them working in your ubuntu laced machine.
What You will need ?
- Ubuntu Machine with Internet Connection.
Steps to Get Lex and Yacc :
Step #1: Open Terminal , which would look something like this.(for demo we are kubuntu but dont wory its much similar to ubuntu.)
Step #2: Now Type sudo apt-get install flex , it will connect to repository and do all stuff of installation for you . then type sudo apt-get install bison , this will install yacc alternative .
Step #3: To make sure your lex(~flex) and yacc(~bison) are installed properly just type in termianl which lex and then which yacc , it would look similar to this.
Now your ubuntu machine is ready for Lex and Yacc programs .
For Compiling And Running Lex Proprams:
1) lex sample.l
2) gcc -lfl lex.yy.c
3) ./a.out
After Compiling Lex and Yacc Proprams m getting the following error :
ReplyDeleteshraddha@ubuntu:~$ cd Desktop
shraddha@ubuntu:~/Desktop$ lex ass4l.l
shraddha@ubuntu:~/Desktop$ yacc -d ass4y.y
shraddha@ubuntu:~/Desktop$ gcc lex.yy.c y.tab.c -ll -ly -lm
/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/liby.a(yyerror.o): In function `yyerror':
(.text+0x1c): undefined reference to `rpl_fprintf'
collect2: error: ld returned 1 exit status
Please help in removing the above error
@pooja: This error is due to the reason that you have not provided your own yyerror() . To resolve you should include yyerror() explicitly like this
Deletevoid yyerror(char *s)
{
fprintf (stderr, "%s\n", s);
}