help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Advanced parsing stack operations ...


From: Hans Aberg
Subject: Re: Advanced parsing stack operations ...
Date: Thu, 5 Jun 2003 12:11:21 +0200

At 06:04 +0100 2003/06/05, Ricardo Rafael wrote:
>       using a Bison %pure-parser is there any way to:

I will give my impressions; perhaps some experts can give a better reply.

>          a) test for a Nth look-ahead token (probably N = 2);

No. The Bison current parser just makes a 0 or 1 token lookahead.

>          b) inject more than one token at a time on the parsing stack?
>(e.g.: many YYBACKUP(); in one rule?!).

No. My impression from looking into the output source code of the parser is
that via YYBACKUP() one can only change the current lookahead token with
value, and use that as the new lookahead.

If you would go beyond that via Bison, then a) sounds like you want a LR(n)
parser, which is implementable of course but would take a great deal of
work. As for b) that would probably require a cut of the parser stack, but
it contains  states, not tokens.

You could try some tweaks: Making the lexer read tokens ahead which are put
in a FIFO buffer, sometimes grammar rewriting helps, and you might try the
GLR parser. The GLR parser would split the stack until the time it is known
which line is the right one, whereupon the wrong one is killed. So this
works like an advanced YYBACKUP, even though still at most one token at a
time is read.

If you want to describe your problem somewhat more as why you want these
feature, perhaps somebody can help you with a tweak around it at the Help
Bison list.

  Hans Aberg






reply via email to

[Prev in Thread] Current Thread [Next in Thread]