Flex / Bison Multiple parser question

Andrew Cheadle <amc4@doc.ic.ac.uk>
Fri, 15 Jun 2007 14:38:30 +0100

          From comp.compilers

Related articles
Flex / Bison Multiple parser question amc4@doc.ic.ac.uk (Andrew Cheadle) (2007-06-15)
Re: Flex / Bison Multiple parser question dickey@saltmine.radix.net (Thomas Dickey) (2007-06-18)
Re: Flex / Bison Multiple parser question dickey@saltmine.radix.net (Thomas Dickey) (2007-06-20)
| List of all articles for this month |

From: Andrew Cheadle <amc4@doc.ic.ac.uk>
Newsgroups: comp.compilers
Date: Fri, 15 Jun 2007 14:38:30 +0100
Organization: Department of Computing, Imperial College London
Keywords: parse, design, comment
Posted-Date: 16 Jun 2007 10:20:52 EDT

Hi,


I am trying to coordinate multiple flex / bison parsers, with their
own lex/yacc grammars, under a single 'master parser' but am having
trouble in threading the FILE stream pointer, yyin, through to (and
back from) each parser. Currently I am forced to associate a FILE
stream with each sub-parser for the file undergoing parsing and each
of the parsers must consume lines not relevant to them until the
section of interest is found - it is only at this point that
sub-parsing proceeds.


Not only is this inefficient, but I am also unable to handle multiple
occurrences of sections that are relevant to a particular parser
within a single file.


Can anyone please suggest how I can solve this problem, I haven't as
yet found a successful way to pass yyin off to these
sub-parsers. Obviously as per the lex book, I'm already using the
macro renaming tricks to cooordinate the parsers under a single master
control parser.


Many thanks for any help that can be provided.


Cheers


Andy


--
*********************************************************************
* Andrew Cheadle email: a.cheadle@doc.ic.ac.uk *
* Department of Computing http://www.doc.ic.ac.uk/~amc4/ *
* Imperial College London *
*********************************************************************
[I have never seen an application that actually needed multiple lexers,
since you can get the same effect in a single lexer by using start
states. Multiple parsers are pretty rare too, since you can combine
them as well by stuffing a per-grammar initial symbol. Tell us what
you're really trying to do, and we can probably offer more useful
advice. -John]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.