This I know
Suppose we have to validate we have to write @check
method inside ".xtend"
get data from model then we can validate.
But content which we printed from grammar how can we validate that
consider following grammar
IniDCommand:
{IniDCommand}
'@D'(value=ANSS1TERM)?
;IniDCommand:
{IniDCommand}
'@D'(value=ANSS1TERM)?
;
In above grammar I can validate "(value=ANSS1TERM)"
this part in xtend this data is available in model. But how to validate '@D'
this data is not available in Model this we are printing from grammar.
How we can read or validate content inside xtend which we printed on Xtext Editor from grammar(.xtext) file.
For more clarity i am adding following example
considere following example
IniC0_61:
{IniC0_61}
'@C0,61,'
;
in Editor i can see like this
@C0,61
Now someone type or change above line in editor like this
@@C0,61
In above line user added extra "@" rest i am printing from grammar. This should throw an error by saying "@@" not allowed.
This how my part of grammar(.xtext) look like
grammar com.herzog.pmide.RoutingLineINI with org.eclipse.xtext.common.Terminals
import "platform:/resource/com.herzog.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)
;
IniRoutingLogicSection:
{IniRoutingLogicSection}
'[Routing]'('\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')*
;
IniDCommand:
{IniDCommand}
'@D'(value=ANSS1TERM)?
;
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)
;
GENCOMMENT :
SYMBOL2(ANSS1TERM)('\r\n')*
(GENCOMMENT)?
;
IniCommand:
(IniDCommand)
;
IniRoutingLine:
(groupComment=GRPCOMMENT)?('\r\n')*
(comment=LINECOMMENT)?('\r\n')*
(unitPositionSampleTypeWay=('Warning_Rate='|'Busy_Rate='|'MaxRecursionConcurence='|'WS_Speed='|'ReactivationTime='|'WaitTime_WS_Reuse='|ANSTERM))(commands+=IniCommand)*('\r\n')*
//(unitPositionSampleTypeWay=ANS1TERM)'='(commands+=IniCommand)*('\r\n')*
;