LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-20-2004, 04:44 PM   #1
gr33ndata
Member
 
Registered: Aug 2003
Location: DMZ
Distribution: Ubuntu
Posts: 144

Rep: Reputation: 15
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++) ??
 
Old 02-22-2004, 01:19 AM   #2
excel28
Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 72

Rep: Reputation: 15
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.
 
Old 02-22-2004, 07:41 AM   #3
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Ya, LEX and YACC are definitely C tools. There is support for C++ in flex but it is considered "experimental".
 
Old 11-18-2007, 01:34 AM   #4
a1ora0
LQ Newbie
 
Registered: Aug 2007
Location: Mysore(KAR), INDIA
Distribution: SLACKWARE12
Posts: 25

Rep: Reputation: 15
Unhappy

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....
 
Old 11-18-2007, 05:12 PM   #5
Fidori
LQ Newbie
 
Registered: Oct 2007
Location: Finland
Distribution: Slackware
Posts: 27

Rep: Reputation: 17
Slackware 12.0 contains flex.

Use -lfl option instead of -ll.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
does ubuntu have lex and yacc,how to use them?? akshay_jp Linux - Software 4 05-26-2010 06:36 PM
Lex and Yacc on Federo 2.0 vivekian Fedora 6 05-20-2006 09:09 AM
Error in Makefile for Lex and Yacc oulevon Programming 2 10-24-2005 12:52 AM
Lex and Yacc on Mandrake 9.2.2 Anuradha Linux - Software 0 07-02-2005 03:32 AM
Lex & YACC coolfrog Programming 3 09-25-2004 07:00 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration