[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Shift reduce errors due to embedded actions
From: |
Axel Kittenberger |
Subject: |
Re: Shift reduce errors due to embedded actions |
Date: |
Tue, 9 Oct 2001 19:24:09 +0200 |
> i have developed a parser for a language similar to c to generate the cross
> reference information of variables and function names used in the source
> code.
> from the embedded actions in the rules section of bison, i invoke a
> function to generate cross reference information about the variables in the
> program, which leads to shift reduce errors.
> how can i avoid getting the shift reduce errors due to embedded actions in
> the rules section of bison?
> is there any way where i can do away with embedded actions while achieving
> the purpose of generating the cross reference information?
Well the answer is simply, but the actions at the end....
I the parser has something like
A B C {action1}
A B D {action2}
there is no problem...
but if it has
A {action1} B C
A {action2} B D
The parser cannot decide when it looked at A (and looked forward to B) if it
shall execute action1 or action2,
as far I understood parser stuff, this is a limition of bisons LALR
algorithm, which is LR(1). (1 look ahead), LR(n) is theoretically possibly,
but I don't know of a open implementation of it. Altough I don't know too
much about this parser theory stuff, so please correct :o)
- Axel
--
|D) http://www.dtone.org
Re: Shift reduce errors due to embedded actions, David Durham, 2001/10/15