Association and cross-referencing [message #1781463] |
Wed, 07 February 2018 09:23  |
Eclipse User |
|
|
|
Hey,
I am trying ways to link and access contained items with cross-referenced IDs, here, I have the following grammar:
Domainmodel:
'dmodel' name=ID
"{"
('cmpTypes' '{' ctps+=CMPType ( "," ctps+=CMPType)* '}' )?
('set' '{'
(cmps+=CMP ("," cmps+=CMP)*)?
(prt=[PRT | QualifiedName])?
'}'
)?
'}'
;
CMPType:
'type' name=ID '{' ('prts' '(' prts+=PRT ( "," prts+=PRT)* ')' )? '}'
;
CMP:
'cmp' name=QualifiedName 'as' cmpType=[CMPType|QualifiedName]
;
PRT:
name=ID
;
QualifiedName:
ID ('.' ID)*
;
and here is how the DSL should look like:
dmodel D1 {
cmpTypes {
type C1 {
prts (P1, P2)
},
type C2 {
prts (P3, P4)
}
}
set {
cmp x as C1,
cmp y as C1,
cmp z as C2
//access items in 'prts' (P1, P2, ...) by cmp IDs (x, y, z)
x.P1 // rather than C1.P1 which works
y.P3
}
}
I want to associate cmp IDs (x, y, z) with items in cmpTypes (C1, C2 ...) and then access contained items in 'prts' (P1, P2, ...) by cmp IDs (x, y, z).
Any suggestions or examples how I could realize this?
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.23909 seconds