-   Programming (
-   -   LEX and YACC with C (

gr33ndata 02-20-2004 05: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 02: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 file
lex LexParse.l <-- makes lex.yy.c file
gcc lex.yy.c -ly -ll <-- to combine the lex and yacc file together.

jtshaw 02-22-2004 08: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 02:34 AM


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....

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 06:12 PM

Slackware 12.0 contains flex.

Use -lfl option instead of -ll.

All times are GMT -5. The time now is 12:49 PM.