在我当前的项目中,我试图在我的编辑器中提供大纲视图。我在xtext中编写了以下语法:
Model:
(vocSpec=VocSpec );
VocSpec:
structKeyword = 'structs' ':' (structs+=Struct)+
resourceKeyword = 'resources:'
sensorKeyword ='sensors' ':'
periodicSensorKeyword ='periodicSensors' ':' (periodicSensors+=PeriodicSensors)*
eventDrivenSensorKeyword ='eventDrivenSensors' ':' (eventSensors+=EventSensors)*
requestBasedSensorKeyword ='requestBasedSensors' ':' (requestSensors+=RequestSensors)*
tagKeyword ='tags' ':' (tags+=Tags)*
actuatorsKeyword ='actuators' ':' (actuators+=Actuator)*
storageKeyword ='storages' ':' (storageService+=StorageService)*
;
Struct:
name=ID (fields+=Field)+;
Field:
name=ID ':' type+=Type ';'
;
/* Periodic Sensor Definition */
PeriodicSensors:
sensorName=EntityName
(generateInfo+=Generate)+
'sample' 'period' INT 'for' INT ';'
;
/* Event Driven Sensor Definition */
EventSensors:
sensorName=EntityName
(generateInfo+=Generate)+
'onCondition' (eventConditions+=EventConditions) ';';
/* Request Based Sensor Definition */
RequestSensors:
sensorName=EntityName
((DataAccess+=DataAccess))*;
/* Tag Definition */
Tags:
sensorName=EntityName
(generateInfo+=Generate)+;
EventConditions:
name=ID ('>' | '<' | '=')* (intValue=INT) (nameUnit=Unit) (',' eventConditions+=EventConditions)?
;
OPERATOR:
opt='>' | opt='<' | opt='=';
EntityName:
(name=ID);
Generate:
'generate' sourceName=SourceName ':' type=Type ';';
SourceName:
name=ID;
Actuator:
actuatorName=EntityName ((actions+=Action))*;
Action:
'action' actionName=ActionName '(' (parameters+=Parameters)* ')' ';';
ActionName:
name=ID;
Parameters:
parameterName=ParameterName ':' type=Type;
ParameterName:
name=ID;
/* Storage Service Definition */
StorageService:
storageServiceName=EntityName
((dataAccesses+=DataAccess))*;
DataAccess:
'generate' sourceName=SourceName ':' dataAccessType=Type
'accessed-by' dataItem=ID ':' type=Type ';'
((actions+=Action))*;
/* Type Definition */
Type:
(primitiveDataType=PrimitiveDataType);
Unit:
name='PPM' | name='miliseconds' | name='seconds' | name='minutes' | name='ppm';
PrimitiveDataType:
INTEGER='Integer' | BOOLEAN='boolean' | STRING='String' | LONG='long' | DOUBLE='double' | structDef=[Struct];
通过上述语法,我编写了以下规范:
此处Sensors
类型 Resource
,periodicSensors
类型 Sensors
。 Tags
类型为Resource
,actuators
类型为resources
。
因此,如果我将其转换为大纲视图,则大纲视图应如下所示:
但是,使用上面的语法,我在xtext生成的编辑器中得到以下大纲视图。如何在xtext编辑器中获得所需的大纲视图。我想我必须修改我的xtext语法,如上所述? /其他的事情。请建议