LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   LEX and YACC with C (http://www.linuxquestions.org/questions/programming-9/lex-and-yacc-with-c-148528/)

gr33ndata 02-20-2004 04:44 PM

LEX and YACC with C
 
Can I use LEX and YACC with a C compiler (GCC), or only C++ compilers (G++ and GCC -X C++) ??

excel28 02-22-2004 01:19 AM

I've only compiled Lex and Yacc files only with C.

The Lex commands should be:
lex LexParse.l <-- makes lex.yy.c file
gcc lex.yy.c -ll <-- to compile the lex file made from previous step. -ll is used tell the compiler to use the lex libraries.

This Yacc command using the Lex file should be:
yacc Yacc.y <-- makes y.tab.c file
lex LexParse.l <-- makes lex.yy.c file
gcc lex.yy.c y.tab.c -ly -ll <-- to combine the lex and yacc file together.

jtshaw 02-22-2004 07:41 AM

Ya, LEX and YACC are definitely C tools. There is support for C++ in flex but it is considered "experimental".

a1ora0 11-18-2007 01:34 AM

Hi..

am using slakcware 12..

when i run "lex pg.l"
it creates lex.yy.c

but then when i run "gcc lex.yy.c -ll"
i get this error....
Quote:

root@anil:~/dwnlds# gcc lex.yy.c -ll
/usr/lib/gcc/i486-slackware-linux/4.1.2/../../../../i486-slackware-linux/bin/ld: cannot find -ll
collect2: ld returned 1 exit status

plz help me....

Fidori 11-18-2007 05:12 PM

Slackware 12.0 contains flex.

Use -lfl option instead of -ll.


All times are GMT -5. The time now is 07:02 PM.