Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Indirect left recursion
Indirect left recursion [message #1823816] Thu, 02 April 2020 13:56 Go to next message
Udo Günthner is currently offline Udo GünthnerFriend
Messages: 1
Registered: April 2020
Junior Member
Hi,

the following grammar does not compile because of a non-LL(*) decision ...

grammar udo.test.Test hidden(WS)

import "http://www.eclipse.org/emf/2002/Ecore" as ecore
generate test...

Test:
    a=E ';';

E returns ex:
    A ({ex.left=current} '|'? right=A)*;

A returns ex:
    P ({ex.left=current} '+' right=P)*;

P returns ex:
    O ({ex.left=current} right=P) | T;

T returns ex:
    '(' right=E ')' | c='X';

O returns ex:
    o=('+' | '-');

terminal WS:
    ' ';


Can anyone please point me to the left recursion here? And how to refactor it?
Thank you
Re: Indirect left recursion [message #1823878 is a reply to message #1823816] Fri, 03 April 2020 12:26 Go to previous messageGo to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 114
Registered: February 2016
Senior Member
Hello Udo,

have you already considered the https://www.eclipse.org/Xtext/documentation/307_special_languages.html#expressions section of the Xtext documentation?

Hope that helps,
Tamás
Re: Indirect left recursion [message #1823886 is a reply to message #1823878] Fri, 03 April 2020 13:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13641
Registered: July 2009
Senior Member
the problematic point is the
'|'?
maybe doing a

parserGenerator={
debugGrammar=true
}
and opening the generated debug grammar in antlrworks 3 helps to analyze


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Indirect left recursion [message #1824091 is a reply to message #1823886] Tue, 07 April 2020 19:41 Go to previous message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 739
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Also consider Holger's blog: https://blogs.itemis.com/en/debugging-xtext-grammars-what-to-do-when-your-language-is-ambiguous
Previous Topic:Any VSCode Directions Updates?
Next Topic:Problem with Xtext running in tomcat 9.0.16 guice 4.2.3, Xtext 2.20.0
Goto Forum:
  


Current Time: Wed Oct 28 06:02:19 GMT 2020

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

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

Back to the top