Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Indirect left recursion
Indirect left recursion [message #1823816] Thu, 02 April 2020 09:56 Go to next message
Eclipse UserFriend
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 08:26 Go to previous messageGo to next message
Eclipse UserFriend
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 09:10 Go to previous messageGo to next message
Eclipse UserFriend
the problematic point is the
'|'?
maybe doing a

parserGenerator={
debugGrammar=true
}
and opening the generated debug grammar in antlrworks 3 helps to analyze
Re: Indirect left recursion [message #1824091 is a reply to message #1823886] Tue, 07 April 2020 15:41 Go to previous message
Eclipse UserFriend
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: Sat Jul 12 14:58:09 EDT 2025

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

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

Back to the top