|
|
|
|
|
|
|
|
Re: Problem with unordered groups [message #558772 is a reply to message #558724] |
Tue, 14 September 2010 11:44 |
Meinte Boersma Messages: 434 Registered: July 2009 Location: Leiden, Netherlands |
Senior Member |
|
|
To muse a little more before filing Bugzillas (or ブグジラ, as the Japanese probably would have it), I had a look at the Xtext grammar def. which happens to be in Xtext, as it should
I was a bit surprised that the part of the language for defining parser rules actually uses an expression language for everything between : and ; In this language there are several infix operators, ordered in increasing precedence: |=alternative, &=unordered alternative and concatenation of "abstract tokens", not separated by anything other than (optional) whitespace!, meaning assignments, keywords, rule calls, actions and everything parenthesized.
So,
optional?='optional'? & 'entity' name=ID
actually means the same as
optional?='optional'? & ( 'entity' name=ID )
because the (invisible) token concatenation operator has higher precedence than the unordered group operator. The grammar fragment accepts both "optional entity Foo" and "entity Foo optional" with identical ASTs. This also explains why the additional parentheses help in our examples. The optionality thing is covered in the 1.0.1 version of the User Guide (not before), but the expression/operator nature is not and would clarify quite a bit.
I also noticed that keywords and rule calls can have cardinality postfixes as well, at least syntax/grammar-wise -haven't checked what happens at and after generation and what semantics hold then, though... It's certainly something I haven't seen in any grammar so far
Xtext blogs: executable models...again? | workshop material | custom scoping with Xtend
[Updated on: Tue, 14 September 2010 11:48] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03802 seconds