Hi Jens,
please try to use unassigned actions in this case:
ReturnStatement :
"return" {ReturnStatement} expression=Expression? ";";
You'll find more details about them in the docs.
Regards,
Sebastian
Am 01.07.2009 14:30 Uhr, schrieb Jens v.P.:
Hi all,
I'm currently migrating my existing (and working!) oAW Xtext grammar to
TMF Xtext. I've found a problem with rules which do not contain model
elements.
This is an example:
--------------------------------------
Statement:
ReturnStatement |
IfStatement |
...
;
ReturnStatement:
"return" (expression=Expression)? ";";
....
--------------------------------------
These rules worked in the old version, but in the new version return
statements are not recognized by the parser anymore if no expression
(which is optional) is specified (that is no element of ReturnStatement
is created). No error message, they are simply ignored. That is in the
following example, line 1 works, line 2 does not work:
--------------
1: return 1;
2: return;
--------------
The same is true for other constructs. Fortunately I found a workaround:
--------------------------------------
ReturnStatement:
x="return" (expression=Expression)? ";";
--------------------------------------
I can use this solution as a pattern ("x=") in all my rules, such as:
--------------------------------------
Block:
x="{" (statements+=BlockStatement)* "}";
BreakStatement:
x="break" ";";
...
--------------------------------------
Is this simply a bug in the TMF Xtext version? All these rules worked
with the "x="-pattern in the previous version.
Cheers
Jens