Question regarding Syntactic Predicates [message #765673] |
Wed, 14 December 2011 08:54  |
Eclipse User |
|
|
|
I have a question regarding syntactic predicates.
Consider the following rule:
expr_power :
expr_before=expr_before
| base=expr_function (=> dexp exp=expr_function);
Note that the rule expr_function is indirectly called by expr_before.
I get the following error during xText generation: (fatal) rule ruleexpr_before has non-LL(*) decision due to recursive rule invocations reachable from alts 1,2. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
Now what I want to accomplish is that the generated parser takes the second alternative, base=expr_function (=>dexp exp=expr_function), whenever the token dexp is seen in the lookahead (dexp is the terminal '**'). Therefore, I put a => in front of dexp.
A problem might be, that expr_function may consume more than one token, so this seems unresolvable by look-ahead only.
Looking at the above problem I see that a derivated problem is that I'm reluctant to put a => in front of the expr_before or expr_function because I do not want to prefer one over the other. Both are important options and also similar as expr_before indirectly calls expr_function
You may think of the following model rule: expr_before: expr_function | (other options...);
I want to add that the grammar from which the rules are originating is compiling fine with SableCC. Therefore it is a valid LALR(1) grammar.
I'm puzzled about what I can do to resolve the non-LL(*)-decision error.
Do you have any suggestions? Is this resolvable by syntactic predicates?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03536 seconds