Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » LL(*)-left refactoring and cross-reference
LL(*)-left refactoring and cross-reference [message #1017161] Sun, 10 March 2013 10:14 Go to next message
Vincent Simonet is currently offline Vincent SimonetFriend
Messages: 8
Registered: March 2013
Junior Member
Hello,

I've a language (lesscss) that requires a grammar entry like:

Statement:
  ident=IDENT term=Term 'set'
| reference=[VariableCrossReference|IDENT] term=Term 'get'
;


where Term is a recursive rule.

This rule is rejected by ANTLR because has non-LL(*) decision due to recursive rule invocations (in short, you need to parse 'set' or 'get' to decide between the first and the second alternative.

The usual way to resolve the issue with LL(*) grammars would be to make a left refactoring like:

Statement:
  ident=IDENT term=Term keywork=('set | 'get')
;


but I cannot do that with Xtext and keep the cross-reference.

Is there a way to workaround this limitation?

Thanks!

--
Vincent
Re: LL(*)-left refactoring and cross-reference [message #1017965 is a reply to message #1017161] Tue, 12 March 2013 21:51 Go to previous message
Vincent Simonet is currently offline Vincent SimonetFriend
Messages: 8
Registered: March 2013
Junior Member
FYI, I found a way to solve the problem. With some hack in the scope provider, it is possible to have a cross-reference in both, i.e. to refactor the grammar definition into:
Statement:
  ident=[VariableCrossReference|IDENT] term=Term 'set'
| reference=[VariableCrossReference|IDENT] term=Term 'get'
;

and then
Statement:
 reference=[VariableCrossReference|IDENT] term=Term ('get' | 'set')
;

Previous Topic:Xtext import problem
Next Topic:Xtext Grammar
Goto Forum:
  


Current Time: Mon Dec 22 18:36:00 GMT 2014

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

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