Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext (The rule is left recursive Problem)
Xtext [message #886434] Thu, 14 June 2012 23:17 Go to next message
Ajit Rathore is currently offline Ajit RathoreFriend
Messages: 1
Registered: June 2012
Junior Member
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 23:30]

Report message to a moderator

Re: Xtext [message #886453 is a reply to message #886434] Fri, 15 June 2012 00:39 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
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 13:52 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
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: Sat Apr 20 09:54:06 GMT 2024

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

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

Back to the top