The ?= operator [message #1790412] |
Sat, 09 June 2018 18:16  |
Eclipse User |
|
|
|
Hello,
In this grammar:
MessageSchema:
schema=SchemaDeclaration
types=TypeDeclarations
;
SchemaDeclaration:
'schema' name=QName 'id' '=' id=INT 'version' '=' version=INT optionalAttrs=OptionalSchemaAttrs?;
OptionalSchemaAttrs:
('headerType' '=' headerType=QName)? (bigEndian ?= 'bigEndian');
TypeDeclarations:
'types' '{' simpleTypes+=SimpleTypeDeclaration+ '}';
I want to allow for 2 optional items to the schema declaration, which I have put in rule OptionalSchemaAttrs: a header type and a switch for flipping to big endian (default is little).
The result is not exactly what I want: if I don't include header type, the presence/absence of keyword 'bigEndian' works as expected:
// this is ok:
schema org.sbelang.examples.v2.ExampleSchema
id = 1 version = 1
// this is also ok:
schema org.sbelang.examples.v2.ExampleSchema
id = 1 version = 1 bigEndian
But if I include a header type, the keyword 'bigEndian' becomes mandatory:
// this is ok:
schema org.sbelang.examples.v2.ExampleSchema
id = 1 version = 1
headerType = a.b.c.D
bigEndian
types {
//...
// this is NOT ok:
schema org.sbelang.examples.v2.ExampleSchema
id = 1 version = 1
headerType = a.b.c.D
types {
//...
The last example gives gives me the error: missing 'bigEndian' at 'types'.
According to the docs:
Quote:
The ?= sign (boolean assignment operator) expects a feature of type EBoolean and sets it to true if the right hand side was consumed, independently from the concrete value of the right hand side.
I don't understand how the presence of headerType affects the requirement for keyword 'bigEndian' to be consumed after it?
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.52161 seconds