LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 10-06-2006, 06:01 PM   #1
Millenniumman
Member
 
Registered: Apr 2006
Posts: 81

Rep: Reputation: 15
Implementing yacc/lex


I have been working on making a parser for a file format. yacc/lex were what I was recommended to use. I have read several guides and I have a good beginning grasp of it. I have been able to make a program that does basic lexical analysis on strings and prints an analysis of command line input.

The problem I am having is that I cannot find a guide anywhere on how to implement the parser in a C++ program. I am planning a C++ class for the file format, such that a file object is initialized with a file path and it then uses the parser to gather information from the file and store it in objects.

How do I call the parser from another file, rather than compile it into an executable?

I am using the GNU tools.
 
Old 10-06-2006, 10:44 PM   #2
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
Quote:
Originally Posted by Millenniumman
How do I call the parser from another file, rather than compile it into an executable?
Any stuff you're using either has to be linked together at compile time (or more correctly, at link time; this is the easy way, with direct access) or has to talk to another process during runtime (this is harder, as it then has to deal with the protocol of its communication mechanism, and it's slower; I don't know of any compilers that work this way, with the lexer and parser separate processes). Trust me, you want your parser to be linked into the overall binary.

(That is, if I understand your question correctly. )
 
Old 10-07-2006, 10:49 AM   #3
Millenniumman
Member
 
Registered: Apr 2006
Posts: 81

Original Poster
Rep: Reputation: 15
So, if I understand correctly, I just compile the y.tab.c and lex.yy.c together with my fileClass.cpp? In that case, does the yacc file need a main function?
 
  


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 with C gr33ndata Programming 4 11-18-2007 05:12 PM
lex and yacc tools ? vagrahb Programming 4 05-19-2006 01:38 PM
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 11:28 PM.

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