help-bison
[Top][All Lists]
Advanced

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

Re: Bison and an one-parse interpreter


From: Hans Aberg
Subject: Re: Bison and an one-parse interpreter
Date: Fri, 2 Aug 2002 12:53:57 +0200

At 15:30 +0530 2002/08/02, address@hidden wrote:

BTW, your subject title seems to be wrong: Please select a new title for
each new problem.

>a: Token1 Token2
>{
>     /*Non recoverable operation*/
>}
>
>Now if I have a input set of tokens like
>
>Token1 Token2
>
>things are fine
>
>But if I have a input set of tokens like
>
>Token1 Token2 #
>(where # is a forbidden token)
>
>Then first the action code for rule a is executed and then the error
>handler for the parser is invoked since
>there is a token that is not accepted by the parser.
>
>The problem is once the action code for a is executed then this cannot be
>recovered from.
>How do we handle this kind of a case?

Error handling is somewhat tricky when using parsing algorithms like the
LALR(1) that Bison is using, because it compacts the parsing table by
merging the states in a manner that when an error is detected, even though
no additional token is shifted, some additional actions may be executed
before the error handling starts. This is the price paid for getting a more
compact parsing table.

So I suspect that if very exact error handling is needed, one should use
the full LR with a table compaction algorithm that does not merge states in
this manner. But that will probably not become available to you:

So, I figure you will have to build a closure that does not execute your
unrecoverable code immediately, and you will have to execute the closure
code at a later point in time when you are sure the parsing has passed
without errors.

  Hans Aberg





reply via email to

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