Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Question regarding Syntactic Predicates(is it possible or not?)
Question regarding Syntactic Predicates [message #765673] Wed, 14 December 2011 13:54 Go to next message
Hannes F is currently offline Hannes FFriend
Messages: 7
Registered: November 2011
Junior Member
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?
Re: Question regarding Syntactic Predicates [message #765691 is a reply to message #765673] Wed, 14 December 2011 14:31 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
The error message told you what you need to do "left-factoring".
Look at any of the articles/examples that explains Expressions.

Regards
- henrik

On 2011-14-12 14:54, Hannes wrote:
> 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?
Re: Question regarding Syntactic Predicates [message #765696 is a reply to message #765691] Wed, 14 December 2011 14:42 Go to previous message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
For some more info on syntactic predicates and links to those articles about expressions: http://dslmeinte.wordpress.com/2011/12/05/using-syntactic-predicates-in-xtext-part-1/ (yes, another shameless plug)

Previous Topic:Where is Guava?
Next Topic:Embed XText Editor on BPMN Model Editor label connections
Goto Forum:
  


Current Time: Thu Apr 25 17:13:53 GMT 2024

Powered by FUDForum. Page generated in 0.03704 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top