Xtext Grammar - Referencing [message #1044805] |
Fri, 19 April 2013 07:14  |
Eclipse User |
|
|
|
I need something like what we do in a programming language, wherein we define a variable and then assign some value to it later.(i need only type int for now)
int a;
int b;
//some functions/other statements etc
....
....
//
a=10;
b=10;
Leaving aside the functions and other statements that may exist, i wrote something like,
Model:
Defintion|Assignment|OtherStatements;
Definition:
'int' name=ID ';
OtherStatements :
//TODO, for now think it is only a name=ID
name=ID
;
Assignment:
definition=[Definition] '=' INT ';'
I have a problem in here. Since the assignment can come anywhere after the Definition how do i ensure that it comes only after definition..
So something like definition followed by assignment
works, which is correct..
int a;
int b;
//other statements
...
...
a=10;
-----------------------------------------------------------------------------
This also works,i.e the definition after assignment
a=10;
...
...
int a;
which is obviously incorrect.
I think there must be some way to resolve it. Can anyone please help as i am relatively new to Xtext.
Thanks in Advance.
Rohit
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.13717 seconds