|Parser seems to confuse assignments / Grammar problem [message #1073631]
||Thu, 25 July 2013 07:55
| Jochen Schmich
Registered: July 2009
I've got a problem with my Xtext grammar - more specifically with the following parser rule:
'property' type=JvmTypeReference (collection?='*')? name=ValidID ('default' default=PropertyDefaultValue | 'opposite' opposite=[Property])? ';'
Now consider the following example code:
property String secondProperty;
(Please note, that the second 'property'-keyword and the ValidID 'secondProperty' have error markers in the editor: 1. Marker says "no viable alternative at input 'property'", 2. marker says "extraneous input 'secondProperty' expecting ';'").
If I hit Ctrl-Space after "Boolean" (while debugging), I noticed, that the instance of Property being passed to my ContentProposalProvider has the value 'String' as its 'name'.
This seems to happen, because the semicolon is missing (which is usually the case, when defining a new Property) - the parser just ignores the following 'property'-keyword and confuses the 'type'-Assignment with the 'name'-Assignment. If I remove the semicolon from the grammar, everything works correctly.
Besides removing the need for mandatory semicolons after each statement, are there other ways to get around this problem?
Thanks in advance,
[Updated on: Thu, 25 July 2013 07:56]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.20695 seconds