I have written this metamodel in a xText project:
Screen:
"Screen name: " name = ID
"Level: " level = STRING
"End: " end = INT
background = [Background]
character = [Character]
(enemies+=Enemy)*
(elements+=Element)*
Background:
"Background{
Id: " id = ID
"Image: " image = [Image]
"}";
...
An all the metaclasses you see there (Background, Character, Enemy, etc) I haven´t had any problem creating the metamodel in ecore but when I try to define a specific model like this (using Ctrl+Space):
Screen name: s1
Level: "easy"
End: 1000
I get an error: mismatched INPUT expecting RULE_ID and I can’t keep on writing with Ctrl+Space. Any ideas why this is not working? Thank you.
The problem with the grammar snippet is a misconception of cross references and containment references. You did not define a background somewhere in your sample file but the grammar expects a reference to a background. If you change the definition to something along these lines, it’ll work:
However, I expect that you actually wanted to use a cross reference instead of a contained background in a given screen. So you have to provide either your complete grammar or define a background prior to using it in a screen.