Hello Xtexters,
I'm having some problems with my grammar where it seems to parse correctly but creates an incomplete semantic model.
The grammar - yes the DECLARE construct is a little odd and not how I would do it from scratch, but this is for a pre-existing language:
GeneralProcessModellingSystem:
{GeneralProcessModellingSystem}
(
"DECLARE"
( "TYPE" ( variableTypes += VariableTypeEntity )* )
| ( "STREAM" ( streamTypes += StreamTypeEntity )* )
"END"
)*
;
VariableTypeEntity:
name = ID
'=' default=RealNumber
':' lowerBound=RealNumber
':' upperBound=RealNumber
("UNIT" '=' unit=STRING)? ;
StreamTypeEntity:
name = ID
"IS"
elements += [VariableTypeEntity] ( ',' elements += [VariableTypeEntity] )
;
RealNumber returns ecore::EDoubleObject:
('-')? INT ( '.' INT )?
;
The input:
String text =
"DECLARE TYPE\n" +
" GasConcentration = 1.0 : -0.0 : 10.0 UNIT = \"mol/m3\"\n" +
"END\n" +
"DECLARE TYPE\n" +
" Length = 0.0 : 0.0 : 100.0 UNIT = \"m\"\n" +
"END";
The output from EmfFormatter#objToStr() on the domain model:
GeneralProcessModellingSystem {
cref VariableTypeEntity variableTypes [
0: VariableTypeEntity {
attr EString name 'GasConcentration'
attr EDoubleObject default '1.0'
attr EDoubleObject lowerBound '-0.0'
attr EDoubleObject upperBound '10.0'
attr EString unit 'mol/m3'
}
]
}
The "Length" TYPE is missing.
If I delete the line:
| ( "STREAM" ( streamTypes += StreamTypeEntity )* )
from the grammar then I get the correct result ...
Regards,
Tom