Parser seems to confuse assignments / Grammar problem [message #1073631] |
Thu, 25 July 2013 03:55  |
Eclipse User |
|
|
|
Hi all,
I've got a problem with my Xtext grammar - more specifically with the following parser rule:
Property:
'property' type=JvmTypeReference (collection?='*')? name=ValidID ('default' default=PropertyDefaultValue | 'opposite' opposite=[Property])? ';'
;
Now consider the following example code:
property Boolean
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,
Jochen
[Updated on: Thu, 25 July 2013 03:56] by Moderator
|
|
|
|
|
Re: Parser seems to confuse assignments / Grammar problem [message #1073643 is a reply to message #1073636] |
Thu, 25 July 2013 04:18  |
Eclipse User |
|
|
|
Hi Alexander - thanks for the quick response:
Well, more or less. The example represents the state of the file, when a user wants creates a 'Property': He inserts the keyword, a type is chosen... - now he hits Ctrl-Space (we want to propose some possible names).
[Updated on: Thu, 25 July 2013 04:19] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.24369 seconds