[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Multiple Parsers
From: |
Jonathon Duerig |
Subject: |
Re: Multiple Parsers |
Date: |
Sun, 16 Mar 2003 13:52:46 -0700 (MST) |
On Sun, 16 Mar 2003 address@hidden wrote:
> It is required that I have multiple parsers that use the same lexer
> in my project. I am aware of the prefixing notation that would enable
> having multiple parsers/lexers but paired with the same names, and bison
> considers the lex to be prefixed same as the parser spec. And I need to
> be able to invoke each parsers individually. Is there a provision
> natively available in bison/flex to do the above.
I'm not sure if there is native support for it, but you could do a simple
forwarding function. It is assumed that this is in combination with the
prefix option.
/* aparse.y */
%{
#include "RealLexer.h"
%}
/* Bison Stuff */
%%
%%
int ayylex(void)
{
realLex();
ayylval = getRealLexSemanticValue();
return getRealLexSyntacticValue();
}
And you could do something similar for bparse.y, cparse.y, etc.
In this case, I'm assuming that the parsing runtimes don't overlap, so it
is set up as a simple module. But one could easily convert to sending
around pointers to structs or whatnot if the thing needs to be reentrant.
Hope this helps.
---
Most of what I read is fiction, but the authors don't admit it.
-Jonathon Duerig