Two similar rules, but with different cross-references [message #1114364] |
Sun, 22 September 2013 12:27  |
Eclipse User |
|
|
|
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 15:29  |
Eclipse User |
|
|
|
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!
|
|
|
Powered by
FUDForum. Page generated in 0.09705 seconds