Variable declaration [message #899570] |
Wed, 01 August 2012 09:25  |
Eclipse User |
|
|
|
Hi,
I'm working on a DSL where it should be possible to differ between a declaration of a element and the definition of a element. For example:
dcl a%=10
dcl b% = 42
a = 12
b=30
b=a
So, I've started with the following construct
VariableName:
name=ID type=Type
;
VariableDeclaration :
'dcl' variableName=VariableName
;
VariableReference:
variableName=[VariableName|ID]
;
VariableAssignment:
variable=[VariableReference] '=' value=VariableValue
;
VariableValue:
{VariableValue}
(variableReference =VariableReference)?
//(value=Value)?
(value=NUMBER)?
;
whereas Type refers to my defined types. I've thought it might be an idea to use cross references like in the following fragment
VariableDef:
name=[VariableDeclaration] '=' INT;
But that's not working and I doubt that this is the right way. I'm new to Xtext and so this question might be quite stupid. Maybe somebody has an idea or can point me into the right direction? Thanks in advance!
Best regards,
Jérôme
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05399 seconds