[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Shift reduce errors due to embedded actions
From: |
Hans Aberg |
Subject: |
Re: Shift reduce errors due to embedded actions |
Date: |
Tue, 16 Oct 2001 10:37:12 +0200 |
At 09:52 -0500 2001/10/15, David Durham wrote:
>I short (and a bit over simplified), inserting the extra mid-rule
>actions causes bison to have to execute that action before going too
>much further in the input (1 token or 1 reduction, not sure)...
One should be careful to note that Bison may or may not may a token
lookahead as needed. This means that if the lexer executes an action in the
token that follows, Bison may or may not execute that before the mid-rule
action.
For example,
A: B { action_1 } C { action_2 }
will by Bison be replaced by something like
A: B @1 C { action_2 }
@1: { action_1 }
If the lexer executes action_C when reading the token C, then action_1 may
or may not have been executed before action_C, depending on whether the C
is needed as a lookahead or not.
> So if
>some rule cannot be distinguished from another rule up to that point of
>the mid-rule action, it can't say, do you action, then realize, 'oh I
>didn't need to do that...' then undo the results of that action...
Bison never backtracks, so I think that reasoning in terms of "undoing
actions" may be confusing as to how Bison really works: Nothing is really
ever undone.
Hans Aberg
Re: Shift reduce errors due to embedded actions, David Durham, 2001/10/15
- Re: Shift reduce errors due to embedded actions,
Hans Aberg <=