Xbase: overwrite the Operator '=' [message #879947] |
Fri, 01 June 2012 07:25 |
Hans-Georg Glöckler Messages: 88 Registered: July 2009 |
Member |
|
|
I use Xtext with Xbase.
My Grammar is
grammar org.eclipse.xtext.example.domainmodel.Domainmodel with org.eclipse.xtext.xbase.Xbase
generate domainmodel "http://www.xtext.org/example/Domainmodel"
DomainModel:
elements+=AbstractElement*;
AbstractElement:
PackageDeclaration | Entity | Import;
PackageDeclaration:
'package' name=QualifiedName elements+=AbstractElement* ';' ;
Import:
'import' importedNamespace=QualifiedNameWithWildCard';';
Entity:
'entity' name=ValidID ('extends' superType=JvmParameterizedTypeReference)? '{'
features+=Feature*
'}';
Feature:
Property | Operation;
Property:
(modifier=Modifier)+ 'var' name=ValidID ':' type=JvmTypeReference ';';
Operation:
(modifier=Modifier)+ 'def' name=ValidID '(' (params+=FullJvmFormalParameter (',' params+=FullJvmFormalParameter)*)? ')' ':' type=JvmTypeReference
body=XBlockExpression ';';
Modifier:
final?='final' & static?='static' & visibility=Visibility;
enum Visibility:
PACKAGE='package' | PRIVATE='private' | PROTECTED='protected' | PUBLIC='public';
QualifiedNameWithWildCard :
QualifiedName ('.' '*')?;
I have 3 questions:
Question 1) Why is the following line of sourcecode not working
Property:
(modifier=Modifier) 'var' name=ValidID ':' type=JvmTypeReference ';';
I get the following jvmmodelinferrer:
rule ruleModifier failed predicate: {getUnorderedGroupHelper().canLeave(grammarAccess.getModifierAccess().getUnorderedGroup())}?
Question 2) Why is the following line of sourcecode not working
Operation:
(modifier=Modifier) 'def' name=ValidID '(' (params+=FullJvmFormalParameter (',' params+=FullJvmFormalParameter)*)? ')' ':' type=JvmTypeReference
body=XBlockExpression ';';
I get the following jvmmodelinferrer:
Multiple markers at this line
- rule ruleModifier failed predicate: {getUnorderedGroupHelper().canLeave(grammarAccess.getModifierAccess().getUnorderedGroup())}?
- missing ';' at 'private
Question 3) How can I overwrite the Operator '=' with ':=' in Xbase
I want to write in the model
val int value3 := value1 + value2;
I send you a picture of the error in the model.
[Updated on: Fri, 01 June 2012 07:46] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02415 seconds