Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Two similar rules, but with different cross-references
Two similar rules, but with different cross-references [message #1114364] Sun, 22 September 2013 16:27 Go to next message
Joe I is currently offline Joe IFriend
Messages: 28
Registered: May 2013
Junior Member
Hi,

consider following grammar:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
	examples+=Example*;
	
Example:
	Object|Var|ObjectCall|VarAssignment
;	

Object:
	'object' name=ID
;

Var:
	'var' name=ID
;

ObjectCall:
	object=[Object]'.'method=ID('('(arguments+=[Var](','arguments+=[Var])*)?')')?
;

VarAssignment:
	var=[Var]('.'attribute=ID)? '=' int=INT
;


The problem is, that the ProposalProvider and the Validator always assume that a VarAssignment is an ObjectCall until '=' is entered.

Now my question is, is there an elegant way to specify these rules, keep the benefit of cross-references and get correct proposals?

Thanks!
Re: Two similar rules, but with different cross-references [message #1114457 is a reply to message #1114364] Sun, 22 September 2013 19:29 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You could use backtracking; hardly elegant.

You could restructure your grammar so that the conflicting syntaxes are
unified and resolved later semantically.

You could change to an LALR technology.

Regards

Ed Willink


On 22/09/2013 17:27, Joe I wrote:
> Hi,
>
> consider following grammar:
>
> grammar org.xtext.example.mydsl.MyDsl with
> org.eclipse.xtext.common.Terminals
>
> generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
>
> Model:
> examples+=Example*;
>
> Example:
> Object|Var|ObjectCall|VarAssignment
> ;
>
> Object:
> 'object' name=ID
> ;
>
> Var:
> 'var' name=ID
> ;
>
> ObjectCall:
> object=[Object]'.'method=ID('('(arguments+=[Var](','arguments+=[Var])*)?')')?
>
> ;
>
> VarAssignment:
> var=[Var]('.'attribute=ID)? '=' int=INT
> ;
>
>
> The problem is, that the ProposalProvider and the Validator always
> assume that a VarAssignment is an ObjectCall until '=' is entered.
> Now my question is, is there an elegant way to specify these rules,
> keep the benefit of cross-references and get correct proposals?
> Thanks!
Previous Topic:What's necessary for using uml2 within xtext plugin?
Next Topic:Value Converters in Xtext
Goto Forum:
  


Current Time: Fri Apr 19 08:29:50 GMT 2024

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

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

Back to the top