I am trying to define some XText for variable specifications according to the following syntax
variables MyVar1 : Bool at 0x020 value=true; MyVar2, MyVar3 : Int at 0x030 value 200; end-variables
Therefore, each definition is syntactically
VarName ["," VarName]* ":" Type ["at" HEX]? ["value" VALUE]? ";"
All variables should be accessible by their link, and the result in the loop should look something like this:
variables +-MyVar1 : Bool +-MyVar2 : Int +-MyVar3 : Int
Edit: In accordance with my actual grammar requested here, which is equivalent to the syntax definition, some lines above.
Variable: name=ID ; Declaration_Var: 'variables' vars+=Declaration_Var_Body+ 'end-variables' ';' ; Declaration_Var_Body: varDecl+=Variable(',' varDecl +=Variable)* ':' type=[TR_Any] ('at' address=HEX)? ; TR_Any: ... ; terminal HEX: ... ;
In this case, the following sequence of characters
variables Test1, Test2, Test3 : DWORD at 0x20; end_var;
leads to the following circuit:
<unnamed> +-- 0x20 | +-- Test1 | +-- Test2 | +-- Test3
which is almost the opposite of what I expected. What I expected and what I want to create in the loop looks like this (the data type and address should not be displayed there, but at least they should be available as properties of the generated class for variable declarations)
Test1 +-- DWORD +-- 0x20 Test2 +-- DWORD +-- 0x20 Test3 +-- DWORD +-- 0x20