Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 10-06-2006, 06:01 PM   #1
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
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
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
Registered: Apr 2006
Posts: 81

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:35 AM.

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