在编辑器中从Xtext获取不需要的错误

时间:2017-12-07 10:12:44

标签: java rcp xtext emf

我使用eclipse EMF / RCP开发了IDE,我使用xtext,rcp和emf开发了一个编辑器

以下是该部分的语法

// automatically generated by Xtext
grammar com.xyz.pmide.RoutingLineINI with org.eclipse.xtext.common.Terminals 

import "platform:/resource/com.xyz.pmide.routingline.xtext.model/model/pmrouting.ecore" 
import "http://www.eclipse.org/emf/2002/Ecore" as ecore

IniRoutingLineProject:
    {IniRoutingLineProject}
        (iniRoutingConfig=IniRoutingConfiguration)?
    ;

IniRoutingConfiguration:    
    {IniRoutingConfiguration}
    (iniRoutingSectConfig=IniRoutingLogicSection)
    (iniLogMessageSectionConfig=IniLogMessageSet)?
    (iniPreDefGroupSectionConfig=IniPreDefGroupVariableSet)?
    (iniRegWSSectionConfig=IniRegisterWSCommandSet)?
    (iniOtherRoutingSectionConfig=IniRoutingPropertySet)
    (iniGlobalRoutingSectionConfig=IniGlobalRoutingSection)?
    (iniAlarmSignalSectionConfig=IniAlarmSignalSection)?
    (iniOptionPopupSectionConfig=IniOptionPopupSection)
;

IniRoutingLogicSection:
    {IniRoutingLogicSection}
    '[Routing]'('\r\n')*
//  ('Warning_Rate='warningRate=ANS1TERM)?('\r\n')*
//  ('Busy_Rate='busyRate=ANS1TERM)?('\r\n')* 
//  ('MaxRecursionConcurence=' maxRecursionOccurence=ANS1TERM)?('\r\n')* 
//  ('WS_Speed=' wsSpeed=ANS1TERM)?('\r\n')* 
//  ('ReactivationTime=' reactivationTime=ANS1TERM)?('\r\n')* 
//  ('WaitTime_WS_Reuse=' waitTimeWSReuse=ANS1TERM)?('\r\n')*
    (routingLines+=IniRoutingLine)*('\r\n')*
;

terminal ALPHA :('a'..'z'|'A'..'Z');

terminal NUM:('0'..'9')+;

terminal SYMBOL : ('.'|','|'('|')'|'{'|'}'|'<'|'>'|'+'|'-'|'*'|'%'|'!'|'"'|':'|'|'|'?'|'#'|'_'|' '|'=');

terminal SYMBOL1 : ('['|']')*;

terminal SYMBOL2 : ('/'|';')* ;

terminal ANS : (ALPHA|NUM|SYMBOL)* SYMBOL2;

terminal SL_COMMENT : '//-' !('\n'|'\r')* ('\r'? '\n')?;

terminal ML_COMMENT : '//*' -> '*//';

ANSTERM : ANS;

ANSS1TERM : (ANS|SYMBOL1)+;

GRPCOMMENT_STR_END : SYMBOL2("===========================================================================================================================================================================") ;

GRPCOMMENT : 
    (GRPCOMMENT_STR_END)('\r\n')*
    SYMBOL2(ANSS1TERM)('\r\n')*
    (GRPCOMMENT_STR_END)('\r\n')*
;


LINECOMMENT : 
//  (LINECOMMENT_STR_END)('\r\n')*
//  (ANSS1TERM|LINECOMMENT)('\r\n')*
//  (LINECOMMENT_STR_END)?('\r\n')*;
    (('/*'('\r\n')*
    (ANSS1TERM)('\r\n')*
    (LINECOMMENT)?('\r\n')*
     '*/'?('\r\n')*)|GENCOMMENT)
;


IniTimeStampSampleSectPropSet:
    {IniTimeStampSampleSectPropSet} 
    '[TimeStamp_Sample]'('\r\n')*
    (inLabKeyValue+=IniUnitPositionsPair)*('\r\n')*
;


IniPositionConnect: 
    {IniPositionConnect}
//  (srcPosition=ANS1TERM)(destPosition=ANS1TERM)?('\r\n')*
    (src_dest_Pos=ANSS1TERM)('\r\n')*
;

IniListSampleSection: 
    {IniListSampleSection}
    '[LISTSAMPLE]'('\r\n')*
    (iniOnType+=IniListSample_OnType)*('\r\n')*
;

IniListSample_OnType: 
    {IniListSample_OnType}
    (sampleType=('OnType'|ANSS1TERM))(popUpNo=ANSS1TERM)?('\r\n')*
;


IniGeneralRoutingSectPropSet: 
    {IniGeneralRoutingSectPropSet}
    '[General]'('\r\n')*
//  (version=('version='|ANSTERM))?('\r\n')*
    (keySet+=IniNewKey_NL)*('\r\n')*
;

IniChildWSTriggerSectionSet:
    {IniChildWSTriggerSectionSet} 
    (iniTriggerSectionConfig+=IniTriggerSectionConfiguration)*('\r\n')*
;


IniTriggerSectionConfiguration: 
    {IniTriggerSectionConfiguration}
    SYMBOL1(sectName=ANSTERM)SYMBOL1('\r\n')*
    (triggerUnit=('TriggerUnit='|ANSTERM))?('\r\n')*
    (createPoint=('CreatePoint='|ANSTERM))?('\r\n')*
;

以下是我的部分验证,或者您可以在编辑器中查看我的部分的检查规则

@Check
    def validate_TriggerSectionConfiguration(IniTriggerSectionConfiguration iniTriggerSectionConfiguration){
        val value = iniTriggerSectionConfiguration.sectName;
        if (value.startsWith("[") && !value.endsWith("]")) {
            error("Missing \"]\"",iniTriggerSectionConfiguration, PmroutingPackage.Literals.INI_TRIGGER_SECTION_CONFIGURATION__SECT_NAME)
        }
    }

以下是我编辑的一部分

enter image description here

如果我用大写S改变名字

enter image description here

如果我将转到红色错误标记我收到此错误消息 enter image description here

  

我正在努力找到我找不到的解决方案。我的问题在于checkRule   如果我没有为该错误写任何验证,为什么xtext会给出这样的错误   错误。当我的名字从这个资本开始时,我得到了这个问题   字母错误A,G,L,M,O,P,R,S,T,W。这是我的代码问题或   xtext有一些错误或我遗失了什么?

0 个答案:

没有答案