[xText] reference scope [message #675333] |
Tue, 31 May 2011 07:44 |
Joel Greenyer Messages: 170 Registered: July 2009 |
Senior Member |
|
|
Hi,
I'd like to build a DSL for something similar to UML composite structure diagrams or SysML internal
block diagrams. In short, in these models you have components that can have ports and consist of
parts ("component instances"). The parts are typed by components. Furthermore, the parts can be
connected by connectors. In addition to connecting the parts, the ends of the connectors refer to a
certain port that shall be connected. The ports, however, are only defined in the components that
type the parts.
One example in the concrete syntax should look like this:
....
component TestComp {
port in implements FlowIn requires FlowOut;
port out implements FlowOut requires FlowIn;
}
component System {
part c1:TestComp;
part c2:TestComp;
connect c1.out to c2.in;
}
....
See that the connector refers to the parts "c1" and "c2" in the component "System" and it refers to
the ports "out" and "in" of the component "TestComp", which types the parts "c1" and "c2".
The grammar for this model looks like this so far:
....
Component:
'component' name=ID '{'
port+=Port*
part+=Part*
connector+=Connector*
'}';
Part:
'part' name=ID ':' type=[Component] ';';
Connector:
'connect' sourceEnd+=ConnectorEnd 'to' targetEnd+=ConnectorEnd ';';
ConnectorEnd:
partWithPort=[Part] '.' port=[Port];
Port:
'port' name=ID ...
The problem is, however, that the connector end does not "see" the ports defined in another
component. There is probably an issue with the scope in which the port definition is visible. I
would like to specify that the port that one may write after the dot must be a port defined for the
component that types the part written before the dot.
Any ideas how to do that?
I suppose that this is not such a rare case, so maybe you can point me to examples?
Thanks!
Joel
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03325 seconds