Closed joerg-holtmann closed 2 years ago
After investigating, the rule for Boolean should be:
Boolean returns Boolean: 'true' | 'false' ;
Because Boolean here does actually come from java.lang.Boolean (see in eastadl22.ecore, i.e. the metamodel). And the rule for Numerical should be:
Numerical returns Numerical: ID ;
Because the Numerical does actually come from java.lang.String in metamodel.
Just tested the new rules and look good, so close the issue for the time being. We use this editor in future is somehow a deep test for this. If there is still anything unsuitable, then back here and reopen it.
Regarding the Numerical rule, please check https://www.eclipse.org/Xtext/documentation/301_grammarlanguage.html, sections "Terminal Rules" for terminal rules ID
and String
and also "Return Types" for learning about default String datatypes and the implementation of value converters.
Numerical
return Numerical
, if the instance class name of the EAST-ADL class Numerical
in eastadl22.ecore is java.lang.String
?ID
for the production rule Numerical
restricts the possible String values more than it should be.The difference between ID and String could be figured out by watching at their definitions, ID could start with a hat '^', but then has to have English letters, however, String could have more freedom. terminal ID: '^'? ('a'..'z'|'A'..'Z'|'$'|'') ('a'..'z'|'A'..'Z'|'$'|''|'0'..'9')*;
terminal STRING: '"' ( '\' . / ('b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\') / | !('\'|'"') ) '"'? | "'" ( '\' . / ('b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\') / | !('\'|"'") ) "'"?; Usually, ID rule could be enough for the use on the Identifiers, and as well as enough for String0 in EastAdlSimplified. There is a possibility that the users want their String0 have more freedom, then they just need modify the String0 rule from: String0 returns String: ID; to: String0 returns String: ID | STRING;
Then the rule of Numerical is more complicated, which could be a binary/octal/decimal/hex/exponent number.
I create rules for the binary/octal/hex number/exponent numbers as follows:
so finally, the rule Numerical is:
And there is no need to customize value converter to them.
Then see the results:
The clue for figuring out the Numerical rule locates in the textual mode of the meta-model, see the following figure:
Two issues with the following production / terminal rules (Xtext generated ToDo's for them to implement the rule or an IValueConverter):
isElementary
: Boolean returns ecore::EBoolean: 'true' | 'false'. There is something wrong with this approach, as there is no auto-completion but one can write true / false with an error.