How to customize the scope of a reference [message #1861630] |
Tue, 24 October 2023 06:08 |
peppa nwpu Messages: 15 Registered: October 2023 |
Junior Member |
|
|
Hello Xtext Community,
I tried to define an architecture description language, but when I use cross-reference, I can't write the correct Scope method. Can you give me some help? Below is part of my Xtext syntax.
Model:
(componentTypes+=ComponentType | componentImpls+=ComponentImpl)*
;
ComponentType returns ComponentType:
( SystemType
| SubSystemType
)
;
ComponentImpl returns ComponentImpl:
SystemImpl
;
/***************************************************************/
Feature :
PortFeature | AccessFeature
;
PortFeature returns PortFeature:
isSync?='sync'? isAsync?='async'? portDirection=('input' | 'output' | 'inout') type=PortType 'port' name=ID ';'
;
PortType returns PortType:
{PortType} 'time' | {PortType} 'event' | {PortType} 'data' | {PortType} ('event' 'data')
;
AccessFeature returns AccessFeature:
accessDirection=('provide' | 'require') 'data' 'access' name=ID ';'
;
Property returns Property:
Period | Variable | Reference
;
Period returns Period:
'period' period=NumericValue 'ms' ';'
;
Variable returns Variable:
(isStateVal?='stateval')? variableType=VariableType name=ID ';'
;
Reference returns Reference:
variableType=VariableType '&' refName+=ID (',' '&' refName+=ID)* '->' ('system' | 'subsystem' | 'activity') componentType=ID sourceName=ID ';'
;
/*************************************************************************/
SystemType returns SystemType:
'system' name=ID
('features' features+=Feature+ )?
('properties' properties+=Property+)?
'end'
;
SubSystemType returns SubSystemType:
'subsystem' name=ID
('features' features+=Feature+ )?
('properties' properties+=Property+)?
'end'
;
/*********************************************************/
Init returns Init:
variableName=ID '=' value=ID ';'
;
SubSystemSubComponent returns SubSystemSubComponent:
'subsystem' subSystemSubComponentType=[SubSystemType|ID] '.' implName=ID componentName=ID ';'
;
DataSubComponent returns DataSubComponent:
'data' dataSubComponentType=[DataComponentType|ID] '.' implName=ID componentName=ID ';'
;
SubComponent returns SubComponent:
SubSystemSubComponent | DataSubComponent
;
Channel :
PortChannel
;
PortChannel returns PortChannel:
portchannelName=ID '[' variableName=ID ']'':' portType=PortType 'port' sourceSubComponent=[SubComponent|ID] '.' sourcePort=[PortFeature|ID] ('<-'|'->'|'<->') sinkSubComponent=[SubComponent|ID] '.' sinkPort=[PortFeature|ID]';'
;
Realization returns Realization:
implemented=[ComponentType|ID];
/*************************************************************************/
SystemImpl:
'system' 'implementation' ownedRealization=Realization '.' name=ID
('init' inits+=Init+)?
('properties' properties+=Property+)?
( 'components'
(ownedSubSystemSubComponent+=SubSystemSubComponent
)+
)?
('channels' channels+=Channel+)?
'end'
;
The following is what goes wrong.
When I write names that use references in the editor, the editor will report an error, so I think there is a problem with the reference range, but I don't know how to customize the reference range.
Below is my ECore metamodel and the Scope I tried to write.
-
Attachment: 1.png
(Size: 33.39KB, Downloaded 142 times) -
Attachment: 2.png
(Size: 67.87KB, Downloaded 146 times) -
Attachment: 3.png
(Size: 126.90KB, Downloaded 145 times)
|
|
|
|
Powered by
FUDForum. Page generated in 0.03151 seconds