Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Xtext (The rule is left recursive Problem)
Xtext [message #886434] Thu, 14 June 2012 19:17 Go to next message
Eclipse UserFriend
I know it has been discussed many times but I could not resolve it on my own hence the post:

I get the message "The rule 'LSParameter' is left recursive." and "This rule call is part of a left recursive call graph." on the grammer below:

Grammer Snippet:

ArithMathicStatement returns LSParameter:
{ArithMathicStatement}
(left=LSParameter operator+=ArithmeticOperator right=LSParameter)
;

BigArithmatic:
left1=ArithMathicStatement (operatorb+=ArithmeticOperator right1+=LSParameter)*
;

LSParameter returns LSParameter:
(LSBoolean | LSNullLiteral | LSIntLiteral | LSStringLiteral | LSConstCall|LSNothingLiteral|LSFunctionCall|BigArithmatic | LSPropertyCall )
;

Please let me know if more information is needed.

[Updated on: Thu, 14 June 2012 19:30] by Moderator

Re: Xtext [message #886453 is a reply to message #886434] Thu, 14 June 2012 20:39 Go to previous messageGo to next message
Eclipse UserFriend
On 2012-15-06 1:17, Ajit Rathore wrote:
> I know it has been discussed many times but I could not resolve it on my
> own hence the post:
>
> I get the message "The rule 'LSParameter' is left recursive." on the
> grammer below:
>
> Grammer Snippet:
>
> ArithMathicStatement returns LSParameter:
> {ArithMathicStatement}
> (left=LSParameter operator+=ArithmeticOperator right=LSParameter)
> ;
>
> BigArithmatic:
> left1=ArithMathicStatement (operatorb+=ArithmeticOperator
> right1+=LSParameter)* ;
>
> LSParameter returns LSParameter:
> (LSBoolean | LSNullLiteral | LSIntLiteral | LSStringLiteral |
> LSConstCall|LSNothingLiteral|LSFunctionCall|BigArithmatic |
> LSPropertyCall )
> ;
>
>
There is a formula to follow for expressions - your snippet does not
follow that forumla. Try googling for "Xtext expression left recursion"
and you will find blog posts by Meinte Boersma and Sven Efftinge on the
topic.

There is also an example Expression language.

Then look at other more complex languages.

Regards
- henrik
Re: Xtext [message #891689 is a reply to message #886453] Mon, 25 June 2012 09:52 Go to previous message
Eclipse UserFriend
On 06/15/2012 02:39 AM, Henrik Lindberg wrote:
> On 2012-15-06 1:17, Ajit Rathore wrote:
>> I know it has been discussed many times but I could not resolve it on my
>> own hence the post:
>>
>> I get the message "The rule 'LSParameter' is left recursive." on the
>> grammer below:
>>
>> Grammer Snippet:
>>
>> ArithMathicStatement returns LSParameter:
>> {ArithMathicStatement}
>> (left=LSParameter operator+=ArithmeticOperator
>> right=LSParameter)
>> ;
>>
>> BigArithmatic:
>> left1=ArithMathicStatement (operatorb+=ArithmeticOperator
>> right1+=LSParameter)* ;
>>
>> LSParameter returns LSParameter:
>> (LSBoolean | LSNullLiteral | LSIntLiteral | LSStringLiteral |
>> LSConstCall|LSNothingLiteral|LSFunctionCall|BigArithmatic |
>> LSPropertyCall )
>> ;
>>
>>
> There is a formula to follow for expressions - your snippet does not
> follow that forumla. Try googling for "Xtext expression left recursion"
> and you will find blog posts by Meinte Boersma and Sven Efftinge on the
> topic.
>
> There is also an example Expression language.

This is an example of Expression language

http://xsemantics.sourceforge.net/xsemantics-documentation/Expressions-example.html#Expressions

hope it helps

cheers
Lorenzo


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
Previous Topic:Re-injection
Next Topic:Adding a language library to a non java project
Goto Forum:
  


Current Time: Wed Jul 23 05:01:10 EDT 2025

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

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

Back to the top