Working with unordered groups [message #1798555] |
Tue, 20 November 2018 07:14  |
Eclipse User |
|
|
|
Hi,
My use case is; I have written a xtext grammar to create classes. The grammar looks like this:
RSELClass:
'Class' name=ID ('subClassOf' '('subClassOf+=[RSELClass|QualifiedName]+ ')')? | {RSELClass} ('instanceOf' '(' instanceOf=[RSELClass|QualifiedName] ')')?
'{'
(
('partitions' partitions+=[RSELClass]+ EndStmt)? &
('subOrdinateTo' subOrdinateTo+=[RSELClass]+ EndStmt)? &
('disjointCategorizes' disjointCategorizes+=[RSELClass]+ EndStmt)? &
('strongSubOrdinateTo' strongSubOrdinateTo+=[RSELClass]+ EndStmt)?
)
'}';
EndStmt:
';'
;
The instance of this grammar looks like this:
Class class {
}
Class B {
}
Class A subClassOf (B) instanceOf (class) {
partitions B;
subOrdinateTo B;
disjointCategorizes B;
strongSubOrdinateTo B;
}
The problem is:
When I am trying to write the code for validation in the RSELModelValidator.xtend, only class member "subClassOf" is getting populated in the instance of RSELClass A. Rest all data members "instanceOf", "partitions", "subOrdinateTo", "disjointCategorizes ", "strongSubOrdinateTo " are null.
However, when I change the grammar and set these elements (data members of class) as ordered:
RSELClass:
'Class' name=ID ('subClassOf' '('subClassOf+=[RSELClass|QualifiedName]+ ')')? ('instanceOf' '(' instanceOf=[RSELClass|QualifiedName] ')')?
'{'
(
('partitions' partitions+=[RSELClass]+ EndStmt)?
('subOrdinateTo' subOrdinateTo+=[RSELClass]+ EndStmt)?
('disjointCategorizes' disjointCategorizes+=[RSELClass]+ EndStmt)?
('strongSubOrdinateTo' strongSubOrdinateTo+=[RSELClass]+ EndStmt)?
)
'}';
EndStmt:
';'
;
It works fine. i.e. all the data members are populated.
Can anyone please guide me what I am missing/doing wrong? Is it a bug in Xtext/Xtend? I want these data members to be unordered.
Any help is much appreciated.
Regards,
Yash
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05356 seconds