TTCN-3 Grammar W. Borgert debacle@debian.org This is the DocBook/XML version of the TTCN-3 BNF taken from ETSI standard ETSI ES 201 873-1 V2.2.1 (2003-02) Methods for Testing and Specification (MTS); The Testing and Test Control Notation version 3; Part 1: TTCN-3 Core Language 0 TTCN module TTCN3Module TTCN3ModuleKeyword TTCN3ModuleId BeginChar [ModuleDefinitionsPart] [ModuleControlPart] EndChar [WithStatement] TTCN3ModuleKeyword "module" TTCN3ModuleId ModuleIdentifier [DefinitiveIdentifier] ModuleIdentifier Identifier DefinitiveIdentifier Dot ObjectIdentifierKeyword "{" DefinitiveObjIdComponentList "}" DefinitiveObjIdComponentList {DefinitiveObjIdComponent}+ DefinitiveObjIdComponent NameForm | DefinitiveNumberForm | DefinitiveNameAndNumberForm DefinitiveNumberForm Number DefinitiveNameAndNumberForm Identifier "(" DefinitiveNumberForm ")" 1 Module definitions part - 1.0 General ModuleDefinitionsPart ModuleDefinitionsList ModuleDefinitionsList {ModuleDefinition [SemiColon]}+ ModuleDefinition (TypeDef | ConstDef | TemplateDef | ModuleParDef | FunctionDef | SignatureDef | TestcaseDef | AltstepDef | ImportDef | GroupDef | ExtFunctionDef | ExtConstDef) [WithStatement] 1.1 Typedef definitions TypeDef TypeDefKeyword TypeDefBody TypeDefBody StructuredTypeDef | SubTypeDef TypeDefKeyword "type" StructuredTypeDef RecordDef | UnionDef | SetDef | RecordOfDef | SetOfDef | EnumDef | PortDef | ComponentDef RecordDef RecordKeyword StructDefBody RecordKeyword "record" StructDefBody (StructTypeIdentifier [StructDefFormalParList] | AddressKeyword) BeginChar [StructFieldDef {"," StructFieldDef}] EndChar StructTypeIdentifier Identifier StructDefFormalParList "(" StructDefFormalPar {"," StructDefFormalPar} ")" StructDefFormalPar FormalValuePar Static semantics: FormalValuePar shall resolve to an in parameter StructFieldDef Type StructFieldIdentifier [ArrayDef] [SubTypeSpec] [OptionalKeyword] StructFieldIdentifier Identifier OptionalKeyword "optional" UnionDef UnionKeyword UnionDefBody UnionKeyword "union" UnionDefBody (StructTypeIdentifier [StructDefFormalParList] | AddressKeyword) BeginChar UnionFieldDef {"," UnionFieldDef} EndChar UnionFieldDef Type StructFieldIdentifier [ArrayDef] [SubTypeSpec] SetDef SetKeyword StructDefBody SetKeyword "set" RecordOfDef RecordKeyword [StringLength] OfKeyword StructOfDefBody OfKeyword "of" StructOfDefBody Type (StructTypeIdentifier | AddressKeyword) [SubTypeSpec] SetOfDef SetKeyword [StringLength] OfKeyword StructOfDefBody EnumDef EnumKeyword (EnumTypeIdentifier | AddressKeyword) BeginChar EnumerationList EndChar EnumKeyword "enumerated" EnumTypeIdentifier Identifier EnumerationList Enumeration {"," Enumeration} Enumeration EnumerationIdentifier ["(" Number ")"] EnumerationIdentifier Identifier SubTypeDef Type (SubTypeIdentifier | AddressKeyword) [ArrayDef] [SubTypeSpec] SubTypeIdentifier Identifier SubTypeSpec AllowedValues | StringLength Static semantics: AllowedValues shall be of the same type as the field being subtyped AllowedValues "(" ValueOrRange {"," ValueOrRange} ")" ValueOrRange RangeDef | SingleConstExpression Static semantics: RangeDef production shall only be used with integer, char, universal char, charstring, universal charstring or float based types Static semantics: When subtyping charstring or universal charstring range and values shall not be mixed in the same SubTypeSpec RangeDef LowerBound ".." UpperBound StringLength LengthKeyword "(" SingleConstExpression [".." UpperBound] ")" Static semantics: StringLength shall only be used with String types or to limit set of and record of. SingleConstExpression and UpperBound shall evaluate to non-negative integer values (in case of UpperBound including infinity) LengthKeyword "length" PortType [GlobalModuleId Dot] PortTypeIdentifier PortDef PortKeyword PortDefBody PortDefBody PortTypeIdentifier PortDefAttribs PortKeyword "port" PortTypeIdentifier Identifier PortDefAttribs MessageAttribs | ProcedureAttribs | MixedAttribs MessageAttribs MessageKeyword BeginChar {MessageList [SemiColon]}+ EndChar MessageList Direction AllOrTypeList Direction InParKeyword | OutParKeyword | InOutParKeyword MessageKeyword "message" AllOrTypeList AllKeyword | TypeList AllKeyword "all" TypeList Type {"," Type} ProcedureAttribs ProcedureKeyword BeginChar {ProcedureList [SemiColon]}+ EndChar ProcedureKeyword "procedure" ProcedureList Direction AllOrSignatureList AllOrSignatureList AllKeyword | SignatureList SignatureList Signature {"," Signature} MixedAttribs MixedKeyword BeginChar {MixedList [SemiColon]}+ EndChar MixedKeyword "mixed" MixedList Direction ProcOrTypeList ProcOrTypeList AllKeyword | (ProcOrType {"," ProcOrType}) ProcOrType Signature | Type ComponentDef ComponentKeyword ComponentTypeIdentifier BeginChar [ComponentDefList] EndChar ComponentKeyword "component" ComponentType [GlobalModuleId Dot] ComponentTypeIdentifier ComponentTypeIdentifier Identifier ComponentDefList {ComponentElementDef [SemiColon]} ComponentElementDef PortInstance | VarInstance | TimerInstance | ConstDef PortInstance PortKeyword PortType PortElement {"," PortElement} PortElement PortIdentifier [ArrayDef] PortIdentifier Identifier 1.2 Constant definitions ConstDef ConstKeyword Type ConstList ConstList SingleConstDef {"," SingleConstDef} SingleConstDef ConstIdentifier [ArrayDef] AssignmentChar ConstantExpression Static semantics: The Value of the ConstantExpression shall be of the same type as the stated type for the constants ConstKeyword "const" ConstIdentifier Identifier 1.3 Template definitions TemplateDef TemplateKeyword BaseTemplate [DerivedDef] AssignmentChar TemplateBody BaseTemplate (Type | Signature) TemplateIdentifier ["(" TemplateFormalParList ")"] TemplateKeyword "template" TemplateIdentifier Identifier DerivedDef ModifiesKeyword TemplateRef ModifiesKeyword "modifies" TemplateFormalParList TemplateFormalPar {"," TemplateFormalPar} TemplateFormalPar FormalValuePar | FormalTemplatePar Static semantics: FormalValuePar shall resolve to an in parameter TemplateBody SimpleSpec | FieldSpecList | ArrayValueOrAttrib Static semantics: Within TemplateBody the ArrayValueOrAttrib can be used for array, record, record of and set of types. SimpleSpec SingleValueOrAttrib FieldSpecList "{"[FieldSpec {"," FieldSpec}] "}" FieldSpec FieldReference AssignmentChar TemplateBody FieldReference StructFieldRef | ArrayOrBitRef | ParRef StructFieldRef StructFieldIdentifier ParRef SignatureParIdentifier Operational semantics: SignatureParIdentifier shall be a formal parameter Identifier from the associated signature definition SignatureParIdentifier ValueParIdentifier ArrayOrBitRef "[" FieldOrBitNumber "]" Static semantics: ArrayRef (ArrayOrBitRef?) shall be optionally used for array types and ASN.1 SET OF and SEQUENCE OF and TTCN record of and set of. The same notation can be used for a Bit reference inside an ASN.1 or TTCN bitstring type FieldOrBitNumber SingleExpression Static semantics: SingleExpression will resolve to a value of integer type SingleValueOrAttrib MatchingSymbol [ExtraMatchingAttributes] | SingleExpression [ExtraMatchingAttributes] | TemplateRefWithParList Static semantics: VariableIdentifier (accessed via SingleExpression) may only be used in inline template definitions to reference variables in the current scope ArrayValueOrAttrib "{" ArrayElementSpecList "}" ArrayElementSpecList ArrayElementSpec {"," ArrayElementSpec} ArrayElementSpec NotUsedSymbol | TemplateBody NotUsedSymbol Dash MatchingSymbol Complement | AnyValue | AnyOrOmit | ValueOrAttribList | Range | BitStringMatch | HexStringMatch | OctetStringMatch | CharStringMatch | SubsetMatch | SupersetMatch ExtraMatchingAttributes LengthMatch | IfPresentMatch | LengthMatch IfPresentMatch BitStringMatch "'" {BinOrMatch} "'" "B" BinOrMatch Bin | AnyValue | AnyOrOmit HexStringMatch "'" {HexOrMatch} "'" "H" HexOrMatch Hex | AnyValue | AnyOrOmit OctetStringMatch "'" {OctOrMatch} "'" "O" OctOrMatch Oct | AnyValue | AnyOrOmit CharStringMatch PatternKeyword Cstring PatternKeyword "pattern" Complement ComplementKeyword ValueList ComplementKeyword "complement" ValueList "(" ConstantExpression {"," ConstantExpression} ")" SubsetMatch SubsetKeyword ValueList Static semantics: Subset matching shall only be used with the set of type SubsetKeyword "subset" SupersetMatch SupersetKeyword ValueList Static semantics: Superset matching shall only be used with the set of type SupersetKeyword "superset" AnyValue "?" AnyOrOmit "*" ValueOrAttribList "(" TemplateBody {"," TemplateBody}+ ")" LengthMatch StringLength IfPresentMatch IfPresentKeyword IfPresentKeyword "ifpresent" Range "(" LowerBound ".." UpperBound ")" LowerBound SingleConstExpression | Minus InfinityKeyword UpperBound SingleConstExpression | InfinityKeyword Static semantics: LowerBound and UpperBound shall evaluate to types integer, char, universal char or float. In case LowerBound or UpperBound evaluates to types char or universal char, only SingleConstExpression may be present InfinityKeyword "infinity" TemplateInstance InLineTemplate TemplateRefWithParList [GlobalModuleId Dot] TemplateIdentifier [TemplateActualParList] | TemplateParIdentifier TemplateRef [GlobalModuleId Dot] TemplateIdentifier | TemplateParIdentifier InLineTemplate [(Type | Signature) Colon] [DerivedDef AssignmentChar] TemplateBody Static semantics: The type field may only be omitted when the type is implicitly unambigous TemplateActualParList "(" TemplateActualPar {"," TemplateActualPar} ")" TemplateActualPar TemplateInstance Static semantics: When the corresponding formal parameter is not of template type the TemplateInstance production shall resolve to one or more SingleExpressions TemplateOps MatchOp | ValueofOp MatchOp MatchKeyword "(" Expression "," TemplateInstance")" Static semantics: The type of the value returned by the expression must be the same as the template type and each field of the template shall resolve to a single value MatchKeyword "match" ValueofOp ValueofKeyword "(" TemplateInstance")" ValueofKeyword "valueof" 1.4 Function definitions FunctionDef FunctionKeyword FunctionIdentifier "("[FunctionFormalParList] ")" [RunsOnSpec] [ReturnType] StatementBlock FunctionKeyword "function" FunctionIdentifier Identifier FunctionFormalParList FunctionFormalPar {"," FunctionFormalPar} FunctionFormalPar FormalValuePar | FormalTimerPar | FormalTemplatePar | FormalPortPar ReturnType ReturnKeyword Type ReturnKeyword "return" RunsOnSpec RunsKeyword OnKeyword ComponentType RunsKeyword "runs" OnKeyword "on" MTCKeyword "mtc" StatementBlock BeginChar [FunctionStatementOrDefList] EndChar FunctionStatementOrDefList {FunctionStatementOrDef [SemiColon]}+ FunctionStatementOrDef FunctionLocalDef | FunctionLocalInst | FunctionStatement FunctionLocalInst VarInstance | TimerInstance FunctionLocalDef ConstDef FunctionStatement ConfigurationStatements | TimerStatements | CommunicationStatements | BasicStatements | BehaviourStatements | VerdictStatements | SUTStatements FunctionInstance FunctionRef "(" [FunctionActualParList] ")" FunctionRef [GlobalModuleId Dot] (FunctionIdentifier | ExtFunctionIdentifier ) | PreDefFunctionIdentifier PreDefFunctionIdentifier Identifier Static semantics: The Identifier will be one of the predefined TTCN-3 Function Identifiers. FunctionActualParList FunctionActualPar {"," FunctionActualPar} FunctionActualPar TimerRef | TemplateInstance | Port | ComponentRef Static semantics: When the corresponding formal parameter is not of template type the TemplateInstance production shall resolve to one or more SingleExpressions i.e., equivalent to the Expression production 1.5 Signature definitions SignatureDef SignatureKeyword SignatureIdentifier "("[SignatureFormalParList] ")" [ReturnType | NoBlockKeyword] [ExceptionSpec] SignatureKeyword "signature" SignatureIdentifier Identifier SignatureFormalParList SignatureFormalPar {"," SignatureFormalPar} SignatureFormalPar FormalValuePar ExceptionSpec ExceptionKeyword "(" ExceptionTypeList ")" ExceptionKeyword "exception" ExceptionTypeList Type {"," Type} NoBlockKeyword "noblock" Signature [GlobalModuleId Dot] SignatureIdentifier 1.6 Testcase definitions TestcaseDef TestcaseKeyword TestcaseIdentifier "("[TestcaseFormalParList] ")" ConfigSpec StatementBlock TestcaseKeyword "testcase" TestcaseIdentifier Identifier TestcaseFormalParList TestcaseFormalPar {"," TestcaseFormalPar} TestcaseFormalPar FormalValuePar | FormalTemplatePar ConfigSpec RunsOnSpec [SystemSpec] SystemSpec SystemKeyword ComponentType SystemKeyword "system" TestcaseInstance ExecuteKeyword "(" TestcaseRef "(" [TestcaseActualParList] ")" ["," TimerValue] ")" ExecuteKeyword "execute" TestcaseRef [GlobalModuleId Dot] TestcaseIdentifier TestcaseActualParList TestcaseActualPar {"," TestcaseActualPar} TestcaseActualPar TemplateInstance Static semantics: When the corresponding formal parameter is not of template type the TemplateInstance production shall resolve to one or more SingleExpressions i.e., equivalent to the Expression production 1.7 Altstep definitions AltstepDef AltstepKeyword AltstepIdentifier "("[AltstepFormalParList] ")" [RunsOnSpec] BeginChar AltstepLocalDefList AltGuardList EndChar AltstepKeyword "altstep" AltstepIdentifier Identifier AltstepFormalParList FunctionFormalParList Static semantics: all formal parameter must be value parameters i.e., in parameters AltstepLocalDefList {AltstepLocalDef [SemiColon]} AltstepLocalDef VarInstance | TimerInstance | ConstDef AltstepInstance AltstepRef "(" [FunctionActualParList] ")" AltstepRef [GlobalModuleId Dot] AltstepIdentifier 1.8 Import definitions ImportDef ImportKeyword ImportFromSpec (AllWithExcepts | (BeginChar ImportSpec EndChar)) ImportKeyword "import" AllWithExcepts AllKeyword [ExceptsDef] ExceptsDef ExceptKeyword BeginChar ExceptSpec EndChar ExceptKeyword "except" ExceptSpec {ExceptElement [SemiColon]} Static semantics: Any of the production components (ExceptGroupSpec, ExceptTypeDefSpec etc.) may be present only once in the ExceptSpec production ExceptElement ExceptGroupSpec | ExceptTypeDefSpec | ExceptTemplateSpec | ExceptConstSpec | ExceptTestcaseSpec | ExceptAltstepSpec | ExceptFunctionSpec | ExceptSignatureSpec | ExceptModuleParSpec ExceptGroupSpec GroupKeyword (ExceptGroupRefList | AllKeyword) ExceptTypeDefSpec TypeDefKeyword (TypeRefList | AllKeyword) ExceptTemplateSpec TemplateKeyword (TemplateRefList | AllKeyword) ExceptConstSpec ConstKeyword (ConstRefList | AllKeyword) ExceptTestcaseSpec TestcaseKeyword (TestcaseRefList | AllKeyword) ExceptAltstepSpec AltstepKeyword (AltstepRefList | AllKeyword) ExceptFunctionSpec FunctionKeyword (FunctionRefList | AllKeyword) ExceptSignatureSpec SignatureKeyword (SignatureRefList | AllKeyword) ExceptModuleParSpec ModuleParKeyword (ModuleParRefList | AllKeyword) ImportSpec {ImportElement [SemiColon]} ImportElement ImportGroupSpec | ImportTypeDefSpec | ImportTemplateSpec | ImportConstSpec | ImportTestcaseSpec | ImportAltstepSpec | ImportFunctionSpec | ImportSignatureSpec | ImportModuleParSpec ImportFromSpec FromKeyword ModuleId [RecursiveKeyword] ModuleId GlobalModuleId [LanguageSpec] Static semantics: LanguageSpec may only be omitted if the referenced module contains TTCN-3 notation LanguageKeyword "language" LanguageSpec LanguageKeyword FreeText GlobalModuleId ModuleIdentifier [Dot ObjectIdentifierValue] RecursiveKeyword "recursive" ImportGroupSpec GroupKeyword (GroupRefList | AllGroupsWithExcept) GroupRefList FullGroupIdentifier {"," FullGroupIdentifier} AllGroupsWithExcept AllKeyword [ExceptKeyword GroupRefList] FullGroupIdentifier GroupIdentifier {Dot GroupIdentifier} [ExceptsDef] ExceptGroupRefList ExceptFullGroupIdentifier {"," ExceptFullGroupIdentifier} ExceptFullGroupIdentifier GroupIdentifier {Dot GroupIdentifier} ImportTypeDefSpec TypeDefKeyword (TypeRefList | AllTypesWithExcept) TypeRefList TypeDefIdentifier {"," TypeDefIdentifier} AllTypesWithExcept AllKeyword [ExceptKeyword TypeRefList] TypeDefIdentifier StructTypeIdentifier | EnumTypeIdentifier | PortTypeIdentifier | ComponentTypeIdentifier | SubTypeIdentifier ImportTemplateSpec TemplateKeyword (TemplateRefList | AllTemplsWithExcept) TemplateRefList TemplateIdentifier {"," TemplateIdentifier} AllTemplsWithExcept AllKeyword [ExceptKeyword TemplateRefList] ImportConstSpec ConstKeyword (ConstRefList | AllConstsWithExcept) ConstRefList ConstIdentifier {"," ConstIdentifier} AllConstsWithExcept AllKeyword [ExceptKeyword ConstRefList] ImportAltstepSpec AltstepKeyword (AltstepRefList | AllAltstepsWithExcept) AltstepRefList AltstepIdentifier {"," AltstepIdentifier} AllAltstepsWithExcept AllKeyword [ExceptKeyword AltstepRefList] ImportTestcaseSpec TestcaseKeyword (TestcaseRefList | AllTestcasesWithExcept) TestcaseRefList TestcaseIdentifier {"," TestcaseIdentifier} AllTestcasesWithExcept AllKeyword [ExceptKeyword TestcaseRefList] ImportFunctionSpec FunctionKeyword (FunctionRefList | AllFunctionsWithExcept) FunctionRefList FunctionIdentifier {"," FunctionIdentifier} AllFunctionsWithExcept AllKeyword [ExceptKeyword FunctionRefList] ImportSignatureSpec SignatureKeyword (SignatureRefList | AllSignaturesWithExcept) SignatureRefList SignatureIdentifier {"," SignatureIdentifier} AllSignaturesWithExcept AllKeyword [ExceptKeyword SignatureRefList] ImportModuleParSpec ModuleParKeyword (ModuleParRefList | AllModuleParWithExcept) ModuleParRefList ModuleParIdentifier {"," ModuleParIdentifier} AllModuleParWithExcept AllKeyword [ExceptKeyword ModuleParRefList] 1.9 Group definitions GroupDef GroupKeyword GroupIdentifier BeginChar [ModuleDefinitionsPart] EndChar GroupKeyword "group" GroupIdentifier Identifier 1.10 External function definitions ExtFunctionDef ExtKeyword FunctionKeyword ExtFunctionIdentifier "("[FunctionFormalParList] ")" [ReturnType] ExtKeyword "external" ExtFunctionIdentifier Identifier 1.11 External constant definitions ExtConstDef ExtKeyword ConstKeyword Type ExtConstIdentifier ExtConstIdentifier Identifier 1.12 Module parameter definitions ModuleParDef ModuleParKeyword "{" ModuleParList "}" ModuleParKeyword "modulepar" ModuleParList ModulePar {SemiColon ModulePar} ModulePar ModuleParType ModuleParIdentifier [AssignmentChar ConstantExpression] {"," ModuleParIdentifier [AssignmentChar ConstantExpression]} Static semantics: The Value of the ConstantExpression shall be of the same type as the stated type for the Parameter ModuleParType Type ModuleParIdentifier Identifier 2 Control part - 2.0 General ModuleControlPart ControlKeyword BeginChar ModuleControlBody EndChar [WithStatement] [SemiColon] ControlKeyword "control" ModuleControlBody [ControlStatementOrDefList] ControlStatementOrDefList {ControlStatementOrDef [SemiColon]}+ ControlStatementOrDef FunctionLocalInst | ControlStatement | FunctionLocalDef ControlStatement TimerStatements | BasicStatements | BehaviourStatements | SUTStatements 2.1 Variable instantiation VarInstance VarKeyword Type VarList VarList SingleVarInstance {"," SingleVarInstance} SingleVarInstance VarIdentifier [ArrayDef] [AssignmentChar VarInitialValue] VarInitialValue Expression VarKeyword "var" VarIdentifier Identifier VariableRef (VarIdentifier | ValueParIdentifier) [ExtendedFieldReference] 2.2 Timer instantiation TimerInstance TimerKeyword TimerList TimerList SingleTimerInstance{"," SingleTimerInstance} SingleTimerInstance TimerIdentifier [ArrayDef] [AssignmentChar TimerValue] TimerKeyword "timer" TimerIdentifier Identifier TimerValue Expression Static semantics: When Expression resolves to SingleExpression it must resolve to a value of type float. Expression shall only resolves to CompoundExpression in the initialiation in default timer value assignment for timer arrays TimerRef TimerIdentifier [ArrayOrBitRef] | TimerParIdentifier [ArrayOrBitRef] 2.3 Component operations ConfigurationStatements ConnectStatement | MapStatement | DisconnectStatement | UnmapStatement | DoneStatement | StartTCStatement | StopTCStatement ConfigurationOps CreateOp | SelfOp | SystemOp | MTCOp | RunningOp CreateOp ComponentType Dot CreateKeyword SystemOp SystemKeyword SelfOp "self" MTCOp MTCKeyword DoneStatement ComponentId Dot DoneKeyword ComponentId ComponentIdentifier | (AnyKeyword | AllKeyword) ComponentKeyword DoneKeyword "done" RunningOp ComponentId Dot RunningKeyword RunningKeyword "running" CreateKeyword "create" ConnectStatement ConnectKeyword PortSpec ConnectKeyword "connect" PortSpec "(" PortRef "," PortRef ")" PortRef ComponentRef Colon Port ComponentRef ComponentIdentifier | SystemOp | SelfOp | MTCOp DisconnectStatement DisconnectKeyword PortSpec DisconnectKeyword "disconnect" MapStatement MapKeyword PortSpec MapKeyword "map" UnmapStatement UnmapKeyword PortSpec UnmapKeyword "unmap" StartTCStatement ComponentIdentifier Dot StartKeyword "(" FunctionInstance ")" Static semantics: the Function instance may only have in parameters Static semantics: the Function instance shall not have timer parameters StartKeyword "start" StopTCStatement StopKeyword | ComponentIdentifier Dot StopKeyword | AllKeyword ComponentKeyword Dot StopKeyword ComponentIdentifier VariableRef | FunctionInstance Static semantics: the variable associated with VariableRef or the Return type associated with FunctionInstance must be of component type 2.4 Port operations Port (PortIdentifier | PortParIdentifier) [ArrayOrBitRef] CommunicationStatements SendStatement | CallStatement | ReplyStatement | RaiseStatement | ReceiveStatement | TriggerStatement | GetCallStatement | GetReplyStatement | CatchStatement | CheckStatement | ClearStatement | StartStatement | StopStatement SendStatement Port Dot PortSendOp PortSendOp SendOpKeyword "(" SendParameter ")" [ToClause] SendOpKeyword "send" SendParameter TemplateInstance ToClause ToKeyword AddressRef ToKeyword "to" AddressRef VariableRef | FunctionInstance Static semantics: VariableRef and FunctionInstance return must be of address or component type CallStatement Port Dot PortCallOp [PortCallBody] PortCallOp CallOpKeyword "(" CallParameters ")" [ToClause] CallOpKeyword "call" CallParameters TemplateInstance ["," CallTimerValue] Static semantics: only out parameters may be omitted or specified with a matching attribute CallTimerValue TimerValue | NowaitKeyword Static semantics: Value must be of type float NowaitKeyword "nowait" PortCallBody BeginChar CallBodyStatementList EndChar CallBodyStatementList {CallBodyStatement [SemiColon]}+ CallBodyStatement CallBodyGuard StatementBlock CallBodyGuard AltGuardChar CallBodyOps CallBodyOps GetReplyStatement | CatchStatement ReplyStatement Port Dot PortReplyOp PortReplyOp ReplyKeyword "(" TemplateInstance [ReplyValue]")" [ToClause] ReplyKeyword "reply" ReplyValue ValueKeyword Expression RaiseStatement Port Dot PortRaiseOp PortRaiseOp RaiseKeyword "(" Signature "," TemplateInstance ")" [ToClause] RaiseKeyword "raise" ReceiveStatement PortOrAny Dot PortReceiveOp PortOrAny Port | AnyKeyword PortKeyword PortReceiveOp ReceiveOpKeyword ["(" ReceiveParameter ")"] [FromClause] [PortRedirect] Static semantics: the PortRedirect option may only be present if the ReceiveParameter option is also present ReceiveOpKeyword "receive" ReceiveParameter TemplateInstance FromClause FromKeyword AddressRef FromKeyword "from" PortRedirect PortRedirectSymbol (ValueSpec [SenderSpec] | SenderSpec) PortRedirectSymbol "->" ValueSpec ValueKeyword VariableRef ValueKeyword "value" SenderSpec SenderKeyword VariableRef Static semantics: VariableRef must be of address or component type SenderKeyword "sender" TriggerStatement PortOrAny Dot PortTriggerOp PortTriggerOp TriggerOpKeyword ["(" ReceiveParameter ")"] [FromClause] [PortRedirect] Static semantics: the PortRedirect option may only be present if the ReceiveParameter option is also present TriggerOpKeyword "trigger" GetCallStatement PortOrAny Dot PortGetCallOp PortGetCallOp GetCallOpKeyword ["(" ReceiveParameter ")"] [FromClause] [PortRedirectWithParam] Static semantics: the PortRedirectWithParam option may only be present if the ReceiveParameter option is also present GetCallOpKeyword "getcall" PortRedirectWithParam PortRedirectSymbol RedirectSpec RedirectSpec ValueSpec [ParaSpec] [SenderSpec] | ParaSpec [SenderSpec] | SenderSpec ParaSpec ParaKeyword ParaAssignmentList ParaKeyword "param" ParaAssignmentList "(" (AssignmentList | VariableList) ")" AssignmentList VariableAssignment {"," VariableAssignment} VariableAssignment VariableRef AssignmentChar ParameterIdentifier Static semantics: the ParameterIdentifiers must be from the corresponding signature definition ParameterIdentifier ValueParIdentifier | TimerParIdentifier | TemplateParIdentifier | PortParIdentifier VariableList VariableEntry {"," VariableEntry} VariableEntry VariableRef | NotUsedSymbol GetReplyStatement PortOrAny Dot PortGetReplyOp PortGetReplyOp GetReplyOpKeyword ["(" ReceiveParameter [ValueMatchSpec] ")"] [FromClause] [PortRedirectWithParam] Static semantics: the PortRedirectWithParam option may only be present if the ReceiveParameter option is also present GetReplyOpKeyword "getreply" ValueMatchSpec ValueKeyword TemplateInstance CheckStatement PortOrAny Dot PortCheckOp PortCheckOp CheckOpKeyword ["(" CheckParameter ")"] CheckOpKeyword "check" CheckParameter CheckPortOpsPresent | FromClausePresent | RedirectPresent FromClausePresent FromClause [PortRedirectSymbol SenderSpec] RedirectPresent PortRedirectSymbol SenderSpec CheckPortOpsPresent PortReceiveOp | PortGetCallOp | PortGetReplyOp | PortCatchOp CatchStatement PortOrAny Dot PortCatchOp PortCatchOp CatchOpKeyword ["("CatchOpParameter ")"] [FromClause] [PortRedirect] Static semantics: the PortRedirect option may only be present if the CatchOpParameter option is also present CatchOpKeyword "catch" CatchOpParameter Signature "," TemplateInstance | TimeoutKeyword ClearStatement PortOrAll Dot PortClearOp PortOrAll Port | AllKeyword PortKeyword PortClearOp ClearOpKeyword ClearOpKeyword "clear" StartStatement PortOrAll Dot PortStartOp PortStartOp StartKeyword StopStatement PortOrAll Dot PortStopOp PortStopOp StopKeyword StopKeyword "stop" AnyKeyword "any" 2.5 Timer operations TimerStatements StartTimerStatement | StopTimerStatement | TimeoutStatement TimerOps ReadTimerOp | RunningTimerOp StartTimerStatement TimerRef Dot StartKeyword ["(" TimerValue ")"] StopTimerStatement TimerRefOrAll Dot StopKeyword TimerRefOrAll TimerRef | AllKeyword TimerKeyword ReadTimerOp TimerRef Dot ReadKeyword ReadKeyword "read" RunningTimerOp TimerRefOrAny Dot RunningKeyword TimeoutStatement TimerRefOrAny Dot TimeoutKeyword TimerRefOrAny TimerRef | AnyKeyword TimerKeyword TimeoutKeyword "timeout" 3 Type Type PredefinedType | ReferencedType PredefinedType BitStringKeyword | BooleanKeyword | CharStringKeyword | UniversalCharString | CharKeyword | UniversalChar | IntegerKeyword | OctetStringKeyword | ObjectIdentifierKeyword | HexStringKeyword | VerdictTypeKeyword | FloatKeyword | AddressKeyword | DefaultKeyword | AnyTypeKeyword BitStringKeyword "bitstring" BooleanKeyword "boolean" IntegerKeyword "integer" OctetStringKeyword "octetstring" ObjectIdentifierKeyword "objid" HexStringKeyword "hexstring" VerdictTypeKeyword "verdicttype" FloatKeyword "float" AddressKeyword "address" DefaultKeyword "default" AnyTypeKeyword "anytype" CharStringKeyword "charstring" UniversalCharString UniversalKeyword CharStringKeyword UniversalKeyword "universal" CharKeyword "char" UniversalChar UniversalKeyword CharKeyword ReferencedType [GlobalModuleId Dot] TypeReference [ExtendedFieldReference] TypeReference StructTypeIdentifier[TypeActualParList] | EnumTypeIdentifier | SubTypeIdentifier | ComponentTypeIdentifier TypeActualParList "(" TypeActualPar {"," TypeActualPar} ")" TypeActualPar ConstantExpression ArrayDef {"[" ArrayBounds [".." ArrayBounds] "]"}+ ArrayBounds SingleConstExpression Static semantics: ArrayBounds will resolve to a non negative value of integer type 4 Value Value PredefinedValue | ReferencedValue PredefinedValue BitStringValue | BooleanValue | CharStringValue | IntegerValue | OctetStringValue | ObjectIdentifierValue | HexStringValue | VerdictTypeValue | EnumeratedValue | FloatValue | AddressValue | OmitValue BitStringValue Bstring BooleanValue "true" | "false" IntegerValue Number OctetStringValue Ostring ObjectIdentifierValue ObjectIdentifierKeyword "{" ObjIdComponentList "}" ReferencedValue must be of type object identifier ObjIdComponentList {ObjIdComponent}+ ObjIdComponent NameForm | NumberForm | NameAndNumberForm NumberForm Number | ReferencedValue Static semantics: ReferencedValue must be of type integer and have a non negative Value NameAndNumberForm Identifier "(" NumberForm ")" NameForm Identifier HexStringValue Hstring VerdictTypeValue "pass" | "fail" | "inconc" | "none" | "error" EnumeratedValue EnumerationIdentifier CharStringValue Cstring | Quadruple Quadruple CharKeyword "(" Group "," Plane "," Row "," Cell ")" Group Number Plane Number Row Number Cell Number FloatValue FloatDotNotation | FloatENotation FloatDotNotation Number Dot DecimalNumber FloatENotation Number [Dot DecimalNumber] Exponential [Minus] Number Exponential "E" ReferencedValue ValueReference [ExtendedFieldReference] ValueReference [GlobalModuleId Dot] (ConstIdentifier | ExtConstIdentifier) | ValueParIdentifier | ModuleParIdentifier | VarIdentifier Number (NonZeroNum {Num}) | "0" NonZeroNum "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" DecimalNumber {Num}+ Num "0" | NonZeroNum Bstring "'" {Bin} "'" "B" Bin "0" | "1" Hstring "'" {Hex} "'" "H" Hex Num | "A" | "B" | "C" | "D" | "E" | "F"| "a" | "b" | "c" | "d" | "e" | "f" Ostring "'" {Oct} "'" "O" Oct Hex Hex Cstring """ {Char} """ Char Reference: A character defined by the relevant CharacterString type. For charstring a character from the character set defined in ISO/IEC 646. For universal charstring a character from any character set defined in ISO/IEC 10646 Identifier Alpha{AlphaNum | Underscore} Alpha UpperAlpha | LowerAlpha AlphaNum Alpha | Num UpperAlpha "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" LowerAlpha "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" ExtendedAlphaNum Reference: A graphical character from the BASIC LATIN or from the LATIN-1 SUPPLEMENT character sets defined in ISO/IEC 10646 (characters from char (0,0,0,33) to char (0,0,0,126), from char (0,0,0,161) to char (0,0,0,172) and from char (0,0,0,174) to char (0,0,0,255) FreeText """ {ExtendedAlphaNum} """ AddressValue "null" OmitValue OmitKeyword OmitKeyword "omit" 5 Parameterization InParKeyword "in" OutParKeyword "out" InOutParKeyword "inout" FormalValuePar [(InParKeyword | InOutParKeyword | OutParKeyword)] Type ValueParIdentifier ValueParIdentifier Identifier FormalPortPar [InOutParKeyword] PortTypeIdentifier PortParIdentifier PortParIdentifier Identifier FormalTimerPar [InOutParKeyword] TimerKeyword TimerParIdentifier TimerParIdentifier Identifier FormalTemplatePar [InParKeyword] TemplateKeyword Type TemplateParIdentifier TemplateParIdentifier Identifier 6 With statement WithStatement WithKeyword WithAttribList WithKeyword "with" WithAttribList "{" MultiWithAttrib "}" MultiWithAttrib {SingleWithAttrib [SemiColon]}+ SingleWithAttrib AttribKeyword [OverrideKeyword] [AttribQualifier] AttribSpec AttribKeyword EncodeKeyword | VariationKeyword | DisplayKeyword | ExtensionKeyword EncodeKeyword "encode" VariationKeyword "variant" DisplayKeyword "display" ExtensionKeyword "extension" OverrideKeyword "override" AttribQualifier "(" DefOrFieldRefList ")" DefOrFieldRefList DefOrFieldRef {"," DefOrFieldRef} DefOrFieldRef DefinitionRef | FieldReference | AllRef | PredefinedType Static semantics: the DefOrFieldRef must refer to a definition or field which is within the module, group or definition to which the with statement is associated DefinitionRef StructTypeIdentifier | EnumTypeIdentifier | PortTypeIdentifier | ComponentTypeIdentifier | SubTypeIdentifier | ConstIdentifier | TemplateIdentifier | AltstepIdentifier | TestcaseIdentifier | FunctionIdentifier | SignatureIdentifier | VarIdentifier | TimerIdentifier | PortIdentifier | ModuleParIdentifier | FullGroupIdentifier AllRef ( GroupKeyword AllKeyword [ExceptKeyword BeginChar GroupRefList EndChar]) | ( TypeDefKeyword AllKeyword [ExceptKeyword BeginChar TypeRefList] EndChar) | ( TemplateKeyword AllKeyword [ExceptKeyword BeginChar TemplateRefList] EndChar) | ( ConstKeyword AllKeyword [ExceptKeyword BeginChar ConstRefList] EndChar) | ( AltstepKeyword AllKeyword [ExceptKeyword BeginChar AltstepRefList] EndChar) | ( TestcaseKeyword AllKeyword [ExceptKeyword BeginChar TestcaseRefList] EndChar) | ( FunctionKeyword AllKeyword [ExceptKeyword BeginChar FunctionRefList] EndChar) | ( SignatureKeyword AllKeyword [ExceptKeyword BeginChar SignatureRefList] EndChar) | ( ModuleParKeyword AllKeyword [ExceptKeyword BeginChar ModuleParRefList] EndChar) AttribSpec FreeText 7 Behaviour statements BehaviourStatements TestcaseInstance | FunctionInstance | ReturnStatement | AltConstruct | InterleavedConstruct | LabelStatement | GotoStatement | RepeatStatement | DeactivateStatement | AltstepInstance Static semantics: TestcaseInstance shall not be called from within an existing executing testcase or function chain called from a testcase i.e., testcases can only be instantiated from the control part or from functions directly called from the control part VerdictStatements SetLocalVerdict VerdictOps GetLocalVerdict SetLocalVerdict SetVerdictKeyword "(" SingleExpression ")" Static semantics: SingleExpression must resolve to a value of type verdict Static semantics: the SetLocalVerdict shall not be used to assign the Value error SetVerdictKeyword "setverdict" GetLocalVerdict "getverdict" SUTStatements ActionKeyword "(" (FreeText | TemplateRefWithParList) ")" ActionKeyword "action" ReturnStatement ReturnKeyword [Expression] AltConstruct AltKeyword BeginChar AltGuardList EndChar AltKeyword "alt" AltGuardList {GuardStatement [SemiColon]}+ [ElseStatement [SemiColon]] GuardStatement AltGuardChar (AltstepInstance | GuardOp StatementBlock) ElseStatement "["ElseKeyword "]" StatementBlock AltGuardChar "[" [BooleanExpression] "]" GuardOp TimeoutStatement | ReceiveStatement | TriggerStatement | GetCallStatement | CatchStatement | CheckStatement | GetReplyStatement | DoneStatement Static semantics: GuardOp used within the module control part. May only contain the timeoutStatement InterleavedConstruct InterleavedKeyword BeginChar InterleavedGuardList EndChar InterleavedKeyword "interleave" InterleavedGuardList {InterleavedGuardElement [SemiColon]}+ InterleavedGuardElement InterleavedGuard InterleavedAction InterleavedGuard "[" "]" GuardOp InterleavedAction StatementBlock Static semantics: the StatementBlock may not contain loop statements, goto, activate, deactivate, stop, return or calls to functions LabelStatement LabelKeyword LabelIdentifier LabelKeyword "label" LabelIdentifier Identifier GotoStatement GotoKeyword LabelIdentifier GotoKeyword "goto" RepeatStatement "repeat" ActivateOp ActivateKeyword "(" AltstepInstance ")" ActivateKeyword "activate" DeactivateStatement DeactivateKeyword ["(" Expression ")"] Static semantics: Expression shall evaluate to a value of default type DeactivateKeyword "deactivate" 8 Basic statements BasicStatements Assignment | LogStatement | LoopConstruct | ConditionalConstruct Expression SingleExpression | CompoundExpression Static semantics: Expression shall not contain Configuration, activate operation or verdict operations within the module control part CompoundExpression FieldExpressionList | ArrayExpression Static semantics: Within CompoundExpression the ArrayExpression can be used for Arrays, record, record of and set of types. FieldExpressionList "{" FieldExpressionSpec {"," FieldExpressionSpec} "}" FieldExpressionSpec FieldReference AssignmentChar Expression ArrayExpression "{" [ArrayElementExpressionList] "}" ArrayElementExpressionList NotUsedOrExpression {"," NotUsedOrExpression} NotUsedOrExpression Expression | NotUsedSymbol ConstantExpression SingleConstExpression | CompoundConstExpression SingleConstExpression SingleExpression Static semantics: SingleConstExpression shall not contain Variables or Module parameters and shall resolve to a constant Value at compile time BooleanExpression SingleExpression Static semantics: BooleanExpression shall resolve to a Value of type boolean CompoundConstExpression FieldConstExpressionList | ArrayConstExpression Static semantics: Within CompoundConstExpression the ArrayConstExpression can be used for Arrays, record, record of and set of types. FieldConstExpressionList "{" FieldConstExpressionSpec {"," FieldConstExpressionSpec} "}" FieldConstExpressionSpec FieldReference AssignmentChar ConstantExpression ArrayConstExpression "{" [ArrayElementConstExpressionList] "}" ArrayElementConstExpressionList ConstantExpression {"," ConstantExpression} Assignment VariableRef AssignmentChar Expression Operational semantics: The Expression on the RHS of Assignment shall evaluate to an explicit Value of the type of the LHS. SingleExpression SimpleExpression {LogicalOp SimpleExpression} Operational semantics: If both SimpleExpressions and the LogicalOp exist then the SimpleExpressions shall evaluate to specific values of compatible types SimpleExpression ["not"] SubExpression Operational semantics: Operands of the not operator shall be of type boolean (TTCN or ASN.1) or derivatives of type boolean SubExpression PartialExpression [RelOp PartialExpression] Operational semantics: If both PartialExpressions and the RelOp exist then the PartialExpressions shall evaluate to specific values of compatible types. Operational semantics: If RelOp is <, >, >=, or <= then each SubExpression shall evaluate to a specific integer, Enumerated or float Value (these values can either be TTCN or ASN.1 values) PartialExpression Result [ShiftOp Result] Operational semantics: Each Result shall resolve to a specific Value. If more than one Result exists the right-hand operand shall be of type integer and if the ShiftOp is << or >> then the left-hand operand shall resolve to either bitstring, hexstring or octetstring type. If the shift op is <@ or @> then the left-hand operand shall be of type bitstring, hexstring, charstring or universal charstring Result SubResult {BitOp SubResult} Operational semantics: If both SubResults and the BitOp exist then the SubResults shall evaluate to specific values of compatible types SubResult ["not4b"] Product Operational semantics: If the not4b operator exists, the operand shall be of type bitstring, octetstring or hexstring. Product Term {AddOp Term} Operational semantics: Each Term shall resolve to a specific Value. If more than one Term exists and the AddOp resolves to StringOp then the terms shall resolve to same type which shall be of bitstring, hexstring, octetstring, charstring or universal charstring.If more than one Term exists and the AddOp does not resolve to StringOp then the Terms shall both resolve to type integer or float. Term Factor {MultiplyOp Factor} Operational semantics: Each Factor shall resolve to a specific Value. If more than one Factor exists then the Factors shall resolve to type integer or float. Factor [UnaryOp] Primary Operational semantics: The Primary shall resolve to a specific Value. If UnaryOp exists and is "not" then Primary shall resolve to type boolean if the UnaryOp is + or - then Primary shall resolve to type integer or float. If the UnaryOp resolves to not4b then the Primary shall resolve to the type bitstring, hexstring or octetstring. Primary OpCall | Value | "(" SingleExpression ")" ExtendedFieldReference {(Dot ( StructFieldIdentifier | ArrayOrBitRef | TypeDefIdentifier)) | ArrayOrBitRef }+ Operational semantics: The TypeDefIdentifier shall be used only if the type of the VarInstance or ReferencedValue in which the ExtendedFieldReference is used is anytype. OpCall ConfigurationOps | VerdictOps | TimerOps | TestcaseInstance | FunctionInstance | TemplateOps | ActivateOp AddOp "+" | "-" | StringOp Operational semantics: Operands of the + or - operators shall be of type integer or float (i.e., TTCN or ASN.1 predefined) or derivations of integer or float (i.e., subrange) MultiplyOp "*" | "/" | "mod" | "rem" Operational semantics: Operands of the *, /, rem or mod operators shall be of type integer or float (i.e., TTCN or ASN.1 predefined) or derivations of integer or float (i.e., subrange). UnaryOp "+" | "-" Operational semantics: Operands of the + or - operators shall be of type integer or float (i.e., TTCN or ASN.1 predefined) or derivations of integer or float (i.e., subrange). RelOp "==" | "<" | ">" | "!=" | ">=" | "<=" Operational semantics: the precedence of the operators is defined here BitOp "and4b" | "xor4b" | "or4b" Operational semantics: Operands of the and4b, or4b or xor4b operator shall be of type bitstring, hexstring or octetstring (TTCN or ASN.1) or derivatives of these types. LogicalOp "and" | "xor" | "or" Operational semantics: Operands of the and, xor, or or operators shall be of type boolean (TTCN or ASN.1) or derivatives of type boolean. Operational semantics: the precedence of the operators is defined here StringOp "&" Operational semantics: Operands of the & operator shall be bitstring, hexstring, octetstring or character string ShiftOp "<<" | ">>" | "<@" | "@>" LogStatement LogKeyword "(" [FreeText] ")" LogKeyword "log" LoopConstruct ForStatement | WhileStatement | DoWhileStatement ForStatement ForKeyword "(" Initial SemiColon Final SemiColon Step ")" StatementBlock ForKeyword "for" Initial VarInstance | Assignment Final BooleanExpression Step Assignment WhileStatement WhileKeyword "(" BooleanExpression ")" StatementBlock WhileKeyword "while" DoWhileStatement DoKeyword StatementBlock WhileKeyword "(" BooleanExpression ")" DoKeyword "do" ConditionalConstruct IfKeyword "(" BooleanExpression ")" StatementBlock {ElseIfClause} [ElseClause] IfKeyword "if" ElseIfClause ElseKeyword IfKeyword "(" BooleanExpression ")" StatementBlock ElseKeyword "else" ElseClause ElseKeyword StatementBlock 9 Miscellaneous productions Dot "." Dash "-" Minus Dash SemiColon ";" Colon ":" Underscore "_" BeginChar "{" EndChar "}" AssignmentChar ":=" Overview of TTCN-3 types Class of type Keyword Sub-type Simple basic types integer range, list char range, list universal char range, list float range, list boolean list objid list verdicttype list Basic string types bitstring list, length hexstring list, length octetstring list, length charstring range, list, length universal charstring range, list, length Structured types record list record of list, length set list set of list, length enumerated list union list Special data types anytype list Special configuration types address port component Special default types default
Precedence of operators Priority Operator type Operator highest Unary/Binary +, - *, /, mod, rem Binary +, -, & Unary not4b Binary and4b Binary xor4b Binary or4b Binary <<, >>, <@, @> Binary <, >, <=, >= Binary ==, != Unary not Binary and Binary xor lowest Binary or
TTCN-3 predefined functions Category Function Keyword Conversion functions Convert integer value to char value int2char Convert integer value to universal char value int2unichar Convert integer value to bitstring value int2bit Convert integer value to hexstring value int2hex Convert integer value to octetstring value int2oct Convert integer value to charstring value int2str Convert integer value to float value int2float Convert float value to integer value float2int Convert char value to integer value char2int Convert universal char value to integer value unichar2int Convert bitstring value to integer value bit2int Convert bitstring value to hexstring value bit2hex Convert bitstring value to octetstring value bit2oct Convert bitstring value to charstring value bit2str Convert hexstring value to integer value hex2int Convert hexstring value to bitstring value hex2bit Convert hexstring value to octetstring value hex2oct Convert hexstring value to charstring value hex2str Convert octetstring value to integer value oct2int Convert octetstring value to bitstring value oct2bit Convert octetstring value to hexstring value oct2hex Convert octetstring value to charstring value oct2str Convert charstring value to integer value str2int Convert charstring value to octetstring value str2oct Length/size functions Return the length of a value of any string type lengthof Return the number of elements in a record, record of, template, set, set of or array sizeof Presence/choice functions Determine if an optional field in a record, record of, template, set or set of is present ispresent Determine which choice has been made in a union type ischosen String functions Returns part of the input string matching the specified pattern description regexp Returns the specified portion of the input string substr Other functions Generate a random float number rnd