On 2006-04-06, at 18:49:20 +0200, Akim Demaille wrote:

> >>> "Marcus" == Marcus Holland-Moritz <[EMAIL PROTECTED]> writes:
> 
>  > Hi,
>  > I'm using bison for a C parser [1], for which I'm currently rewriting
>  > the part that parses expressions.
> 
>  > While being at it, I wondered if it's possible to reuse a certain part
>  > of a bison generated parser, e.g. by setting a different %start token
>  > at runtime.
> 
> I use the following technique.
> 
> Suppose you want to branch on nonterminals foo and bar.  Introduce
> fresh tokens START_FOO and START_BAR, and use the following real
> axiom:
> 
> start:
>   START_FOO foo
> | START_BAR bar
> 
> then the trick is to have your scanner pass either START token first.

Cool, it seems like that was just what I was looking for.
I'll have a closer look when I've overcome my jetlag...

> If you have a bleeding edge bison supporting push parsers, that's
> trivial :)  If you wrote yylex yourself, it shouldn't be too hard.

Yes, I wrote my own yylex.

Thank you very much for your help!

Marcus

-- 
Sattinger's Law:
        It works better if you plug it in.


_______________________________________________
[email protected] http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to