|Lex/Yacc: Multiple parsers in one file firstname.lastname@example.org (Christoph B.) (2006-03-29)|
|Re: Lex/Yacc: Multiple parsers in one file email@example.com (Joshua Shinavier) (2006-04-01)|
|Re: Lex/Yacc: Multiple parsers in one file firstname.lastname@example.org (Oliver Bandel) (2006-04-03)|
|Re: Lex/Yacc: Multiple parsers in one file email@example.com (Paul Ogilvie) (2006-04-08)|
|From:||"Christoph B." <firstname.lastname@example.org>|
|Date:||29 Mar 2006 18:55:45 -0500|
|Keywords:||parse, question, comment|
|Posted-Date:||29 Mar 2006 18:55:45 EST|
Thanks for supporting me on my C/C++ problem, finally I got it fixed and
my parser is working pretty fine now. Unfortunately the next problem is
to be solved. I need to merge the input of two different files (or file
types), that need different parsers. They do not need to be parsed
simultaneously but because these files are related quite closely to each
other, I would prefer to put the parsers together in one.
Does anyone know where to find a simple example on how to use mulitple
parsers in one file? Or maybe someone can give me instructions or a
Again, I believe I should mention that I am really a newbie on lex/yacc
and that I am quite new to coding C++ as well.
So what I believe I need is two different lex files for two different
syntaces. But one yacc file should be enough I believe. I've been
googling for quite some time, what I found out is that yacc and lex
support a -P parameter that gives the global variables different
suffices. So what I know is that it IS possible to combine multiple
parsers, but I do not know HOW exactly they can be merged.
Thank you very much for your help in advance,
[This has come up before. If you really want different parsers, you put the two
grammars in separate files and use -p to give the parsers different names. If they
are similar, you can often combine them and have the lexer provide a different
initial token so it knows what it's parsing, e.g.:
start: FOO foo-start-rule | BAR bar-start-rule ;
Return to the
Search the comp.compilers archives again.