I'm oversimplifying the example, but here is an excerpt from my grammar
Edit:
"EDIT" type="Time" |
"EDIT" type="ListOf"
;
And here is an excerpt from my xtend junit test.
val input = '''EDIT LISTOF'''
val expectedFormed = '''EDIT ListOf"
assertEquals(expectedFormat, input.parse.serialize(SaveOptions::newBuilder.format().getOptions()))
Where I am expecting that I should be able to use a different case for "ListOf" than what is specified in the grammar.
Instead of getting an assertion failure I get an error:
java.lang.RuntimeException: Could not serialize EObject via backtracking.
Constraint: null (type='Time' | type='ListOf') null
Values: type(1)
Semantic Object: ...->Edit
If I keep everything the same as the grammar, then I dont get this exception.
If I keep everything the same as the grammar and change EDIT to any other case, I dont get this exception.
If I keep everything the same as the grammar and change ListOf to any other case then I get this exception.
I've tried attaching a IValueConverter for the Edit rule (hoping I could normalize the input to the grammar values) but it is not being invoked for serialization.
Note the failure only occurs on serialization.
Parsing and formatting work fine with any case for the ListOf. (i.e I can run this in a the IDE and it recognizes the tokens correctly and will format the text editor).
What is special about capturing the string in a feature that causes it to fail during serialization?