Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Left recursion(java and left recursion)
icon9.gif  Left recursion [message #1741725] Sun, 28 August 2016 23:42 Go to next message
Tatiana Silva is currently offline Tatiana SilvaFriend
Messages: 1
Registered: August 2016
Junior Member
Hi, I'm trying to do a lexical analysis at Java grammar (university project). And I have this problem of how to remove left recursion in the package_name rule.

      | ( package_name "." identifier ) 

I tried to using something that we learned in class:

      | package_name1

	"." identifier package_name1 | empty

But what would be the empty in xtext?
Re: Left recursion [message #1741791 is a reply to message #1741725] Mon, 29 August 2016 15:58 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7106
Registered: July 2009
Senior Member

Xtext is very unusual, unlike anything a traditional grammar course might cover.

Xtext does not support left recursion or epsilon. Major pain.

But Xtext does support EBNF */+/?. Fantastic.

So you must recast your problem into what Xtext supports.

package_name: names+=identifier ('.' names+=identifier)*


Ed Willink
Re: Left recursion [message #1741850 is a reply to message #1741791] Tue, 30 August 2016 07:41 Go to previous message
Stéphane Galland is currently offline Stéphane GallandFriend
Messages: 123
Registered: July 2014
Location: Belfort, France
Senior Member
You could also inherit from the Xbase grammar, and define the package definition in your rule as:
'package' package=QualifiedName ';'

Previous Topic:xtext unnamed tree
Next Topic:Xtext grammar ambiguity problem
Goto Forum:

Current Time: Wed Apr 21 21:46:16 GMT 2021

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

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

Back to the top