help-bison
[Top][All Lists]
Advanced

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

Re: Odd parser behaviour


From: Heiko Wundram
Subject: Re: Odd parser behaviour
Date: Mon, 25 Sep 2006 09:01:55 +0200
User-agent: KMail/1.9.4

Am Montag, 25. September 2006 08:49 schrieben Sie:
> <snip grammar info>
>
> Except that it actually takes the entire "opt_C opt_D E" path - if an A
> is seen, it will reduce opt_C and opt_D then error out on the "E" rule,
> while it should have reduced up to the "bar" nterm, and only try to
> error out then (except that foo's action would have YYACCEPTed the
> grammar before it reaches the point at which an error should be
> produced).

How do you expect it to reduce to A before erroring out? There's absolutely no 
reduction path that justifies

foo *-> A

as the only sensible (meaning, justified by a rule) reduction at the point 
you're referring to is opt_C and opt_D; these are also only reduced because 
of bison's grammar compression algorithm, because actually the parser should 
already error out not finding any matching lookahead in state 1.

Bison reduces everything as far as possible before erroring out (that's a 
general properly of LALR(1)-parsers), but here, there's absolutely no rule 
for it to do what you want, so the error occurs on the shift on the expected 
E.

Maybe, you should change the grammar to  look like the following (which has a 
path to justify "foo *-> A"):

bar -> A star_xyzzy

star_xyzzy ->
           -> star_xyzzy xyzzy

That will reduce an erraneous string to A before erroring out.

Hope this helps!

-- 
--- Heiko Wundram.

  ____      _          _                    ___ _____
 / ___| ___| |__  _ __| | _____ _ __  ___  |_ _|_   _|
| |  _ / _ \ '_ \| '__| |/ / _ \ '_ \/ __|  | |  | |
| |_| |  __/ | | | |  |   <  __/ | | \__ \_ | |  | |
 \____|\___|_| |_|_|  |_|\_\___|_| |_|___(_)___| |_|

FON 0511-59027954
FAX 0511-59027957
Gehrkens.IT GmbH
Mailänder Strasse 2
http://www.gehrkens.it
http://www.xencon.net




reply via email to

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