[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
I am using sablecc to parse some if statements, the
grammar is as follows:
general_expression then [true]:statement |
general_expression then [true]:statement else statement;
After run SableCC, I got the following error
conflict in state [stack: TIf PGeneralExpression TThen
PStatement *] on TElse
[exec] [ PIfStatement =
TIf PGeneralExpression TThen PStatement * TElse
PIfStatement = TIf PGeneralExpression TThen PStatement * ] fol
lowed by TElse
The message basically says that there is a
reduce/shift conflict after it sees the
keyword "else". I would like the code behaving do
shift first. Any suggestion?
Also I look at simplecc.sablecc sample, it looks
like they have similar grammar to
define the "if" statements, just wondering how they
can avoid the problem.
Thanks a lot.