1 Star 0 Fork 0

Lzl/ttcn

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
TTCN.g4 33.48 KB
一键复制 编辑 原始数据 按行查看 历史
Lzl 提交于 2021-12-02 15:52 . test all the examples
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
grammar TTCN;
import TTCNLexerRules;
// 1 TTCN-3 module
ttcn3module : TTCN3ModuleKeyword moduleid
'{'
moduledefinitionslist?
'}'
withstatement?
SemiColon?;
// 3
moduleid : Identifier languagespec?;
// 4
languagespec : LanguageKeyword freetext (',' freetext)*;
//6 General
moduledefinitionslist : (moduledefinition SemiColon?)+;
//7
moduledefinition : ((('public' | 'friend' | 'private')? (typedef |
constdef | templatedef | modulepardef | functiondef |
signaturedef | testcasedef | altstepdef | importdef |
extfunctiondef | modulecontroldef)) | ('public'? groupdef)| ('private'? friendmoduledef))
withstatement?;
//9 Typedef definitions
typedef : TypeDefKeyword typedefbody;
//10
typedefbody : structuredtypedef | subtypedef;
//12
structuredtypedef : recorddef | uniondef | setdef |
recordofdef | setofdef | enumdef | portdef | componentdef |
mapdef;
//13 typE
mapdef : MapKeyword FromKeyword typE ToKeyword
(typE | nestedtypedef | mapdef);
// 14
recorddef : RecordKeyword structdefbody;
// 16
structdefbody : identifieroraddr '{'
(structfielddef (',' structfielddef)*)?
'}';
// 17
structfielddef : (typE | nestedtypedef) Identifier arraydef? subtypespec? OptionalKeyword?;
// 18
nestedtypedef : nestedrecorddef | nesteduniondef | nestedsetdef |
nestedrecordofdef | nestedsetofdef | nestedenumdef;
// 19
nestedrecorddef : RecordKeyword '{' (structfielddef (',' structfielddef)*)? '}';
// 20
nesteduniondef : UnionKeyword '{' unionfielddef (',' unionfielddef)* '}';
// 21
nestedsetdef : SetKeyword '{' (structfielddef (',' structfielddef)*)? '}';
// 22
nestedrecordofdef : RecordKeyword stringlength? OfKeyword (typE | nestedtypedef);
// 23
nestedsetofdef : SetKeyword stringlength? OfKeyword (typE | nestedtypedef);
// 24
nestedenumdef : EnumKeyword '{' enumerationlist '}';
// 26
uniondef : UnionKeyword uniondefbody;
// 28
uniondefbody : identifieroraddr '{' unionfielddef (',' unionfielddef)* '}';
// 29
unionfielddef : (DefaultModifier)? (typE | nestedtypedef) Identifier arraydef? subtypespec?;
// 30
setdef : SetKeyword structdefbody;
// 32
recordofdef : RecordKeyword stringlength? OfKeyword structofdefbody;
// 34
structofdefbody : (typE | nestedtypedef) identifieroraddr subtypespec?;
// 35
setofdef : SetKeyword stringlength? OfKeyword structofdefbody;
// 36
enumdef : EnumKeyword identifieroraddr '{' enumerationlist '}';
// 38
enumerationlist : enumeration (',' enumeration)*;
// 39
enumeration : Identifier ('(' integervalueorrange (',' integervalueorrange)* ')')?;
// 40
integervalueorrange : integervalue ('..' integervalue)? | singleexpression;
// 41
integervalue : Minus? Number;
// 42
subtypedef : typE identifieroraddr arraydef? subtypespec?;
// 43
subtypespec : allowedvaluesspec stringlength? | stringlength;
// 44
allowedvaluesspec : '(' ((templateorrange (',' templateorrange)* ) | charstringmatch) ')';
// 45
templateorrange : rangedef | templatebody | typE;
// 46
rangedef : bound '..' bound;
// 47
stringlength : LengthKeyword '(' singleexpression ('..' (singleexpression | InfinityKeyword))? ')';
// 49
portdef : PortKeyword portdefbody;
// 50
portdefbody : Identifier portdefattribs;
// 52
portdefattribs : messageattribs | procedureattribs | mixedattribs;
// 53
messageattribs : MessageKeyword '{' ((addressdecl |
messagelist | configparamdef) SemiColon? )+ '}';
// 54
configparamdef : mapparamdef | unmapparadef;
// 55
mapparamdef : MapKeyword ParamKeyword '(' formalvaluepar (',' formalvaluepar)* ')';
// 56
unmapparadef : UnmapKeyword ParamKeyword '(' formalvaluepar (',' formalvaluepar)* ')';
// 57
addressdecl : AddressKeyword typE;
//58
messagelist : direction allortypelist;
//59
direction : InParKeyword | OutParKeyword | InOutParKeyword;
//61
allortypelist : AllKeyword | typelist;
// 63
typelist : typE (',' typE)*;
// 64
procedureattribs : ProcedureKeyword '{' ((addressdecl | procedurelist | configparamdef) SemiColon? )+ '}';
// 66
procedurelist : direction allorsignaturelist;
// 67
allorsignaturelist : AllKeyword | signaturelist;
// 68
signaturelist : signature (',' signature)*;
// 69
mixedattribs : MixedKeyword '{' ((addressdecl | mixedlist | configparamdef) SemiColon?)+;
// 71
mixedlist : direction procortypelist;
// 72
procortypelist : AllKeyword | (procortype (',' procortype)*);
// 73
procortype : signature | typE;
// 74
componentdef : ComponentKeyword Identifier (ExtendsKeyword componenttype (','componenttype)*)?
'{' componentdeflist? '}';
// 77
componenttype : extendedidentifier;
// 78
componentdeflist : (componentelementdef withstatement? SemiColon?)*;
// 79
componentelementdef : portinstance | varinstance | timerinstance | constdef | templatedef;
// 80
portinstance : PortKeyword extendedidentifier portelement (',' portelement)*;
// 81
portelement : Identifier arraydef?;
// 82
constdef : ConstKeyword typE constlist;
// 83
constlist : singleconstdef (',' singleconstdef)*;
// 84
singleconstdef : Identifier arraydef? AssignmentChar constantexpression;
// 86 error
templatedef : TemplateKeyword templaterestriction? FuzzyModifier? DeterministicModifier?
AbstractModifier? basetemplate deriveddef? AssignmentChar basetemplatebody;
// 87
basetemplate : (typE | signature) Identifier ('(' templateorvalueformalparlist ')')?;
// 89
deriveddef : ModifiesKeyword (extendedidentifier | basetemplatebody);
// 91
templateorvalueformalparlist : templateorvalueformalpar (',' templateorvalueformalpar)*;
// 92
templateorvalueformalpar : formalvaluepar | formaltemplatepar;
// 93
templatebody : derivedtemplatebody | basetemplatebody;
// 94 del simplespec
basetemplatebody : (simplespec | fieldspeclist | arrayvalueorattrib) extramatchingattributes?;
// 95
simplespec : (singleexpression ('&' simpletemplatespec)?) | simpletemplatespec;
// 96
simpletemplatespec : singletemplateexpression ('&' simplespec)?;
// 97 error
singletemplateexpression : matchingsymbol | ((templaterefwithparlist extendedfieldreference?)) |
extendedidentifier enumtemplateextension;
// 98
enumtemplateextension : '(' (basetemplatebody | range) (',' (basetemplatebody | range))* ')';
// 99
fieldspeclist : '{' fieldspec (',' fieldspec)* '}';
// 100
fieldspec : fieldreference AssignmentChar (templatebody | Minus);
// 101
fieldreference : structfieldref | indexref | parref;
// 102
structfieldref : Identifier | predefinedtype | typereference;
// 103
parref : Identifier;
// 104
indexref : '[' singleexpression ']';
// 105
arrayvalueorattrib : '{' arrayelementspeclist? '}';
// 106
arrayelementspeclist : arrayelementspec (',' arrayelementspec)*;
// 107
arrayelementspec : Minus | permutationmatch | templatebody;
// 108
matchingsymbol : complement | (AnyValue wildcardlengthmatch?) |
(AnyOrOmit wildcardlengthmatch?) | listoftemplates | range |
binstringmatch | hexstringmatch | octetstringmatch | charstringmatch |
subsetmatch | supersetmatch | decodedcontentmatch;
// 109
decodedcontentmatch : DecodedMatchKeyword ('(' expression? ')')? templateinstance;
// 111
extramatchingattributes : stringlength | IfPresentKeyword | (stringlength IfPresentKeyword);
// 112
binstringmatch : Bstring | B_STRING_MATCH;
// 114
hexstringmatch : Hstring | H_STRING_MATCH;
// 116
octetstringmatch : Ostring | O_STRING_MATCH;
// 118
charstringmatch : PatternKeyword CaseInsenModifier? patternparticle ('&' patternparticle)*;
// 119 patterN
patternparticle : patterN | referencedvalue;
patternelementtwo : ('{' ('\\')? referencedvalue '}') | ('\\' 'N' '{' (referencedvalue | typE) '}');
// 121
patterN : Cstring | '"'(patternelementtwo)* '"';
// 129
complement : ComplementKeyword listoftemplates;
// 131
listoftemplates : '(' templatelistitem (',' templatelistitem)* ')';
// 132
templatelistitem : templatebody | allelementsform;
// 133
allelementsform : AllKeyword FromKeyword templatebody;
// 134
subsetmatch : SubsetKeyword listoftemplates;
// 136
supersetmatch : SupersetKeyword listoftemplates;
// 138
permutationmatch : PermutationKeyword listoftemplates;
// 142
wildcardlengthmatch : LengthKeyword '(' singleexpression ')';
// 145
range : '(' bound '..' bound ')';
// 146
bound : (('!')? singleexpression) | (Minus? InfinityKeyword);
// 148
actualparassignment : Identifier ':=' templateinstance;
// 149
templaterefwithparlist : extendedidentifier actualparlist?;
// 150
templateinstance : ((typE | signature) Colon)? templatebody;
// 151
derivedtemplatebody : ModifiesKeyword basetemplatebody AssignmentChar basetemplatebody;
// 152
actualparlist :((actualpar (',' actualpar)*) (',' actualparassignment)* |
(actualparassignment (',' actualparassignment)*))?;
// 153
actualpar : templateinstance | Minus;
// 154
templateops : matchop | valueofop | omitop | presentop;
// 155
matchop : MatchKeyword '(' expression ',' templateinstance ')';
// 157
valueofop : ValueofKeyword '(' templateinstance ')';
// 159
omitop : OmitKeyword '(' templateinstance ')';
// 160
presentop : PresentKeyword '(' templateinstance ')';
// 161
functiondef : FunctionKeyword (DeterministicModifier | ControlModifier)?
identifierorcontrol
'(' functionformalparlist? ')' runsonspec? mtcspec? systemspec? returntype? statementblock;
// 163
functionformalparlist : functionformalpar (',' functionformalpar)*;
// 164
functionformalpar : formalvaluepar | formaltemplatepar;
// 165
returntype : ReturnKeyword templatemodifier? typE arraydef?;
// 167
runsonspec : RunsKeyword OnKeyword componenttype;
// 170
mtcspec : MTCKeyword componenttype;
// 172
statementblock : '{' functiondeforstatementlist? '}';
// 173 error
functiondeforstatementlist : ((functionLdef | functionstatement) SemiColon?)+;
// 174 error
functionLdef : (functionlocaldef | functionlocalinst) withstatement?;
// 175
functionlocalinst : varinstance | timerinstance;
// 176
functionlocaldef : constdef | templatedef;
// 177
functionstatement : configurationstatements | timerstatements
| communicationstatements | basicstatements | behaviourstatements
| setlocalverdict | sutstatements | testcaseoperation;
// 178
functioninstance : functionref ('(' actualparlist ')')?;
// 179
functionref : (Identifier Dot)? (Identifier | predeffunctionidentifier | ControlKeyword)
| pre_def_function_identifier;
// 180
predeffunctionidentifier : Identifier (CaseInsenModifier)?;
// 181
signaturedef : SignatureKeyword Identifier '(' signatureformalparlist? ')'
(returntype | NoBlockKeyword)? exceptionspec?;
// 183
signatureformalparlist : formalvaluepar (',' formalvaluepar)*;
// 184
exceptionspec : ExceptionKeyword '(' typelist ')';
// 186
signature : extendedidentifier;
// 188 testcase definitions
testcasedef : TestcaseKeyword Identifier '(' templateorvalueformalparlist? ')' configspec statementblock;
// 190
configspec : runsonspec? systemspec?;
// 191
systemspec : SystemKeyword componenttype;
// 193
testcaseinstance : ExecuteKeyword '(' extendedidentifier '(' actualparlist?
')' (',' (expression | Minus) (',' singleexpression)?)? ')';
// 195 altstep definitions
altstepdef : AltstepKeyword (ControlModifier)? (InterleavedKeyword)? Identifier '('
(functionformalparlist)? ')' runsonspec? mtcspec? systemspec? '{'
altsteplocaldeflist altguardlist '}';
// 197
altsteplocaldeflist : (altsteplocaldef (withstatement)? (SemiColon)?)*;
// 198
altsteplocaldef : varinstance | timerinstance | constdef | templatedef;
// 199
altstepinstance : extendedidentifier '(' actualparlist? ')';
// 200 import definitions
importdef : ImportKeyword importfromspec ('->' Identifier)? (allwithexcepts | ('{' importspec '}'));
// 202
allwithexcepts : AllKeyword exceptsdef?;
// 203
exceptsdef : ExceptKeyword '{' exceptspec '}';
// 205
exceptspec : (exceptelement (SemiColon)?)*;
// 206
exceptelement : exceptgroupspec | excepttypedefspec | excepttemplatespec | exceptconstspec | excepttestcasespec | exceptaltstepspec
| exceptfunctionspec | exceptsignaturespec | exceptmoduleparspec;
// 207
exceptgroupspec : GroupKeyword (qualifiedidentifierlist | AllKeyword);
// 208
identifierlistorall : identifierlist | AllKeyword;
// 209
typeidlistorall : typeidentifierlist | AllKeyword;
// 210
funcidlistorall : funcidentifierlist | AllKeyword;
// 211
excepttypedefspec : TypeDefKeyword typeidlistorall;
// 212
excepttemplatespec : TemplateKeyword identifierlistorall;
// 213
exceptconstspec : ConstKeyword identifierlistorall;
// 214
excepttestcasespec : TestcaseKeyword identifierlistorall;
// 215
exceptaltstepspec : AltstepKeyword identifierlistorall;
// 216
exceptfunctionspec : FunctionKeyword funcidlistorall;
// 217
exceptsignaturespec : SignatureKeyword identifierlistorall;
// 218
exceptmoduleparspec : ModuleParKeyword identifierlistorall;
// 219
importspec : (importelement (SemiColon)?)*;
// 220
importelement : importgroupspec | importtypedefspec | importtemplatespec | importconstspec | importtestcasespec |
importaltstepspec | importfunctionspec | importsignaturespec | importmoduleparspec | importimportspec;
// 221
importfromspec : FromKeyword moduleid;
// 222
importgroupspec : GroupKeyword (groupreflistwithexcept | allgroupswithexcept);
// 223
groupreflistwithexcept : qualifiedidentifierwithexcept (',' qualifiedidentifierwithexcept)*;
// 224
allgroupswithexcept : AllKeyword (ExceptKeyword qualifiedidentifierlist)?;
// 225
qualifiedidentifierwithexcept : qualifiedidentifier (exceptsdef)?;
// 226
identifierlistorallwithexcept : identifierlist | allwithexcept;
// 227
typeidlistorallwithexcept : typeidentifierlist | alltypesexcept;
// 228
funcidlistorallwithexcept : funcidentifierlist | allfunctionsexcept;
// 229
importtypedefspec : TypeDefKeyword typeidlistorallwithexcept;
// 230
allwithexcept : AllKeyword (ExceptKeyword identifierlist)?;
// 231
alltypesexcept : AllKeyword (ExceptKeyword typeidentifierlist)?;
// 232
allfunctionsexcept : AllKeyword (ExceptKeyword funcidentifierlist)?;
// 233
importtemplatespec : TemplateKeyword identifierlistorallwithexcept;
// 234
importconstspec : ConstKeyword identifierlistorallwithexcept;
// 235
importaltstepspec : AltstepKeyword identifierlistorallwithexcept;
// 236
importtestcasespec : TestcaseKeyword identifierlistorallwithexcept;
// 237
importfunctionspec : FunctionKeyword funcidlistorallwithexcept;
// 238
importsignaturespec : SignatureKeyword identifierlistorallwithexcept;
// 239
importmoduleparspec : ModuleParKeyword identifierlistorallwithexcept;
// 240
importimportspec : ImportKeyword AllKeyword;
// 241
typeidentifierlist : identifieroraddr (',' identifieroraddr)*;
// 242
identifieroraddr : Identifier | AddressKeyword;
// 243
funcidentifierlist : identifierorcontrol (',' identifierorcontrol)*;
// 244
identifierorcontrol : Identifier | ControlKeyword;
// 245 group definitions
groupdef : GroupKeyword Identifier '{' (moduledefinitionslist)? '}';
// 247 external function definitions
extfunctiondef : ExtKeyword FunctionKeyword (DeterministicModifier | ControlModifier)? Identifier '(' functionformalparlist? ')' returntype?;
// 249 module parameter definitions
modulepardef : ModuleParKeyword (modulepar | ('{' multitypedmoduleparlist '}'));
// 251
multitypedmoduleparlist : (modulepar SemiColon?)*;
// 252
modulepar : templatemodifier? typE moduleparlist;
// 253
moduleparlist : Identifier (AssignmentChar templatebody)? (',' Identifier (AssignmentChar templatebody)?)*;
// 254 friend module definitions
friendmoduledef : 'friend' 'module' identifierlist SemiColon?;
// 255 module control function
modulecontroldef : ControlKeyword statementblock;
// local definitions
// 257 variable instantiations
varinstance : VarKeyword ((((LazyModifier | FuzzyModifier) (DeterministicModifier)?)? typE varlist) |
(templatemodifier ((LazyModifier | FuzzyModifier) (DeterministicModifier)?)? typE tempvarlist));
// 258
varlist : singlevarinstance (',' singlevarinstance)*;
// 259
singlevarinstance : Identifier arraydef? (AssignmentChar expression)?;
// 261
tempvarlist : singletempvarinstance (',' singletempvarinstance)*;
// 262
singletempvarinstance : Identifier arraydef? (AssignmentChar templatebody)?;
// 263
valueref : Identifier (extendedfieldreference)?;
// 264 timer instantiation
timerinstance : TimerKeyword varlist;
// 266
arrayidentifierref : Identifier (indexref)*;
// operations
// 267 component operations
configurationstatements : connectstatement | mapstatement | disconnectstatement | unmapstatement |
(NoDefaultModifier)? donestatement | (NoDefaultModifier)? killedstatement | starttcstatement | stoptcstatement |
killtcstatement | setencodestatement;
// 268
configurationops : createop | SelfOp | SystemKeyword | MTCKeyword | runningop | aliveop;
// 269
createop : componenttype Dot CreateKeyword ('(' (singleexpression | Minus) (',' singleexpression)? ')')? AliveKeyword?;
// 271
donestatement : componentorany Dot DoneKeyword ('->' (valuestorespec)? (indexspec)?)?;
// 272
componentorany : objectreference | (AnyKeyword (ComponentKeyword | FromKeyword valueref)) | (AllKeyword ComponentKeyword);
// 273
valuestorespec : ValueKeyword valueref;
// 274
indexassignment : '->' indexspec;
// 275
indexspec : IndexModifier valuestorespec;
// 276 error
killedstatement : componentorany Dot KilledKeyword ('->')? valuestorespec? indexspec?;
// 279
runningop : componentorany Dot RunningKeyword indexassignment?;
// 281
aliveop : componentorany Dot AliveKeyword indexassignment?;
// 284
connectstatement : ConnectKeyword singleconnectionspec;
// 286
singleconnectionspec : '(' portref ',' portref ')';
// 287
portref : componentref Colon arrayidentifierref;
// 288
componentref : objectreference | SystemKeyword | SelfOp | MTCKeyword;
// 289
disconnectstatement : DisconnectKeyword (singleconnectionspec | allconnectionsspec | allportsspec | allcompsallportsspec)?;
// 290
allconnectionsspec : '(' portref ')';
// 291
allportsspec : '(' componentref ':' AllKeyword PortKeyword ')';
// 292
allcompsallportsspec : '(' AllKeyword ComponentKeyword ':' AllKeyword PortKeyword ')';
// 294
mapstatement : MapKeyword singleconnectionspec (paramclause)?;
// 295
paramclause : ParamKeyword actualparlist;
// 297
unmapstatement : UnmapKeyword (singleconnectionspec (paramclause)? | allconnectionsspec (paramclause)? | allportsspec | allcompsallportsspec
| '(' valueref ',' singleexpression ')')?;
// 299
starttcstatement : objectreference Dot StartKeyword '(' (functioninstance | altstepinstance) ')';
// 301
stoptcstatement : StopKeyword | (componentreferenceorliteral | AllKeyword ComponentKeyword) Dot StopKeyword;
// 302
componentreferenceorliteral : objectreference | MTCKeyword | SelfOp;
// 303
killtcstatement : KillKeyword | ((componentreferenceorliteral | AllKeyword ComponentKeyword) Dot KillKeyword);
// 304
objectreference : valueref | functioninstance;
// 306
setencodestatement : (singleexpression | (AllKeyword PortKeyword) | SelfOp) | '.' SetEncodeKeyword '(' typE ',' singleexpression ')';
// 308 port operations
communicationstatements : sendstatement | callstatement | replystatement | raisestatement | (NoDefaultModifier)? receivingstatement |
clearstatement | startstatement | stopstatement | haltstatement | checkstatestatement;
// 309
receivingstatement : receivestatement | triggerstatement | getcallstatement | getreplystatement | catchstatement | checkstatement;
// 310
sendstatement : objectreference Dot portsendop;
// 311
portsendop : SendOpKeyword '(' templateinstance ')' toclause?;
// 313
toclause : ToKeyword (templateinstance | addressreflist | AllKeyword ComponentKeyword);
// 314
addressreflist : '(' templateinstance (',' templateinstance)* ')';
// 316
callstatement : objectreference Dot portcallop portcallbody?;
// 317
portcallop : CallOpKeyword '(' callparameters ')' toclause?;
// 319
callparameters : templateinstance (',' calltimervalue)?;
// 320
calltimervalue : expression | NowaitKeyword;
// 322
portcallbody : '{' callbodystatementlist '}';
// 323
callbodystatementlist : (callbodystatement (SemiColon)?)+;
// 324
callbodystatement : callbodyguard statementblock?;
// 325
callbodyguard : altguardchar callbodyops;
// 326
callbodyops : getreplystatement | catchstatement;
// 327
replystatement : objectreference Dot portreplyop;
// 328
portreplyop : ReplyKeyword '(' templateinstance (replyvalue)? ')' toclause?;
// 330
replyvalue : ValueKeyword templatebody;
// 331
raisestatement : objectreference Dot portraiseop;
// 332
portraiseop : RaiseKeyword '(' signature ',' templateinstance ')' toclause;
// 335
receivestatement : portorany Dot portreceiveop;
// 336
portorany : objectreference | (AnyKeyword (PortKeyword | FromKeyword valueref));
// 337
portreceiveop : ReceiveOpKeyword ('(' templateinstance ')')? fromclause? portredirect?;
// 339
fromclause : FromKeyword (templateinstance | addressreflist | AnyKeyword ComponentKeyword);
// 341
portredirect : '->' ((valuespec senderspec? indexspec?) | (senderspec indexspec?) | indexspec);
// 343
valuespec : ValueKeyword (valueref | ('(' singlevaluespec (',' singlevaluespec)* ')'));
// 344
singlevaluespec : valueref (AssignmentChar (DecodedModifier ('(' (expression)? ')')?)? fieldreference extendedfieldreference)?;
// 346
senderspec : SenderKeyword valueref;
// 348
triggerstatement : portorany Dot porttriggerop;
// 349
porttriggerop : TriggerOpKeyword ('(' templateinstance ')')? fromclause? portredirect?;
// 351
getcallstatement : portorany Dot portgetcallop;
// 352
portgetcallop : GetCallOpKeyword ('(' templateinstance ')')? fromclause? portredirectwithparam?;
// 354
portredirectwithparam : '->' redirectwithparamspec;
// 355
redirectwithparamspec : (paramspec senderspec? indexspec?) | (senderspec indexspec?) | indexspec;
// 356
paramspec : ParamKeyword paramassignmentlist;
// 358
paramassignmentlist : '(' (assignmentlist | variablelist) ')';
// 359
assignmentlist : variableassignment (',' variableassignment)*;
// 360 error
variableassignment : valueref AssignmentChar (DecodedModifier '(' (expression)? ')')? Identifier;
// 361
variablelist : variableentry (',' variableentry)*;
// 362
variableentry : valueref | Minus;
// 363
getreplystatement : portorany Dot portgetreplyop;
// 364
portgetreplyop : GetReplyOpKeyword ('(' templateinstance valuematchspec? ')')? fromclause? portredirectwithvalueandparam?;
// 365
portredirectwithvalueandparam : '->' redirectwithvalueandparamspec;
// 366
redirectwithvalueandparamspec : (valuespec paramspec? senderspec? indexspec?) | redirectwithparamspec;
// 368
valuematchspec : ValueKeyword templateinstance;
// 369
checkstatement : portorany Dot portcheckop;
// 370
portcheckop : CheckOpKeyword ('(' checkparameter ')')?;
// 372
checkparameter : checkportopspresent | fromclausepresent | redirectpresent;
// 373
fromclausepresent : fromclause ('->' ((senderspec indexspec?) | indexspec))?;
// 374
redirectpresent : '->' ((senderspec indexspec?) | indexspec);
// 375
checkportopspresent : portreceiveop | portgetcallop | portgetreplyop | portcatchop;
// 376
catchstatement : portorany Dot portcatchop;
// 377
portcatchop : CatchOpKeyword ('(' catchopparameter ')')? fromclause? portredirect?;
// 379
catchopparameter : signature (',' templateinstance)? | TimeoutKeyword;
// 380
clearstatement : portorall Dot ClearOpKeyword;
// 381
portorall : objectreference | AllKeyword PortKeyword;
// 383
startstatement : portorall Dot StartKeyword;
// 384
stopstatement : portorall Dot StopKeyword;
// 386
haltstatement : portorall Dot HaltKeyword;
// 389
checkstatestatement : portorallany Dot CheckStateKeyword '(' singleexpression ')';
// 390
portorallany : portorall | AnyKeyword PortKeyword;
// 392 timer operations
timerstatements : starttimerstatement | stoptimerstatement | NoDefaultModifier? timeoutstatement;
// 393
timerops : readtimerop | runningtimerop;
// 394
starttimerstatement : objectreference Dot StartKeyword ('(' expression ')')?;
// 395
stoptimerstatement : timerreforall Dot StopKeyword;
// 396
timerreforall : objectreference | AllKeyword TimerKeyword;
// 397
readtimerop : objectreference Dot ReadKeyword;
// 399
runningtimerop : timerreforany Dot RunningKeyword indexassignment?;
// 400
timeoutstatement : timerreforany Dot TimeoutKeyword indexassignment?;
// 401
timerreforany : objectreference | (AnyKeyword TimerKeyword) | (AnyKeyword FromKeyword Identifier);
// 403 testcase operation
testcaseoperation : TestcaseKeyword '.' StopKeyword ('(' (logitem (',')?)* ')')?;
// 404 type
typE : predefinedtype | referencedtype;
// 405
predefinedtype : BitStringKeyword | BooleanKeyword | CharStringKeyword | universalcharstring | IntegerKeyword | OctetStringKeyword
| HexStringKeyword | VerdictTypeKeyword | FloatKeyword | AddressKeyword | DefaultKeyword | AnyTypeKeyword | TimerKeyword;
// 417
universalcharstring : UniversalKeyword CharStringKeyword;
// 419
referencedtype : extendedidentifier (extendedtypefieldreference)?;
// 420
typereference : extendedidentifier;
// 421
arraydef : ('[' singleexpression ('..' singleexpression)? ']')+;
// 422
extendedtypefieldreference : ((Dot (Identifier | predefinedtype | FromKeyword | ToKeyword)) | ('[' Minus ']'))+;
// 423 value
value : predefinedvalue | referencedvalue;
// 424
predefinedvalue : Bstring | BooleanValue | charstringvalue | integervalue | Ostring | Hstring | VerdictTypeValue |
floatvalue | AddressValue | OmitKeyword;
// 427
charstringvalue : Cstring | CharKeyword '(' Number ',' Number ',' Number ',' Number ')' | Usilikenotation;
// 432
floatvalue : Floatdotnotation | Floatenotation | NaNKeyword;
// 437
referencedvalue : (extendedidentifier extendedfieldreference?) | referencedenumvalue;
// 438
referencedenumvalue : (referencedtype Dot)? Identifier extendedenumreference;
// 439
extendedenumreference : '(' integervalue ')';
// 458
freetext : Cstring;
// 466 parameterization
formalvaluepar : (InParKeyword | InOutParKeyword | OutParKeyword)? ((LazyModifier | FuzzyModifier) DeterministicModifier?)? typE Identifier
arraydef? (':=' (expression | Minus))?;
// 467
formaltemplatepar : (InParKeyword | InOutParKeyword | OutParKeyword)? templatemodifier ((LazyModifier | FuzzyModifier) DeterministicModifier?)?
typE Identifier arraydef? (':=' (templateinstance | Minus))?;
// 468
templatemodifier : TemplateKeyword | restrictedtemplate;
// 469
restrictedtemplate : OmitKeyword | (TemplateKeyword templaterestriction);
// 470
templaterestriction : '(' (OmitKeyword | ValueKeyword | PresentKeyword) ')';
// Statements
// 471 with statement
withstatement : 'with' withattriblist;
// 473
withattriblist : '{' ((standardattribute | variantattribute) SemiColon?)* '}';
// 474
// multiwithattrib : (singlewithattrib SemiColon?)*;
// 475
// singlewithattrib : standardattribute | variantattribute;
// 476
standardattribute : attribkeyword (OverrideKeyword | LocalModifier)? attribqualifier? freetext;
// 477
variantattribute : VariantKeyword (OverrideKeyword | LocalModifier)? attribqualifier? (relatedencoding '.')? freetext;
// 478
relatedencoding : freetext | ('{' freetext (',' freetext)* '}');
// 479
attribkeyword : EncodeKeyword | DisplayKeyword | ExtensionKeyword | OptionalKeyword;
// 486
attribqualifier : '(' deforfieldreflist ')';
// 487
deforfieldreflist : deforfieldref (',' deforfieldref)*;
// 488
deforfieldref : qualifiedidentifier | ((fieldreference | '[' Minus ']') (extendedfieldortypereference)?) | allref;
// 489
qualifiedidentifier : (Identifier Dot)* Identifier;
// 490
extendedfieldortypereference : ((Dot (Identifier | predefinedtype)) | indexref | ('[' Minus ']'))+;
// 491
allref : (GroupKeyword AllKeyword (ExceptKeyword '{' qualifiedidentifierlist '}')?) | ((TypeDefKeyword | TemplateKeyword | ConstKeyword |
AltstepKeyword | TestcaseKeyword | FunctionKeyword | SignatureKeyword | ModuleParKeyword) AllKeyword (ExceptKeyword '{' identifierlist '}')?);
// 492 behaviour statements
behaviourstatements : testcaseinstance | functioninstance | returnstatement | altconstruct | interleavedconstruct | labelstatement |
gotostatement | RepeatStatement | deactivatestatement | altstepinstance | activateop | BreakStatement | ContinueStatement;
// 493
setlocalverdict : SetVerdictKeyword '(' singleexpression (',' logitem)* ')';
// 496
sutstatements : ActionKeyword '(' actiontext (StringOp actiontext)* ')';
// 498
actiontext : freetext | expression;
// 499
returnstatement : ReturnKeyword templateinstance?;
// 500
altconstruct : AltKeyword NoDefaultModifier? '{' altsteplocaldeflist altguardlist '}';
// 502
altguardlist : ((guardstatement | elsestatement) SemiColon?)*;
// 503 ???
guardstatement : altguardchar (altstepinstance statementblock? | guardop statementblock?) ;
// 504
elsestatement : '[' ElseKeyword ']' statementblock;
// 505
altguardchar : '[' booleanexpression? ']';
// 506
guardop : timeoutstatement | receivestatement | triggerstatement | getcallstatement | catchstatement | checkstatement | getreplystatement |
donestatement | killedstatement;
// 507
interleavedconstruct : InterleavedKeyword NoDefaultModifier? '{' interleavedguardlist '}';
// 509
interleavedguardlist : (interleavedguardelement SemiColon?)+;
// 510
interleavedguardelement : interleavedguard statementblock?;
// 511
interleavedguard : '[' ']' guardop;
// 512
labelstatement : LabelKeyword Identifier;
// 514
gotostatement : GotoKeyword Identifier;
// 517
activateop : ActivateKeyword '(' altstepinstance ')';
// 519
deactivatestatement : DeactivateKeyword ('(' objectreference ')')?;
// 523 basic statements
basicstatements : assignment | logstatement | loopconstruct | conditionalconstruct | selectcaseconstruct | statementblock;
// 524
expression : singleexpression | compoundexpression;
// 525
compoundexpression : fieldexpressionlist | arrayormixedexpression;
// 526
fieldexpressionlist : '{' fieldexpressionspec (',' fieldexpressionspec)* '}';
// 527
fieldexpressionspec : fieldreference AssignmentChar notusedorexpression;
// 528
arrayormixedexpression : '{' (arrayelementexpressionlist (',' fieldexpressionspec)*)? '}';
// 529
arrayelementexpressionlist : notusedorexpression (',' notusedorexpression)*;
// 530
notusedorexpression : expression | Minus;
// 531
constantexpression : singleexpression | compoundconstexpression;
// 532
booleanexpression : singleexpression;
// 533
compoundconstexpression : fieldconstexpressionlist | arrayconstexpression;
// 534
fieldconstexpressionlist : '{' fieldconstexpressionspec (',' fieldconstexpressionspec)* '}';
// 535
fieldconstexpressionspec : fieldreference AssignmentChar constantexpression;
// 536
arrayconstexpression : '{' arrayelementconstexpressionlist? '}';
// 537
arrayelementconstexpressionlist : constantexpression (',' constantexpression)*;
// 538
assignment : valueref AssignmentChar templatebody;
// 539
singleexpression : xorexpression ('or' xorexpression)*;
// 540
xorexpression : andexpression ('xor' andexpression)*;
// 541
andexpression : notexpression ('and' notexpression)*;
// 542
notexpression : ('not')? equalexpression;
// 543
equalexpression : relexpression (EqualOp relexpression)*;
// 544
relexpression : shiftexpression (RelOp shiftexpression)? | compoundexpression;
// 545
shiftexpression : bitorexpression (ShiftOp bitorexpression)*;
// 546
bitorexpression : bitxorexpression ('or4b' bitxorexpression)*;
// 547
bitxorexpression : bitandexpression ('xor4b' bitandexpression)*;
// 548
bitandexpression : bitnotexpression ('and4b' bitnotexpression)*;
// 549
bitnotexpression : ('not4b')? addexpression;
// 550
addexpression : mulexpression (('+' | '-' | '&') mulexpression)*;
// 551
mulexpression : unaryexpression (('*' | '/' | 'mod' | 'rem') unaryexpression)* | compoundexpression;
// 552
unaryexpression : ('+' | '-')? primary;
// 553
primary : opcall | presencecheckingop | value | '(' singleexpression ')';
// 554
extendedfieldreference : ((Dot (Identifier | predefinedtype | FromKeyword | ToKeyword)) | indexref | decodedfieldreference)+;
// 555
decodedfieldreference : '=>' decodedfieldtype;
// 556
decodedfieldtype : predefinedtype | Identifier | '(' typE (',' expression)? ')';
// 557 add checkstatestatement
opcall : configurationops | GetLocalVerdict | timerops | testcaseinstance | (functioninstance extendedfieldreference?) |
(templateops extendedfieldreference?) | activateop | getattributeop | checkstatestatement;
// 558
presencecheckingop : ('ispresent' | 'ischosen' | 'isvalue' | 'isbound') '(' templateinstance ')';
// 566
logstatement : LogKeyword '(' logitem (',' logitem)* ')';
// 568
logitem : freetext | templateinstance;
// 569
loopconstruct : forstatement | whilestatement | dowhilestatement;
// 570
forstatement : ForKeyword '(' initial SemiColon booleanexpression SemiColon assignment ')' statementblock;
// 572
initial : varinstance | assignment;
// 573
whilestatement : WhileKeyword '(' booleanexpression ')' statementblock;
// 575
dowhilestatement : DoKeyword statementblock WhileKeyword '(' booleanexpression ')';
// 577
conditionalconstruct : IfKeyword '(' booleanexpression ')' statementblock (elseifclause)* elseclause?;
// 579
elseifclause : ElseKeyword IfKeyword '(' booleanexpression ')' statementblock;
// 581
elseclause : ElseKeyword statementblock;
// 582
selectcaseconstruct : SelectKeyword UnionKeyword? '(' singleexpression ')' selectcasebody;
// 584
selectcasebody : '{' (selectcase)+ caseelse? '}';
// 585
selectcase : CaseKeyword ('(' templateinstance (',' templateinstance)* ')' | ElseKeyword) statementblock;
// 586
caseelse : CaseKeyword ElseKeyword statementblock;
// 588
extendedidentifier : (Identifier Dot)? Identifier;
// 589
identifierlist : Identifier (',' Identifier)*;
// 590
qualifiedidentifierlist : qualifiedidentifier (',' qualifiedidentifier)*;
// 591
getattributeop : (typE) '.' getattributespec;
// getattributeop : (typE | templateinstance) '.' getattributespec;
// 592
getattributespec : EncodeKeyword | VariantKeyword ('(' freetext ')')? | DisplayKeyword | ExtensionKeyword | OptionalKeyword;
// 内置函数
pre_def_function_identifier
: T_INT2CHAR
| T_INT2UNICHAR
| T_INT2BIT
| T_INT2HEX
| T_INT2OCT
| T_INT2STR
| T_INT2FLOAT
| T_FLOAT2INT
| T_CHAR2INT
| T_CHAR2OCT
| T_UNICHAR2INT
| T_BIT2INT
| T_BIT2HEX
| T_BIT2OCT
| T_BIT2STR
| T_HEX2INT
| T_HEX2BIT
| T_HEX2OCT
| T_HEX2STR
| T_OCT2INT
| T_OCT2BIT
| T_OCT2HEX
| T_OCT2STR
| T_OCT2CHAR
| T_STR2INT
| T_STR2OCT
| T_STR2FLOAT
| T_LENGTHOF
| T_SIZEOF
| T_REGEXP
| T_SUBSTR
| T_REPLACE
| T_RND
;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/code_lzl/ttcn.git
git@gitee.com:code_lzl/ttcn.git
code_lzl
ttcn
ttcn
master

搜索帮助