1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
25 * Szabo, Janos Zoltan – initial implementation
28 * Zalanyi, Balazs Andor
30 ******************************************************************************/
31 /* Syntax check parser and compiler for TTCN-3 */
33 /* BNF compliance: v3.2.1 with extensions */
44 #include "../../common/dbgnew.hh"
45 #include "../../common/memory.h"
47 #include "../datatypes.h"
48 #include "Attributes.hh"
52 #include "../Identifier.hh"
53 #include "Templatestuff.hh"
54 #include "AST_ttcn3.hh"
56 #include "../CompType.hh"
57 #include "../CompField.hh"
58 #include "../EnumItem.hh"
59 #include "../SigParam.hh"
61 #include "../subtype.hh"
62 #include "../Value.hh"
63 #include "../Valuestuff.hh"
64 #include "../ustring.hh"
65 #include "Ttcnstuff.hh"
66 #include "TtcnTemplate.hh"
67 #include "Templatestuff.hh"
68 #include "ArrayDimensions.hh"
69 #include "PatternString.hh"
70 #include "Statement.hh"
73 using namespace Common;
75 const char *infile = NULL;
77 static Ttcn::Module *act_ttcn3_module = NULL;
78 static Ttcn::ErroneousAttributeSpec *act_ttcn3_erroneous_attr_spec = NULL;
79 bool is_erroneous_parsed = false;
80 static void ttcn3_error(const char *str);
81 static Group* act_group = NULL;
82 extern string anytype_field(const string& type_name);
83 static bool anytype_access = false;
88 static void yyprint(FILE *file, int type, const YYSTYPE& value);
89 #define YYPRINT(f,t,v) yyprint(f,t,v)
93 extern Modules *modules;
95 extern FILE *ttcn3_in;
96 extern char *ttcn3_text;
97 extern int ttcn3_lex();
98 extern void init_ttcn3_lex();
99 extern void free_ttcn3_lex();
100 extern void set_md5_checksum(Ttcn::Module *m);
102 extern void init_erroneous_lex(const char* p_infile, int p_line, int p_column);
103 struct yy_buffer_state;
104 extern int ttcn3_lex_destroy(void);
105 extern yy_buffer_state *ttcn3__scan_string(const char *yy_str);
106 extern void free_dot_flag_stuff();
108 extern string *parse_charstring_value(const char *str, const Location& loc);
109 extern PatternString* parse_pattern(const char *str, const Location& loc);
111 static const string anyname("anytype");
113 /* Various C macros */
115 #define YYERROR_VERBOSE
120 /* Bison declarations */
122 /*********************************************************************
124 *********************************************************************/
127 /* NOTE: the union is written to compiler.tab.hh, which is #included
128 * into compiler.l; therefore all types used here must be declared
129 * in compiler.l (forward declared or #included) */
130 bool bool_val; /* boolean value */
131 char *str; /* simple string value */
132 unsigned char uchar_val;
134 int_val_t *int_val; /* integer value */
135 Real float_val; /* float value */
138 ustring *ustring_val;
140 Type::typetype_t typetype;
141 PortTypeBody::PortOperationMode_t portoperationmode;
142 Value::operationtype_t operationtype;
143 Value::macrotype_t macrotype;
144 SingleWithAttrib::attribtype_t attribtype;
145 ImpMod::imptype_t imptype;
148 AltGuards *altguards;
149 ArrayDimension *arraydimension;
150 AttributeSpec *attributespec;
151 CompField *compfield;
152 CompFieldMap *compfieldmap;
155 Definition *definition;
158 EnumItems *enumitems;
159 FieldOrArrayRef *fieldorarrayref;
160 FormalPar *formalpar;
161 FormalParList *formalparlist;
163 FriendMod *friendMod;
165 IfClauses *ifclauses;
167 LengthRestriction *lenrestr;
169 LogArguments *logargs;
170 NamedTemplate *namedtempl;
171 NamedTemplates *namedtempls;
172 NamedValue *namedvalue;
173 NamedValues *namedvalues;
174 IndexedTemplate *indexedtempl;
175 IndexedTemplates *indexedtempls;
176 IndexedValue *indexedvalue;
177 MultiWithAttrib *multiwithattrib;
179 ParamAssignment *parass;
180 ParamAssignments *parasss;
181 ParamRedirect *parredir;
182 ParsedActualParameters *parsedpar;
183 PatternString *patstr;
184 Qualifier *qualifier;
185 Qualifiers *qualifiers;
186 SelectCase *selectcase;
187 SelectCases *selectcases;
188 SignatureExceptions *signexc;
189 SignatureParam *signparam;
190 SignatureParamList *signparamlist;
191 SingleWithAttrib *singlewithattrib;
193 StatementBlock *statementblock;
194 SubTypeParse *subtypeparse;
196 TemplateInstance *templinst;
197 TemplateInstances *templinsts;
199 Ttcn::Assignment *ass;
200 Ttcn::Ref_base *refbase;
201 Ttcn::Ref_pard *refpard;
202 Ttcn::Reference *reference;
203 ValueRange *valuerange;
208 VariableEntries *variableentries;
209 VariableEntry *variableentry;
210 vector<SubTypeParse> *subtypeparses;
211 CompTypeRefList *comprefs;
212 ComponentTypeBody *compbody;
213 template_restriction_t template_restriction;
217 ErroneousAttributeSpec::indicator_t indicator;
218 } erroneous_indicator;
220 struct arraydimension_list_t {
222 ArrayDimension **elements;
223 } arraydimension_list;
227 FieldOrArrayRef **elements;
228 } fieldorarrayref_list;
232 Ttcn::Definition **elements;
237 Ttcn::FriendMod **elements;
242 Statement **elements;
247 const char **elements;
252 bool lower_exclusive;
254 bool upper_exclusive;
259 bool returns_template;
260 template_restriction_t template_restriction;
266 } returntypeornoblock;
279 Ttcn::Types *in_list, *out_list, *inout_list;
280 bool in_all, out_all, inout_all;
284 Ttcn::Reference *ref;
290 LengthRestriction *len_restr;
291 } extramatchingattrs;
296 FormalParList *fp_list;
305 Ttcn::Ref_pard *ref_pard;
306 Value *derefered_value;
307 ParsedActualParameters *ap_list;
312 Ttcn::Ref_pard *ref_pard;
313 Value *derefered_value;
314 TemplateInstances *ap_list;
318 TemplateInstance *templ_inst;
323 Value *calltimerval; // if NULL: see nowait
328 TemplateInstance *templ_inst;
329 Value *calltimerval; // if NULL: see nowait
331 Value *val; // not used in callparams
335 TemplateInstance *templ_inst;
341 Ttcn::Reference *signature;
342 TemplateInstance *templ_inst;
347 Ttcn::Reference *redirectval;
348 Ttcn::Reference *redirectsender;
352 ParamRedirect *redirectparam;
353 Ttcn::Reference *redirectsender;
354 } portredirectwithparam;
357 Ttcn::Reference *redirectval;
358 ParamRedirect *redirectparam;
359 Ttcn::Reference *redirectsender;
360 } portredirectwithvalueandparam;
363 TemplateInstance *templ_inst;
364 TemplateInstance *valuematch;
368 TemplateInstance *templ_inst;
369 TemplateInstance *fromclause;
370 Ttcn::Reference *redirectval;
371 Ttcn::Reference *redirectsender;
375 TemplateInstance *templ_inst;
376 TemplateInstance *fromclause;
377 ParamRedirect *redirectparam;
378 Ttcn::Reference *redirectsender;
382 TemplateInstance *templ_inst;
383 TemplateInstance *valuematch;
384 TemplateInstance *fromclause;
385 Ttcn::Reference *redirectval;
386 ParamRedirect *redirectparam;
387 Ttcn::Reference *redirectsender;
391 Ttcn::Reference *signature;
392 TemplateInstance *templ_inst;
397 Ttcn::Reference *signature;
398 TemplateInstance *templ_inst;
400 TemplateInstance *fromclause;
401 Ttcn::Reference *redirectval;
402 Ttcn::Reference *redirectsender;
406 Statement::statementtype_t statementtype;
407 Ttcn::Reference *signature;
408 TemplateInstance *templ_inst;
409 TemplateInstance *valuematch;
411 TemplateInstance *fromclause;
412 Ttcn::Reference *redirectval;
413 ParamRedirect *redirectparam;
414 Ttcn::Reference *redirectsender;
419 Ttcn::Reference *portref;
424 Ttcn::Reference *portref1;
426 Ttcn::Reference *portref2;
430 TemplateInstance *donematch;
431 Ttcn::Reference *redirect;
437 Ttcn::Reference *ref;
444 Ttcn::Assignment *ass;
448 Ttcn::Reference *runsonref;
449 Ttcn::Reference *systemref;
459 ParsedActualParameters *ap_list;
463 struct extconstidentifier_t {
466 } extconstidentifier;
470 extconstidentifier_t *elements;
473 struct singlevarinst_t {
475 arraydimension_list_t arrays;
476 Value *initial_value;
480 struct singlevarinst_list_t {
482 struct singlevarinst_t *elements;
483 } singlevarinst_list;
485 struct singletempvarinst_t {
487 arraydimension_list_t arrays;
488 Template *initial_value;
492 struct singletempvarinst_list_t {
494 singletempvarinst_t *elements;
495 } singletempvarinst_list;
497 struct singlemodulepar_t {
503 struct singletemplatemodulepar_t {
507 } singletemplatemodulepar;
509 struct singlemodulepar_list_t {
511 singlemodulepar_t *elements;
512 } singlemodulepar_list;
514 struct singletemplatemodulepar_list_t {
516 singletemplatemodulepar_t *elements;
517 } singletemplatemodulepar_list;
519 struct portelement_t {
521 ArrayDimensions *dims;
525 struct portelement_list_t {
527 portelement_t *elements;
530 struct runs_on_compref_or_self_t {
532 Ttcn::Reference *reference;
533 } runs_on_compref_or_self;
536 visibility_t visibility;
540 /* Tokens of TTCN-3 */
542 /*********************************************************************
543 * Tokens with semantic value
544 *********************************************************************/
546 /* Terminals with semantic value */
548 %token <int_val> Number
549 %token <float_val> FloatValue
550 %token <id> IDentifier "Identifier"
552 %token <string_val> Bstring
559 %token NullValue "ASN.1_NULL_value"
560 %token <macrotype> MacroValue
562 /*********************************************************************
563 * Tokens without semantic value
564 *********************************************************************/
566 /* Terminals without semantic value - keywords, operators, etc. */
568 %token TOK_errval "erroneous_value"
570 /* A number of terminals (including ApplyKeyword, CallOpKeyword, etc)
571 * are listed as unused by Bison. They do not appear in any rule,
572 * because the lexer does some magic to combine them with the preceding dot
573 * and returns a (DotApplyKeyword, DotCallOpKeyword, etc) instead.
574 * This magic requires the presence of the unused keywords.
575 * (It can return an ApplyKeyword if not preceded by a dot) */
576 %token TitanErroneousHackKeyword
578 %token ActivateKeyword
579 %token AddressKeyword
583 %token AltstepKeyword
587 %token AnyTypeKeyword
589 %token BitStringKeyword
590 %token BooleanKeyword
594 %token CatchOpKeyword
596 %token CharStringKeyword
597 %token CheckOpKeyword
598 %token CheckStateKeyword
599 %token ClearOpKeyword
600 %token ComplementKeyword
601 %token ComponentKeyword
602 %token ConnectKeyword
604 %token ContinueKeyword
605 %token ControlKeyword
607 %token DeactivateKeyword
608 %token DefaultKeyword
609 %token DerefersKeyword
610 %token DisconnectKeyword
611 %token DisplayKeyword
619 %token ExceptionKeyword
620 %token ExecuteKeyword
621 %token ExtendsKeyword
622 %token ExtensionKeyword
630 %token FunctionKeyword
631 %token GetCallOpKeyword
632 %token GetReplyOpKeyword
633 %token GetVerdictKeyword
637 %token HexStringKeyword
639 %token IfPresentKeyword
642 %token InfinityKeyword
643 %token InOutParKeyword
645 %token IntegerKeyword
646 %token InterleavedKeyword
650 %token LanguageKeyword
655 %token MessageKeyword
658 %token ModifiesKeyword
659 %token ModuleParKeyword
662 %token NoBlockKeyword
668 %token ObjectIdentifierKeyword
669 %token OctetStringKeyword
673 %token OptionalKeyword
677 %token OverrideKeyword
680 %token PatternKeyword
681 %token PermutationKeyword
682 %token PresentKeyword
684 %token PrivateKeyword
685 %token ProcedureKeyword
689 %token ReceiveOpKeyword
691 %token RecursiveKeyword
697 %token RunningKeyword
704 %token SetVerdictKeyword
705 %token SignatureKeyword
709 %token SupersetKeyword
711 %token TemplateKeyword
712 %token TestcaseKeyword
713 %token TimeoutKeyword
716 %token TriggerOpKeyword
718 %token TTCN3ModuleKeyword
719 %token TypeDefKeyword
721 %token UniversalKeyword
724 %token ValueofKeyword
726 %token VariantKeyword
727 %token VerdictTypeKeyword
733 /* modifier keywords */
737 /* TITAN specific keywords */
738 %token TitanSpecificTryKeyword
739 %token TitanSpecificCatchKeyword
740 %token TitanSpecificProfilerKeyword
742 /* Keywords combined with a leading dot */
744 /* If a '.' (dot) character is followed by one of the keywords below the
745 * lexical analyzer shall return one combined token instead of two distinct
746 * tokens. This eliminates the ambiguity that causes additional shift/reduce
747 * conflicts because the dot can be either the part of a field reference or a
748 * built-in operation denoted by a keyword. */
750 %token DotAliveKeyword
751 %token DotApplyKeyword
752 %token DotCallOpKeyword
753 %token DotCatchOpKeyword
754 %token DotCheckOpKeyword
755 %token DotCheckStateKeyword
756 %token DotClearOpKeyword
757 %token DotCreateKeyword
758 %token DotDoneKeyword
759 %token DotGetCallOpKeyword
760 %token DotGetReplyOpKeyword
761 %token DotHaltKeyword
762 %token DotKillKeyword
763 %token DotKilledKeyword
764 %token DotRaiseKeyword
765 %token DotReadKeyword
766 %token DotReceiveOpKeyword
767 %token DotReplyKeyword
768 %token DotRunningKeyword
769 %token DotSendOpKeyword
770 %token DotStartKeyword
771 %token DotStopKeyword
772 %token DotTimeoutKeyword
773 %token DotTriggerOpKeyword
775 /* Predefined function identifiers */
777 %token bit2hexKeyword
778 %token bit2intKeyword
779 %token bit2octKeyword
780 %token bit2strKeyword
781 %token char2intKeyword
782 %token char2octKeyword
784 %token float2intKeyword
785 %token hex2bitKeyword
786 %token hex2intKeyword
787 %token hex2octKeyword
788 %token hex2strKeyword
789 %token int2bitKeyword
790 %token int2charKeyword
791 %token int2enumKeyword
792 %token int2floatKeyword
793 %token int2hexKeyword
794 %token int2octKeyword
795 %token int2strKeyword
796 %token int2unicharKeyword
797 %token isvalueKeyword
798 %token isboundKeyword
799 %token ischosenKeyword
800 %token ispresentKeyword
801 %token lengthofKeyword
802 %token oct2bitKeyword
803 %token oct2charKeyword
804 %token oct2hexKeyword
805 %token oct2intKeyword
806 %token oct2strKeyword
807 %token oct2unicharKeyword
809 %token replaceKeyword
811 %token testcasenameKeyword
813 %token str2floatKeyword
814 %token str2intKeyword
815 %token str2octKeyword
817 %token unichar2intKeyword
818 %token unichar2charKeyword
819 %token unichar2octKeyword
821 %token float2strKeyword
822 %token str2bitKeyword
823 %token str2hexKeyword
825 %token log2strKeyword
826 %token enum2intKeyword
828 %token encvalueKeyword
829 %token decvalueKeyword
831 %token ttcn2stringKeyword
832 %token string2ttcnKeyword
833 %token remove_bomKeyWord
834 %token get_stringencodingKeyWord
835 %token encode_base64KeyWord
836 %token decode_base64KeyWord
837 %token encvalue_unicharKeyWord
838 %token decvalue_unicharKeyWord
839 %token any2unistrKeyWord
841 /* Multi-character operators */
843 %token AssignmentChar ":="
845 %token PortRedirectSymbol "->"
853 %token _RR "@>" /* Name clash with bn.h:292 */
855 /*********************************************************************
856 * Semantic types of nonterminals
857 *********************************************************************/
859 %type <bool_val> optAliveKeyword optOptionalKeyword optOverrideKeyword
860 optErrValueRaw optAllKeyword optLazyEval
861 %type <str> FreeText optLanguageSpec PatternChunk PatternChunkList
862 %type <uchar_val> Group Plane Row Cell
863 %type <id> FieldIdentifier FieldReference GlobalModuleId
864 IdentifierOrAddressKeyword StructFieldRef PredefOrIdentifier
865 %type <string_val> CstringList
866 %type <ustring_val> Quadruple
867 %type <uid_list> USI UIDlike
869 %type <typetype> PredefinedType
870 %type <portoperationmode> PortOperationMode
871 %type <operationtype> PredefinedOpKeyword1 PredefinedOpKeyword2 PredefinedOpKeyword3
873 %type <activateop> ActivateOp
874 %type <attribtype> AttribKeyword
876 %type <altguard> CallBodyStatement AltGuard ElseStatement GuardStatement
877 InterleavedGuardElement
878 %type <altguards> AltGuardList CallBodyStatementList InterleavedGuardList
880 %type <arraydimension> ArrayIndex
881 %type <attributespec> AttribSpec
882 %type <compbody> optComponentDefList ComponentElementDefList
883 %type <compfield> StructFieldDef UnionFieldDef
884 %type <compfieldmap> StructFieldDefList optStructFieldDefList UnionFieldDefList
885 %type <definition> AltstepDef ExtFunctionDef FunctionDef TemplateDef TestcaseDef
886 %type <deftype> TypeDefBody StructuredTypeDef SubTypeDef RecordDef UnionDef
887 SetDef RecordOfDef SetOfDef EnumDef PortDef PortDefBody ComponentDef
888 TypeDef SignatureDef FunctionTypeDef AltstepTypeDef TestcaseTypeDef
889 %type <deftimer> SingleTimerInstance
890 %type <enumitem> Enumeration
891 %type <enumitems> EnumerationList
892 %type <fieldorarrayref> ArrayOrBitRef ArrayOrBitRefOrDash FieldOrArrayReference
893 %type <formalpar> FormalValuePar FormalTemplatePar FormalTimerPar
894 TemplateFormalPar FunctionFormalPar TestcaseFormalPar
895 %type <formalparlist> optTemplateFormalParList TemplateFormalParList
896 optFunctionFormalParList FunctionFormalParList optTestcaseFormalParList
897 TestcaseFormalParList optAltstepFormalParList
898 %type <group> GroupDef GroupIdentifier
899 %type <friend_list> FriendModuleDef
900 %type <ifclause> ElseIfClause
901 %type <ifclauses> seqElseIfClause
902 %type <impmod> ImportFromSpec ModuleId ImportDef
903 %type <lenrestr> optStringLength LengthMatch StringLength
904 %type <logarg> LogItem
905 %type <logargs> LogItemList
906 %type <multiwithattrib> MultiWithAttrib WithAttribList WithStatement
907 optWithStatement optWithStatementAndSemiColon
908 %type <namedtempl> FieldSpec
909 %type <namedtempls> seqFieldSpec
910 %type <namedvalue> FieldExpressionSpec
911 %type <namedvalues> seqFieldExpressionSpec
912 %type <indexedtempl> ArraySpec
913 %type <indexedtempls> seqArraySpec
914 %type <indexedvalue> ArrayExpressionSpec
915 %type <oidcomp> NumberForm NameAndNumberForm ObjIdComponent
916 %type <parass> VariableAssignment
917 %type <parasss> AssignmentList
918 %type <parredir> ParamAssignmentList ParamSpec
919 %type <patstr> CharStringMatch
920 %type <qualifier> DefOrFieldRef FullGroupIdentifier
921 %type <qualifiers> DefOrFieldRefList optAttribQualifier
922 %type <selectcase> SelectCase
923 %type <selectcases> seqSelectCase SelectCaseBody
924 %type <signexc> ExceptionTypeList optExceptionSpec
925 %type <signparam> SignatureFormalPar
926 %type <signparamlist> SignatureFormalParList optSignatureFormalParList
927 %type <singlewithattrib> SingleWithAttrib
928 %type <stmt> AltConstruct BasicStatements BreakStatement BehaviourStatements
929 CallBodyOps CallStatement CatchStatement CheckStatement ClearStatement
930 CommunicationStatements ConditionalConstruct ConfigurationStatements
931 ConnectStatement ContinueStatement ControlStatement DeactivateStatement
932 DisconnectStatement DoWhileStatement DoneStatement ForStatement
933 FunctionStatement GetCallStatement GetReplyStatement GotoStatement GuardOp
934 HaltStatement InterleavedConstruct KillTCStatement KilledStatement
935 LabelStatement LogStatement LoopConstruct MapStatement RaiseStatement
936 ReceiveStatement RepeatStatement ReplyStatement ReturnStatement SUTStatements
937 SendStatement SetLocalVerdict StartStatement StartTCStatement
938 StartTimerStatement StopExecutionStatement StopStatement StopTCStatement
939 StopTimerStatement TimeoutStatement TimerStatements TriggerStatement
940 UnmapStatement VerdictStatements WhileStatement SelectCaseConstruct
941 StopTestcaseStatement String2TtcnStatement ProfilerStatement int2enumStatement
942 %type <statementblock> StatementBlock optElseClause FunctionStatementOrDefList
943 ControlStatementOrDefList ModuleControlBody
944 %type <subtypeparse> ValueOrRange
945 %type <templ> MatchingSymbol SingleValueOrAttrib SimpleSpec TemplateBody
946 ArrayElementSpec ArrayValueOrAttrib FieldSpecList ArraySpecList
947 AllElementsFrom TemplateListElem
948 %type <templinst> AddressRef FromClause FunctionActualPar InLineTemplate
949 ReceiveParameter SendParameter TemplateActualPar TemplateInstance
950 /* TestcaseActualPar */ ValueMatchSpec optFromClause optParDefaultValue
952 %type <parsedpar> FunctionActualParList TestcaseActualParList
953 optFunctionActualParList optTestcaseActualParList
954 NamedPart UnnamedPart
955 %type <templinsts> optTemplateActualParList
956 seqTemplateActualPar seqTemplateInstance
957 %type <templs> ValueOrAttribList seqValueOrAttrib ValueList Complement
958 ArrayElementSpecList SubsetMatch SupersetMatch PermutationMatch
959 %type <ass> Assignment Step
960 %type <refbase> DerivedRefWithParList TemplateRefWithParList DecValueArg
961 %type <refpard> FunctionInstance AltstepInstance
962 %type <reference> PortType optDerivedDef DerivedDef Signature VariableRef
963 TimerRef TimerRefOrAny Port PortOrAny PortOrAll ValueSpec
964 SenderSpec ComponentType optRunsOnSpec RunsOnSpec optSystemSpec
965 %type <valuerange> Range
966 %type <type> NestedEnumDef NestedRecordDef NestedRecordOfDef NestedSetDef
967 NestedSetOfDef NestedTypeDef NestedUnionDef PortDefAttribs ReferencedType
968 Type TypeOrNestedTypeDef NestedFunctionTypeDef NestedAltstepTypeDef
969 NestedTestcaseTypeDef
970 %type <types> TypeList AllOrTypeList
971 %type <value> AddressValue AliveOp AllPortsSpec AltGuardChar ArrayBounds
972 ArrayExpression ArrayExpressionList BitStringValue BooleanExpression
973 BooleanValue CharStringValue ComponentRef ComponentReferenceOrLiteral
974 ComponentOrDefaultReference CompoundExpression ConfigurationOps CreateOp
975 DereferOp Expression FieldExpressionList Final GetLocalVerdict HexStringValue
976 IntegerValue LowerBound MTCOp MatchOp NotUsedOrExpression ObjIdComponentList
977 ObjectIdentifierValue OctetStringValue OmitValue OpCall PredefinedOps
978 PredefinedValue ReadTimerOp ReferOp ReferencedValue RunningOp RunningTimerOp
979 SelfOp SingleExpression SingleLowerBound SystemOp TemplateOps TimerOps
980 TimerValue UpperBound Value ValueofOp VerdictOps VerdictValue optReplyValue
981 optTestcaseTimerValue optToClause ProfilerRunningOp
982 %type <values> ArrayElementExpressionList seqArrayExpressionSpec
983 %type <variableentries> VariableList
984 %type <variableentry> VariableEntry
985 %type <subtypeparses> seqValueOrRange AllowedValues optSubTypeSpec
987 %type <arraydimension_list> optArrayDef
988 %type <fieldorarrayref_list> optExtendedFieldReference
989 %type <def_list> AltstepLocalDef AltstepLocalDefList ComponentElementDef
990 ConstDef ExtConstDef FunctionLocalDef FunctionLocalInst ModuleDef ModulePar
991 ModuleParDef MultiTypedModuleParList PortInstance TimerInstance TimerList
993 %type <stmt_list> FunctionStatementOrDef ControlStatementOrDef
995 %type <rangedef> RangeDef
996 %type <returntype> optReturnType
997 %type <returntypeornoblock> optReturnTypeOrNoBlockKeyword
998 %type <structdefbody> StructDefBody UnionDefBody
999 %type <structofdefbody> StructOfDefBody
1000 %type <portdefbody> PortDefList seqPortDefList PortDefLists
1001 %type <ischosenarg> IschosenArg
1002 %type <extramatchingattrs> optExtraMatchingAttributes
1003 %type <basetemplate> BaseTemplate
1004 %type <templateref> TemplateRef TestcaseRef FunctionRef
1005 %type <testcaseinst> TestcaseInstance
1006 %type <portsendop> PortSendOp
1007 %type <calltimerval> CallTimerValue
1008 %type <portcallop> PortCallOp CallParameters
1009 %type <portreplyop> PortReplyOp
1010 %type <portraiseop> PortRaiseOp
1011 %type <portredirect> optPortRedirect
1012 %type <portredirectwithparam> optPortRedirectWithParam
1013 %type <portredirectwithvalueandparam> optPortRedirectWithValueAndParam
1014 %type <getreplypar> optGetReplyParameter
1015 %type <portreceiveop> PortReceiveOp PortTriggerOp
1016 %type <portgetcallop> PortGetCallOp
1017 %type <portgetreplyop> PortGetReplyOp
1018 %type <catchoppar> optCatchOpParameter CatchOpParameter
1019 %type <portcatchop> PortCatchOp
1020 %type <portcheckop> optCheckParameter CheckParameter CheckPortOpsPresent
1021 FromClausePresent RedirectPresent
1022 %type <portref> PortRef AllConnectionsSpec
1023 %type <connspec> SingleConnectionSpec SingleOrMultiConnectionSpec
1024 %type <donepar> optDoneParameter
1025 %type <reforid> Reference
1026 %type <initial> Initial
1027 %type <configspec> ConfigSpec
1028 %type <createpar> optCreateParameter
1029 %type <applyop> ApplyOp
1030 %type <identifier_list> IdentifierList
1031 %type <singlevarinst> SingleConstDef SingleVarInstance
1032 %type <singlevarinst_list> ConstList VarList
1033 %type <singletempvarinst> SingleTempVarInstance
1034 %type <singletempvarinst_list> TempVarList
1035 %type <singlemodulepar> SingleModulePar
1036 %type <singletemplatemodulepar> SingleTemplateModulePar
1037 %type <singlemodulepar_list> ModuleParList
1038 %type <singletemplatemodulepar_list> TemplateModuleParList
1039 %type <portelement> PortElement
1040 %type <portelement_list> PortElementList
1041 %type <comprefs> optExtendsDef ComponentTypeList
1042 %type <runs_on_compref_or_self> optRunsOnComprefOrSelf
1043 %type <template_restriction> TemplateRestriction optTemplateRestriction
1044 TemplateOptRestricted
1045 %type <visbilitytype> optVisibility ComponentElementVisibility
1046 %type <float_val> FloatOrSpecialFloatValue
1047 %type <erroneous_indicator> ErroneousIndicator
1048 %type <imptype> ImportSpec ImportElement
1050 /*********************************************************************
1052 *********************************************************************/
1055 act_group = $$->get_parent_group();
1060 %destructor {Free($$);}
1069 delete $$.derefered_value;
1074 %destructor {delete $$;}
1088 ArrayElementExpressionList
1090 ArrayElementSpecList
1109 CallBodyStatementList
1116 CommunicationStatements
1119 ComponentElementDefList
1120 ComponentOrDefaultReference
1122 ComponentReferenceOrLiteral
1126 ConditionalConstruct
1128 ConfigurationStatements
1132 ControlStatementOrDefList
1139 DerivedRefWithParList
1153 FieldOrArrayReference
1165 FunctionActualParList
1168 FunctionFormalParList
1171 FunctionStatementOrDefList
1185 IdentifierOrAddressKeyword
1190 InterleavedConstruct
1191 InterleavedGuardElement
1192 InterleavedGuardList
1200 String2TtcnStatement
1212 NestedAltstepTypeDef
1214 NestedFunctionTypeDef
1219 NestedTestcaseTypeDef
1227 ObjectIdentifierValue
1275 SignatureFormalParList
1288 StopExecutionStatement
1289 StopTestcaseStatement
1306 TemplateFormalParList
1309 TemplateRefWithParList
1310 /* TestcaseActualPar */
1311 TestcaseActualParList
1314 TestcaseFormalParList
1351 optAltstepFormalParList
1359 optFunctionActualParList
1360 optFunctionFormalParList
1366 optSignatureFormalParList
1368 optStructFieldDefList
1370 optTemplateActualParList
1371 optTemplateFormalParList
1372 optTestcaseActualParList
1373 optTestcaseFormalParList
1374 optTestcaseTimerValue
1377 optWithStatementAndSemiColon
1379 seqFieldExpressionSpec
1381 seqTemplateActualPar
1387 for (size_t i = 0; i < $$->size(); i++) delete (*$$)[i];
1396 for(size_t i=0; i<$$.nElements; i++) delete $$.elements[i];
1403 ControlStatementOrDef
1407 FunctionStatementOrDef
1411 MultiTypedModuleParList
1417 optExtendedFieldReference
1433 optReturnTypeOrNoBlockKeyword
1451 delete $$.inout_list;
1464 delete $$.len_restr;
1466 optExtraMatchingAttributes
1485 delete $$.derefered_value;
1492 delete $$.templ_inst;
1498 delete $$.calltimerval;
1503 delete $$.templ_inst;
1504 delete $$.calltimerval;
1507 PortCallOp CallParameters
1510 delete $$.templ_inst;
1517 delete $$.signature;
1518 delete $$.templ_inst;
1524 delete $$.redirectval;
1525 delete $$.redirectsender;
1530 delete $$.redirectparam;
1531 delete $$.redirectsender;
1533 optPortRedirectWithParam
1536 delete $$.redirectval;
1537 delete $$.redirectparam;
1538 delete $$.redirectsender;
1540 optPortRedirectWithValueAndParam
1543 delete $$.templ_inst;
1544 delete $$.valuematch;
1546 optGetReplyParameter
1549 delete $$.templ_inst;
1550 delete $$.fromclause;
1551 delete $$.redirectval;
1552 delete $$.redirectsender;
1558 delete $$.templ_inst;
1559 delete $$.fromclause;
1560 delete $$.redirectparam;
1561 delete $$.redirectsender;
1566 delete $$.templ_inst;
1567 delete $$.valuematch;
1568 delete $$.fromclause;
1569 delete $$.redirectval;
1570 delete $$.redirectparam;
1571 delete $$.redirectsender;
1576 delete $$.signature;
1577 delete $$.templ_inst;
1583 delete $$.signature;
1584 delete $$.templ_inst;
1585 delete $$.fromclause;
1586 delete $$.redirectval;
1587 delete $$.redirectsender;
1592 delete $$.signature;
1593 delete $$.templ_inst;
1594 delete $$.valuematch;
1595 delete $$.fromclause;
1596 delete $$.redirectval;
1597 delete $$.redirectparam;
1598 delete $$.redirectsender;
1619 SingleConnectionSpec
1620 SingleOrMultiConnectionSpec
1623 delete $$.donematch;
1629 if ($$.is_ref) delete $$.ref;
1641 delete $$.runsonref;
1642 delete $$.systemref;
1659 for (size_t i = 0; i < $$.nElements; i++) delete $$.elements[i].id;
1666 for (size_t i = 0; i < $$.arrays.nElements; i++)
1667 delete $$.arrays.elements[i];
1668 Free($$.arrays.elements);
1669 delete $$.initial_value;
1673 SingleTempVarInstance
1676 for (size_t i = 0; i < $$.nElements; i++) {
1677 delete $$.elements[i].id;
1678 for (size_t j = 0; i < $$.elements[i].arrays.nElements; j++)
1679 delete $$.elements[i].arrays.elements[j];
1680 Free($$.elements[i].arrays.elements);
1681 delete $$.elements[i].initial_value;
1699 SingleTemplateModulePar
1702 for (size_t i = 0; i < $$.nElements; i++) {
1703 delete $$.elements[i].id;
1704 delete $$.elements[i].defval;
1711 for (size_t i = 0; i < $$.nElements; i++) {
1712 delete $$.elements[i].id;
1713 delete $$.elements[i].deftempl;
1717 TemplateModuleParList
1726 for (size_t i = 0; i < $$.nElements; i++) {
1727 delete $$.elements[i].id;
1728 delete $$.elements[i].dims;
1735 delete $$.reference;
1737 optRunsOnComprefOrSelf
1739 /*********************************************************************
1740 * Operator precedences (lowest first)
1741 *********************************************************************/
1748 %nonassoc '<' '>' GE LE
1755 %left '*' '/' ModKeyword RemKeyword
1763 XXX Source of conflicts (26 S/R):
1765 1.) 9 conflicts in one state
1766 The Expression after 'return' keyword is optional in ReturnStatement.
1767 For 9 tokens the parser cannot decide whether the token is a part of
1768 the return expression (shift) or it is the beginning of the next statement
1771 2.) 9 distinct states, each with one conflict caused by token '['
1772 The local definitions in altsteps can be followed immediately by the guard
1773 expression. When the parser sees the '[' token it cannot decide whether it
1774 belongs to the local definition as array dimension or array subreference
1775 (shift) or it is the beginning of the first guard expression (reduce).
1776 The situations are the following:
1777 - var t v := ref <here> [
1778 - var t v := ref[subref] <here> [
1779 - var t v := ref.integer <here> [
1780 - var t v := ref.subref <here> [
1783 - var t v := ref.objid{...}.subref <here> [
1784 - var template t v <here> [
1785 - var t v := function(...)<subrefs> <here> [
1788 The sequence identifier.objid can be either the beginning of a module name
1789 qualified with a module object identifier (shift) or a reference to an objid
1790 value within an entity of type anytype (reduce).
1793 The '{' token after a call statement can be either the part of the response and
1794 exception handling part (shift) or the beginning of the next statement, which
1795 is a StatementBlock (reduce). Note that StatementBlock as a statement is a
1796 non-standard language extension.
1798 5.) 5 conflicts in in three states, related to named parameters
1800 6.) 1 Conflict due to pattern concatenation
1802 Note that the parser implemented by bison always chooses to shift instead of
1803 reduce in case of conflicts.
1808 /*********************************************************************
1810 *********************************************************************/
1812 /* The grammar of TTCN-3 */
1813 /* The numbers correspond to ES 201 873-1 V4.1.2 (2009-07) */
1818 if (is_erroneous_parsed) {
1819 delete act_ttcn3_module;
1820 act_ttcn3_module = NULL;
1821 Location loc(infile, @1);
1822 loc.error("The erroneous attribute cannot be a TTCN-3 module.");
1825 | TitanErroneousHackKeyword ErroneousAttributeSpec
1827 if (!is_erroneous_parsed) {
1828 delete act_ttcn3_erroneous_attr_spec;
1829 act_ttcn3_erroneous_attr_spec = NULL;
1830 Location loc(infile, @$);
1831 loc.error("File `%s' does not contain a TTCN-3 module.", infile);
1837 ErroneousAttributeSpec:
1838 ErroneousIndicator AssignmentChar TemplateInstance optAllKeyword
1840 act_ttcn3_erroneous_attr_spec = new ErroneousAttributeSpec($1.is_raw, $1.indicator, $3, $4);
1845 ValueKeyword optErrValueRaw
1847 $$.indicator = ErroneousAttributeSpec::I_VALUE;
1850 | IDentifier optErrValueRaw
1852 if ($1->get_ttcnname()=="before") $$.indicator = ErroneousAttributeSpec::I_BEFORE;
1853 else if ($1->get_ttcnname()=="after") $$.indicator = ErroneousAttributeSpec::I_AFTER;
1855 Location loc(infile, @1);
1856 loc.error("Invalid indicator. Valid indicators are: "
1857 "`before', `value' and `after'");
1858 $$.indicator = ErroneousAttributeSpec::I_INVALID;
1866 /* empty */ { $$ = false; }
1867 | AllKeyword { $$ = true; }
1871 /* empty */ { $$ = false; }
1872 | '(' IDentifier ')'
1874 if ($2->get_ttcnname()=="raw") $$ = true;
1876 Location loc(infile, @2);
1877 loc.error("Invalid keyword, only the optional `raw' keyword can be used here.");
1885 /* A.1.6.0 TTCN Module */
1888 TTCN3ModuleId ModuleBody optWithStatementAndSemiColon optError
1890 act_ttcn3_module->set_with_attr($3);
1891 if (anytype_access) {
1892 // If there was an attempted access to an anytype field, artificially
1893 // create a type definition as if the following appeared in TTCN-3:
1894 // type union anytype { /* empty, members added later */ }
1895 // NOTE: anything which looks like usage of an anytype field will bring
1896 // the local anytype to life, which trumps any imported anytype
1897 // (when resolving, the local anytype will be found first).
1898 // TODO: just to be safe, anytype should be removed from the exports.
1899 Type *t = new Type(Type::T_ANYTYPE);
1900 Identifier *anytype_id = new Identifier(Identifier::ID_TTCN, anyname);
1901 Def_Type *anytypedef = new Def_Type(anytype_id, t);
1902 anytypedef->set_parent_path(act_ttcn3_module->get_attrib_path());
1903 act_ttcn3_module->add_ass(anytypedef);
1904 // Def_Type is-a Definition is-a Assignment
1910 optError TTCN3ModuleKeyword IDentifier optDefinitiveIdentifier
1911 optLanguageSpec optError
1913 act_ttcn3_module = new Ttcn::Module($3);
1914 act_ttcn3_module->set_scope_name($3->get_dispname());
1915 act_ttcn3_module->set_language_spec($5);
1921 GlobalModuleId optLanguageSpec
1923 $$ = new ImpMod($1);
1924 $$->set_language_spec($2);
1929 GlobalModuleId: // 5
1930 IDentifier { $$ = $1; }
1931 | IDentifier '.' ObjectIdentifierValue
1932 { $$ = $1; delete $3; }
1936 /* empty */ { $$ = NULL; }
1937 | LanguageKeyword FreeText { $$ = $2; } // sort-of 7 LanguageSpec
1941 '{' optErrorBlock '}'
1942 | '{' ModuleDefinitionsList optErrorBlock '}'
1943 | '{' ModuleDefinitionsList ModuleControlPart optErrorBlock '}'
1944 | '{' ModuleControlPart optErrorBlock '}'
1947 /* A.1.6.1 Module definitions part */
1949 /* A.1.6.1.0 General */
1951 ModuleDefinitionsList: // 10
1952 ModuleDefinition optSemiColon
1953 | error ModuleDefinition optSemiColon
1954 | ModuleDefinitionsList optErrorBlock ModuleDefinition optSemiColon
1957 optVisibility: // 12
1958 // /* empty */ { $$.visibility = PUBLIC;}
1959 /* empty */ { $$.visibility = NOCHANGE;}
1960 | PublicKeyword { $$.visibility = PUBLIC;}
1961 | PrivateKeyword { $$.visibility = PRIVATE;}
1962 | FriendKeyword { $$.visibility = FRIEND;}
1965 /* A definition _in_ the module, not a definition _of_ a module */
1966 ModuleDefinition: // 11
1967 optVisibility ModuleDef optWithStatement
1969 for (size_t i = 0; i < $2.nElements; i++) {
1971 if (i == 0) $2.elements[i]->set_with_attr($3);
1972 else $2.elements[i]->set_with_attr($3->clone());
1974 if ($1.visibility != NOCHANGE) {
1975 $2.elements[i]->set_visibility($1.visibility);
1977 act_ttcn3_module->add_ass($2.elements[i]);
1979 $2.elements[i]->set_parent_path(act_group->get_attrib_path());
1980 act_group->add_ass($2.elements[i]);
1982 $2.elements[i]->set_parent_path(act_ttcn3_module->get_attrib_path());
1987 | optVisibility ImportDef optWithStatement
1989 $2->set_with_attr($3);
1990 if ($1.visibility != NOCHANGE) {
1991 $2->set_visibility($1.visibility);
1994 $2->set_parent_path(act_group->get_attrib_path());
1995 act_group->add_impmod($2);
1997 $2->set_parent_path(act_ttcn3_module->get_attrib_path());
1999 act_ttcn3_module->add_impmod($2);
2001 | PublicKeyword GroupDef optWithStatement
2002 { // only public allowed for group, and it's redundant
2003 $2->set_with_attr($3);
2004 act_group = $2->get_parent_group();
2006 | GroupDef optWithStatement
2007 { // same code as above
2008 $1->set_with_attr($2);
2009 act_group = $1->get_parent_group();
2011 | PrivateKeyword FriendModuleDef optWithStatement
2012 { // only private allowed for "friend module", and it's redundant
2013 for (size_t i = 0; i < $2.nElements; i++) {
2015 if (i == 0) $2.elements[i]->set_with_attr($3);
2016 else $2.elements[i]->set_with_attr($3->clone());
2018 act_ttcn3_module->add_friendmod($2.elements[i]);
2020 $2.elements[i]->set_parent_path(act_group->get_attrib_path());
2021 act_group->add_friendmod($2.elements[i]);
2023 $2.elements[i]->set_parent_path(act_ttcn3_module->get_attrib_path());
2028 | FriendModuleDef optWithStatement
2029 { // same code as above
2030 for (size_t i = 0; i < $1.nElements; i++) {
2032 if (i == 0) $1.elements[i]->set_with_attr($2);
2033 else $1.elements[i]->set_with_attr($2->clone());
2035 act_ttcn3_module->add_friendmod($1.elements[i]);
2037 $1.elements[i]->set_parent_path(act_group->get_attrib_path());
2038 act_group->add_friendmod($1.elements[i]);
2040 $1.elements[i]->set_parent_path(act_ttcn3_module->get_attrib_path());
2048 ConstDef { $$ = $1; }
2049 | ModuleParDef { $$ = $1; }
2053 $$.elements = (Ttcn::Definition**)
2054 Malloc(sizeof(*$$.elements));
2055 $$.elements[0] = $1;
2060 $$.elements = (Ttcn::Definition**)
2061 Malloc(sizeof(*$$.elements));
2062 $$.elements[0] = $1;
2067 $$.elements = (Ttcn::Definition**)
2068 Malloc(sizeof(*$$.elements));
2069 $$.elements[0] = $1;
2074 $$.elements = (Ttcn::Definition**)
2075 Malloc(sizeof(*$$.elements));
2076 $$.elements[0] = $1;
2081 $$.elements = (Ttcn::Definition**)
2082 Malloc(sizeof(*$$.elements));
2083 $$.elements[0] = $1;
2088 $$.elements = (Ttcn::Definition**)
2089 Malloc(sizeof(*$$.elements));
2090 $$.elements[0] = $1;
2095 $$.elements = (Ttcn::Definition**)
2096 Malloc(sizeof(*$$.elements));
2097 $$.elements[0] = $1;
2099 | ExtConstDef { $$ = $1; }
2102 /* A.1.6.1.1 Typedef definitions */
2105 TypeDefKeyword TypeDefBody
2108 $$->set_location(infile, @$);
2113 StructuredTypeDef { $$ = $1; }
2114 | SubTypeDef { $$ = $1; }
2117 StructuredTypeDef: // 16
2118 RecordDef { $$ = $1; }
2119 | UnionDef { $$ = $1; }
2120 | SetDef { $$ = $1; }
2121 | RecordOfDef { $$ = $1; }
2122 | SetOfDef { $$ = $1; }
2123 | EnumDef { $$ = $1; }
2124 | PortDef { $$ = $1; }
2125 | ComponentDef { $$ = $1; }
2126 | FunctionTypeDef { $$ = $1; }
2127 | AltstepTypeDef { $$ = $1; }
2128 | TestcaseTypeDef { $$ = $1; }
2132 RecordKeyword StructDefBody
2134 Type *type = new Type(Type::T_SEQ_T, $2.cfm);
2135 type->set_location(infile, @$);
2136 $$ = new Def_Type($2.id, type);
2140 StructDefBody: // 19
2141 IDentifier optStructDefFormalParList
2142 '{' optStructFieldDefList '}'
2147 | AddressKeyword '{' optStructFieldDefList '}'
2149 $$.id = new Identifier(Identifier::ID_TTCN, string("address"));
2154 optStructDefFormalParList:
2155 /* empty */ optError
2156 | '(' StructDefFormalParList optError ')'
2158 Location loc(infile, @$);
2159 loc.error("Type parameterization is not currently supported");
2163 Location loc(infile, @$);
2164 loc.error("Type parameterization is not currently supported");
2168 StructDefFormalParList: // -> 202 784 "Advanced Parameterization", 9
2169 optError StructDefFormalPar
2170 | StructDefFormalParList optError ',' optError StructDefFormalPar
2171 | StructDefFormalParList optError ',' error
2174 StructDefFormalPar: // -> 202 784 "Advanced Parameterization", 10
2175 FormalValuePar { delete $1; }
2178 optStructFieldDefList:
2179 /* empty */ optError { $$ = new CompFieldMap; }
2180 | StructFieldDefList optError { $$ = $1; }
2184 optError StructFieldDef
2186 $$ = new CompFieldMap;
2189 | StructFieldDefList optError ',' optError StructFieldDef
2194 | StructFieldDefList optError ',' error { $$ = $1; }
2197 StructFieldDef: // 21
2198 TypeOrNestedTypeDef IDentifier optArrayDef optSubTypeSpec optOptionalKeyword
2201 /* The subtype constraint belongs to the innermost embedded type of
2202 * possible nested 'record of' or 'set of' constructs. */
2204 while (t->is_seof()) t = t->get_ofType();
2205 t->set_parsed_restrictions($4);
2208 /* creation of array type(s) if necessary (from right to left) */
2209 for (size_t i = $3.nElements; i > 0; i--) {
2210 type = new Type(Type::T_ARRAY, type, $3.elements[i - 1], true);
2211 type->set_location(*$1);
2214 $$ = new CompField($2, type, $5);
2215 $$->set_location(infile, @$);
2220 /* empty */ { $$ = false; }
2221 | OptionalKeyword { $$ = true; }
2224 TypeOrNestedTypeDef:
2226 | NestedTypeDef { $$ = $1; }
2229 NestedTypeDef: // 22
2230 NestedRecordDef { $$ = $1; }
2231 | NestedUnionDef { $$ = $1; }
2232 | NestedSetDef { $$ = $1; }
2233 | NestedRecordOfDef { $$ = $1; }
2234 | NestedSetOfDef { $$ = $1; }
2235 | NestedEnumDef { $$ = $1; }
2236 | NestedFunctionTypeDef { $$ = $1; }
2237 | NestedAltstepTypeDef { $$ = $1; }
2238 | NestedTestcaseTypeDef { $$ = $1; }
2241 NestedRecordDef: // 23
2242 RecordKeyword '{' optStructFieldDefList '}'
2244 $$ = new Type(Type::T_SEQ_T, $3);
2245 $$->set_location(infile, @$);
2249 NestedUnionDef: // 24
2250 UnionKeyword '{' UnionFieldDefList optError '}'
2252 $$ = new Type(Type::T_CHOICE_T, $3);
2253 $$->set_location(infile, @$);
2258 SetKeyword '{' optStructFieldDefList '}'
2260 $$ = new Type(Type::T_SET_T, $3);
2261 $$->set_location(infile, @$);
2265 NestedRecordOfDef: // 26
2266 RecordKeyword optStringLength OfKeyword TypeOrNestedTypeDef
2268 $$ = new Type(Type::T_SEQOF, $4);
2270 vector<SubTypeParse> *vstp = new vector<SubTypeParse>;
2271 SubTypeParse *stp = new SubTypeParse($2);
2273 $$->set_parsed_restrictions(vstp);
2275 $$->set_location(infile, @$);
2279 NestedSetOfDef: // 27
2280 SetKeyword optStringLength OfKeyword TypeOrNestedTypeDef
2282 $$ = new Type(Type::T_SETOF, $4);
2284 vector<SubTypeParse> *vstp = new vector<SubTypeParse>;
2285 SubTypeParse *stp = new SubTypeParse($2);
2287 $$->set_parsed_restrictions(vstp);
2289 $$->set_location(infile, @$);
2293 NestedEnumDef: // 28
2294 EnumKeyword '{' EnumerationList optError '}'
2296 $$ = new Type(Type::T_ENUM_T, $3);
2297 $$->set_location(infile, @$);
2301 NestedFunctionTypeDef:
2302 FunctionKeyword '(' optFunctionFormalParList ')'
2303 optRunsOnComprefOrSelf optReturnType
2305 $3->set_location(infile, @2, @4);
2306 $$ = new Type(Type::T_FUNCTION, $3, $5.reference, $5.self, $6.type,
2307 $6.returns_template, $6.template_restriction);
2308 $$->set_location(infile, @$);
2312 NestedAltstepTypeDef:
2313 AltstepKeyword '(' optAltstepFormalParList ')'
2314 optRunsOnComprefOrSelf
2316 $3->set_location(infile, @2, @4);
2317 $$ = new Type(Type::T_ALTSTEP, $3, $5.reference, $5.self);
2318 $$->set_location(infile, @$);
2322 NestedTestcaseTypeDef:
2323 TestcaseKeyword '(' optTestcaseFormalParList ')'
2326 $3->set_location(infile, @2, @4);
2327 $$ = new Type(Type::T_TESTCASE, $3, $5.runsonref,
2329 $$->set_location(infile, @$);
2334 UnionKeyword UnionDefBody
2336 Type *type = new Type(Type::T_CHOICE_T, $2.cfm);
2337 type->set_location(infile, @$);
2338 $$ = new Def_Type($2.id, type);
2343 IDentifier optStructDefFormalParList
2344 '{' UnionFieldDefList optError '}'
2349 | AddressKeyword '{' UnionFieldDefList optError '}'
2351 $$.id = new Identifier(Identifier::ID_TTCN, string("address"));
2357 optError UnionFieldDef
2359 $$ = new CompFieldMap;
2362 | UnionFieldDefList optError ',' optError UnionFieldDef
2367 | UnionFieldDefList optError ',' error { $$ = $1; }
2368 | error { $$ = new CompFieldMap; }
2371 UnionFieldDef: // 34
2372 TypeOrNestedTypeDef IDentifier optArrayDef optSubTypeSpec
2375 /* The subtype constraint belongs to the innermost embedded type of
2376 * possible nested 'record of' or 'set of' constructs. */
2378 while (t->is_seof()) t = t->get_ofType();
2379 t->set_parsed_restrictions($4);
2382 /* creation of array type(s) if necessary (from right to left) */
2383 for (size_t i = $3.nElements; i > 0; i--) {
2384 type = new Type(Type::T_ARRAY, type, $3.elements[i - 1], true);
2385 type->set_location(*$1);
2388 $$ = new CompField($2, type, false);
2389 $$->set_location(infile, @$);
2394 SetKeyword StructDefBody
2396 Type *type = new Type(Type::T_SET_T, $2.cfm);
2397 type->set_location(infile, @$);
2398 $$ = new Def_Type($2.id, type);
2403 RecordKeyword optStringLength OfKeyword StructOfDefBody
2405 Type *type = new Type(Type::T_SEQOF, $4.type);
2407 vector<SubTypeParse> *vstp = new vector<SubTypeParse>;
2408 vstp->add(new SubTypeParse($2));
2409 type->set_parsed_restrictions(vstp);
2411 type->set_location(infile, @$);
2412 $$ = new Def_Type($4.id, type);
2416 StructOfDefBody: // 39
2417 TypeOrNestedTypeDef IdentifierOrAddressKeyword optSubTypeSpec
2420 /* The subtype constraint belongs to the innermost embedded type of
2421 * possible nested 'record of' or 'set of' constructs. */
2423 while (t->is_seof()) t = t->get_ofType();
2424 t->set_parsed_restrictions($3);
2431 IdentifierOrAddressKeyword:
2432 IDentifier { $$ = $1; }
2435 $$ = new Identifier(Identifier::ID_TTCN, string("address"));
2440 SetKeyword optStringLength OfKeyword StructOfDefBody
2442 Type *type = new Type(Type::T_SETOF, $4.type);
2444 vector<SubTypeParse> *vstp = new vector<SubTypeParse>;
2445 vstp->add(new SubTypeParse($2));
2446 type->set_parsed_restrictions(vstp);
2448 type->set_location(infile, @$);
2449 $$ = new Def_Type($4.id, type);
2454 EnumKeyword IdentifierOrAddressKeyword
2455 '{' EnumerationList optError '}'
2457 Type *type = new Type(Type::T_ENUM_T, $4);
2458 type->set_location(infile, @$);
2459 $$ = new Def_Type($2, type);
2463 EnumerationList: // 44
2464 optError Enumeration
2469 | EnumerationList optError ',' optError Enumeration
2474 | EnumerationList optError ',' error { $$ = $1; }
2475 | error { $$ = new EnumItems; }
2481 $$ = new EnumItem($1, NULL);
2482 $$->set_location(infile, @$);
2484 | IDentifier '(' Number optError ')'
2486 Value *value = new Value(Value::V_INT, $3);
2487 value->set_location(infile, @3);
2488 $$ = new EnumItem($1, value);
2489 $$->set_location(infile, @$);
2491 | IDentifier '(' '-' Number optError ')'
2494 Value *value = new Value(Value::V_INT, $4);
2495 value->set_location(infile, @3, @4);
2496 $$ = new EnumItem($1, value);
2497 $$->set_location(infile, @$);
2499 | IDentifier '(' error ')'
2501 Value *value = new Value(Value::V_ERROR);
2502 value->set_location(infile, @3);
2503 $$ = new EnumItem($1, value);
2504 $$->set_location(infile, @$);
2509 Type IdentifierOrAddressKeyword optArrayDef optSubTypeSpec
2511 /* the subtype constraint belongs to the innermost type */
2512 if ($4) $1->set_parsed_restrictions($4);
2514 /* creation of array type(s) if necessary (from right to left) */
2515 for (size_t i = $3.nElements; i > 0; i--) {
2516 type = new Type(Type::T_ARRAY, type, $3.elements[i - 1], true);
2517 type->set_location(*$1);
2520 $$ = new Def_Type($2, type);
2524 optSubTypeSpec: // [49]
2525 /* empty */ { $$ = 0; }
2526 | AllowedValues { $$ = $1; }
2527 | AllowedValues StringLength
2530 $$->add(new SubTypeParse($2));
2534 $$ = new vector<SubTypeParse>;
2535 $$->add(new SubTypeParse($1));
2539 AllowedValues: // 50
2540 '(' seqValueOrRange optError ')' { $$ = $2; }
2541 | '(' CharStringMatch optError ')'
2543 $$ = new vector<SubTypeParse>;
2544 $$->add(new SubTypeParse($2));
2546 | '(' error ')' { $$ = new vector<SubTypeParse>; }
2550 optError ValueOrRange
2552 $$ = new vector<SubTypeParse>;
2555 | seqValueOrRange optError ',' optError ValueOrRange
2560 | seqValueOrRange optError ',' error { $$ = $1; }
2564 RangeDef { $$ = new SubTypeParse($1.lower, $1.lower_exclusive, $1.upper, $1.upper_exclusive); }
2565 | Expression { $$ = new SubTypeParse($1); }
2569 LowerBound DotDot UpperBound
2571 $$.lower_exclusive = false;
2573 $$.upper_exclusive = false;
2576 | '!' LowerBound DotDot UpperBound
2578 $$.lower_exclusive = true;
2580 $$.upper_exclusive = false;
2583 | LowerBound DotDot '!' UpperBound
2585 $$.lower_exclusive = false;
2587 $$.upper_exclusive = true;
2590 | '!' LowerBound DotDot '!' UpperBound
2592 $$.lower_exclusive = true;
2594 $$.upper_exclusive = true;
2600 /* empty */ optError { $$ = 0; }
2601 | StringLength { $$ = $1; }
2605 LengthKeyword '(' Expression optError ')'
2607 $$ = new LengthRestriction($3);
2608 $$->set_location(infile, @$);
2610 | LengthKeyword '(' Expression DotDot UpperBound optError ')'
2612 $$ = new LengthRestriction($3, $5);
2613 $$->set_location(infile, @$);
2615 | LengthKeyword '(' error ')'
2617 Value *value = new Value(Value::V_ERROR);
2618 value->set_location(infile, @3);
2619 $$ = new LengthRestriction(value);
2620 $$->set_location(infile, @$);
2627 $$ = new Ttcn::Reference($1);
2628 $$->set_location(infile, @$);
2630 | IDentifier '.' IDentifier
2632 $$ = new Ttcn::Reference($1, $3);
2633 $$->set_location(infile, @$);
2635 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
2637 $$ = new Ttcn::Reference($1, $5);
2638 $$->set_location(infile, @$);
2644 PortKeyword PortDefBody { $$ = $2; }
2648 IDentifier PortDefAttribs
2650 $$ = new Def_Type($1, $2);
2654 PortDefAttribs: // 60
2655 PortOperationMode PortDefLists
2657 PortTypeBody *body = new PortTypeBody($1,
2658 $2.in_list, $2.out_list, $2.inout_list,
2659 $2.in_all, $2.out_all, $2.inout_all);
2660 body->set_location(infile, @$);
2661 $$ = new Type(Type::T_PORT, body);
2662 $$->set_location(infile, @$);
2667 MessageKeyword { $$ = PortTypeBody::PO_MESSAGE; } // 61
2668 | ProcedureKeyword { $$ = PortTypeBody::PO_PROCEDURE; } // 68
2669 | MixedKeyword { $$ = PortTypeBody::PO_MIXED; } // 73
2670 | error { $$ = PortTypeBody::PO_MIXED; }
2674 '{' seqPortDefList '}' { $$ = $2; }
2682 $$.inout_all = false;
2687 optError PortDefList optSemiColon { $$ = $2; }
2688 | seqPortDefList PortDefList optSemiColon
2693 $$.in_list->steal_types($2.in_list);
2695 } else $$.in_list = $2.in_list;
2699 $$.out_list->steal_types($2.out_list);
2701 } else $$.out_list = $2.out_list;
2703 if ($2.inout_list) {
2704 if ($$.inout_list) {
2705 $$.inout_list->steal_types($2.inout_list);
2706 delete $2.inout_list;
2707 } else $$.inout_list = $2.inout_list;
2711 Location loc(infile, @2);
2712 loc.warning("Duplicate directive `in all' in port type definition");
2713 } else $$.in_all = true;
2717 Location loc(infile, @2);
2718 loc.warning("Duplicate directive `out all' in port type definition");
2719 } else $$.out_all = true;
2723 Location loc(infile, @2);
2724 loc.warning("Duplicate directive `inout all' in port type definition");
2725 } else $$.inout_all = true;
2731 InParKeyword AllOrTypeList
2735 $$.in_list->set_location(infile, @$);
2744 $$.inout_all = false;
2746 | OutParKeyword AllOrTypeList
2752 $$.out_list->set_location(infile, @$);
2759 $$.inout_all = false;
2761 | InOutParKeyword AllOrTypeList
2769 $$.inout_list->set_location(infile, @$);
2770 $$.inout_all = false;
2773 $$.inout_all = true;
2776 | InParKeyword error
2783 $$.inout_all = false;
2785 | OutParKeyword error
2792 $$.inout_all = false;
2794 | InOutParKeyword error
2801 $$.inout_all = false;
2805 AllOrTypeList: // 65
2806 AllKeyword { $$ = 0; }
2807 | TypeList { $$ = $1; }
2816 | TypeList optError ',' optError Type
2821 | TypeList optError ',' error { $$ = $1; }
2825 ComponentKeyword IDentifier
2827 '{' optComponentDefList '}'
2830 if ($3) $5->add_extends($3);
2831 $5->set_location(infile, @$);
2832 Type *type = new Type(Type::T_COMPONENT, $5);
2833 type->set_location(infile, @$);
2834 $$ = new Def_Type($2, type);
2839 /* empty */ optError { $$ = 0; }
2840 | ExtendsKeyword ComponentTypeList optError
2843 $$->set_location(infile, @1, @2);
2845 | ExtendsKeyword error { $$ = 0; }
2849 optError ComponentType
2851 $$ = new CompTypeRefList();
2854 | ComponentTypeList optError ',' optError ComponentType
2859 | ComponentTypeList optError ',' error { $$ = $1; }
2862 ComponentType: // 81
2865 $$ = new Ttcn::Reference($1);
2866 $$->set_location(infile, @$);
2868 | IDentifier '.' IDentifier
2870 $$ = new Ttcn::Reference($1, $3);
2871 $$->set_location(infile, @$);
2873 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
2875 $$ = new Ttcn::Reference($1, $5);
2876 $$->set_location(infile, @$);
2881 optComponentDefList:
2882 optError /* empty */ { $$ = new ComponentTypeBody(); }
2883 | ComponentElementDefList optError { $$ = $1; }
2886 ComponentElementDefList:
2887 optError ComponentElementDef optSemiColon
2889 $$ = new ComponentTypeBody();
2890 for (size_t i = 0; i < $2.nElements; i++)
2891 $$->add_ass($2.elements[i]);
2894 | ComponentElementDefList optError ComponentElementDef optSemiColon
2897 for (size_t i = 0; i < $3.nElements; i++)
2898 $$->add_ass($3.elements[i]);
2903 ComponentElementVisibility:
2904 PublicKeyword { $$.visibility = PUBLIC;}
2905 | PrivateKeyword { $$.visibility = PRIVATE;}
2908 ComponentElementDef: // 84
2909 PortInstance { $$ = $1; }
2910 | VarInstance { $$ = $1; }
2911 | TimerInstance { $$ = $1; }
2912 | ConstDef { $$ = $1; }
2913 | ComponentElementVisibility PortInstance
2916 for (size_t i = 0; i < $2.nElements; i++) {
2917 $2.elements[i]->set_visibility($1.visibility);
2920 | ComponentElementVisibility VarInstance
2923 for (size_t i = 0; i < $2.nElements; i++) {
2924 $2.elements[i]->set_visibility($1.visibility);
2927 | ComponentElementVisibility TimerInstance
2930 for (size_t i = 0; i < $2.nElements; i++) {
2931 $2.elements[i]->set_visibility($1.visibility);
2934 | ComponentElementVisibility ConstDef
2937 for (size_t i = 0; i < $2.nElements; i++) {
2938 $2.elements[i]->set_visibility($1.visibility);
2944 PortKeyword PortType PortElementList
2946 $$.nElements = $3.nElements;
2947 $$.elements = (Ttcn::Definition**)
2948 Malloc($$.nElements*sizeof(*$$.elements));
2949 for (size_t i = 0; i < $3.nElements; i++) {
2950 Ttcn::Reference *ref = i > 0 ? $2->clone() : $2;
2951 $$.elements[i] = new Ttcn::Def_Port($3.elements[i].id, ref,
2952 $3.elements[i].dims);
2953 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
2960 optError PortElement
2963 $$.elements = (YYSTYPE::portelement_t*)Malloc(sizeof(*$$.elements));
2964 $$.elements[0] = $2;
2966 | PortElementList ',' optError PortElement
2968 $$.nElements = $1.nElements + 1;
2969 $$.elements = (YYSTYPE::portelement_t*)
2970 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
2971 $$.elements[$$.nElements - 1] = $4;
2973 | PortElementList ',' error { $$ = $1; }
2977 IDentifier optArrayDef
2980 if ($2.nElements > 0) {
2981 $$.dims = new ArrayDimensions;
2982 for (size_t i = 0; i < $2.nElements; i++) $$.dims->add($2.elements[i]);
2989 /* A.1.6.1.2 Constant definitions */
2992 ConstKeyword Type ConstList
2994 $$.nElements = $3.nElements;
2995 $$.elements = (Ttcn::Definition**)
2996 Malloc($$.nElements*sizeof(*$$.elements));
2997 for (size_t i = 0; i < $$.nElements; i++) {
3000 type = new Type(Type::T_REFDSPEC, $2);
3001 type->set_location(*$2);
3003 /* creation of array type(s) if necessary (from right to left) */
3004 for (size_t j = $3.elements[i].arrays.nElements; j > 0; j--) {
3005 type = new Type(Type::T_ARRAY, type,
3006 $3.elements[i].arrays.elements[j - 1], false);
3007 type->set_location(*$2);
3009 Free($3.elements[i].arrays.elements);
3011 /* Create the definition */
3012 $$.elements[i] = new Def_Const($3.elements[i].id,
3013 type, $3.elements[i].initial_value);
3014 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
3021 optError SingleConstDef
3024 $$.elements = (YYSTYPE::singlevarinst_t*)Malloc(sizeof(*$$.elements));
3025 $$.elements[0] = $2;
3027 | ConstList ',' optError SingleConstDef
3029 $$.nElements = $1.nElements + 1;
3030 $$.elements = (YYSTYPE::singlevarinst_t*)
3031 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
3032 $$.elements[$$.nElements - 1] = $4;
3036 SingleConstDef: // 90
3037 IDentifier optArrayDef AssignmentChar Expression
3041 $$.initial_value = $4;
3047 FunctionKeyword IDentifier '(' optFunctionFormalParList ')'
3048 optRunsOnComprefOrSelf optReturnType
3050 $4->set_location(infile, @3, @5);
3051 Type *type = new Type(Type::T_FUNCTION, $4, $6.reference, $6.self, $7.type,
3052 $7.returns_template, $7.template_restriction);
3053 type->set_location(infile, @$);
3054 $$ = new Ttcn::Def_Type($2, type);
3055 $$->set_location(infile, @$);
3060 AltstepKeyword IDentifier '(' optAltstepFormalParList ')'
3061 optRunsOnComprefOrSelf
3063 $4->set_location(infile, @3, @5);
3064 Type *type = new Type(Type::T_ALTSTEP, $4, $6.reference, $6.self);
3065 type->set_location(infile, @$);
3066 $$ = new Ttcn::Def_Type($2, type);
3067 $$->set_location(infile, @$);
3072 TestcaseKeyword IDentifier '(' optTestcaseFormalParList ')'
3075 $4->set_location(infile, @3, @5);
3076 Type *type = new Type(Type::T_TESTCASE, $4, $6.runsonref,
3078 type->set_location(infile, @$);
3079 $$ = new Ttcn::Def_Type($2, type);
3080 $$->set_location(infile, @$);
3084 /* A.1.6.1.3 Template definitions */
3087 TemplateKeyword optTemplateRestriction BaseTemplate
3088 optDerivedDef AssignmentChar TemplateBody
3090 $$ = new Def_Template($2, $3.name, $3.type, $3.fp_list, $4, $6);
3091 $$->set_location(infile, @$);
3096 Type IDentifier optTemplateFormalParList
3102 /* | Signature IDentifier optTemplateFormalParList -- covered by the previous
3107 /* empty */ { $$ = 0; }
3108 | DerivedDef { $$ = $1; }
3112 ModifiesKeyword TemplateRef
3114 $$ = new Ttcn::Reference($2.modid, $2.id);
3115 $$->set_location(infile, @$);
3117 | ModifiesKeyword error { $$ = 0; }
3120 optTemplateFormalParList:
3121 /* empty */ optError { $$ = 0; }
3122 | '(' TemplateFormalParList optError ')'
3125 $$->set_location(infile, @$);
3129 $$ = new FormalParList;
3130 $$->set_location(infile, @$);
3134 TemplateFormalParList: // 99 is a FormalParList*
3135 optError TemplateFormalPar
3137 $$ = new FormalParList;
3140 | TemplateFormalParList optError ',' optError TemplateFormalPar
3145 | TemplateFormalParList optError ',' error { $$ = $1; }
3148 TemplateFormalPar: // 100
3149 FormalValuePar { $$ = $1; }
3150 | FormalTemplatePar { $$ = $1; }
3153 TemplateBody: // 101 is a Template*
3154 SimpleSpec optExtraMatchingAttributes
3157 $$->set_length_restriction($2.len_restr);
3158 $$->set_ifpresent($2.is_ifpresent);
3160 | FieldSpecList optExtraMatchingAttributes
3163 $$->set_length_restriction($2.len_restr);
3164 $$->set_ifpresent($2.is_ifpresent);
3166 | ArraySpecList optExtraMatchingAttributes
3169 $$->set_length_restriction($2.len_restr);
3170 $$->set_ifpresent($2.is_ifpresent);
3172 | ArrayValueOrAttrib optExtraMatchingAttributes
3175 $$->set_length_restriction($2.len_restr);
3176 $$->set_ifpresent($2.is_ifpresent);
3181 SingleValueOrAttrib { $$ = $1; }
3184 FieldSpecList: // 103
3187 $$ = new Template(Template::TEMPLATE_LIST, new Templates());
3188 $$->set_location(infile, @$);
3191 | '{' seqFieldSpec optError '}'
3193 $$ = new Template($2); // NAMED_TEMLATE_LIST
3194 $$->set_location(infile, @$);
3198 $$ = new Template(Template::TEMPLATE_ERROR);
3199 $$->set_location(infile, @$);
3203 /* Sequence of FieldSpec. \note Cannot be empty */
3204 seqFieldSpec: // a NamedTemplates*
3207 $$ = new NamedTemplates();
3212 $$ = new NamedTemplates();
3215 | seqFieldSpec optError ',' optError FieldSpec
3220 | seqFieldSpec optError ',' error { $$ = $1; }
3223 FieldSpec: // 104 a NamedTemplate*
3224 FieldReference AssignmentChar TemplateBody
3226 $$ = new NamedTemplate($1, $3);
3227 $$->set_location(infile, @$);
3229 | FieldReference AssignmentChar NotUsedSymbol
3231 Template* temp = new Template(Template::TEMPLATE_NOTUSED);
3232 temp->set_location(infile, @3);
3233 $$ = new NamedTemplate($1, temp);
3234 $$->set_location(infile, @$);
3238 FieldReference: // 105
3239 StructFieldRef { $$ = $1; }
3240 /* | ArrayOrBitRef -- covered by ArraySpecList */
3241 /* | ParRef -- covered by StructFieldRef */
3244 StructFieldRef: // 106 (and 107. ParRef)
3245 PredefOrIdentifier { $$ = $1; }
3247 Note: Non-parameterized type references are covered by (StructField)Identifier.
3248 Parameterized type references are covered by FunctionInstance */
3251 Location loc(infile, @$);
3252 loc.error("Reference to a parameterized field of type `anytype' is "
3253 "not currently supported");
3255 $$ = new Identifier(Identifier::ID_TTCN, string("<error>"));
3260 '{' seqArraySpec optError '}'
3262 $$ = new Template($2);
3263 $$->set_location(infile, @$);
3270 $$ = new IndexedTemplates();
3273 /* It was optError before. */
3276 $$ = new IndexedTemplates();
3279 | seqArraySpec optError ',' optError ArraySpec
3284 | seqArraySpec optError ',' error { $$ = $1; }
3288 ArrayOrBitRef AssignmentChar TemplateBody
3290 $$ = new IndexedTemplate($1, $3);
3291 $$->set_location(infile, @$);
3295 ArrayOrBitRef: // 109
3298 $$ = new FieldOrArrayRef($2);
3299 $$->set_location(infile, @$);
3303 $$ = new FieldOrArrayRef(new Value(Value::V_ERROR));
3304 $$->set_location(infile, @$);
3308 SingleValueOrAttrib: // 111
3309 MatchingSymbol { $$ = $1; }
3312 if ($1->get_valuetype() == Value::V_OMIT) {
3314 $$ = new Template(Template::OMIT_VALUE);
3315 } else $$ = new Template($1); // SPECIFIC_VALUE; SingleExpr is a Template*
3316 $$->set_location(infile, @$);
3318 /* | TemplateRefWithParList -- covered by SingleExpression */
3321 ArrayValueOrAttrib: // 112
3322 '{' ArrayElementSpecList optError '}'
3324 $$ = new Template(Template::TEMPLATE_LIST, $2);
3325 $$->set_location(infile, @$);
3329 ArrayElementSpecList: // 113
3335 | error ArrayElementSpec
3340 | ArrayElementSpecList optError ',' optError ArrayElementSpec
3345 | ArrayElementSpecList optError ',' error { $$ = $1; }
3348 ArrayElementSpec: // 114 is a Template*
3351 $$ = new Template(Template::TEMPLATE_NOTUSED);
3352 $$->set_location(infile, @$);
3356 $$ = new Template(Template::PERMUTATION_MATCH, $1);
3357 $$->set_location(infile, @$);
3359 | TemplateListElem { $$ = $1; }
3362 NotUsedSymbol: // 115
3366 MatchingSymbol: // 116 is a Template*
3369 $$ = new Template(Template::COMPLEMENTED_LIST, $1);
3370 $$->set_location(infile, @$);
3374 $$ = new Template(Template::ANY_VALUE);
3375 $$->set_location(infile, @$);
3379 $$ = new Template(Template::ANY_OR_OMIT);
3380 $$->set_location(infile, @$);
3384 $$ = new Template(Template::VALUE_LIST, $1);
3385 $$->set_location(infile, @$);
3389 $$ = new Template($1);
3390 $$->set_location(infile, @$);
3394 $$ = new Template(Template::BSTR_PATTERN, $1);
3395 $$->set_location(infile, @$);
3399 $$ = new Template(Template::HSTR_PATTERN, $1);
3400 $$->set_location(infile, @$);
3404 $$ = new Template(Template::OSTR_PATTERN, $1);
3405 $$->set_location(infile, @$);
3409 $$ = new Template($1);
3410 $$->set_location(infile, @$);
3414 $$ = new Template(Template::SUBSET_MATCH, $1);
3415 $$->set_location(infile, @$);
3419 $$ = new Template(Template::SUPERSET_MATCH, $1);
3420 $$->set_location(infile, @$);
3422 | '(' AllElementsFrom ')'
3424 $$ = new Template(Template::VALUE_LIST_ALL_FROM, $2);
3425 $$->set_location(infile, @$);
3429 optExtraMatchingAttributes: // [117]
3432 $$.is_ifpresent = false;
3433 $$.len_restr = NULL;
3438 $$.is_ifpresent = false;
3442 $$.len_restr = NULL;
3443 $$.is_ifpresent = true;
3445 | LengthMatch IfPresentMatch
3448 $$.is_ifpresent = true;
3452 CharStringMatch: // 124
3453 PatternKeyword PatternChunkList
3455 Location loc(infile, @2);
3456 $$ = parse_pattern($2, loc);
3459 | PatternKeyword NocaseKeyword PatternChunkList
3461 // @nocase is ignored for now
3462 Location loc(infile, @3);
3463 $$ = parse_pattern($3, loc);
3473 | PatternChunkList '&' PatternChunk
3476 $$ = mputstr($$, $3);
3488 switch ($1->get_valuetype()) {
3489 case Value::V_REFD: {
3490 /* Pretend to be a reference. Let pstring_la.l discover the
3492 Common::Reference *ref = $1->get_reference();
3493 $$ = mprintf("{%s}", (ref->get_dispname()).c_str());
3495 case Value::V_UNDEF_LOWERID: {
3496 const Common::Identifier *id = $1->get_val_id();
3497 $$ = mprintf("{%s}", (id->get_dispname()).c_str());
3500 FATAL_ERROR("Internal error.");
3502 /* Forget the Node. */
3507 ustring::universal_char& uc = $1->operator[](0);
3508 $$ = mprintf("\\q{%d,%d,%d,%d}", uc.group, uc.plane, uc.row, uc.cell);
3513 Complement: // 130 is a Templates*
3514 ComplementKeyword ValueList { $$ = $2; }
3517 ValueList: // 132 is a Templates*
3518 '(' seqValueOrAttrib optError ')' { $$ = $2; }
3519 | '(' error ')' { $$ = new Templates; }
3522 seqValueOrAttrib: // is a Templates*
3523 optError TemplateListElem
3528 | seqValueOrAttrib optError ',' optError TemplateListElem
3533 | seqValueOrAttrib optError ',' error { $$ = $1; }
3536 SubsetMatch: // 133 is a Templates*
3537 SubsetKeyword ValueList { $$ = $2; }
3540 SupersetMatch: // 135 is a Templates*
3541 SupersetKeyword ValueList { $$ = $2; }
3544 PermutationMatch: // 137 is a Templates*
3545 PermutationKeyword ValueList { $$ = $2; }
3556 TemplateListElem: // is a Template*
3561 AllElementsFrom: // is a Template*
3562 AllKeyword FromKeyword TemplateBody
3563 { // $3 is a Template*
3564 $$ = new Template($3); // Constructs ALL_FROM
3565 $$->set_location(infile, @$);
3569 ValueOrAttribList: // 142 is a Templates*
3570 /* ValueOrAttribList always has two or more elements
3571 * (there's always a comma) and is reduced through
3572 * ValueOrAttribList -> MatchingSymbol -> SingleValueOrAttrib
3574 * The one-element list is reduced through
3575 * '(' SingleExpression ')' -> SingleExpression -> SingleValueOrAttrib */
3576 '(' TemplateListElem optError ',' seqValueOrAttrib optError ')'
3579 $$->add_front_t($2);
3581 | '(' error TemplateListElem optError ',' seqValueOrAttrib optError ')'
3584 $$->add_front_t($3);
3589 StringLength { $$ = $1; }
3592 IfPresentMatch: // 144
3597 '(' SingleLowerBound DotDot UpperBound optError ')'
3598 { $$ = new ValueRange($2, $4); }
3604 if ($1->is_parsed_infinity()==-1) {
3605 /* the conflicting rule alternative faked here: '-' InfinityKeyword */
3617 if ($1->is_parsed_infinity()==-1) {
3618 /* the conflicting rule alternative faked here: '-' InfinityKeyword */
3630 if ($1->is_parsed_infinity()==1) {
3631 /* the conflicting rule alternative faked here: InfinityKeyword */
3640 TemplateInstance: // 151
3641 InLineTemplate { $$ = $1; }
3644 TemplateRefWithParList: /* refbase */ // 153 ?
3645 TemplateRef optTemplateActualParList
3648 $$ = new Ttcn::Ref_pard($1.modid, $1.id, new ParsedActualParameters($2));
3649 $$->set_location(infile, @$);
3651 $$ = new Ttcn::Reference($1.modid, $1.id);
3652 $$->set_location(infile, @$);
3663 | IDentifier '.' IDentifier
3668 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
3676 InLineTemplate: // 155
3679 $$ = new TemplateInstance(0, 0, $1);
3680 $$->set_location(infile, @$);
3682 | Type ':' TemplateBody
3684 $$ = new TemplateInstance($1, 0, $3);
3685 $$->set_location(infile, @$);
3687 /* | Signature ':' TemplateBody -- covered by the previous rule */
3688 | DerivedRefWithParList AssignmentChar TemplateBody
3690 $$ = new TemplateInstance(0, $1, $3);
3691 $$->set_location(infile, @$);
3693 | Type ':' DerivedRefWithParList AssignmentChar TemplateBody
3695 $$ = new TemplateInstance($1, $3, $5);
3696 $$->set_location(infile, @$);
3698 /* | Signature ':' DerivedRefWithParList AssignmentChar TemplateBody
3699 -- covered by the previous rule */
3702 DerivedRefWithParList: // 156
3703 ModifiesKeyword TemplateRefWithParList { $$ = $2; }
3706 optTemplateActualParList: // [157]
3707 /* empty */ optError { $$ = 0; }
3708 | '(' seqTemplateActualPar optError ')'
3711 $$->set_location(infile, @$);
3715 $$ = new TemplateInstances;
3716 $$->set_location(infile, @$);
3720 seqTemplateActualPar:
3721 optError TemplateActualPar
3723 $$ = new TemplateInstances;
3726 | seqTemplateActualPar optError ',' optError TemplateActualPar
3731 | seqTemplateActualPar optError ',' error { $$ = $1; }
3734 TemplateActualPar: // 158
3735 TemplateInstance { $$ = $1; }
3738 Template *t = new Template(Template::TEMPLATE_NOTUSED);
3739 t->set_location(infile, @$);
3740 $$ = new TemplateInstance(0, 0, t);
3741 $$->set_location(infile, @$);
3746 MatchOp { $$ = $1; }
3747 | ValueofOp { $$ = $1; }
3751 MatchKeyword '(' optError Expression optError ',' optError TemplateInstance
3754 $$ = new Value(Value::OPTYPE_MATCH, $4, $8);
3755 $$->set_location(infile, @$);
3757 | MatchKeyword '(' error ')'
3759 Value *v = new Value(Value::V_ERROR);
3760 v->set_location(infile, @3);
3761 Template *t = new Template(Template::TEMPLATE_ERROR);
3762 t->set_location(infile, @3);
3763 TemplateInstance *ti = new TemplateInstance(0, 0, t);
3764 ti->set_location(infile, @3);
3765 $$ = new Value(Value::OPTYPE_MATCH, v, ti);
3766 $$->set_location(infile, @$);
3771 ValueofKeyword '(' optError TemplateInstance optError ')'
3773 $$ = new Value(Value::OPTYPE_VALUEOF, $4);
3774 $$->set_location(infile, @$);
3776 | ValueofKeyword '(' error ')'
3778 Template *t = new Template(Template::TEMPLATE_ERROR);
3779 t->set_location(infile, @3);
3780 TemplateInstance *ti = new TemplateInstance(0, 0, t);
3781 ti->set_location(infile, @3);
3782 $$ = new Value(Value::OPTYPE_VALUEOF, ti);
3783 $$->set_location(infile, @$);
3787 /* A.1.6.1.4 Function definitions */
3790 FunctionKeyword IDentifier '(' optFunctionFormalParList ')'
3791 optRunsOnSpec optReturnType optError StatementBlock
3793 $4->set_location(infile, @3, @5);
3794 $$ = new Def_Function($2, $4, $6, $7.type, $7.returns_template,
3795 $7.template_restriction, $9);
3796 $$->set_location(infile, @$);
3800 optFunctionFormalParList: // [167]
3801 /* empty */ { $$ = new FormalParList; }
3802 | FunctionFormalParList { $$ = $1; }
3803 | error { $$ = new FormalParList; }
3806 FunctionFormalParList: // 167
3807 optError FunctionFormalPar
3809 $$ = new FormalParList;
3812 | FunctionFormalParList optError ',' optError FunctionFormalPar
3817 | FunctionFormalParList optError ',' error { $$ = $1; }
3820 FunctionFormalPar: // 168
3821 FormalValuePar { $$ = $1; }
3822 | FormalTimerPar { $$ = $1; }
3823 | FormalTemplatePar { $$ = $1; }
3824 /*| FormalPortPar -- covered by FormalValuePar */
3827 optReturnType: // [169]
3831 $$.returns_template = false;
3832 $$.template_restriction = TR_NONE;
3834 | ReturnKeyword Type
3837 $$.returns_template = false;
3838 $$.template_restriction = TR_NONE;
3840 | ReturnKeyword TemplateOptRestricted Type
3843 $$.returns_template = true;
3844 $$.template_restriction = $2;
3846 | ReturnKeyword error
3849 $$.returns_template = false;
3850 $$.template_restriction = TR_NONE;
3854 optRunsOnComprefOrSelf:
3860 | RunsKeyword OnKeyword SelfKeyword
3868 /* empty */ { $$ = 0; }
3869 | RunsOnSpec { $$ = $1; }
3870 | RunsKeyword error { $$ = 0; }
3874 RunsKeyword OnKeyword ComponentType { $$ = $3; }
3877 /* StatementBlock changed in 4.1.2 to explicitly prevent statements
3878 * followed by definitions. TITAN still allows them to be mixed. */
3879 StatementBlock: /* StatementBlock *statementblock */ // 175
3882 $$ = new StatementBlock;
3883 $$->set_location(infile, @$);
3885 | '{' FunctionStatementOrDefList optError '}'
3888 $$->set_location(infile, @$);
3892 FunctionStatementOrDefList: // (171 in 3.2.1)
3893 optError FunctionStatementOrDef optSemiColon
3895 $$ = new StatementBlock;
3896 for(size_t i=0; i<$2.nElements; i++) $$->add_stmt($2.elements[i]);
3899 | FunctionStatementOrDefList optError FunctionStatementOrDef optSemiColon
3902 for(size_t i=0; i<$3.nElements; i++) $$->add_stmt($3.elements[i]);
3907 FunctionStatementOrDef: // (172 in 3.2.1)
3908 FunctionLocalDef // constant or template definition
3910 $$.nElements=$1.nElements;
3911 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
3912 for(size_t i=0; i<$1.nElements; i++) {
3913 $$.elements[i]=new Statement(Statement::S_DEF, $1.elements[i]);
3914 $$.elements[i]->set_location(*$1.elements[i]);
3918 | FunctionLocalInst // variable or timer instance
3920 $$.nElements=$1.nElements;
3921 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
3922 for(size_t i=0; i<$1.nElements; i++) {
3923 $$.elements[i]=new Statement(Statement::S_DEF, $1.elements[i]);
3924 $$.elements[i]->set_location(*$1.elements[i]);
3931 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
3936 FunctionLocalInst: // 178
3937 VarInstance { $$=$1; }
3938 | TimerInstance { $$=$1; }
3941 FunctionLocalDef: // 179
3947 $$.elements = (Ttcn::Definition**)Malloc(sizeof(*$$.elements));
3948 $$.elements[0] = $1;
3952 FunctionStatement: // 180
3953 ConfigurationStatements {$$=$1;}
3954 | TimerStatements {$$=$1;}
3955 | CommunicationStatements {$$=$1;}
3956 | BasicStatements {$$=$1;}
3957 | BehaviourStatements {$$=$1;}
3958 | VerdictStatements {$$=$1;}
3959 | SUTStatements {$$=$1;}
3960 | StopExecutionStatement { $$ = $1; }
3961 | StopTestcaseStatement { $$ = $1; }
3962 | ProfilerStatement { $$ = $1; }
3963 | int2enumStatement { $$ = $1; }
3966 FunctionInstance: /* refpard */ // 181
3967 FunctionRef '(' optFunctionActualParList ')'
3968 /* templateref templinsts */
3970 $3->set_location(infile, @2, @4);
3971 $$ = new Ttcn::Ref_pard($1.modid, $1.id, $3);
3972 $$->set_location(infile, @$);
3982 | IDentifier '.' IDentifier
3987 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
3995 optFunctionActualParList: /* parsedpar */ // [185]
3996 /* empty */ optError { $$ = new ParsedActualParameters; }
3997 | FunctionActualParList optError { $$ = $1; }
4000 /* ***** this * can * not * be * empty ****************** */
4001 FunctionActualParList: /* parsedpar */ // 184
4004 | UnnamedPart ',' NamedPart
4005 /* Splitting the NamedPart and UnnamedPart ensures that a named parameter
4006 * followed by an unnamed one causes a syntax error */
4008 /* UnnamedPart becomes the value */
4010 /* append the elements from NamedPart */
4011 const size_t n3 = $3->get_nof_nps();
4012 for (size_t i = 0; i < n3; ++i) {
4013 $$->add_np( $3->extract_np_byIndex(i) );
4019 UnnamedPart: /* parsedpar */
4020 /*optError*/ FunctionActualPar
4022 $$ = new ParsedActualParameters;
4025 | UnnamedPart /*optError*/ ',' /*optError*/ FunctionActualPar
4026 /* These optErrors mess up the parsing of actual parameters.
4027 * After only one FunctionActualPar, it is reduced to UnnamedPart
4028 * and the rest is expected to be the NamedPart */
4033 | UnnamedPart optError ',' error { $$ = $1; }
4036 NamedPart: /* parsedpar */
4037 seqFieldSpec /* namedtempls */
4039 $$ = new ParsedActualParameters(0, new NamedParams);
4040 const size_t n1 = $1->get_nof_nts();
4041 for (size_t i = 0; i < n1; ++i) {
4042 NamedTemplate *pnt = $1->get_nt_byIndex(i);
4043 TemplateInstance *pti = new TemplateInstance(0,0,pnt->extract_template());
4044 NamedParam *pnp = new NamedParam(pnt->get_name().clone(), pti);
4045 pnp->set_location(*pnt);
4049 $$->set_location(infile, @$);
4050 // This call to ParsedActualParameters::set_location copies the same
4051 // location info to the named and unnamed part. We cannot copy
4052 // the location info from the NamedTemplates to the named part,
4053 // because NamedTemplates is not a Location.
4057 FunctionActualPar: /* templinst */ // 185
4059 TemplateInstance { $$ = $1; }
4062 Template *t = new Template(Template::TEMPLATE_NOTUSED);
4063 t->set_location(infile, @$);
4064 $$ = new TemplateInstance(0, 0, t);
4065 $$->set_location(infile, @$);
4068 | ComponentRef -- TemplateInstance covers all the others */
4072 Reference DotApplyKeyword '(' optFunctionActualParList ')'
4074 if($1.is_ref) $$.value = new Value(Value::V_REFD, $1.ref);
4076 Ttcn::Reference *t_ref = new Ttcn::Reference($1.id);
4077 t_ref->set_location(infile, @1);
4078 $$.value = new Value(Value::V_REFD, t_ref);
4080 $$.value->set_location(infile, @1);
4082 $$.ap_list->set_location(infile, @3 , @5);
4084 | FunctionInstance DotApplyKeyword '(' optFunctionActualParList ')'
4086 $$.value = new Value(Value::V_REFD, $1);
4087 $$.value->set_location(infile, @1);
4089 $$.ap_list->set_location(infile, @3 , @5);
4091 | ApplyOp DotApplyKeyword '(' optFunctionActualParList ')'
4093 $$.value = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
4094 $$.value->set_location(infile, @1);
4096 $$.ap_list->set_location(infile, @3 , @5);
4101 DerefersKeyword '(' Expression ')' { $$ = $3; }
4104 /* A.1.6.1.5 Signature definitions */
4106 SignatureDef: // 187
4107 SignatureKeyword IDentifier
4108 '(' optSignatureFormalParList ')' optReturnTypeOrNoBlockKeyword
4111 Type *type = new Type(Type::T_SIGNATURE, $4, $6.type, $6.no_block_kw, $7);
4112 type->set_location(infile, @3, @7);
4113 $$ = new Ttcn::Def_Type($2, type);
4114 $$->set_location(infile, @$);
4118 optSignatureFormalParList: // [190]
4119 /* empty */ { $$ = 0; }
4120 | SignatureFormalParList { $$ = $1; }
4124 SignatureFormalParList: // 190
4125 optError SignatureFormalPar
4127 $$ = new SignatureParamList;
4130 | SignatureFormalParList optError ',' optError SignatureFormalPar
4135 | SignatureFormalParList optError ',' error { $$ = $1; }
4138 SignatureFormalPar: // 191
4141 $$ = new SignatureParam(SignatureParam::PARAM_IN, $1, $2);
4142 $$->set_location(infile, @$);
4144 | InParKeyword Type IDentifier
4146 $$ = new SignatureParam(SignatureParam::PARAM_IN, $2, $3);
4147 $$->set_location(infile, @$);
4149 | InOutParKeyword Type IDentifier
4151 $$ = new SignatureParam(SignatureParam::PARAM_INOUT, $2, $3);
4152 $$->set_location(infile, @$);
4154 | OutParKeyword Type IDentifier
4156 $$ = new SignatureParam(SignatureParam::PARAM_OUT, $2, $3);
4157 $$->set_location(infile, @$);
4161 optReturnTypeOrNoBlockKeyword:
4165 $$.no_block_kw = false;
4167 | ReturnKeyword Type
4170 $$.no_block_kw = false;
4175 $$.no_block_kw = true;
4179 optExceptionSpec: // [192]
4180 /* empty */ { $$ = NULL; }
4181 | ExceptionKeyword '(' error ')' { $$ = NULL; }
4182 | ExceptionKeyword '(' ExceptionTypeList optError ')'
4185 $$->set_location(infile, @$);
4189 ExceptionTypeList: // 194
4192 $$ = new SignatureExceptions;
4195 | ExceptionTypeList optError ',' optError Type
4200 | ExceptionTypeList optError ',' error { $$ = $1; }
4206 $$ = new Ttcn::Reference($1);
4207 $$->set_location(infile, @$);
4209 | IDentifier '.' IDentifier
4211 $$ = new Ttcn::Reference($1, $3);
4212 $$->set_location(infile, @$);
4214 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
4216 $$ = new Ttcn::Reference($1, $5);
4217 $$->set_location(infile, @$);
4222 /* A.1.6.1.6 Testcase definitions */
4225 TestcaseKeyword IDentifier '(' optTestcaseFormalParList ')'
4226 ConfigSpec optError StatementBlock
4228 $4->set_location(infile, @3, @5);
4229 $$ = new Def_Testcase($2, $4, $6.runsonref, $6.systemref, $8);
4230 $$->set_location(infile, @$);
4234 optTestcaseFormalParList: // [200]
4235 /* empty */ { $$ = new FormalParList; }
4236 | TestcaseFormalParList { $$ = $1; }
4237 | error { $$ = new FormalParList; }
4240 TestcaseFormalParList: // 200
4241 optError TestcaseFormalPar
4243 $$ = new FormalParList;
4246 | TestcaseFormalParList optError ',' optError TestcaseFormalPar
4251 | TestcaseFormalParList optError ',' error { $$ = $1; }
4254 TestcaseFormalPar: // 201
4255 FormalValuePar { $$ = $1; }
4256 | FormalTemplatePar { $$ = $1; }
4260 RunsOnSpec optSystemSpec
4267 optSystemSpec: // [203]
4268 /* empty */ { $$ = 0; }
4269 | SystemKeyword ComponentType { $$ = $2; }
4270 | SystemKeyword error { $$ = 0; }
4273 TestcaseInstance: // 205
4274 ExecuteKeyword '(' TestcaseRef '(' optTestcaseActualParList ')'
4275 optTestcaseTimerValue optError ')'
4277 $5->set_location(infile, @4, @6);
4278 $$.ref_pard = new Ttcn::Ref_pard($3.modid, $3.id, $5);
4279 $$.ref_pard->set_location(infile, @3, @6);
4280 $$.derefered_value = 0;
4284 | ExecuteKeyword '(' DereferOp '(' optTestcaseActualParList ')'
4285 optTestcaseTimerValue optError ')'
4287 $5->set_location(infile, @4, @6);
4289 $$.derefered_value = $3;
4293 | ExecuteKeyword '(' error ')'
4296 $$.derefered_value = 0;
4308 | IDentifier '.' IDentifier
4313 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
4321 optTestcaseTimerValue:
4322 /* empty */ { $$ = 0; }
4323 | ',' optError Expression { $$ = $3; }
4326 $$ = new Value(Value::V_ERROR);
4327 $$->set_location(infile, @$);
4331 optTestcaseActualParList: // [202]
4332 /* empty */ optError { $$ = new ParsedActualParameters; }
4333 | TestcaseActualParList optError { $$ = $1; }
4336 TestcaseActualParList: // 208
4339 | UnnamedPart ',' NamedPart
4340 /* Splitting the NamedPart and UnnamedPart ensures that a named parameter
4341 * followed by an unnamed one causes a syntax error */
4343 /* UnnamedPart becomes the value */
4345 /* append the elements from NamedPart */
4346 const size_t n3 = $3->get_nof_nps();
4347 for (size_t i = 0; i < n3; ++i) {
4348 $$->add_np( $3->extract_np_byIndex(i) );
4354 optError TestcaseActualPar
4356 $$ = new TemplateInstances;
4359 | TestcaseActualParList optError ',' optError TestcaseActualPar
4364 | TestcaseActualParList optError ',' error { $$ = $1; }
4370 TemplateInstance { $$ = $1; }
4373 Template *t = new Template(Template::TEMPLATE_NOTUSED);
4374 t->set_location(infile, @$);
4375 $$ = new TemplateInstance(0, 0, t);
4376 $$->set_location(infile, @$);
4381 /* A.1.6.1.7 Altstep definitions */
4384 AltstepKeyword IDentifier '(' optAltstepFormalParList ')' optRunsOnSpec
4385 optError '{' AltstepLocalDefList AltGuardList optError '}'
4387 StatementBlock *sb = new StatementBlock;
4388 for (size_t i = 0; i < $9.nElements; i++) {
4389 Statement *stmt = new Statement(Statement::S_DEF, $9.elements[i]);
4390 stmt->set_location(*$9.elements[i]);
4394 $4->set_location(infile, @4);
4395 $$ = new Def_Altstep($2, $4, $6, sb, $10);
4396 $$->set_location(infile, @$);
4400 optAltstepFormalParList: // [214]
4401 /* empty */ { $$ = new FormalParList; }
4402 | FunctionFormalParList { $$ = $1; }
4403 | error { $$ = new FormalParList; }
4406 AltstepLocalDefList: // 215
4412 | AltstepLocalDefList optError AltstepLocalDef optSemiColon
4414 $$.nElements = $1.nElements + $3.nElements;
4415 $$.elements = (Ttcn::Definition**)
4416 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4417 memcpy($$.elements + $1.nElements, $3.elements,
4418 $3.nElements * sizeof(*$$.elements));
4423 AltstepLocalDef: // 216
4424 VarInstance { $$ = $1; }
4425 | TimerInstance { $$ = $1; }
4426 | ConstDef { $$ = $1; }
4431 $$.elements = (Ttcn::Definition**)Malloc(sizeof(*$$.elements));
4432 $$.elements[0] = $1;
4436 AltstepInstance: /* refpard */ // 217
4437 FunctionRef '(' optFunctionActualParList ')'
4439 $3->set_location(infile, @2, @4);
4440 $$ = new Ttcn::Ref_pard($1.modid, $1.id, $3);
4441 $$->set_location(infile, @$);
4445 /* Taken over by FunctionRef
4448 | IDentifier '.' IDentifier
4449 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
4453 /* A.1.6.1.8 Import definitions */
4456 ImportKeyword ImportFromSpec AllWithExcepts
4458 $2->set_imptype(ImpMod::I_ALL);
4459 $2->set_location(infile, @$);
4463 | ImportKeyword ImportFromSpec '{' ImportSpec '}'
4465 Location loc(infile, @$);
4466 if ( $4 == ImpMod::I_IMPORTSPEC) {
4467 loc.warning("Unsupported selective import statement was treated as "
4470 $2->set_imptype($4);
4471 $2->set_location(infile, @$);
4477 AllWithExcepts: // 221
4479 | AllKeyword ExceptsDef
4481 Location loc(infile, @$);
4482 loc.warning("Unsupported selective import statement was treated as "
4488 ExceptKeyword '{' ExceptSpec '}'
4492 /* empty */ optError
4493 | ExceptSpec ExceptElement optSemiColon
4496 ExceptElement: // 225
4499 | ExceptTemplateSpec
4501 | ExceptTestcaseSpec
4503 | ExceptFunctionSpec
4504 | ExceptSignatureSpec
4505 | ExceptModuleParSpec
4508 ExceptGroupSpec: // 226
4509 GroupKeyword ExceptGroupRefList
4510 | GroupKeyword AllKeyword
4513 ExceptTypeDefSpec: // 227
4514 TypeDefKeyword TypeRefList
4515 | TypeDefKeyword AllKeyword
4518 ExceptTemplateSpec: // 228
4519 TemplateKeyword TemplateRefList
4520 | TemplateKeyword AllKeyword
4523 ExceptConstSpec: // 229
4524 ConstKeyword ConstRefList
4525 | ConstKeyword AllKeyword
4528 ExceptTestcaseSpec: // 230
4529 TestcaseKeyword TestcaseRefList
4530 | TestcaseKeyword AllKeyword
4533 ExceptAltstepSpec: // 231
4534 AltstepKeyword AltstepRefList
4535 | AltstepKeyword AllKeyword
4538 ExceptFunctionSpec: // 232
4539 FunctionKeyword FunctionRefList
4540 | FunctionKeyword AllKeyword
4543 ExceptSignatureSpec: // 233
4544 SignatureKeyword SignatureRefList
4545 | SignatureKeyword AllKeyword
4548 ExceptModuleParSpec: // 234
4549 ModuleParKeyword ModuleParRefList
4550 | ModuleParKeyword AllKeyword
4554 /* empty */ optError
4555 { $$ = ImpMod::I_ALL; }
4556 | ImportSpec ImportElement optSemiColon
4559 case ImpMod::I_ALL: // it was empty before
4563 case ImpMod::I_IMPORTSPEC:
4565 case ImpMod::I_IMPORTSPEC:
4566 // selective import followed by another selective import: NOP
4568 case ImpMod::I_IMPORTIMPORT:
4569 $$ = $2; // import of import wins over selective import
4571 default: // including I_ALL
4572 FATAL_ERROR("Selective import cannot be followed by import all");
4576 case ImpMod::I_IMPORTIMPORT:
4578 case ImpMod::I_IMPORTSPEC:
4579 // import of import followed by selective import: NOP (import of import wins)
4581 case ImpMod::I_IMPORTIMPORT:
4582 // import of import following another import of import: error
4583 Location(infile, @2).error("Import of imports can only be used once");
4585 default: // including I_ALL
4586 FATAL_ERROR("Import of imports cannot be followed by import all");
4591 FATAL_ERROR("Invalid import type");
4596 ImportElement: // 236
4598 { $$ = ImpMod::I_IMPORTSPEC; }
4600 { $$ = ImpMod::I_IMPORTSPEC; }
4601 | ImportTemplateSpec
4602 { $$ = ImpMod::I_IMPORTSPEC; }
4604 { $$ = ImpMod::I_IMPORTSPEC; }
4605 | ImportTestcaseSpec
4606 { $$ = ImpMod::I_IMPORTSPEC; }
4608 { $$ = ImpMod::I_IMPORTSPEC; }
4609 | ImportFunctionSpec
4610 { $$ = ImpMod::I_IMPORTSPEC; }
4611 | ImportSignatureSpec
4612 { $$ = ImpMod::I_IMPORTSPEC; }
4613 | ImportModuleParSpec
4614 { $$ = ImpMod::I_IMPORTSPEC; }
4616 { $$ = ImpMod::I_IMPORTIMPORT; }
4620 ImportKeyword AllKeyword
4622 ImportFromSpec: // 237
4623 FromKeyword ModuleId { $$ = $2; }
4624 | FromKeyword ModuleId RecursiveKeyword // already deprecated in v3.2.1
4627 $$->set_recursive();
4631 ImportGroupSpec: // 239
4632 GroupKeyword GroupRefListWithExcept
4633 | GroupKeyword AllGroupsWithExcept
4634 | GroupKeyword error
4637 GroupRefList: // 240
4638 optError FullGroupIdentifier { delete $2; }
4639 | GroupRefList optError ',' optError FullGroupIdentifier { delete $5; }
4640 | GroupRefList optError ',' error
4643 GroupRefListWithExcept: // 241
4644 optError FullGroupIdentifierWithExcept
4645 | GroupRefListWithExcept optError ',' optError FullGroupIdentifierWithExcept
4646 | GroupRefListWithExcept optError ',' error
4649 AllGroupsWithExcept: // 242
4652 | AllKeyword ExceptKeyword GroupRefList
4653 | AllKeyword ExceptKeyword error
4656 FullGroupIdentifier: // 243
4659 $$ = new Qualifier();
4660 $$->add(new FieldOrArrayRef($1));
4661 $$->set_location(infile, @$);
4663 | FullGroupIdentifier '.' IDentifier
4666 $$->add(new FieldOrArrayRef($3));
4667 $$->set_location(infile, @$);
4671 FullGroupIdentifierWithExcept: // 244
4672 FullGroupIdentifier { delete $1; }
4673 | FullGroupIdentifier ExceptsDef { delete $1; }
4676 ExceptGroupRefList: // 245
4677 optError ExceptFullGroupIdentifier
4678 | ExceptGroupRefList optError ',' optError ExceptFullGroupIdentifier
4679 | ExceptGroupRefList optError ',' error
4682 ExceptFullGroupIdentifier: // 246
4683 FullGroupIdentifier { delete $1;}
4686 ImportTypeDefSpec: // 247
4687 TypeDefKeyword TypeRefList
4688 | TypeDefKeyword AllTypesWithExcept
4689 | TypeDefKeyword error
4693 optError IDentifier { delete $2; }
4694 | TypeRefList optError ',' optError IDentifier { delete $5; }
4695 | TypeRefList optError ',' error
4698 AllTypesWithExcept: // 249
4701 | AllKeyword ExceptKeyword TypeRefList
4702 | AllKeyword ExceptKeyword error
4705 /* 250. TypeDefIdentifier is replaced by IDentifier */
4707 ImportTemplateSpec: // 251
4708 TemplateKeyword TemplateRefList
4709 | TemplateKeyword AllTemplsWithExcept
4710 | TemplateKeyword error
4713 TemplateRefList: // 252
4714 optError IDentifier { delete $2; }
4715 | TemplateRefList optError ',' optError IDentifier { delete $5; }
4716 | TemplateRefList optError ',' error
4719 AllTemplsWithExcept: // 253
4722 | AllKeyword ExceptKeyword TemplateRefList
4723 | AllKeyword ExceptKeyword error
4726 ImportConstSpec: // 254
4727 ConstKeyword ConstRefList
4728 | ConstKeyword AllConstsWithExcept
4729 | ConstKeyword error
4732 ConstRefList: // 255
4733 optError IDentifier { delete $2; }
4734 | ConstRefList optError ',' optError IDentifier { delete $5; }
4735 | ConstRefList optError ',' error
4738 AllConstsWithExcept: // 256
4741 | AllKeyword ExceptKeyword ConstRefList
4742 | AllKeyword ExceptKeyword error
4745 ImportAltstepSpec: // 257
4746 AltstepKeyword AltstepRefList
4747 | AltstepKeyword AllAltstepsWithExcept
4748 | AltstepKeyword error
4751 AltstepRefList: // 258
4752 optError IDentifier { delete $2; }
4753 | AltstepRefList optError ',' optError IDentifier { delete $5; }
4754 | AltstepRefList optError ',' error
4757 AllAltstepsWithExcept: // 259
4760 | AllKeyword ExceptKeyword AltstepRefList
4761 | AllKeyword ExceptKeyword error
4764 ImportTestcaseSpec: // 260
4765 TestcaseKeyword TestcaseRefList
4766 | TestcaseKeyword AllTestcasesWithExcept
4767 | TestcaseKeyword error
4770 TestcaseRefList: // 261
4771 optError IDentifier { delete $2; }
4772 | TestcaseRefList optError ',' optError IDentifier { delete $5; }
4773 | TestcaseRefList optError ',' error
4776 AllTestcasesWithExcept: // 262
4779 | AllKeyword ExceptKeyword TestcaseRefList
4780 | AllKeyword ExceptKeyword error
4783 ImportFunctionSpec: // 263
4784 FunctionKeyword FunctionRefList
4785 | FunctionKeyword AllFunctionsWithExcept
4786 | FunctionKeyword error
4789 FunctionRefList: // 264
4790 optError IDentifier { delete $2; }
4791 | FunctionRefList optError ',' optError IDentifier { delete $5; }
4792 | FunctionRefList optError ',' error
4795 AllFunctionsWithExcept: // 265
4798 | AllKeyword ExceptKeyword FunctionRefList
4799 | AllKeyword ExceptKeyword error
4802 ImportSignatureSpec: // 266
4803 SignatureKeyword SignatureRefList
4804 | SignatureKeyword AllSignaturesWithExcept
4805 | SignatureKeyword error
4808 SignatureRefList: // 267
4809 optError IDentifier { delete $2; }
4810 | SignatureRefList optError ',' optError IDentifier { delete $5; }
4811 | SignatureRefList optError ',' error
4814 AllSignaturesWithExcept: // 268
4817 | AllKeyword ExceptKeyword SignatureRefList
4818 | AllKeyword ExceptKeyword error
4821 ImportModuleParSpec: // 269
4822 ModuleParKeyword ModuleParRefList
4823 | ModuleParKeyword AllModuleParWithExcept
4824 | ModuleParKeyword error
4827 ModuleParRefList: // 270
4828 optError IDentifier { delete $2; }
4829 | ModuleParRefList optError ',' optError IDentifier { delete $5; }
4830 | ModuleParRefList optError ',' error
4833 AllModuleParWithExcept: // 271
4836 | AllKeyword ExceptKeyword ModuleParRefList
4837 | AllKeyword ExceptKeyword error
4840 // 272 ImportImportSpec: ImportKeyword AllKeyword
4842 /* A.1.6.1.9 Group definitions */
4845 GroupIdentifier '{' optErrorBlock '}'
4848 $$->set_location(infile, @$);
4850 | GroupIdentifier '{' ModuleDefinitionsList optErrorBlock '}'
4853 $$->set_location(infile, @$);
4857 GroupIdentifier: // 274 (followed by) 275.
4858 GroupKeyword IDentifier
4861 $$->set_parent_group(act_group);
4862 $$->set_location(infile, @$);
4864 act_group->add_group($$);
4865 $$->set_parent_path(act_group->get_attrib_path());
4867 act_ttcn3_module->add_group($$);
4868 $$->set_parent_path(act_ttcn3_module->get_attrib_path());
4874 /* A.1.6.1.10 External function definitions */
4876 ExtFunctionDef: // 276
4877 ExtKeyword FunctionKeyword IDentifier
4878 '(' optFunctionFormalParList ')' optReturnType
4880 $5->set_location(infile, @4, @6);
4881 $$ = new Def_ExtFunction($3, $5, $7.type, $7.returns_template,
4882 $7.template_restriction);
4883 $$->set_location(infile, @$);
4887 /* A.1.6.1.11 External constant definitions */
4890 ExtKeyword ConstKeyword Type IdentifierList
4892 $$.nElements = $4.nElements;
4893 $$.elements = (Ttcn::Definition**)
4894 Malloc($$.nElements * sizeof(*$$.elements));
4895 for (size_t i = 0; i < $$.nElements; i++) {
4898 type = new Type(Type::T_REFDSPEC, $3);
4899 type->set_location(*$3);
4901 $$.elements[i] = new Ttcn::Def_ExtConst($4.elements[i].id, type);
4902 $$.elements[i]->set_location(infile, $4.elements[i].yyloc);
4908 IdentifierList: // 280 ExtConstIdentifierList
4912 $$.elements = (YYSTYPE::extconstidentifier_t*)Malloc(sizeof(*$$.elements));
4913 $$.elements[0].id = $2;
4914 $$.elements[0].yyloc = @2;
4916 | IdentifierList ',' optError IDentifier
4918 $$.nElements = $1.nElements + 1;
4919 $$.elements = (YYSTYPE::extconstidentifier_t*)
4920 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4921 $$.elements[$1.nElements].id = $4;
4922 $$.elements[$1.nElements].yyloc = @4;
4924 | IdentifierList ',' error { $$ = $1; }
4927 /* A.1.6.1.12 Module parameter definitions */
4929 ModuleParDef: // 282
4930 ModuleParKeyword ModulePar { $$ = $2; }
4931 | ModuleParKeyword '{' MultiTypedModuleParList optError '}' { $$ = $3; }
4932 | ModuleParKeyword '{' error '}' { $$.nElements = 0; $$.elements = NULL; }
4935 MultiTypedModuleParList: // 284
4936 optError ModulePar optSemiColon { $$ = $2; }
4937 | MultiTypedModuleParList optError ModulePar optSemiColon
4939 $$.nElements = $1.nElements + $3.nElements;
4940 $$.elements = (Ttcn::Definition**)
4941 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4942 memcpy($$.elements + $1.nElements, $3.elements,
4943 $3.nElements * sizeof(*$$.elements));
4951 $$.nElements = $2.nElements;
4952 $$.elements = (Ttcn::Definition**)
4953 Malloc($$.nElements * sizeof(*$$.elements));
4954 for(size_t i = 0; i < $2.nElements; i++) {
4957 type = new Type(Type::T_REFDSPEC, $1);
4958 type->set_location(*$1);
4960 $$.elements[i] = new Def_Modulepar($2.elements[i].id, type,
4961 $2.elements[i].defval);
4962 $$.elements[i]->set_location(infile, $2.elements[i].yyloc);
4966 | TemplateKeyword Type TemplateModuleParList
4968 $$.nElements = $3.nElements;
4969 $$.elements = (Ttcn::Definition**)Malloc($$.nElements * sizeof(*$$.elements));
4970 for(size_t i = 0; i < $3.nElements; i++) {
4973 type = new Type(Type::T_REFDSPEC, $2);
4974 type->set_location(*$2);
4976 $$.elements[i] = new Def_Modulepar_Template($3.elements[i].id, type, $3.elements[i].deftempl);
4977 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
4983 ModuleParList: // 287
4984 optError SingleModulePar
4987 $$.elements = (YYSTYPE::singlemodulepar_t*)Malloc(sizeof(*$$.elements));
4988 $$.elements[0] = $2;
4990 | ModuleParList ',' optError SingleModulePar
4992 $$.nElements = $1.nElements + 1;
4993 $$.elements = (YYSTYPE::singlemodulepar_t*)
4994 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4995 $$.elements[$$.nElements - 1] = $4;
4999 TemplateModuleParList: // 287
5000 optError SingleTemplateModulePar
5003 $$.elements = (YYSTYPE::singletemplatemodulepar_t*)Malloc(sizeof(*$$.elements));
5004 $$.elements[0] = $2;
5006 | TemplateModuleParList ',' optError SingleTemplateModulePar
5008 $$.nElements = $1.nElements + 1;
5009 $$.elements = (YYSTYPE::singletemplatemodulepar_t*)
5010 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
5011 $$.elements[$$.nElements - 1] = $4;
5022 | IDentifier AssignmentChar Expression
5030 SingleTemplateModulePar:
5037 | IDentifier AssignmentChar TemplateBody
5046 FriendModuleDef: // 289
5047 FriendKeyword TTCN3ModuleKeyword IdentifierList optSemiColon
5049 $$.nElements = $3.nElements;
5050 $$.elements = (Ttcn::FriendMod**)
5051 Malloc($$.nElements*sizeof(*$$.elements));
5052 for (size_t i = 0; i < $$.nElements; i++) {
5053 $$.elements[i] = new FriendMod($3.elements[i].id);
5054 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
5060 /* A.1.6.2 Control part */
5062 /* A.1.6.2.0 General */
5064 ModuleControlPart: // 290
5065 optError ControlKeyword
5066 '{' ModuleControlBody '}'
5067 optWithStatementAndSemiColon
5069 ControlPart* controlpart = new ControlPart($4);
5070 controlpart->set_location(infile, @2, @6);
5071 controlpart->set_with_attr($6);
5072 controlpart->set_parent_path(act_ttcn3_module->get_attrib_path());
5073 act_ttcn3_module->add_controlpart(controlpart);
5077 ModuleControlBody: // 292
5078 /* empty */ optError { $$=new StatementBlock(); }
5079 | ControlStatementOrDefList { $$ = $1; }
5082 ControlStatementOrDefList: // 293
5083 optError ControlStatementOrDef optSemiColon
5085 $$=new StatementBlock();
5086 for(size_t i=0; i<$2.nElements; i++) $$->add_stmt($2.elements[i]);
5089 | ControlStatementOrDefList optError ControlStatementOrDef optSemiColon
5092 for(size_t i=0; i<$3.nElements; i++) $$->add_stmt($3.elements[i]);
5097 ControlStatementOrDef: // 294
5100 $$.nElements=$1.nElements;
5101 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
5102 for(size_t i=0; i<$1.nElements; i++) {
5103 $$.elements[i]=new Statement(Statement::S_DEF, $1.elements[i]);
5104 $$.elements[i]->set_location(*$1.elements[i]);
5110 $$.nElements=$1.nElements;
5111 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
5112 for(size_t i=0; i<$1.nElements; i++) {
5113 $$.elements[i]=new Statement(Statement::S_DEF, $1.elements[i]);
5114 $$.elements[i]->set_location(*$1.elements[i]);
5121 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
5126 ControlStatement: /* Statement *stmt */ // 295
5127 TimerStatements { $$ = $1; }
5128 | BasicStatements { $$ = $1; }
5129 | BehaviourStatements { $$ = $1; }
5130 | SUTStatements { $$ = $1; }
5131 | StopExecutionStatement { $$ = $1; }
5132 | ProfilerStatement { $$ = $1; }
5133 | int2enumStatement { $$ = $1; }
5136 /* A.1.6.2.1 Variable instantiation */
5139 VarKeyword Type VarList
5141 $$.nElements = $3.nElements;
5142 $$.elements = (Ttcn::Definition**)
5143 Malloc($$.nElements*sizeof(*$$.elements));
5144 for (size_t i = 0; i < $$.nElements; i++) {
5147 type = new Type(Type::T_REFDSPEC, $2);
5148 type->set_location(*$2);
5150 /* creation of array type(s) if necessary (from right to left) */
5151 for (size_t j = $3.elements[i].arrays.nElements; j > 0; j--) {
5152 type = new Type(Type::T_ARRAY, type,
5153 $3.elements[i].arrays.elements[j - 1], false);
5154 type->set_location(*$2);
5156 Free($3.elements[i].arrays.elements);
5158 /* Create the definition */
5159 $$.elements[i] = new Def_Var($3.elements[i].id,
5160 type, $3.elements[i].initial_value);
5161 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
5165 | VarKeyword TemplateOptRestricted Type TempVarList
5167 $$.nElements = $4.nElements;
5168 $$.elements = (Ttcn::Definition**)
5169 Malloc($$.nElements * sizeof(*$$.elements));
5170 for (size_t i = 0; i < $$.nElements; i++) {
5173 type = new Type(Type::T_REFDSPEC, $3);
5174 type->set_location(*$3);
5176 /* creation of array type(s) if necessary (from right to left) */
5177 for (size_t j = $4.elements[i].arrays.nElements; j > 0; j--) {
5178 type = new Type(Type::T_ARRAY, type,
5179 $4.elements[i].arrays.elements[j - 1], false);
5180 type->set_location(*$3);
5182 Free($4.elements[i].arrays.elements);
5184 /* Create the definition */
5185 $$.elements[i] = new Def_Var_Template($4.elements[i].id, type,
5186 $4.elements[i].initial_value, $2);
5187 $$.elements[i]->set_location(infile, $4.elements[i].yyloc);
5195 optError SingleVarInstance
5198 $$.elements = (YYSTYPE::singlevarinst_t*)Malloc(sizeof(*$$.elements));
5199 $$.elements[0] = $2;
5201 | VarList ',' optError SingleVarInstance
5203 $$.nElements = $1.nElements + 1;
5204 $$.elements = (YYSTYPE::singlevarinst_t*)
5205 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
5206 $$.elements[$$.nElements - 1] = $4;
5210 SingleVarInstance: // 298
5211 IDentifier optArrayDef
5215 $$.initial_value = 0;
5218 | IDentifier optArrayDef AssignmentChar Expression
5222 $$.initial_value = $4;
5228 optError SingleTempVarInstance
5231 $$.elements = (YYSTYPE::singletempvarinst_t*)Malloc(sizeof(*$$.elements));
5232 $$.elements[0] = $2;
5234 | TempVarList ',' optError SingleTempVarInstance
5236 $$.nElements = $1.nElements + 1;
5237 $$.elements = (YYSTYPE::singletempvarinst_t*)
5238 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
5239 $$.elements[$$.nElements - 1] = $4;
5243 SingleTempVarInstance: // 303
5244 IDentifier optArrayDef
5248 $$.initial_value = NULL;
5251 | IDentifier optArrayDef AssignmentChar TemplateBody
5255 $$.initial_value = $4;
5263 if ($1.is_ref) $$ = $1.ref;
5265 $$ = new Ttcn::Reference($1.id);
5266 $$->set_location(infile, @$);
5271 /* A.1.6.2.2 Timer instantiation */
5273 TimerInstance: // 306
5274 TimerKeyword TimerList { $$ = $2; }
5278 optError SingleTimerInstance
5281 $$.elements = (Ttcn::Definition**)Malloc(sizeof(*$$.elements));
5282 $$.elements[0] = $2;
5284 | TimerList ',' optError SingleTimerInstance
5286 $$.nElements = $1.nElements + 1;
5287 $$.elements = (Ttcn::Definition**)
5288 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
5289 $$.elements[$$.nElements - 1] = $4;
5293 SingleTimerInstance: // 308
5294 IDentifier optArrayDef
5296 ArrayDimensions *dims;
5297 if ($2.nElements > 0) {
5298 dims = new ArrayDimensions;
5299 for (size_t i = 0; i < $2.nElements; i++) dims->add($2.elements[i]);
5302 $$ = new Ttcn::Def_Timer($1, dims, 0);
5303 $$->set_location(infile, @$);
5305 | IDentifier optArrayDef AssignmentChar TimerValue
5307 ArrayDimensions *dims;
5308 if ($2.nElements > 0) {
5309 dims = new ArrayDimensions;
5310 for (size_t i = 0; i < $2.nElements; i++) dims->add($2.elements[i]);
5313 $$ = new Ttcn::Def_Timer($1, dims, $4);
5314 $$->set_location(infile, @$);
5319 Expression { $$ = $1; }
5323 VariableRef { $$ = $1; }
5326 /* A.1.6.2.3 Component operations */
5328 ConfigurationStatements: // 313
5329 ConnectStatement { $$ = $1; }
5330 | MapStatement { $$ = $1; }
5331 | DisconnectStatement { $$ = $1; }
5332 | UnmapStatement { $$ = $1; }
5333 | DoneStatement { $$ = $1; }
5334 | KilledStatement { $$ = $1; }
5335 | StartTCStatement { $$ = $1; }
5336 | StopTCStatement { $$ = $1; }
5337 | KillTCStatement { $$ = $1; }
5340 ConfigurationOps: // 314
5345 | RunningOp {$$=$1;}
5346 | AliveOp { $$ = $1; }
5350 VariableRef DotCreateKeyword optCreateParameter optAliveKeyword
5352 $$ = new Value(Value::OPTYPE_COMP_CREATE, $1, $3.name, $3.loc, $4);
5353 $$->set_location(infile, @$);
5363 | '(' optError Expression optError ')'
5368 | '(' optError Expression optError ',' optError Expression optError ')'
5373 | '(' optError NotUsedSymbol optError ',' optError Expression optError ')'
5385 optAliveKeyword: // [328]
5386 /* empty */ { $$ = false; }
5387 | AliveKeyword { $$ = true; }
5393 $$=new Value(Value::OPTYPE_COMP_SYSTEM);
5394 $$->set_location(infile, @$);
5401 $$=new Value(Value::OPTYPE_COMP_SELF);
5402 $$->set_location(infile, @$);
5409 $$=new Value(Value::OPTYPE_COMP_MTC);
5410 $$->set_location(infile, @$);
5414 DoneStatement: // 319
5415 ComponentOrDefaultReference DotDoneKeyword optDoneParameter
5417 $$ = new Statement(Statement::S_DONE, $1, $3.donematch, $3.redirect);
5418 $$->set_location(infile, @$);
5420 | AnyKeyword ComponentKeyword DotDoneKeyword
5422 $$ = new Statement(Statement::S_DONE, Statement::C_ANY);
5423 $$->set_location(infile, @$);
5425 | AllKeyword ComponentKeyword DotDoneKeyword
5427 $$ = new Statement(Statement::S_DONE, Statement::C_ALL);
5428 $$->set_location(infile, @$);
5438 | optReceiveParameter PortRedirectSymbol ValueSpec
5445 KilledStatement: // 320
5446 ComponentOrDefaultReference DotKilledKeyword
5448 $$ = new Statement(Statement::S_KILLED, $1);
5449 $$->set_location(infile, @$);
5451 | AnyKeyword ComponentKeyword DotKilledKeyword
5453 $$ = new Statement(Statement::S_KILLED, Statement::C_ANY);
5454 $$->set_location(infile, @$);
5456 | AllKeyword ComponentKeyword DotKilledKeyword
5458 $$ = new Statement(Statement::S_KILLED, Statement::C_ALL);
5459 $$->set_location(infile, @$);
5465 ComponentOrDefaultReference
5466 | AnyKeyword ComponentKeyword
5467 | AllKeyword ComponentKeyword
5472 /* VariableRef DotRunningKeyword -- covered by RunningTimerOp */
5473 FunctionInstance DotRunningKeyword
5475 Value *t_val = new Value(Value::V_REFD, $1);
5476 t_val->set_location(infile, @1);
5477 $$ = new Value(Value::OPTYPE_COMP_RUNNING, t_val);
5478 $$->set_location(infile, @$);
5480 | ApplyOp DotRunningKeyword
5482 Value *t_val = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5483 t_val->set_location(infile, @1);
5484 $$ = new Value(Value::OPTYPE_COMP_RUNNING, t_val);
5485 $$->set_location(infile, @$);
5487 | AnyKeyword ComponentKeyword DotRunningKeyword
5489 $$ = new Value(Value::OPTYPE_COMP_RUNNING_ANY);
5490 $$->set_location(infile, @$);
5492 | AllKeyword ComponentKeyword DotRunningKeyword
5494 $$ = new Value(Value::OPTYPE_COMP_RUNNING_ALL);
5495 $$->set_location(infile, @$);
5500 ComponentOrDefaultReference DotAliveKeyword
5502 $$ = new Value(Value::OPTYPE_COMP_ALIVE, $1);
5503 $$->set_location(infile, @$);
5505 | AnyKeyword ComponentKeyword DotAliveKeyword
5507 $$ = new Value(Value::OPTYPE_COMP_ALIVE_ANY);
5508 $$->set_location(infile, @$);
5510 | AllKeyword ComponentKeyword DotAliveKeyword
5512 $$ = new Value(Value::OPTYPE_COMP_ALIVE_ALL);
5513 $$->set_location(infile, @$);
5517 ConnectStatement: // 329
5518 ConnectKeyword SingleConnectionSpec
5520 $$=new Statement(Statement::S_CONNECT,
5521 $2.compref1, $2.portref1, $2.compref2, $2.portref2);
5522 $$->set_location(infile, @$);
5526 SingleConnectionSpec: // 331
5527 '(' PortRef optError ',' optError PortRef optError ')'
5529 $$.compref1 = $2.compref;
5530 $$.portref1 = $2.portref;
5531 $$.compref2 = $6.compref;
5532 $$.portref2 = $6.portref;
5537 ComponentRef ':' Port
5544 ComponentRef: // 333
5545 ComponentOrDefaultReference { $$ = $1; }
5546 | SystemOp { $$ = $1; }
5547 | SelfOp { $$ = $1; }
5548 | MTCOp { $$ = $1; }
5551 DisconnectStatement: // 335
5554 Location loc(infile, @$);
5555 loc.error("Disconnect operation on multiple connections is "
5556 "not currently supported");
5557 $$ = new Statement(Statement::S_ERROR);
5558 $$->set_location(infile, @$);
5560 | DisconnectKeyword SingleOrMultiConnectionSpec
5562 if ($2.portref1 && $2.portref2 && $2.compref1 && $2.compref2) {
5563 $$ = new Statement(Statement::S_DISCONNECT,
5564 $2.compref1, $2.portref1, $2.compref2, $2.portref2);
5566 Location loc(infile, @$);
5567 loc.error("Disconnect operation on multiple connections is "
5568 "not currently supported");
5573 $$ = new Statement(Statement::S_ERROR);
5575 $$->set_location(infile, @$);
5579 SingleOrMultiConnectionSpec: // 336
5580 SingleConnectionSpec { $$ = $1; }
5581 | AllConnectionsSpec
5583 $$.compref1 = $1.compref;
5584 $$.portref1 = $1.portref;
5595 | AllCompsAllPortsSpec
5604 AllConnectionsSpec: // 337
5605 '(' PortRef optError ')' { $$ = $2; }
5608 AllPortsSpec: // 338
5609 '(' ComponentRef ':' AllKeyword PortKeyword optError ')' { $$ = $2; }
5612 AllCompsAllPortsSpec: // 339
5613 '(' AllKeyword ComponentKeyword ':' AllKeyword PortKeyword optError ')'
5616 MapStatement: // 341
5617 MapKeyword SingleConnectionSpec
5619 $$=new Statement(Statement::S_MAP,
5620 $2.compref1, $2.portref1,
5621 $2.compref2, $2.portref2);
5622 $$->set_location(infile, @$);
5626 UnmapStatement: // 343
5629 $$ = new Statement(Statement::S_ERROR);
5630 $$->set_location(infile, @$);
5631 Location loc(infile, @$);
5632 loc.error("Unmap operation on multiple mappings is "
5633 "not currently supported");
5635 | UnmapKeyword SingleOrMultiConnectionSpec
5637 if ($2.compref1 && $2.portref1 && $2.compref1 && $2.compref2) {
5638 $$ = new Statement(Statement::S_UNMAP,
5639 $2.compref1, $2.portref1, $2.compref2, $2.portref2);
5641 Location loc(infile, @$);
5642 loc.error("Unmap operation on multiple mappings is "
5643 "not currently supported");
5648 $$ = new Statement(Statement::S_ERROR);
5650 $$->set_location(infile, @$);
5654 StartTCStatement: // 345
5655 /* VariableRef DotStartKeyword '(' FunctionInstance ')'
5656 -- covered by StartTimerStatement */
5657 VariableRef DotStartKeyword '(' DereferOp '(' optFunctionActualParList ')'
5660 Value *t_val = new Value(Value::V_REFD, $1);
5661 t_val->set_location(infile, @1);
5662 $6->set_location(infile, @5, @7);
5663 //ParsedActualParameters *pap = new ParsedActualParameters($6);
5664 $$ = new Statement(Statement::S_START_COMP_REFD, t_val, $4, $6);
5665 $$->set_location(infile, @$);
5667 | FunctionInstance DotStartKeyword '(' FunctionInstance optError ')'
5669 Value *t_val = new Value(Value::V_REFD, $1);
5670 t_val->set_location(infile, @1);
5671 $$ = new Statement(Statement::S_START_COMP, t_val, $4);
5672 $$->set_location(infile, @$);
5674 | FunctionInstance DotStartKeyword '(' DereferOp '('
5675 optFunctionActualParList ')' optError ')'
5677 Value *t_val = new Value(Value::V_REFD, $1);
5678 t_val->set_location(infile, @1);
5679 $6->set_location(infile, @5 , @7);
5680 $$ = new Statement(Statement::S_START_COMP_REFD, t_val, $4, $6);
5681 $$->set_location(infile, @$);
5683 | FunctionInstance DotStartKeyword '(' error ')'
5686 $$ = new Statement(Statement::S_ERROR);
5687 $$->set_location(infile, @$);
5689 | ApplyOp DotStartKeyword '(' FunctionInstance ')'
5691 Value *t_val = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5692 t_val->set_location(infile, @1);
5693 $$ = new Statement(Statement::S_START_COMP, t_val, $4);
5694 $$->set_location(infile, @$);
5696 | ApplyOp DotStartKeyword '(' DereferOp '(' optFunctionActualParList ')'
5699 Value *t_val = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5700 t_val->set_location(infile, @1);
5701 $6->set_location(infile, @5 , @7);
5702 $$ = new Statement(Statement::S_START_COMP_REFD, t_val, $4, $6);
5703 $$->set_location(infile, @$);
5705 | ApplyOp DotStartKeyword '(' error ')'
5709 $$ = new Statement(Statement::S_ERROR);
5710 $$->set_location(infile, @$);
5714 StopTCStatement: // 337
5715 /* VariableRef DotStopKeyword -- covered by StopTimerStatement */
5716 FunctionInstance DotStopKeyword
5718 Value *t_val = new Value(Value::V_REFD, $1);
5719 t_val->set_location(infile, @1);
5720 $$ = new Statement(Statement::S_STOP_COMP, t_val);
5721 $$->set_location(infile, @$);
5723 | ApplyOp DotStopKeyword
5725 Value *t_val = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5726 t_val->set_location(infile, @1);
5727 $$ = new Statement(Statement::S_STOP_COMP, t_val);
5728 $$->set_location(infile, @$);
5730 | MTCOp DotStopKeyword
5732 $$ = new Statement(Statement::S_STOP_COMP, $1);
5733 $$->set_location(infile, @$);
5735 | SelfOp DotStopKeyword
5737 $$ = new Statement(Statement::S_STOP_COMP, $1);
5738 $$->set_location(infile, @$);
5740 | AllKeyword ComponentKeyword DotStopKeyword
5742 $$ = new Statement(Statement::S_STOP_COMP, (Value*)0);
5743 $$->set_location(infile, @$);
5747 ComponentReferenceOrLiteral: // 348
5748 ComponentOrDefaultReference { $$ = $1; }
5749 | MTCOp { $$ = $1; }
5750 | SelfOp { $$ = $1; }
5753 KillTCStatement: // 349
5756 Value *self = new Value(Value::OPTYPE_COMP_SELF);
5757 self->set_location(infile, @1);
5758 $$ = new Statement(Statement::S_KILL, self);
5759 $$->set_location(infile, @$);
5761 | ComponentReferenceOrLiteral DotKillKeyword
5763 $$ = new Statement(Statement::S_KILL, $1);
5764 $$->set_location(infile, @$);
5766 | AllKeyword ComponentKeyword DotKillKeyword
5768 $$ = new Statement(Statement::S_KILL, (Value*)0);
5769 $$->set_location(infile, @$);
5773 ComponentOrDefaultReference: // 350
5776 $$ = new Value(Value::V_REFD, $1);
5777 $$->set_location(infile, @$);
5781 $$ = new Value(Value::V_REFD, $1);
5782 $$->set_location(infile, @$);
5786 $$ = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5787 $$->set_location(infile, @$);
5791 /* A.1.6.2.4 Port operations */
5794 VariableRef { $$ = $1; }
5797 CommunicationStatements: // 353
5798 SendStatement {$$ = $1;}
5799 | CallStatement {$$ = $1;}
5800 | ReplyStatement {$$ = $1;}
5801 | RaiseStatement {$$ = $1;}
5802 | ReceiveStatement {$$ = $1;}
5803 | TriggerStatement {$$ = $1;}
5804 | GetCallStatement {$$ = $1;}
5805 | GetReplyStatement {$$ = $1;}
5806 | CatchStatement {$$ = $1;}
5807 | CheckStatement {$$ = $1;}
5808 | ClearStatement {$$ = $1;}
5809 | StartStatement {$$ = $1;}
5810 | StopStatement {$$ = $1;}
5811 | HaltStatement {$$ = $1;}
5814 SendStatement: // 354
5815 Port DotSendOpKeyword PortSendOp
5817 $$ = new Statement(Statement::S_SEND, $1, $3.templ_inst, $3.val);
5818 $$->set_location(infile, @$);
5823 '(' SendParameter optError ')' optToClause
5828 | '(' error ')' optToClause
5830 Template *t = new Template(Template::TEMPLATE_ERROR);
5831 t->set_location(infile, @2);
5832 $$.templ_inst = new TemplateInstance(0, 0, t);
5833 $$.templ_inst->set_location(infile, @2);
5838 SendParameter: // 357
5839 TemplateInstance { $$=$1; }
5842 optToClause: // [3583]
5843 /* empty */ { $$ = 0; }
5844 | ToKeyword AddressRef
5846 Template *templ = $2->get_Template();
5847 if (!$2->get_Type() && !$2->get_DerivedRef() && templ->is_Value()) {
5848 $$ = templ->get_Value();
5850 Location loc(infile, @$);
5851 loc.error("Multicast communication is not currently supported");
5856 /* | ToKeyword AddressRefList -- covered by the previous rule
5857 (as ValueOrAttribList) */
5858 | ToKeyword AllKeyword ComponentKeyword
5860 Location loc(infile, @$);
5861 loc.error("Broadcast communication is not currently supported");
5864 | ToKeyword error { $$ = 0; }
5868 AddressRefList: // 359
5869 '(' seqAddressRef ')'
5874 | seqAddressRef ',' AddressRef
5879 TemplateInstance { $$ = $1; }
5882 CallStatement: // 362
5883 Port DotCallOpKeyword PortCallOp optPortCallBody
5885 $$ = new Statement(Statement::S_CALL, $1, $3.templ_inst,
5886 $3.calltimerval, $3.nowait, $3.val, $4);
5887 $$->set_location(infile, @$);
5892 '(' CallParameters optError ')' optToClause
5894 $$.templ_inst = $2.templ_inst;
5895 $$.calltimerval = $2.calltimerval;
5896 $$.nowait = $2.nowait;
5899 | '(' error ')' optToClause
5901 Template *t = new Template(Template::TEMPLATE_ERROR);
5902 t->set_location(infile, @2);
5903 $$.templ_inst = new TemplateInstance(0, 0, t);
5904 $$.templ_inst->set_location(infile, @2);
5905 $$.calltimerval = 0;
5911 CallParameters: // 365
5918 | TemplateInstance ',' optError CallTimerValue
5921 $$.calltimerval=$4.calltimerval;
5922 $$.nowait=$4.nowait;
5926 CallTimerValue: // 366
5939 optPortCallBody: // [368]
5940 /* empty */ { $$=0; }
5941 | '{' CallBodyStatementList optError '}' { $$=$2; }
5942 | '{' error '}' { $$ = new AltGuards; }
5945 CallBodyStatementList: // 369
5946 optError CallBodyStatement
5951 | CallBodyStatementList optError CallBodyStatement
5958 CallBodyStatement: // 370 and 371. rolled into one.
5959 AltGuardChar CallBodyOps ';' // This alternative is a TITAN extension
5961 $$=new AltGuard($1, $2, new StatementBlock());
5962 $$->set_location(infile, @$);
5964 | AltGuardChar CallBodyOps optSemiColon StatementBlock optSemiColon
5966 $$=new AltGuard($1, $2, $4);
5967 $$->set_location(infile, @$);
5972 GetReplyStatement {$$=$1;}
5973 | CatchStatement {$$=$1;}
5976 ReplyStatement: // 373
5977 Port DotReplyKeyword PortReplyOp
5979 $$ = new Statement(Statement::S_REPLY, $1, $3.templ_inst,
5980 $3.replyval, $3.toclause);
5981 $$->set_location(infile, @$);
5986 '(' TemplateInstance optReplyValue optError ')' optToClause
5992 | '(' error ')' optToClause
5994 Template *t = new Template(Template::TEMPLATE_ERROR);
5995 t->set_location(infile, @2);
5996 $$.templ_inst = new TemplateInstance(0, 0, t);
5997 $$.templ_inst->set_location(infile, @2);
6003 optReplyValue: // [376]
6004 /* empty */ { $$=0; }
6005 | ValueKeyword Expression { $$=$2; }
6006 | ValueKeyword error { $$ = 0; }
6009 RaiseStatement: // 377
6010 Port DotRaiseKeyword PortRaiseOp
6012 if ($3.signature) $$ = new Statement(Statement::S_RAISE, $1,
6013 $3.signature, $3.templ_inst, $3.toclause);
6015 $$ = new Statement(Statement::S_ERROR);
6017 delete $3.signature;
6018 delete $3.templ_inst;
6021 $$->set_location(infile, @$);
6026 '(' Signature optError ',' optError TemplateInstance optError ')' optToClause
6032 | '(' error ')' optToClause
6041 ReceiveStatement: // 380
6042 PortOrAny DotReceiveOpKeyword PortReceiveOp
6044 $$ = new Statement(Statement::S_RECEIVE, $1, $3.templ_inst,
6045 $3.fromclause, $3.redirectval, $3.redirectsender);
6046 $$->set_location(infile, @$);
6052 | AnyKeyword PortKeyword { $$ = 0; }
6055 PortReceiveOp: // 382
6056 optReceiveParameter optFromClause optPortRedirect
6060 $$.redirectval = $3.redirectval;
6061 $$.redirectsender = $3.redirectsender;
6065 optReceiveParameter: // [384]
6066 /* empty */ { $$ = 0; }
6067 | '(' ReceiveParameter optError ')' { $$ = $2; }
6070 Template *t = new Template(Template::TEMPLATE_ERROR);
6071 t->set_location(infile, @2);
6072 $$ = new TemplateInstance(0, 0, t);
6073 $$->set_location(infile, @$);
6077 ReceiveParameter: // 384
6078 TemplateInstance { $$ = $1; }
6081 optFromClause: // [385]
6082 /* empty */ { $$=0; }
6083 | FromClause { $$=$1; }
6087 FromKeyword AddressRef { $$=$2; }
6088 | FromKeyword error { $$ = 0; }
6091 optPortRedirect: // [387]
6095 $$.redirectsender=0;
6097 | PortRedirectSymbol ValueSpec
6100 $$.redirectsender=0;
6102 | PortRedirectSymbol SenderSpec
6105 $$.redirectsender=$2;
6107 | PortRedirectSymbol ValueSpec SenderSpec
6110 $$.redirectsender=$3;
6112 | PortRedirectSymbol error
6115 $$.redirectsender=0;
6120 ValueKeyword VariableRef { $$ = $2; }
6121 | ValueKeyword error { $$ = 0; }
6125 SenderKeyword VariableRef { $$ = $2; }
6126 | SenderKeyword error { $$ = 0; }
6129 TriggerStatement: // 393
6130 PortOrAny DotTriggerOpKeyword PortTriggerOp
6132 $$ = new Statement(Statement::S_TRIGGER, $1, $3.templ_inst,
6133 $3.fromclause, $3.redirectval, $3.redirectsender);
6134 $$->set_location(infile, @$);
6138 PortTriggerOp: // 394
6139 optReceiveParameter optFromClause optPortRedirect
6143 $$.redirectval = $3.redirectval;
6144 $$.redirectsender = $3.redirectsender;
6148 GetCallStatement: // 396
6149 PortOrAny DotGetCallOpKeyword PortGetCallOp
6151 $$ = new Statement(Statement::S_GETCALL, $1, $3.templ_inst,
6152 $3.fromclause, $3.redirectparam, $3.redirectsender);
6153 $$->set_location(infile, @$);
6157 PortGetCallOp: // 397
6158 optReceiveParameter optFromClause optPortRedirectWithParam
6162 $$.redirectparam = $3.redirectparam;
6163 $$.redirectsender = $3.redirectsender;
6167 optPortRedirectWithParam: // [399]
6171 $$.redirectsender=0;
6173 | PortRedirectSymbol ParamSpec
6175 $$.redirectparam=$2;
6176 $$.redirectsender=0;
6178 | PortRedirectSymbol ParamSpec SenderSpec
6180 $$.redirectparam=$2;
6181 $$.redirectsender=$3;
6183 | PortRedirectSymbol SenderSpec
6186 $$.redirectsender=$2;
6188 | PortRedirectSymbol error
6191 $$.redirectsender=0;
6196 ParamKeyword ParamAssignmentList { $$ = $2; }
6197 | ParamKeyword error { $$ = 0; }
6200 ParamAssignmentList: // 403
6201 '(' AssignmentList optError ')'
6203 $$=new ParamRedirect($2);
6204 $$->set_location(infile, @$);
6206 | '(' VariableList optError ')'
6208 $$=new ParamRedirect($2);
6209 $$->set_location(infile, @$);
6213 $$=new ParamRedirect(new ParamAssignments());
6214 $$->set_location(infile, @$);
6218 AssignmentList: // 404
6221 $$ = new ParamAssignments();
6224 | error VariableAssignment
6226 $$ = new ParamAssignments();
6229 | AssignmentList optError ',' optError VariableAssignment
6234 | AssignmentList optError ',' error { $$ = $1; }
6237 VariableAssignment: // 405
6238 VariableRef AssignmentChar IDentifier
6240 $$ = new ParamAssignment($3, $1);
6241 $$->set_location(infile, @$);
6245 VariableList: // 407
6248 $$ = new VariableEntries();
6251 | error VariableEntry
6253 $$ = new VariableEntries();
6256 | VariableList optError ',' optError VariableEntry
6261 | VariableList optError ',' error { $$ = $1; }
6264 VariableEntry: // 408
6267 $$ = new VariableEntry($1);
6268 $$->set_location(infile, @$);
6272 $$ = new VariableEntry;
6273 $$->set_location(infile, @$);
6277 GetReplyStatement: // 409
6278 PortOrAny DotGetReplyOpKeyword PortGetReplyOp
6280 $$ = new Statement(Statement::S_GETREPLY, $1, $3.templ_inst,
6281 $3.valuematch, $3.fromclause, $3.redirectval,
6282 $3.redirectparam, $3.redirectsender);
6283 $$->set_location(infile, @$);
6287 PortGetReplyOp: // 410
6288 optGetReplyParameter optFromClause optPortRedirectWithValueAndParam
6290 $$.templ_inst = $1.templ_inst;
6291 $$.valuematch = $1.valuematch;
6293 $$.redirectval = $3.redirectval;
6294 $$.redirectparam = $3.redirectparam;
6295 $$.redirectsender = $3.redirectsender;
6299 optPortRedirectWithValueAndParam: // [411]
6304 $$.redirectsender=0;
6306 | PortRedirectSymbol ValueSpec
6310 $$.redirectsender=0;
6312 | PortRedirectSymbol ValueSpec ParamSpec
6315 $$.redirectparam=$3;
6316 $$.redirectsender=0;
6318 | PortRedirectSymbol ValueSpec SenderSpec
6322 $$.redirectsender=$3;
6324 | PortRedirectSymbol ValueSpec ParamSpec SenderSpec
6327 $$.redirectparam=$3;
6328 $$.redirectsender=$4;
6330 | PortRedirectSymbol ParamSpec
6333 $$.redirectparam=$2;
6334 $$.redirectsender=0;
6336 | PortRedirectSymbol SenderSpec
6340 $$.redirectsender=$2;
6342 | PortRedirectSymbol ParamSpec SenderSpec
6345 $$.redirectparam=$2;
6346 $$.redirectsender=$3;
6348 | PortRedirectSymbol error
6352 $$.redirectsender=0;
6356 optGetReplyParameter:
6362 | '(' ReceiveParameter optError ')'
6367 | '(' ReceiveParameter ValueMatchSpec optError ')'
6374 Template *t = new Template(Template::TEMPLATE_ERROR);
6375 t->set_location(infile, @2);
6376 $$.templ_inst = new TemplateInstance(0, 0, t);
6377 $$.templ_inst->set_location(infile, @2);
6382 ValueMatchSpec: // 414
6383 ValueKeyword TemplateInstance { $$=$2; }
6384 | ValueKeyword error { $$ = 0; }
6387 CheckStatement: // 415
6388 PortOrAny DotCheckOpKeyword optCheckParameter
6390 switch ($3.statementtype) {
6391 case Statement::S_CHECK:
6392 $$ = new Statement(Statement::S_CHECK, $1, $3.templ_inst,
6395 case Statement::S_CHECK_RECEIVE:
6396 $$ = new Statement(Statement::S_CHECK_RECEIVE, $1, $3.templ_inst,
6397 $3.fromclause, $3.redirectval, $3.redirectsender);
6399 case Statement::S_CHECK_GETCALL:
6400 $$ = new Statement(Statement::S_CHECK_GETCALL, $1, $3.templ_inst,
6401 $3.fromclause, $3.redirectparam, $3.redirectsender);
6403 case Statement::S_CHECK_GETREPLY:
6404 $$ = new Statement(Statement::S_CHECK_GETREPLY, $1, $3.templ_inst,
6405 $3.valuematch, $3.fromclause, $3.redirectval,
6406 $3.redirectparam, $3.redirectsender);
6408 case Statement::S_CHECK_CATCH:
6409 $$ = new Statement(Statement::S_CHECK_CATCH, $1, $3.signature,
6410 $3.templ_inst, $3.timeout, $3.fromclause,
6411 $3.redirectval, $3.redirectsender);
6414 FATAL_ERROR("Internal error.");
6416 $$->set_location(infile, @$);
6420 optCheckParameter: // [418]
6423 $$.statementtype = Statement::S_CHECK;
6430 $$.redirectparam = 0;
6431 $$.redirectsender = 0;
6433 | '(' CheckParameter optError ')' { $$ = $2; }
6436 $$.statementtype = Statement::S_CHECK;
6443 $$.redirectparam = 0;
6444 $$.redirectsender = 0;
6448 CheckParameter: // 418
6449 CheckPortOpsPresent { $$ = $1; }
6450 | FromClausePresent { $$ = $1; }
6451 | RedirectPresent { $$ = $1; }
6454 FromClausePresent: // 419
6457 $$.statementtype = Statement::S_CHECK;
6464 $$.redirectparam = 0;
6465 $$.redirectsender = 0;
6467 | FromClause PortRedirectSymbol SenderSpec
6469 $$.statementtype = Statement::S_CHECK;
6476 $$.redirectparam = 0;
6477 $$.redirectsender = $3;
6481 RedirectPresent: // 420
6482 PortRedirectSymbol SenderSpec
6484 $$.statementtype = Statement::S_CHECK;
6491 $$.redirectparam = 0;
6492 $$.redirectsender = $2;
6496 CheckPortOpsPresent: // 421
6497 ReceiveOpKeyword PortReceiveOp
6499 $$.statementtype = Statement::S_CHECK_RECEIVE;
6501 $$.templ_inst = $2.templ_inst;
6504 $$.fromclause = $2.fromclause;
6505 $$.redirectval = $2.redirectval;
6506 $$.redirectparam = 0;
6507 $$.redirectsender = $2.redirectsender;
6509 | GetCallOpKeyword PortGetCallOp
6511 $$.statementtype = Statement::S_CHECK_GETCALL;
6513 $$.templ_inst = $2.templ_inst;
6516 $$.fromclause = $2.fromclause;
6518 $$.redirectparam = $2.redirectparam;
6519 $$.redirectsender = $2.redirectsender;
6521 | GetReplyOpKeyword PortGetReplyOp
6523 $$.statementtype = Statement::S_CHECK_GETREPLY;
6525 $$.templ_inst = $2.templ_inst;
6526 $$.valuematch = $2.valuematch;
6528 $$.fromclause = $2.fromclause;
6529 $$.redirectval = $2.redirectval;
6530 $$.redirectparam = $2.redirectparam;
6531 $$.redirectsender = $2.redirectsender;
6533 | CatchOpKeyword PortCatchOp
6535 $$.statementtype = Statement::S_CHECK_CATCH;
6536 $$.signature = $2.signature;
6537 $$.templ_inst = $2.templ_inst;
6539 $$.timeout = $2.timeout;
6540 $$.fromclause = $2.fromclause;
6541 $$.redirectval = $2.redirectval;
6542 $$.redirectparam = 0;
6543 $$.redirectsender = $2.redirectsender;
6547 CatchStatement: // 422
6548 PortOrAny DotCatchOpKeyword PortCatchOp
6550 $$ = new Statement(Statement::S_CATCH, $1, $3.signature, $3.templ_inst,
6551 $3.timeout, $3.fromclause, $3.redirectval,
6553 $$->set_location(infile, @$);
6558 optCatchOpParameter optFromClause optPortRedirect
6560 $$.signature = $1.signature;
6561 $$.templ_inst = $1.templ_inst;
6562 $$.timeout = $1.timeout;
6564 $$.redirectval = $3.redirectval;
6565 $$.redirectsender = $3.redirectsender;
6569 optCatchOpParameter: // [425]
6576 | '(' CatchOpParameter optError ')' { $$ = $2; }
6585 CatchOpParameter: // 425
6586 Signature optError ',' optError TemplateInstance
6600 ClearStatement: // 426
6601 PortOrAll DotClearOpKeyword
6603 $$ = new Statement(Statement::S_CLEAR, $1);
6604 $$->set_location(infile, @$);
6610 | AllKeyword PortKeyword { $$ = 0; }
6613 StartStatement: // 430
6614 /* Port DotPortStartKeyword -- covered by StartTimerStatement */
6615 AllKeyword PortKeyword DotStartKeyword
6617 $$=new Statement(Statement::S_START_PORT, (Ttcn::Reference*)0);
6618 $$->set_location(infile, @$);
6622 StopStatement: // 432
6623 /* Port DotPortStopKeyword -- covered by StopTimerStatement */
6624 AllKeyword PortKeyword DotStopKeyword
6626 $$=new Statement(Statement::S_STOP_PORT, (Ttcn::Reference*)0);
6627 $$->set_location(infile, @$);
6631 HaltStatement: // 435
6632 PortOrAll DotHaltKeyword
6634 $$ = new Statement(Statement::S_HALT, $1);
6635 $$->set_location(infile, @$);
6639 /* A.1.6.2.5 Timer operations */
6641 TimerStatements: // 439
6642 StartTimerStatement { $$ = $1; }
6643 | StopTimerStatement { $$ = $1; }
6644 | TimeoutStatement { $$ = $1; }
6648 ReadTimerOp { $$ = $1; }
6649 | RunningTimerOp { $$ = $1; }
6652 StartTimerStatement: // 441
6653 VariableRef DotStartKeyword
6655 $$ = new Statement(Statement::S_START_UNDEF, $1, (Value*)0);
6656 $$->set_location(infile, @$);
6658 | VariableRef DotStartKeyword '(' Expression optError ')'
6660 $$ = new Statement(Statement::S_START_UNDEF, $1, $4);
6661 $$->set_location(infile, @$);
6663 | VariableRef DotStartKeyword '(' error ')'
6665 Value *v = new Value(Value::V_ERROR);
6666 v->set_location(infile, @4);
6667 $$ = new Statement(Statement::S_START_UNDEF, $1, v);
6668 $$->set_location(infile, @$);
6672 StopTimerStatement: // 442
6673 TimerRef DotStopKeyword
6675 $$ = new Statement(Statement::S_STOP_UNDEF, $1, (Value*)0);
6676 $$->set_location(infile, @$);
6678 | AllKeyword TimerKeyword DotStopKeyword
6680 $$ = new Statement(Statement::S_STOP_TIMER, (Ttcn::Reference*)0);
6681 $$->set_location(infile, @$);
6685 /* no separate rule, folded into StopTimerStatement
6686 TimerRefOrAll: // 443
6688 | AllKeyword TimerKeyword
6693 TimerRef DotReadKeyword
6695 $$ = new Value(Value::OPTYPE_TMR_READ, $1);
6696 $$->set_location(infile, @$);
6700 RunningTimerOp: // 446
6701 TimerRef DotRunningKeyword
6703 $$ = new Value(Value::OPTYPE_UNDEF_RUNNING, $1);
6704 $$->set_location(infile, @$);
6706 | AnyKeyword TimerKeyword DotRunningKeyword
6708 $$ = new Value(Value::OPTYPE_TMR_RUNNING_ANY);
6709 $$->set_location(infile, @$);
6713 TimeoutStatement: // 447
6714 TimerRefOrAny DotTimeoutKeyword
6716 $$ = new Statement(Statement::S_TIMEOUT, $1);
6717 $$->set_location(infile, @$);
6721 TimerRefOrAny: // 448
6722 TimerRef { $$ = $1; }
6723 | AnyKeyword TimerKeyword { $$ = 0; }
6732 $$->set_location(infile, @$);
6734 | AnyTypeKeyword /* a predefined type with special treatment */
6736 anytype_access = true;
6737 Identifier *id = new Identifier(Identifier::ID_TTCN, string("anytype"));
6738 Ttcn::Reference *ref = new Ttcn::Reference(id);
6739 ref->set_location(infile, @1);
6740 $$ = new Type(Type::T_REFD, ref);
6742 | ReferencedType { $$ = $1; }
6746 PredefinedType: // 451, but see below
6747 BitStringKeyword { $$ = Type::T_BSTR; }
6748 | BooleanKeyword { $$ = Type::T_BOOL; }
6749 | CharStringKeyword { $$ = Type::T_CSTR; }
6750 | UniversalCharString { $$ = Type::T_USTR; }
6751 | CharKeyword // not in the standard anymore
6753 Location loc(infile, @$);
6754 loc.warning("Obsolete type `char' was substituted with `charstring'");
6757 | UniversalChar // not in the standard anymore
6759 Location loc(infile, @$);
6760 loc.warning("Obsolete type `universal char' was substituted with "
6761 "`universal charstring'");
6764 | IntegerKeyword { $$ = Type::T_INT; }
6765 | OctetStringKeyword { $$ = Type::T_OSTR; }
6766 | HexStringKeyword { $$ = Type::T_HSTR; }
6767 | VerdictTypeKeyword { $$ = Type::T_VERDICT; }
6768 | FloatKeyword { $$ = Type::T_REAL; }
6769 | AddressKeyword { $$ = Type::T_ADDRESS; }
6770 | DefaultKeyword { $$ = Type::T_DEFAULT; }
6771 | ObjectIdentifierKeyword { $$ = Type::T_OID; }
6773 * AnyTypeKeyword is not part of PredefinedType (this differs from the BNF
6774 * in the TTCN-3 standard).
6775 * PredefinedType is used in two contexts:
6776 * - as a RHS for Type, above (where AnyTypeKeyword needs special treatment,
6777 * and it's easier to appear as an alternative to PredefinedType)
6778 * - as field name for the anytype (where anytype is not permitted)
6782 UniversalCharString: // 463
6783 UniversalKeyword CharStringKeyword
6787 UniversalKeyword CharKeyword
6790 ReferencedType: // 465
6793 if ($1.is_ref) $$ = new Type(Type::T_REFD, $1.ref);
6795 Ttcn::Reference *ref = new Ttcn::Reference($1.id);
6796 ref->set_location(infile, @1);
6797 $$ = new Type(Type::T_REFD, ref);
6799 $$->set_location(infile, @$);
6801 | FunctionInstance optExtendedFieldReference
6802 /* covers all parameterized type references */
6804 Location loc(infile, @1);
6805 loc.error("Reference to parameterized type is not currently supported");
6807 for (size_t i = 0; i < $2.nElements; i++) delete $2.elements[i];
6809 $$ = new Type(Type::T_ERROR);
6810 $$->set_location(infile, @$);
6815 TypeReference: // 466
6817 | IDentifier TypeActualParList
6821 TypeActualParList: // -> 202 784 "Advanced Parameterization"
6822 '(' seqTypeActualPar optError ')'
6826 seqTypeActualPar: // -> 202 784 "Advanced Parameterization"
6827 optError TypeActualPar
6828 | seqTypeActualPar optError ',' optError TypeActualPar
6829 | seqTypeActualPar optError ',' error
6832 TypeActualPar: // -> 202 784 "Advanced Parameterization"
6833 Expression { delete $1; }
6836 optArrayDef: // [467]
6842 | optArrayDef ArrayIndex
6844 $$.nElements = $1.nElements + 1;
6845 $$.elements = (ArrayDimension**)
6846 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
6847 $$.elements[$1.nElements] = $2;
6854 $$ = new ArrayDimension($2);
6855 $$->set_location(infile, @$);
6857 | '[' ArrayBounds DotDot ArrayBounds ']'
6859 $$ = new ArrayDimension($2, $4);
6860 $$->set_location(infile, @$);
6864 Value *v = new Value(Value::V_ERROR);
6865 v->set_location(infile, @2);
6866 $$ = new ArrayDimension(v);
6867 $$->set_location(infile, @$);
6872 Expression { $$ = $1; }
6878 PredefinedValue { $$ = $1; }
6879 | ReferencedValue { $$ = $1; }
6882 PredefinedValue: // 470
6883 BitStringValue { $$ = $1; }
6884 | BooleanValue { $$ = $1; }
6885 | CharStringValue { $$ = $1; }
6886 | IntegerValue { $$ = $1; }
6887 | OctetStringValue { $$ = $1; }
6888 | HexStringValue { $$ = $1; }
6889 | VerdictValue { $$ = $1; }
6890 /* | EnumeratedValue -- covered by ReferencedValue */
6891 | FloatOrSpecialFloatValue
6893 $$ = new Value(Value::V_REAL, $1);
6894 $$->set_location(infile, @$);
6896 | AddressValue { $$ = $1; }
6897 | OmitValue { $$ = $1; }
6900 $$ = new Value(Value::V_NULL);
6901 $$->set_location(infile, @$);
6905 $$ = new Value(Value::V_MACRO, $1);
6906 $$->set_location(infile, @$);
6908 | ObjectIdentifierValue { $$ = $1; }
6911 $$=new Value(Value::V_ERROR);
6912 $$->set_location(infile, @$);
6916 BitStringValue: // 471
6919 $$ = new Value(Value::V_BSTR, $1);
6920 $$->set_location(infile, @$);
6924 BooleanValue: // 472
6927 $$ = new Value(Value::V_BOOL, true);
6928 $$->set_location(infile, @$);
6932 $$ = new Value(Value::V_BOOL, false);
6933 $$->set_location(infile, @$);
6937 /* TTCN-3 core language V4.2.1 */
6938 FloatOrSpecialFloatValue:
6953 IntegerValue: // 473
6956 $$ = new Value(Value::V_INT, $1);
6957 $$->set_location(infile, @$);
6961 OctetStringValue: // 474
6964 $$ = new Value(Value::V_OSTR, $1);
6965 $$->set_location(infile, @$);
6969 HexStringValue: // 475
6972 $$ = new Value(Value::V_HSTR, $1);
6973 $$->set_location(infile, @$);
6977 VerdictValue: // 476 VerdictTypeValue
6980 $$ = new Value(Value::V_VERDICT, Value::Verdict_NONE);
6981 $$->set_location(infile, @$);
6985 $$ = new Value(Value::V_VERDICT, Value::Verdict_PASS);
6986 $$->set_location(infile, @$);
6990 $$ = new Value(Value::V_VERDICT, Value::Verdict_INCONC);
6991 $$->set_location(infile, @$);
6995 $$ = new Value(Value::V_VERDICT, Value::Verdict_FAIL);
6996 $$->set_location(infile, @$);
7000 $$ = new Value(Value::V_VERDICT, Value::Verdict_ERROR);
7001 $$->set_location(infile, @$);
7005 CharStringValue: // 478
7008 if ($1->is_cstr()) $$ = new Value(Value::V_CSTR, $1);
7010 $$ = new Value(Value::V_USTR, new ustring(*$1));
7013 $$->set_location(infile, @$);
7017 $$ = new Value(Value::V_USTR, new ustring(*$1));
7019 $$->set_location(infile, @$);
7023 $$ = new Value(Value::V_USTR, new ustring($1.elements, $1.nElements));
7024 for(size_t i = 0; i < $1.nElements; ++i) {
7025 Free((char*)$1.elements[i]);
7028 $$->set_location(infile, @$);
7035 Location loc(infile, @1);
7036 $$ = parse_charstring_value($1, loc);
7042 CharKeyword '(' optError UIDlike optError ')'
7052 $$.elements = (const char**)
7053 Realloc($$.elements, ($$.nElements) * sizeof(*$$.elements));
7054 $$.elements[$$.nElements-1] = $1;
7056 | UIDlike optError ',' optError Cstring {
7057 $$.nElements = $1.nElements + 1;
7058 $$.elements = (const char**)
7059 Realloc($1.elements, ($$.nElements) * sizeof(*$$.elements));
7060 $$.elements[$$.nElements-1] = $5;
7065 CharKeyword '(' optError Group optError ',' optError Plane optError ','
7066 optError Row optError ',' optError Cell optError ')'
7067 { $$ = new ustring($4, $8, $12, $16); }
7068 | CharKeyword '(' error ')' { $$ = new ustring; }
7074 if (*$1 < 0 || *$1 > 127) {
7075 Location loc(infile, @1);
7076 loc.error("The first number of quadruple (group) must be within the "
7077 "range 0 .. 127 instead of %s", $1->t_str().c_str());
7078 $$ = *$1 < 0 ? 0 : 127;
7089 if (*$1 < 0 || *$1 > 255) {
7090 Location loc(infile, @1);
7091 loc.error("The second number of quadruple (plane) must be within the "
7092 "range 0 .. 255 instead of %s", $1->t_str().c_str());
7093 $$ = *$1 < 0 ? 0 : 255;
7104 if (*$1 < 0 || *$1 > 255) {
7105 Location loc(infile, @1);
7106 loc.error("The third number of quadruple (row) must be within the "
7107 "range 0 .. 255 instead of %s", $1->t_str().c_str());
7108 $$ = *$1 < 0 ? 0 : 255;
7119 if (*$1 < 0 || *$1 > 255) {
7120 Location loc(infile, @1);
7121 loc.error("The fourth number of quadruple (cell) must be within the "
7122 "range 0 .. 255 instead of %s", $1->t_str().c_str());
7123 $$ = *$1 < 0 ? 0 : 255;
7132 Cstring { $$ = $1; }
7135 $$ = mputstr($1, $2);
7140 AddressValue: // 510
7143 $$ = new Value(Value::V_TTCN3_NULL);
7144 $$->set_location(infile, @$);
7151 $$ = new Value(Value::V_OMIT);
7152 $$->set_location(infile, @$);
7156 ReferencedValue: // 489
7159 if ($1.is_ref) $$ = new Value(Value::V_REFD, $1.ref);
7160 else $$ = new Value(Value::V_UNDEF_LOWERID, $1.id);
7161 $$->set_location(infile, @$);
7164 Reference: // 490 ValueReference
7170 | IDentifier '.' PredefOrIdentifier optExtendedFieldReference
7173 $$.ref = new Ttcn::Reference($1);
7174 FieldOrArrayRef *fieldref = new FieldOrArrayRef($3);
7175 fieldref->set_location(infile, @3);
7176 $$.ref->add(fieldref);
7177 for (size_t i = 0; i < $4.nElements; i++) $$.ref->add($4.elements[i]);
7179 $$.ref->set_location(infile, @$);
7181 | IDentifier ArrayOrBitRef optExtendedFieldReference
7184 $$.ref = new Ttcn::Reference($1);
7186 for (size_t i = 0; i < $3.nElements; i++) $$.ref->add($3.elements[i]);
7188 $$.ref->set_location(infile, @$);
7190 | IDentifier '[' NotUsedSymbol ']'
7193 $$.ref = new Ttcn::Reference($1);
7194 Value* novalue = new Value(Value::V_NOTUSED);
7195 novalue->set_location(infile, @3);
7196 $$.ref->add(new FieldOrArrayRef(novalue));
7197 $$.ref->set_location(infile, @$);
7199 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
7200 optExtendedFieldReference
7203 $$.ref = new Ttcn::Reference($1, $5);
7205 for (size_t i = 0; i < $6.nElements; i++) $$.ref->add($6.elements[i]);
7207 $$.ref->set_location(infile, @$);
7211 /* A.1.6.5 Parameterization */
7214 /* empty */ { $$ = false; }
7215 | LazyKeyword { $$ = true; }
7218 FormalValuePar: // 516
7219 optLazyEval Type IDentifier optParDefaultValue
7221 $$ = new FormalPar(Common::Assignment::A_PAR_VAL, $2, $3, $4, $1);
7222 $$->set_location(infile, @$);
7224 | InParKeyword optLazyEval Type IDentifier optParDefaultValue
7226 $$ = new FormalPar(Common::Assignment::A_PAR_VAL_IN, $3, $4, $5, $2);
7227 $$->set_location(infile, @$);
7229 | InOutParKeyword Type IDentifier optParDefaultValue
7231 $$ = new FormalPar(Common::Assignment::A_PAR_VAL_INOUT, $2, $3, $4);
7232 $$->set_location(infile, @$);
7234 | OutParKeyword Type IDentifier optParDefaultValue
7236 $$ = new FormalPar(Common::Assignment::A_PAR_VAL_OUT, $2, $3, $4);
7237 $$->set_location(infile, @$);
7242 FormalPortPar: // 518
7243 IDentifier IDentifier
7244 | InOutParKeyword IDentifier IDentifier
7248 FormalTimerPar: // 520
7249 TimerKeyword IDentifier optParDefaultValue
7251 $$ = new FormalPar(Common::Assignment::A_PAR_TIMER, $2, $3);
7252 $$->set_location(infile, @$);
7254 | InOutParKeyword TimerKeyword IDentifier optParDefaultValue
7256 $$ = new FormalPar(Common::Assignment::A_PAR_TIMER, $3, $4);
7257 $$->set_location(infile, @$);
7261 FormalTemplatePar: // 522
7262 TemplateOptRestricted optLazyEval Type IDentifier optParDefaultValue
7264 $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_IN, $1, $3, $4, $5, $2);
7265 $$->set_location(infile, @$);
7267 | InParKeyword TemplateOptRestricted optLazyEval Type IDentifier optParDefaultValue
7269 $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_IN, $2, $4, $5, $6, $3);
7270 $$->set_location(infile, @$);
7272 | InOutParKeyword TemplateOptRestricted Type IDentifier optParDefaultValue
7274 $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_INOUT, $2, $3, $4, $5);
7275 $$->set_location(infile, @$);
7277 | OutParKeyword TemplateOptRestricted Type IDentifier optParDefaultValue
7279 $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_OUT, $2, $3, $4, $5);
7280 $$->set_location(infile, @$);
7284 /* template with optional restriction */
7285 TemplateOptRestricted:
7286 TemplateKeyword optTemplateRestriction
7296 optTemplateRestriction:
7297 /* none */ { $$ = TR_NONE; }
7298 | TemplateRestriction { $$ = $1; }
7300 TemplateRestriction:
7301 '(' OmitKeyword ')' { $$ = TR_OMIT; }
7302 | '(' ValueKeyword ')' { $$ = TR_VALUE; }
7303 | '(' PresentKeyword ')' { $$ = TR_PRESENT; }
7307 /* empty */ { $$ = NULL; }
7308 | AssignmentChar TemplateInstance { $$ = $2; }
7309 | AssignmentChar NotUsedSymbol
7311 Template *t = new Template(Template::TEMPLATE_NOTUSED);
7312 t->set_location(infile, @$);
7313 $$ = new TemplateInstance(0, 0, t);
7314 $$->set_location(infile, @$);
7318 /* A.1.6.6 With statement */
7320 optWithStatement: // [526]
7321 /* empty */ { $$ = NULL; }
7322 | WithStatement { $$ = $1; }
7325 optWithStatementAndSemiColon:
7326 /* empty */ { $$ = NULL; }
7327 | WithStatement { $$ = $1; }
7328 | ';' { $$ = NULL; }
7329 | WithStatement ';' { $$ = $1; }
7332 WithStatement: // 526
7333 WithKeyword WithAttribList { $$ = $2; }
7336 WithAttribList: // 528
7337 '{' MultiWithAttrib optError '}' { $$ = $2; }
7338 | '{' error '}' { $$ = NULL; }
7341 MultiWithAttrib: // 529
7342 optError SingleWithAttrib optSemiColon
7344 $$ = new MultiWithAttrib;
7345 $$->set_location(infile, @$);
7346 $$->add_element($2);
7348 | MultiWithAttrib optError SingleWithAttrib optSemiColon
7351 $$->add_element($3);
7355 SingleWithAttrib: // 530
7356 AttribKeyword optOverrideKeyword optAttribQualifier AttribSpec
7358 $$ = new SingleWithAttrib($1,$2,$3,$4);
7359 $$->set_location(infile, @$);
7363 AttribKeyword: // 531
7364 EncodeKeyword { $$ = SingleWithAttrib::AT_ENCODE; }
7365 | VariantKeyword { $$ = SingleWithAttrib::AT_VARIANT; }
7366 | DisplayKeyword { $$ = SingleWithAttrib::AT_DISPLAY; }
7367 | ExtensionKeyword { $$ = SingleWithAttrib::AT_EXTENSION; }
7368 | OptionalKeyword { $$ = SingleWithAttrib::AT_OPTIONAL; }
7371 /* workaround to get rid of ErroneousKeyword which would clash with
7372 * existing TTCN-3 source code */
7373 if ($1->get_ttcnname()=="erroneous") $$ = SingleWithAttrib::AT_ERRONEOUS;
7375 Location loc(infile, @1);
7376 loc.error("Invalid attribute. Valid attributes are: "
7377 "`encode', `variant' , `display' , `extension', `optional' and `erroneous'");
7378 if ($1->get_ttcnname()=="titan")
7380 " ________ _____ ________ ____ __ _ \n"
7381 "(___ ___) (_ _) (___ ___) ( ) / \\ / ) \n"
7382 " ) ) | | ) ) / /\\ \\ / /\\ \\ / / \n"
7383 " ( ( | | ( ( ( (__) ) ) ) ) ) ) ) \n"
7384 " ) ) | | ) ) ) ( ( ( ( ( ( ( \n"
7385 " ( ( _| |__ ( ( / /\\ \\ / / \\ \\/ / \n"
7386 " /__\\ /_____( /__\\ /__( )__\\ (_/ \\__/ \n");
7387 $$ = SingleWithAttrib::AT_INVALID;
7393 optOverrideKeyword: // [536]
7394 /* empty */ { $$ = false; }
7395 | OverrideKeyword { $$ = true; }
7398 optAttribQualifier: // [537]
7399 /* empty */ { $$ = NULL; }
7400 | '(' DefOrFieldRefList optError ')' { $$ = $2; }
7401 | '(' error ')' { $$ = NULL; }
7404 DefOrFieldRefList: // 538
7405 optError DefOrFieldRef
7407 $$ = new Qualifiers();
7408 if ($2) $$->add_qualifier($2);
7410 | DefOrFieldRefList optError ',' optError DefOrFieldRef
7413 if ($5) $$->add_qualifier($5);
7415 | DefOrFieldRefList optError ',' error { $$ = $1; }
7418 ArrayOrBitRefOrDash:
7419 ArrayOrBitRef { $$ = $1; }
7420 | '[' NotUsedSymbol ']'
7422 Value* novalue = new Value(Value::V_NOTUSED);
7423 novalue->set_location(infile, @2);
7424 $$ = new FieldOrArrayRef(novalue);
7425 $$->set_location(infile, @$);
7428 DefOrFieldRef: // 539
7431 $$ = new Qualifier();
7432 $$->add(new FieldOrArrayRef($1));
7433 $$->set_location(infile, @1);
7435 | IDentifier '.' IDentifier optExtendedFieldReference
7437 $$ = new Qualifier();
7438 $$->add(new FieldOrArrayRef($1));
7439 $$->add(new FieldOrArrayRef($3));
7440 for(size_t i=0; i<$4.nElements; i++) {
7441 $$->add($4.elements[i]);
7444 $$->set_location(infile, @$);
7446 | IDentifier ArrayOrBitRefOrDash optExtendedFieldReference
7448 $$ = new Qualifier();
7449 $$->add(new FieldOrArrayRef($1));
7451 for(size_t i=0; i<$3.nElements; i++) {
7452 $$->add($3.elements[i]);
7455 $$->set_location(infile, @$);
7457 | ArrayOrBitRefOrDash optExtendedFieldReference
7459 $$ = new Qualifier();
7461 for(size_t i=0; i<$2.nElements; i++) {
7462 $$->add($2.elements[i]);
7465 $$->set_location(infile, @$);
7469 Location loc(infile, @$);
7470 loc.error("Reference to multiple definitions in attribute qualifiers is "
7471 "not currently supported");
7477 GroupKeyword AllKeyword
7478 | GroupKeyword AllKeyword ExceptKeyword '{' GroupRefList optError '}'
7479 | TypeDefKeyword AllKeyword
7480 | TypeDefKeyword AllKeyword ExceptKeyword '{' TypeRefList optError '}'
7481 | TemplateKeyword AllKeyword
7482 | TemplateKeyword AllKeyword ExceptKeyword '{' TemplateRefList optError '}'
7483 | ConstKeyword AllKeyword
7484 | ConstKeyword AllKeyword ExceptKeyword '{' ConstRefList optError '}'
7485 | AltstepKeyword AllKeyword
7486 | AltstepKeyword AllKeyword ExceptKeyword '{' AltstepRefList optError '}'
7487 | TestcaseKeyword AllKeyword
7488 | TestcaseKeyword AllKeyword ExceptKeyword '{' TestcaseRefList optError '}'
7489 | FunctionKeyword AllKeyword
7490 | FunctionKeyword AllKeyword ExceptKeyword '{' FunctionRefList optError '}'
7491 | SignatureKeyword AllKeyword
7492 | SignatureKeyword AllKeyword ExceptKeyword '{' SignatureRefList optError '}'
7493 | ModuleParKeyword AllKeyword
7494 | ModuleParKeyword AllKeyword ExceptKeyword '{' ModuleParRefList optError '}'
7500 $$ = new AttributeSpec(string($1));
7501 $$->set_location(infile, @$);
7506 /* A.1.6.7 Behaviour statements */
7508 BehaviourStatements: // 543
7511 if ($1.ref_pard) $$ = new Statement(Statement::S_TESTCASE_INSTANCE,
7512 $1.ref_pard, $1.value);
7513 else if($1.derefered_value) {
7514 $$ = new Statement(Statement::S_TESTCASE_INSTANCE_REFD,
7515 $1.derefered_value, $1.ap_list->steal_tis(), $1. value);
7518 else $$ = new Statement(Statement::S_ERROR);
7519 $$->set_location(infile, @$);
7523 $$ = new Statement(Statement::S_UNKNOWN_INSTANCE, $1);
7524 $$->set_location(infile, @$);
7528 $$ = new Statement(Statement::S_UNKNOWN_INVOKED, $1.value, $1.ap_list);
7529 $$->set_location(infile, @$);
7531 | ReturnStatement { $$ = $1; }
7532 | AltConstruct { $$ = $1; }
7533 | InterleavedConstruct { $$ = $1; }
7534 | LabelStatement { $$ = $1; }
7535 | GotoStatement { $$=$1; }
7536 | RepeatStatement { $$ = $1; }
7537 | BreakStatement { $$ = $1; }
7538 | ContinueStatement { $$ = $1; }
7539 | DeactivateStatement { $$ = $1; }
7540 /* | AltstepInstance -- covered by FunctionInstance */
7543 if ($1.ref_pard) $$ = new Statement(Statement::S_ACTIVATE, $1.ref_pard);
7544 else if($1.derefered_value) $$ = new Statement(Statement::S_ACTIVATE_REFD,
7545 $1.derefered_value, new ParsedActualParameters($1.ap_list));
7546 else $$ = new Statement(Statement::S_ERROR);
7547 $$->set_location(infile, @$);
7551 VerdictStatements: // 544
7552 SetLocalVerdict { $$ = $1; }
7556 GetLocalVerdict { $$ = $1; }
7559 SetLocalVerdict: // 546
7560 SetVerdictKeyword '(' Expression optError ',' LogItemList optError ')'
7562 $$=new Statement(Statement::S_SETVERDICT, $3, $6);
7563 $$->set_location(infile, @$);
7565 | SetVerdictKeyword '(' Expression optError ')'
7567 $$=new Statement(Statement::S_SETVERDICT, $3, (LogArguments*)0);
7568 $$->set_location(infile, @$);
7570 | SetVerdictKeyword '(' error ')'
7572 Value *v = new Value(Value::V_ERROR);
7573 v->set_location(infile, @3);
7574 $$ = new Statement(Statement::S_SETVERDICT, v);
7575 $$->set_location(infile, @$);
7579 GetLocalVerdict: // 548
7582 $$=new Value(Value::OPTYPE_GETVERDICT);
7583 $$->set_location(infile, @$);
7587 SUTStatements: // 549
7588 ActionKeyword '(' ')'
7590 $$=new Statement(Statement::S_ACTION, (LogArguments*)0);
7591 $$->set_location(infile, @$);
7593 | ActionKeyword '(' LogItemList optError ')'
7595 $$=new Statement(Statement::S_ACTION, $3);
7596 $$->set_location(infile, @$);
7598 | ActionKeyword '(' error ')'
7600 $$=new Statement(Statement::S_ACTION, new LogArguments());
7601 $$->set_location(infile, @$);
7605 StopExecutionStatement:
7608 $$=new Statement(Statement::S_STOP_EXEC);
7609 $$->set_location(infile, @$);
7613 StopTestcaseStatement:
7614 TestcaseKeyword DotStopKeyword
7616 $$ = new Statement(Statement::S_STOP_TESTCASE, (LogArguments*)0);
7617 $$->set_location(infile, @$);
7619 | TestcaseKeyword DotStopKeyword '(' LogItemList optError ')'
7621 $$ = new Statement(Statement::S_STOP_TESTCASE, $4);
7622 $$->set_location(infile, @$);
7626 /* these deliberately don't have their locations set */
7628 TitanSpecificProfilerKeyword DotStartKeyword
7630 $$ = new Statement(Statement::S_START_PROFILER);
7632 | TitanSpecificProfilerKeyword DotStopKeyword
7634 $$ = new Statement(Statement::S_STOP_PROFILER);
7639 int2enumKeyword '(' optError Expression optError ',' optError Reference optError ')'
7641 Ttcn::Reference* out_ref;
7642 if ($8.is_ref) out_ref = $8.ref;
7644 out_ref = new Ttcn::Reference($8.id);
7645 out_ref->set_location(infile, @8);
7647 $$ = new Statement(Statement::S_INT2ENUM, $4, out_ref);
7648 $$->set_location(infile, @$);
7653 TitanSpecificProfilerKeyword DotRunningKeyword
7655 $$ = new Value(Value::OPTYPE_PROF_RUNNING);
7656 $$->set_location(infile, @$);
7660 ReturnStatement: // 552
7663 $$=new Statement(Statement::S_RETURN, (Template*)0);
7664 $$->set_location(infile, @$);
7666 | ReturnKeyword TemplateBody
7668 $$=new Statement(Statement::S_RETURN, $2);
7669 $$->set_location(infile, @$);
7673 AltConstruct: // 553
7674 AltKeyword '{' AltGuardList optError '}'
7676 $$=new Statement(Statement::S_ALT, $3);
7677 $$->set_location(infile, @$);
7679 | AltKeyword '{' error '}'
7681 $$=new Statement(Statement::S_ALT, new AltGuards());
7682 $$->set_location(infile, @$);
7686 AltGuardList: // 555
7692 | AltGuardList optError AltGuard
7700 GuardStatement { $$ = $1; }
7701 | ElseStatement { $$ = $1; }
7704 GuardStatement: // 556
7705 AltGuardChar AltstepInstance optSemiColon
7707 $$=new AltGuard($1, $2, 0);
7708 $$->set_location(infile, @$);
7710 | AltGuardChar ApplyOp optSemiColon
7712 $$=new AltGuard($1, $2.value, $2.ap_list->steal_tis(), 0);
7713 $$->set_location(infile, @$);
7716 | AltGuardChar AltstepInstance optSemiColon StatementBlock optSemiColon
7718 $$=new AltGuard($1, $2, $4);
7719 $$->set_location(infile, @$);
7721 | AltGuardChar ApplyOp optSemiColon StatementBlock optSemiColon
7723 $$= new AltGuard($1, $2.value, $2.ap_list->steal_tis(), $4);
7724 $$->set_location(infile, @$);
7727 | AltGuardChar GuardOp ';'
7729 $$=new AltGuard($1, $2, new StatementBlock());
7730 $$->set_location(infile, @$);
7732 | AltGuardChar GuardOp optSemiColon StatementBlock optSemiColon
7734 $$=new AltGuard($1, $2, $4);
7735 $$->set_location(infile, @$);
7739 ElseStatement: // 557
7740 '[' ElseKeyword ']' StatementBlock optSemiColon
7742 $$=new AltGuard($4);
7743 $$->set_location(infile, @$);
7747 AltGuardChar: // 558
7749 | '[' BooleanExpression ']' { $$ = $2; }
7753 TimeoutStatement { $$=$1; }
7754 | ReceiveStatement { $$=$1; }
7755 | TriggerStatement { $$=$1; }
7756 | GetCallStatement { $$=$1; }
7757 | CatchStatement { $$=$1; }
7758 | CheckStatement { $$=$1; }
7759 | GetReplyStatement { $$=$1; }
7760 | DoneStatement { $$=$1; }
7761 | KilledStatement { $$ = $1; }
7764 InterleavedConstruct: // 560
7765 InterleavedKeyword '{' InterleavedGuardList optError '}'
7767 $$ = new Statement(Statement::S_INTERLEAVE, $3);
7768 $$->set_location(infile, @$);
7770 | InterleavedKeyword '{' error '}'
7772 $$ = new Statement(Statement::S_INTERLEAVE, new AltGuards());
7773 $$->set_location(infile, @$);
7777 InterleavedGuardList: // 562
7778 optError InterleavedGuardElement
7780 $$ = new AltGuards();
7783 | InterleavedGuardList optError InterleavedGuardElement
7784 { $$ = $1; $$->add_ag($3); }
7787 InterleavedGuardElement: // 563
7788 '[' optError ']' GuardOp ';'
7790 $$ = new AltGuard(0, $4, new StatementBlock());
7791 $$->set_location(infile, @$);
7793 | '[' optError ']' GuardOp optSemiColon StatementBlock optSemiColon
7795 $$ = new AltGuard(0, $4, $6);
7796 $$->set_location(infile, @$);
7800 /* The following were folded into the above rule:
7802 InterleavedGuardElement: // 563
7803 InterleavedGuard InterleavedAction
7806 InterleavedGuard: // 564
7810 InterleavedAction: // 565
7815 LabelStatement: // 566
7816 LabelKeyword IDentifier
7818 $$=new Statement(Statement::S_LABEL, $2);
7819 $$->set_location(infile, @$);
7823 GotoStatement: // 569
7824 GotoKeyword IDentifier
7826 $$=new Statement(Statement::S_GOTO, $2);
7827 $$->set_location(infile, @$);
7829 | GotoKeyword AltKeyword
7831 Location loc(infile, @$);
7832 loc.warning("Obsolete statement `goto alt' was substituted with `repeat'");
7833 $$=new Statement(Statement::S_REPEAT);
7834 $$->set_location(infile, @$);
7838 RepeatStatement: // 571
7841 $$=new Statement(Statement::S_REPEAT);
7842 $$->set_location(infile, @$);
7847 ActivateKeyword '(' AltstepInstance optError ')'
7850 $$.derefered_value = 0;
7853 | ActivateKeyword '(' DereferOp '(' optFunctionActualParList ')' optError ')'
7855 $5->set_location(infile, @4, @6);
7857 $$.derefered_value = $3;
7858 $$.ap_list = $5->steal_tis(); /* XXX perhaps propagate the datatype instead ? */
7861 | ActivateKeyword '(' error ')'
7864 $$.derefered_value = 0;
7870 RefersKeyword '(' FunctionRef ')'
7872 Ttcn::Reference* t_ref = new Ttcn::Reference($3.modid, $3.id);
7873 t_ref->set_location(infile, @3);
7874 $$ = new Value(Value::V_REFER, t_ref);
7875 $$->set_location(infile, @$);
7879 DeactivateStatement: // 574
7882 $$=new Statement(Statement::S_DEACTIVATE, (Value*)0);
7883 $$->set_location(infile, @$);
7885 | DeactivateKeyword '(' Expression optError ')'
7887 $$=new Statement(Statement::S_DEACTIVATE, $3);
7888 $$->set_location(infile, @$);
7890 | DeactivateKeyword '(' error ')'
7892 Value *v = new Value(Value::V_ERROR);
7893 v->set_location(infile, @3);
7894 $$ = new Statement(Statement::S_DEACTIVATE, v);
7895 $$->set_location(infile, @$);
7899 BreakStatement: // 576
7902 $$=new Statement(Statement::S_BREAK);
7903 $$->set_location(infile, @$);
7907 ContinueStatement: // 577
7910 $$=new Statement(Statement::S_CONTINUE);
7911 $$->set_location(infile, @$);
7915 /* A.1.6.8 Basic statements */
7917 BasicStatements: // 578
7920 $$=new Statement(Statement::S_ASSIGNMENT, $1);
7921 $$->set_location(infile, @$);
7923 | LogStatement { $$ = $1; }
7924 | String2TtcnStatement { $$ = $1; }
7927 $$ = new Statement(Statement::S_BLOCK, $1);
7928 $$->set_location(infile, @$);
7930 | TitanSpecificTryKeyword StatementBlock
7932 $$ = new Statement(Statement::S_BLOCK, $2);
7933 $2->set_exception_handling(StatementBlock::EH_TRY);
7934 $$->set_location(infile, @$);
7936 | TitanSpecificCatchKeyword '(' IDentifier ')' StatementBlock
7938 $$ = new Statement(Statement::S_BLOCK, $5);
7939 $5->set_exception_handling(StatementBlock::EH_CATCH);
7940 /* add a newly constructed first statement which will contain the error message,
7941 same as: 'var charstring IDentifier;' */
7942 Type* str_type = new Type(Type::T_CSTR);
7943 str_type->set_location(infile, @3);
7944 Def_Var* str_def = new Def_Var($3, str_type, 0);
7945 str_def->set_location(infile, @3);
7946 Statement* str_stmt = new Statement(Statement::S_DEF, str_def);
7947 str_stmt->set_location(infile, @3);
7948 $5->add_stmt(str_stmt, true);
7949 $$->set_location(infile, @$);
7951 | LoopConstruct { $$ = $1; }
7952 | ConditionalConstruct { $$ = $1; }
7953 | SelectCaseConstruct { $$ = $1; }
7957 '(' optError Expression optError ')' { $$ = $3; }
7960 $$ = new Value(Value::V_ERROR);
7961 $$->set_location(infile, @$);
7963 | '+' Expression %prec UnarySign
7965 $$ = new Value(Value::OPTYPE_UNARYPLUS, $2);
7966 $$->set_location(infile, @$);
7968 | '-' Expression %prec UnarySign
7970 $$ = new Value(Value::OPTYPE_UNARYMINUS, $2);
7971 $$->set_location(infile, @$);
7973 | Expression '*' Expression
7975 $$ = new Value(Value::OPTYPE_MULTIPLY, $1, $3);
7976 $$->set_location(infile, @$);
7978 | Expression '/' Expression
7980 $$ = new Value(Value::OPTYPE_DIVIDE, $1, $3);
7981 $$->set_location(infile, @$);
7983 | Expression ModKeyword Expression
7985 $$ = new Value(Value::OPTYPE_MOD, $1, $3);
7986 $$->set_location(infile, @$);
7988 | Expression RemKeyword Expression
7990 $$ = new Value(Value::OPTYPE_REM, $1, $3);
7991 $$->set_location(infile, @$);
7993 | Expression '+' Expression
7995 $$ = new Value(Value::OPTYPE_ADD, $1, $3);
7996 $$->set_location(infile, @$);
7998 | Expression '-' Expression
8000 $$ = new Value(Value::OPTYPE_SUBTRACT, $1, $3);
8001 $$->set_location(infile, @$);
8003 | Expression '&' Expression
8005 $$ = new Value(Value::OPTYPE_CONCAT, $1, $3);
8006 $$->set_location(infile, @$);
8008 | Not4bKeyword Expression
8010 $$ = new Value(Value::OPTYPE_NOT4B, $2);
8011 $$->set_location(infile, @$);
8013 | Expression And4bKeyword Expression
8015 $$ = new Value(Value::OPTYPE_AND4B, $1, $3);
8016 $$->set_location(infile, @$);
8018 | Expression Xor4bKeyword Expression
8020 $$ = new Value(Value::OPTYPE_XOR4B, $1, $3);
8021 $$->set_location(infile, @$);
8023 | Expression Or4bKeyword Expression
8025 $$ = new Value(Value::OPTYPE_OR4B, $1, $3);
8026 $$->set_location(infile, @$);
8028 | Expression SL Expression
8030 $$ = new Value(Value::OPTYPE_SHL, $1, $3);
8031 $$->set_location(infile, @$);
8033 | Expression SR Expression
8035 $$ = new Value(Value::OPTYPE_SHR, $1, $3);
8036 $$->set_location(infile, @$);
8038 | Expression RL Expression
8040 $$ = new Value(Value::OPTYPE_ROTL, $1, $3);
8041 $$->set_location(infile, @$);
8043 | Expression _RR Expression
8045 $$ = new Value(Value::OPTYPE_ROTR, $1, $3);
8046 $$->set_location(infile, @$);
8048 | Expression '<' Expression
8050 $$ = new Value(Value::OPTYPE_LT, $1, $3);
8051 $$->set_location(infile, @$);
8053 | Expression '>' Expression
8055 $$ = new Value(Value::OPTYPE_GT, $1, $3);
8056 $$->set_location(infile, @$);
8058 | Expression LE Expression
8060 $$ = new Value(Value::OPTYPE_LE, $1, $3);
8061 $$->set_location(infile, @$);
8063 | Expression GE Expression
8065 $$ = new Value(Value::OPTYPE_GE, $1, $3);
8066 $$->set_location(infile, @$);
8068 | Expression EQ Expression
8070 $$ = new Value(Value::OPTYPE_EQ, $1, $3);
8071 $$->set_location(infile, @$);
8073 | Expression NE Expression
8075 $$ = new Value(Value::OPTYPE_NE, $1, $3);
8076 $$->set_location(infile, @$);
8078 | NotKeyword Expression
8080 $$ = new Value(Value::OPTYPE_NOT, $2);
8081 $$->set_location(infile, @$);
8083 | Expression AndKeyword Expression
8085 $$ = new Value(Value::OPTYPE_AND, $1, $3);
8086 $$->set_location(infile, @$);
8088 | Expression XorKeyword Expression
8090 $$ = new Value(Value::OPTYPE_XOR, $1, $3);
8091 $$->set_location(infile, @$);
8093 | Expression OrKeyword Expression
8095 $$ = new Value(Value::OPTYPE_OR, $1, $3);
8096 $$->set_location(infile, @$);
8098 | OpCall { $$ = $1; }
8099 | Value { $$ = $1; }
8100 | CompoundExpression { $$ = $1; }
8103 CompoundExpression: // 565
8104 FieldExpressionList { $$ = $1; }
8105 | ArrayExpressionList { $$ = $1; }
8106 | ArrayExpression { $$ = $1; }
8109 FieldExpressionList: // 581
8110 '{' seqFieldExpressionSpec optError '}'
8112 $$ = new Value(Value::V_SEQ, $2);
8113 $$->set_location(infile, @$);
8117 seqFieldExpressionSpec:
8120 $$ = new NamedValues();
8123 | error FieldExpressionSpec
8125 $$ = new NamedValues();
8128 | seqFieldExpressionSpec optError ',' optError FieldExpressionSpec
8133 | seqFieldExpressionSpec optError ',' error { $$ = $1; }
8136 FieldExpressionSpec: // 582
8137 FieldReference AssignmentChar NotUsedOrExpression
8139 $$ = new NamedValue($1, $3);
8140 $$->set_location(infile, @$);
8144 ArrayExpressionList:
8145 '{' seqArrayExpressionSpec optError '}'
8147 $$ = new Value(Value::V_SEQOF, $2);
8148 $$->set_location(infile, @$);
8152 seqArrayExpressionSpec:
8153 optError ArrayExpressionSpec
8155 // The only place for indexed-list notation.
8156 $$ = new Values(true);
8159 | seqArrayExpressionSpec optError ',' optError ArrayExpressionSpec
8164 | seqArrayExpressionSpec optError ',' error { $$ = $1; }
8167 ArrayExpressionSpec:
8168 ArrayOrBitRef AssignmentChar Expression
8170 $$ = new IndexedValue($1, $3);
8171 $$->set_location(infile, @$);
8175 ArrayExpression: // 583
8178 $$ = new Value(Value::V_SEQOF, new Values);
8179 $$->set_location(infile, @$);
8181 | '{' ArrayElementExpressionList optError '}'
8183 $$ = new Value(Value::V_SEQOF, $2);
8184 $$->set_location(infile, @$);
8188 $$ = new Value(Value::V_ERROR);
8189 $$->set_location(infile, @$);
8193 ArrayElementExpressionList: // 584
8199 | error NotUsedOrExpression
8204 | ArrayElementExpressionList optError ',' optError NotUsedOrExpression
8209 | ArrayElementExpressionList optError ',' error { $$ = $1; }
8212 NotUsedOrExpression: // 585
8213 Expression { $$ = $1; }
8216 $$ = new Value(Value::V_NOTUSED);
8217 $$->set_location(infile, @$);
8221 BooleanExpression: // 588
8222 Expression { $$ = $1; }
8225 $$ = new Value(Value::V_ERROR);
8226 $$->set_location(infile, @$);
8231 VariableRef AssignmentChar TemplateBody
8233 $$ = new Ttcn::Assignment($1, $3);
8234 $$->set_location(infile, @$);
8238 /* This can not be a single CompoundExpression (as opposed to Expression) */
8239 SingleExpression: // 595
8240 '(' SingleExpression ')' { $$ = $2; }
8241 | '(' error SingleExpression ')' { $$ = $3; }
8244 $$ = new Value(Value::V_ERROR);
8245 $$->set_location(infile, @$);
8247 | '+' Expression %prec UnarySign
8249 $$ = new Value(Value::OPTYPE_UNARYPLUS, $2);
8250 $$->set_location(infile, @$);
8252 | '-' Expression %prec UnarySign
8254 $$ = new Value(Value::OPTYPE_UNARYMINUS, $2);
8255 $$->set_location(infile, @$);
8257 | SingleExpression '*' Expression
8259 $$ = new Value(Value::OPTYPE_MULTIPLY, $1, $3);
8260 $$->set_location(infile, @$);
8262 | SingleExpression '/' Expression
8264 $$ = new Value(Value::OPTYPE_DIVIDE, $1, $3);
8265 $$->set_location(infile, @$);
8267 | SingleExpression ModKeyword Expression
8269 $$ = new Value(Value::OPTYPE_MOD, $1, $3);
8270 $$->set_location(infile, @$);
8272 | SingleExpression RemKeyword Expression
8274 $$ = new Value(Value::OPTYPE_REM, $1, $3);
8275 $$->set_location(infile, @$);
8277 | SingleExpression '+' Expression
8279 $$ = new Value(Value::OPTYPE_ADD, $1, $3);
8280 $$->set_location(infile, @$);
8282 | SingleExpression '-' Expression
8284 $$ = new Value(Value::OPTYPE_SUBTRACT, $1, $3);
8285 $$->set_location(infile, @$);
8287 | SingleExpression '&' Expression
8289 $$ = new Value(Value::OPTYPE_CONCAT, $1, $3);
8290 $$->set_location(infile, @$);
8292 | Not4bKeyword Expression
8294 $$ = new Value(Value::OPTYPE_NOT4B, $2);
8295 $$->set_location(infile, @$);
8297 | SingleExpression And4bKeyword Expression
8299 $$ = new Value(Value::OPTYPE_AND4B, $1, $3);
8300 $$->set_location(infile, @$);
8302 | SingleExpression Xor4bKeyword Expression
8304 $$ = new Value(Value::OPTYPE_XOR4B, $1, $3);
8305 $$->set_location(infile, @$);
8307 | SingleExpression Or4bKeyword Expression
8309 $$ = new Value(Value::OPTYPE_OR4B, $1, $3);
8310 $$->set_location(infile, @$);
8312 | SingleExpression SL Expression
8314 $$ = new Value(Value::OPTYPE_SHL, $1, $3);
8315 $$->set_location(infile, @$);
8317 | SingleExpression SR Expression
8319 $$ = new Value(Value::OPTYPE_SHR, $1, $3);
8320 $$->set_location(infile, @$);
8322 | SingleExpression RL Expression
8324 $$ = new Value(Value::OPTYPE_ROTL, $1, $3);
8325 $$->set_location(infile, @$);
8327 | SingleExpression _RR Expression
8329 $$ = new Value(Value::OPTYPE_ROTR, $1, $3);
8330 $$->set_location(infile, @$);
8332 | SingleExpression '<' Expression
8334 $$ = new Value(Value::OPTYPE_LT, $1, $3);
8335 $$->set_location(infile, @$);
8337 | SingleExpression '>' Expression
8339 $$ = new Value(Value::OPTYPE_GT, $1, $3);
8340 $$->set_location(infile, @$);
8342 | SingleExpression LE Expression
8344 $$ = new Value(Value::OPTYPE_LE, $1, $3);
8345 $$->set_location(infile, @$);
8347 | SingleExpression GE Expression
8349 $$ = new Value(Value::OPTYPE_GE, $1, $3);
8350 $$->set_location(infile, @$);
8352 | SingleExpression EQ Expression
8354 $$ = new Value(Value::OPTYPE_EQ, $1, $3);
8355 $$->set_location(infile, @$);
8357 | SingleExpression NE Expression
8359 $$ = new Value(Value::OPTYPE_NE, $1, $3);
8360 $$->set_location(infile, @$);
8362 | NotKeyword Expression
8364 $$ = new Value(Value::OPTYPE_NOT, $2);
8365 $$->set_location(infile, @$);
8367 | SingleExpression AndKeyword Expression
8369 $$ = new Value(Value::OPTYPE_AND, $1, $3);
8370 $$->set_location(infile, @$);
8372 | SingleExpression XorKeyword Expression
8374 $$ = new Value(Value::OPTYPE_XOR, $1, $3);
8375 $$->set_location(infile, @$);
8377 | SingleExpression OrKeyword Expression
8379 $$ = new Value(Value::OPTYPE_OR, $1, $3);
8380 $$->set_location(infile, @$);
8382 | OpCall { $$ = $1; }
8383 | Value { $$ = $1; }
8386 optExtendedFieldReference:
8387 // perhaps this should be called seqExtendedFieldReference,
8388 // but the convention appears to be that seq... can not be empty
8394 | optExtendedFieldReference FieldOrArrayReference
8396 $$.nElements = $1.nElements + 1;
8397 $$.elements = (FieldOrArrayRef**)
8398 Realloc($1.elements, ($$.nElements) * sizeof(*$$.elements));
8399 $$.elements[$1.nElements] = $2;
8403 FieldOrArrayReference:
8406 $$ = new FieldOrArrayRef($2);
8407 $$->set_location(infile, @$);
8409 | ArrayOrBitRefOrDash { $$ = $1; }
8413 PredefOrIdentifier { $$ = $1; }
8414 | IDentifier /* maybe PredefOrIdentifier here too */ TypeActualParList
8416 Location loc(infile, @$);
8417 loc.error("Reference to a parameterized field of type `anytype' is "
8418 "not currently supported");
8424 ConfigurationOps { $$ = $1; }
8425 | VerdictOps { $$ = $1; }
8426 | TimerOps { $$ = $1; }
8429 if ($1.ref_pard) $$ = new Value(Value::OPTYPE_EXECUTE, $1.ref_pard,
8431 else if($1.derefered_value)
8432 $$ = new Value(Value::OPTYPE_EXECUTE_REFD, $1.derefered_value, $1.ap_list,
8434 else $$ = new Value(Value::V_ERROR);
8435 $$->set_location(infile, @$);
8437 | FunctionInstance optExtendedFieldReference
8439 for (size_t i = 0; i < $2.nElements; i++) $1->add($2.elements[i]);
8441 $$ = new Value(Value::V_REFD, $1);
8442 $$->set_location(infile, @$);
8446 $$ = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
8447 $$->set_location(infile, @$);
8449 | TemplateOps { $$ = $1; }
8450 | PredefinedOps { $$ = $1; }
8451 | ReferOp { $$ = $1; }
8454 if ($1.ref_pard) $$ = new Value(Value::OPTYPE_ACTIVATE, $1.ref_pard);
8455 else if($1.derefered_value) $$ = new Value(Value::OPTYPE_ACTIVATE_REFD,
8456 $1.derefered_value, new ParsedActualParameters($1.ap_list));
8457 else $$ = new Value(Value::V_ERROR);
8458 $$->set_location(infile, @$);
8460 | ProfilerRunningOp { $$ = $1; }
8461 | PortOrAny DotCheckStateKeyword '(' SingleExpression ')'
8463 $$ = new Value(Value::OPTYPE_CHECKSTATE_ANY, $1, $4);
8464 $$->set_location(infile, @$);
8466 // PortOrAll would cause a conflict
8467 | AllKeyword PortKeyword DotCheckStateKeyword '(' SingleExpression ')'
8469 Ttcn::Reference *r = NULL;
8470 $$ = new Value(Value::OPTYPE_CHECKSTATE_ALL, r, $5);
8471 $$->set_location(infile, @$);
8476 PredefinedOpKeyword1 '(' optError Expression optError ')'
8478 $$ = new Value($1, $4);
8479 $$->set_location(infile, @$);
8481 | PredefinedOpKeyword1 '(' error ')'
8483 Value *v1 = new Value(Value::V_ERROR);
8484 v1->set_location(infile, @3);
8485 $$ = new Value($1, v1);
8486 $$->set_location(infile, @$);
8488 | PredefinedOpKeyword2 '(' optError Expression optError ',' optError
8489 Expression optError ')'
8491 $$ = new Value($1, $4, $8);
8492 $$->set_location(infile, @$);
8494 | PredefinedOpKeyword2 '(' error ')'
8496 Value *v1 = new Value(Value::V_ERROR);
8497 v1->set_location(infile, @3);
8498 Value *v2 = new Value(Value::V_ERROR);
8499 v2->set_location(infile, @3);
8500 $$ = new Value($1, v1, v2);
8501 $$->set_location(infile, @$);
8503 | PredefinedOpKeyword3 '(' optError Expression optError ',' optError
8504 Expression optError ')'
8506 $$ = new Value($1, $4, $8);
8507 $$->set_location(infile, @$);
8509 | PredefinedOpKeyword3 '(' optError Expression optError ')'
8511 $$ = new Value($1, $4, (Common::Value*)NULL);
8512 $$->set_location(infile, @$);
8514 | PredefinedOpKeyword3 '(' error ')'
8516 Value *v1 = new Value(Value::V_ERROR);
8517 v1->set_location(infile, @3);
8518 Value *v2 = new Value(Value::V_ERROR);
8519 v2->set_location(infile, @3);
8520 $$ = new Value($1, v1, v2);
8521 $$->set_location(infile, @$);
8523 | decompKeyword '(' optError Expression optError ',' optError
8524 Expression optError ',' optError Expression optError ')'
8526 $$ = new Value(Value::OPTYPE_DECOMP, $4, $8, $12);
8527 $$->set_location(infile, @$);
8529 | decompKeyword '(' error ')'
8531 Value *v1 = new Value(Value::V_ERROR);
8532 v1->set_location(infile, @3);
8533 Value *v2 = new Value(Value::V_ERROR);
8534 v2->set_location(infile, @3);
8535 Value *v3 = new Value(Value::V_ERROR);
8536 v3->set_location(infile, @3);
8537 $$ = new Value(Value::OPTYPE_DECOMP, v1, v2, v3);
8538 $$->set_location(infile, @$);
8540 | regexpKeyword '(' optError TemplateInstance optError ',' optError
8541 TemplateInstance optError ',' optError Expression optError ')'
8543 $$ = new Value(Value::OPTYPE_REGEXP, $4, $8, $12);
8544 $$->set_location(infile, @$);
8546 | regexpKeyword NocaseKeyword '(' optError TemplateInstance optError ',' optError
8547 TemplateInstance optError ',' optError Expression optError ')'
8549 $$ = new Value(Value::OPTYPE_REGEXP, $5, $9, $13);
8550 $$->set_location(infile, @$);
8552 | regexpKeyword '(' error ')'
8554 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8555 t1->set_location(infile, @3);
8556 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8557 ti1->set_location(infile, @3);
8558 Template *t2 = new Template(Template::TEMPLATE_ERROR);
8559 t2->set_location(infile, @3);
8560 TemplateInstance *ti2 = new TemplateInstance(0, 0, t2);
8561 ti2->set_location(infile, @3);
8562 Value *v3 = new Value(Value::V_ERROR);
8563 v3->set_location(infile, @3);
8564 $$ = new Value(Value::OPTYPE_REGEXP, ti1, ti2, v3);
8565 $$->set_location(infile, @$);
8567 | regexpKeyword NocaseKeyword '(' error ')'
8569 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8570 t1->set_location(infile, @4);
8571 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8572 ti1->set_location(infile, @4);
8573 Template *t2 = new Template(Template::TEMPLATE_ERROR);
8574 t2->set_location(infile, @4);
8575 TemplateInstance *ti2 = new TemplateInstance(0, 0, t2);
8576 ti2->set_location(infile, @4);
8577 Value *v3 = new Value(Value::V_ERROR);
8578 v3->set_location(infile, @4);
8579 $$ = new Value(Value::OPTYPE_REGEXP, ti1, ti2, v3);
8580 $$->set_location(infile, @$);
8582 | encvalueKeyword '(' optError TemplateInstance optError ')'
8584 $$ = new Value(Value::OPTYPE_ENCODE, $4);
8585 $$->set_location(infile, @$);
8587 | encvalueKeyword '(' error ')'
8589 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8590 t1->set_location(infile, @3);
8591 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8592 ti1->set_location(infile, @3);
8593 $$ = new Value(Value::OPTYPE_ENCODE, ti1);
8594 $$->set_location(infile, @$);
8596 | substrKeyword '(' optError TemplateInstance optError ',' optError
8597 Expression optError ',' optError Expression optError ')'
8599 $$ = new Value(Value::OPTYPE_SUBSTR, $4, $8, $12);
8600 $$->set_location(infile, @$);
8602 | substrKeyword '(' error ')'
8604 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8605 t1->set_location(infile, @3);
8606 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8607 ti1->set_location(infile, @3);
8608 Value *v2 = new Value(Value::V_ERROR);
8609 v2->set_location(infile, @3);
8610 Value *v3 = new Value(Value::V_ERROR);
8611 v3->set_location(infile, @3);
8612 $$ = new Value(Value::OPTYPE_SUBSTR, ti1, v2, v3);
8613 $$->set_location(infile, @$);
8615 | replaceKeyword '(' optError TemplateInstance optError ',' optError
8616 Expression optError ',' optError Expression optError ',' optError
8617 TemplateInstance optError ')'
8619 $$ = new Value(Value::OPTYPE_REPLACE, $4, $8, $12, $16);
8620 $$->set_location(infile, @$);
8622 | replaceKeyword '(' error ')'
8624 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8625 t1->set_location(infile, @3);
8626 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8627 ti1->set_location(infile, @3);
8628 Value *v2 = new Value(Value::V_ERROR);
8629 v2->set_location(infile, @3);
8630 Value *v3 = new Value(Value::V_ERROR);
8631 v3->set_location(infile, @3);
8632 Template *t4 = new Template(Template::TEMPLATE_ERROR);
8633 t4->set_location(infile, @3);
8634 TemplateInstance *ti4 = new TemplateInstance(0, 0, t4);
8635 ti4->set_location(infile, @3);
8636 $$ = new Value(Value::OPTYPE_REPLACE, ti1, v2, v3, ti4);
8637 $$->set_location(infile, @$);
8639 | decvalueKeyword '(' optError DecValueArg optError ',' optError DecValueArg optError ')'
8641 $$ = new Value(Value::OPTYPE_DECODE, $4, $8);
8642 $$->set_location(infile, @$);
8644 | decvalueKeyword '(' error ')'
8646 /*Value *v1 = new Value(Value::V_ERROR);
8647 v1->set_location(infile, @3);
8648 TemplateInstance *t2 = new TemplateInstance(Type::T_ERROR);*/
8649 $$ = new Value(Value::V_ERROR);
8650 $$->set_location(infile, @$);
8652 | isvalueKeyword '(' optError TemplateInstance optError ')'
8654 $$ = new Value(Value::OPTYPE_ISVALUE, $4);
8655 $$->set_location(infile, @$);
8657 | isvalueKeyword '(' error ')'
8659 $$ = new Value(Value::V_ERROR);
8660 $$->set_location(infile, @$);
8662 | isboundKeyword '(' optError TemplateInstance optError ')'
8664 $$ = new Value(Value::OPTYPE_ISBOUND, $4);
8665 $$->set_location(infile, @$);
8667 | isboundKeyword '(' error ')'
8669 $$ = new Value(Value::V_ERROR);
8670 $$->set_location(infile, @$);
8672 | ischosenKeyword '(' optError IschosenArg optError ')'
8674 $$ = new Value(Value::OPTYPE_ISCHOSEN, $4.ref, $4.id);
8675 $$->set_location(infile, @$);
8677 | ischosenKeyword '(' error ')'
8679 $$ = new Value(Value::V_ERROR);
8680 $$->set_location(infile, @$);
8682 | ispresentKeyword '(' optError TemplateInstance optError ')'
8684 $$ = new Value(Value::OPTYPE_ISPRESENT, $4);
8685 $$->set_location(infile, @$);
8687 | ispresentKeyword '(' error ')'
8689 $$ = new Value(Value::V_ERROR);
8690 $$->set_location(infile, @$);
8692 | lengthofKeyword '(' optError TemplateInstance optError ')'
8694 $$ = new Value(Value::OPTYPE_LENGTHOF, $4);
8695 $$->set_location(infile, @$);
8697 | lengthofKeyword '(' error ')'
8699 $$ = new Value(Value::V_ERROR);
8700 $$->set_location(infile, @$);
8702 | rndKeyword '(' ')'
8704 $$ = new Value(Value::OPTYPE_RND);
8705 $$->set_location(infile, @$);
8707 | rndKeyword '(' optError Expression optError ')'
8709 $$ = new Value(Value::OPTYPE_RNDWITHVAL, $4);
8710 $$->set_location(infile, @$);
8712 | rndKeyword '(' error ')'
8714 Value *v = new Value(Value::V_ERROR);
8715 v->set_location(infile, @3);
8716 $$ = new Value(Value::OPTYPE_RNDWITHVAL, v);
8717 $$->set_location(infile, @$);
8719 | sizeofKeyword '(' optError TemplateInstance optError ')'
8721 $$ = new Value(Value::OPTYPE_SIZEOF, $4);
8722 $$->set_location(infile, @$);
8724 | sizeofKeyword '(' error ')'
8726 $$ = new Value(Value::V_ERROR);
8727 $$->set_location(infile, @$);
8729 | log2strKeyword '(' ')'
8731 $$ = new Value(Value::OPTYPE_LOG2STR, new LogArguments());
8732 $$->set_location(infile, @$);
8734 | log2strKeyword '(' LogItemList optError ')'
8736 $$ = new Value(Value::OPTYPE_LOG2STR, $3);
8737 $$->set_location(infile, @$);
8739 | log2strKeyword '(' error ')'
8741 $$ = new Value(Value::OPTYPE_LOG2STR, new LogArguments());
8742 $$->set_location(infile, @$);
8744 | any2unistrKeyWord '(' LogItemList optError ')'
8746 if ($3->get_nof_logargs() != 1) {
8747 Location loc(infile, @1);
8748 loc.error("The any2unistr function takes exactly one argument, not %lu.",
8749 $3->get_nof_logargs());
8751 $$ = new Value(Value::OPTYPE_ANY2UNISTR, new LogArguments());
8752 $$->set_location(infile, @$);
8754 $$ = new Value(Value::OPTYPE_ANY2UNISTR, $3);
8755 $$->set_location(infile, @$);
8758 | testcasenameKeyword '(' ')'
8760 $$ = new Value(Value::OPTYPE_TESTCASENAME);
8761 $$->set_location(infile, @$);
8763 | ttcn2stringKeyword '(' optError TemplateInstance optError ')'
8765 $$ = new Value(Value::OPTYPE_TTCN2STRING, $4);
8766 $$->set_location(infile, @$);
8768 | ttcn2stringKeyword '(' error ')'
8770 $$ = new Value(Value::V_ERROR);
8771 $$->set_location(infile, @$);
8773 | encvalue_unicharKeyWord '(' optError TemplateInstance optError ',' optError
8774 Expression optError ')'
8776 $$ = new Value(Value::OPTYPE_ENCVALUE_UNICHAR, $4, $8);
8777 $$->set_location(infile, @$);
8779 | encvalue_unicharKeyWord '(' optError TemplateInstance optError ')'
8781 $$ = new Value(Value::OPTYPE_ENCVALUE_UNICHAR, $4);
8782 $$->set_location(infile, @$);
8784 | encvalue_unicharKeyWord '(' error ')'
8786 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8787 t1->set_location(infile, @3);
8788 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8789 ti1->set_location(infile, @3);
8790 $$ = new Value(Value::OPTYPE_ENCVALUE_UNICHAR, ti1);
8791 $$->set_location(infile, @$);
8793 | decvalue_unicharKeyWord '(' optError DecValueArg optError ',' optError
8794 DecValueArg optError ')'
8796 $$ = new Value(Value::OPTYPE_DECVALUE_UNICHAR, $4, $8);
8797 $$->set_location(infile, @$);
8799 | decvalue_unicharKeyWord '(' optError DecValueArg optError ',' optError
8800 DecValueArg optError ',' optError Expression optError ')'
8802 $$ = new Value(Value::OPTYPE_DECVALUE_UNICHAR, $4, $8, $12);
8803 $$->set_location(infile, @$);
8805 | decvalue_unicharKeyWord '(' error ')'
8807 $$ = new Value(Value::V_ERROR);
8808 $$->set_location(infile, @$);
8815 if ($1.is_ref) $$ = $1.ref;
8817 $$ = new Ttcn::Reference($1.id);
8818 $$->set_location(infile, @$);
8821 | FunctionInstance { $$ = $1; }
8825 IDentifier { $$ = $1; }
8826 | PredefinedType /* shall not be "anytype" */
8828 // Construct an identifier "on the fly" ($1 here is just a typetype_t)
8829 const char* builtin_typename = Type::get_typename_builtin($1);
8830 if (0 == builtin_typename) FATAL_ERROR("Unexpected type %d", $1);
8831 const string& at_field = anytype_field(string(builtin_typename));
8833 $$ = new Identifier(Identifier::ID_TTCN, at_field);
8837 $$ = new Identifier(Identifier::ID_NAME, string("NULL"));
8840 IschosenArg: /* see also Reference... */
8841 IDentifier '.' PredefOrIdentifier
8843 $$.ref = new Ttcn::Reference($1);
8844 $$.ref->set_location(infile, @1);
8847 | IDentifier '.' PredefOrIdentifier optExtendedFieldReference '.' PredefOrIdentifier
8849 $$.ref = new Ttcn::Reference($1);
8850 FieldOrArrayRef *fieldref = new FieldOrArrayRef($3);
8851 fieldref->set_location(infile, @3);
8852 $$.ref->add(fieldref);
8853 for(size_t i=0; i<$4.nElements; i++) $$.ref->add($4.elements[i]);
8855 $$.ref->set_location(infile, @1, @4);
8858 | IDentifier ArrayOrBitRef optExtendedFieldReference '.' PredefOrIdentifier
8860 $$.ref = new Ttcn::Reference($1);
8862 for(size_t i=0; i<$3.nElements; i++) $$.ref->add($3.elements[i]);
8864 $$.ref->set_location(infile, @1, @3);
8867 | IDentifier '.' ObjectIdentifierValue '.' IDentifier optExtendedFieldReference
8868 '.' PredefOrIdentifier
8870 $$.ref = new Ttcn::Reference($1, $5);
8872 for(size_t i=0; i<$6.nElements; i++) $$.ref->add($6.elements[i]);
8874 $$.ref->set_location(infile, @1, @6);
8879 PredefinedOpKeyword1:
8880 bit2hexKeyword { $$ = Value::OPTYPE_BIT2HEX; }
8881 | bit2intKeyword { $$ = Value::OPTYPE_BIT2INT; }
8882 | bit2octKeyword { $$ = Value::OPTYPE_BIT2OCT; }
8883 | bit2strKeyword { $$ = Value::OPTYPE_BIT2STR; }
8884 | char2intKeyword { $$ = Value::OPTYPE_CHAR2INT; }
8885 | char2octKeyword { $$ = Value::OPTYPE_CHAR2OCT; }
8886 | float2intKeyword { $$ = Value::OPTYPE_FLOAT2INT; }
8887 | float2strKeyword { $$ = Value::OPTYPE_FLOAT2STR; }
8888 | hex2bitKeyword { $$ = Value::OPTYPE_HEX2BIT; }
8889 | hex2intKeyword { $$ = Value::OPTYPE_HEX2INT; }
8890 | hex2octKeyword { $$ = Value::OPTYPE_HEX2OCT; }
8891 | hex2strKeyword { $$ = Value::OPTYPE_HEX2STR; }
8892 | int2charKeyword { $$ = Value::OPTYPE_INT2CHAR; }
8893 | int2floatKeyword { $$ = Value::OPTYPE_INT2FLOAT; }
8894 | int2strKeyword { $$ = Value::OPTYPE_INT2STR; }
8895 | int2unicharKeyword { $$ = Value::OPTYPE_INT2UNICHAR; }
8896 | oct2bitKeyword { $$ = Value::OPTYPE_OCT2BIT; }
8897 | oct2charKeyword { $$ = Value::OPTYPE_OCT2CHAR; }
8898 | oct2hexKeyword { $$ = Value::OPTYPE_OCT2HEX; }
8899 | oct2intKeyword { $$ = Value::OPTYPE_OCT2INT; }
8900 | oct2strKeyword { $$ = Value::OPTYPE_OCT2STR; }
8901 | str2bitKeyword { $$ = Value::OPTYPE_STR2BIT; }
8902 | str2floatKeyword { $$ = Value::OPTYPE_STR2FLOAT; }
8903 | str2hexKeyword { $$ = Value::OPTYPE_STR2HEX; }
8904 | str2intKeyword { $$ = Value::OPTYPE_STR2INT; }
8905 | str2octKeyword { $$ = Value::OPTYPE_STR2OCT; }
8906 | unichar2intKeyword { $$ = Value::OPTYPE_UNICHAR2INT; }
8907 | unichar2charKeyword { $$ = Value::OPTYPE_UNICHAR2CHAR; }
8908 | enum2intKeyword { $$ = Value::OPTYPE_ENUM2INT; }
8909 | remove_bomKeyWord { $$ = Value::OPTYPE_REMOVE_BOM; }
8910 | get_stringencodingKeyWord { $$ = Value::OPTYPE_GET_STRINGENCODING; }
8911 | decode_base64KeyWord { $$ = Value::OPTYPE_DECODE_BASE64; }
8914 PredefinedOpKeyword2:
8915 int2bitKeyword { $$ = Value::OPTYPE_INT2BIT; }
8916 | int2hexKeyword { $$ = Value::OPTYPE_INT2HEX; }
8917 | int2octKeyword { $$ = Value::OPTYPE_INT2OCT; }
8920 PredefinedOpKeyword3:
8921 unichar2octKeyword { $$ = Value::OPTYPE_UNICHAR2OCT; }
8922 | oct2unicharKeyword { $$ = Value::OPTYPE_OCT2UNICHAR; }
8923 | encode_base64KeyWord { $$ = Value::OPTYPE_ENCODE_BASE64; }
8926 String2TtcnStatement:
8927 string2ttcnKeyword '(' optError Expression optError ',' optError Reference optError ')'
8929 Ttcn::Reference* out_ref;
8930 if ($8.is_ref) out_ref = $8.ref;
8932 out_ref = new Ttcn::Reference($8.id);
8933 out_ref->set_location(infile, @8);
8935 $$ = new Statement(Statement::S_STRING2TTCN, $4, out_ref);
8936 $$->set_location(infile, @$);
8940 LogStatement: // 619
8943 $$=new Statement(Statement::S_LOG, (LogArguments*)0);
8944 $$->set_location(infile, @$);
8946 | LogKeyword '(' LogItemList optError ')'
8948 $$=new Statement(Statement::S_LOG, $3);
8949 $$->set_location(infile, @$);
8951 | LogKeyword '(' error ')'
8953 $$=new Statement(Statement::S_LOG, new LogArguments());
8954 $$->set_location(infile, @$);
8961 $$ = new LogArguments();
8964 | LogItemList optError ',' optError LogItem
8969 | LogItemList optError ',' error { $$ = $1; }
8975 $$ = new LogArgument($1);
8976 $$->set_location(infile, @$);
8980 LoopConstruct: // 622
8981 ForStatement { $$ = $1; }
8982 | WhileStatement { $$ = $1; }
8983 | DoWhileStatement { $$ = $1; }
8986 ForStatement: // 623
8987 ForKeyword '(' Initial ';' Final ';' Step optError ')'
8990 $$ = new Statement(Statement::S_FOR, $3.defs, $3.ass, $5, $7, $10);
8991 $$->set_location(infile, @$);
8998 $$.defs = new Definitions;
8999 for (size_t i = 0; i < $1.nElements; i++) $$.defs->add_ass($1.elements[i]);
9010 $$.defs = new Definitions;
9016 BooleanExpression { $$ = $1; }
9020 Assignment { $$ = $1; }
9021 /** \todo for-ban nem lehet null a step
9022 | error { $$=NULL; }
9026 WhileStatement: // 628
9027 WhileKeyword '(' BooleanExpression ')' StatementBlock
9029 $$=new Statement(Statement::S_WHILE, $3, $5);
9030 $$->set_location(infile, @$);
9034 DoWhileStatement: // 630
9035 DoKeyword StatementBlock
9036 WhileKeyword '(' BooleanExpression ')'
9038 $$=new Statement(Statement::S_DOWHILE, $5, $2);
9039 $$->set_location(infile, @$);
9043 ConditionalConstruct: // 632
9044 IfKeyword '(' BooleanExpression ')'
9046 seqElseIfClause optElseClause
9048 IfClause *ic=new IfClause($3, $5);
9049 ic->set_location(infile, @1, @5);
9050 $6->add_front_ic(ic);
9051 $$=new Statement(Statement::S_IF, $6, $7,
9052 $7 ? new Location(infile, @7) : 0);
9053 $$->set_location(infile, @$);
9058 /* empty */ { $$=new IfClauses(); }
9059 | seqElseIfClause ElseIfClause
9066 ElseIfClause: // 634
9067 ElseKeyword IfKeyword '(' BooleanExpression ')' StatementBlock
9069 $$=new IfClause($4, $6);
9070 $$->set_location(infile, @$);
9074 optElseClause: // [636]
9075 /* empty */ { $$=0; }
9076 | ElseKeyword StatementBlock { $$=$2; }
9079 SelectCaseConstruct: // 637
9080 SelectKeyword '(' Expression optError ')' SelectCaseBody
9082 $$=new Statement(Statement::S_SELECT, $3, $6);
9083 $$->set_location(infile, @$);
9085 | SelectKeyword '(' error ')' SelectCaseBody
9087 Value *v = new Value(Value::V_ERROR);
9088 v->set_location(infile, @3);
9089 $$=new Statement(Statement::S_SELECT, v, $5);
9090 $$->set_location(infile, @$);
9094 SelectCaseBody: // 639
9095 '{' seqSelectCase optError '}' {$$=$2;}
9096 | '{' error '}' {$$=new SelectCases;}
9105 | seqSelectCase optError SelectCase
9113 CaseKeyword '(' seqTemplateInstance optError ')' StatementBlock optSemiColon
9115 $3->set_location(infile, @2, @5);
9116 $$=new SelectCase($3, $6);
9117 $$->set_location(infile, @$);
9119 | CaseKeyword '(' error ')' StatementBlock optSemiColon
9121 TemplateInstances *tis = new TemplateInstances;
9122 tis->set_location(infile, @2, @4);
9123 $$ = new SelectCase(tis, $5);
9124 $$->set_location(infile, @$);
9126 | CaseKeyword ElseKeyword StatementBlock optSemiColon
9128 $$=new SelectCase(0, $3);
9129 $$->set_location(infile, @$);
9133 seqTemplateInstance:
9134 optError TemplateInstance
9136 $$ = new TemplateInstances;
9139 | seqTemplateInstance optError ',' optError TemplateInstance
9144 | seqTemplateInstance optError ',' error { $$ = $1; }
9147 /* A.1.6.9 Miscellaneous productions */
9149 optSemiColon: // [645]
9154 /* A.1 ASN.1 support, from ES 201 873-7 V3.1.1 (2005-06) */
9156 optDefinitiveIdentifier:
9158 | DefinitiveIdentifier
9161 DefinitiveIdentifier:
9162 '.' ObjectIdentifierKeyword '{' DefinitiveObjIdComponentList optError '}'
9163 | '.' ObjectIdentifierKeyword '{' error '}'
9166 DefinitiveObjIdComponentList:
9167 optError DefinitiveObjIdComponent
9168 | DefinitiveObjIdComponentList optError DefinitiveObjIdComponent
9171 DefinitiveObjIdComponent:
9173 | DefinitiveNumberForm
9174 | DefinitiveNameAndNumberForm
9177 DefinitiveNumberForm:
9178 Number { delete $1; }
9181 DefinitiveNameAndNumberForm:
9182 IDentifier '(' Number optError ')' { delete $1; delete $3; }
9183 | IDentifier '(' error ')' { delete $1; }
9186 ObjectIdentifierValue:
9187 ObjectIdentifierKeyword '{' ObjIdComponentList optError '}'
9190 $$->set_location(infile, @$);
9192 | ObjectIdentifierKeyword '{' error '}'
9194 $$ = new Value(Value::V_ERROR);
9195 $$->set_location(infile, @$);
9200 optError ObjIdComponent
9202 $$ = new Value(Value::V_OID);
9203 $$->add_oid_comp($2);
9205 | ObjIdComponentList optError ObjIdComponent
9208 $$->add_oid_comp($3);
9213 /* NameForm -- covered by NumberForm (as ReferencedValue) */
9214 NumberForm { $$ = $1; }
9215 | NameAndNumberForm { $$ = $1; }
9221 Value *v = new Value(Value::V_INT, $1);
9222 v->set_location(infile, @1);
9223 $$ = new OID_comp(0, v);
9224 $$->set_location(infile, @$);
9229 /* it can be only a referenced value */
9230 Value *v = new Value(Value::V_REFD, $1.ref);
9231 v->set_location(infile, @1);
9232 $$ = new OID_comp(v);
9234 /* it can be either a name form or a referenced value */
9235 $$ = new OID_comp($1.id, 0);
9237 $$->set_location(infile, @$);
9242 IDentifier '(' Number optError ')'
9244 Value *v = new Value(Value::V_INT, $3);
9245 v->set_location(infile, @3);
9246 $$ = new OID_comp($1, v);
9247 $$->set_location(infile, @$);
9249 | IDentifier '(' ReferencedValue optError ')'
9251 $$ = new OID_comp($1, $3);
9252 $$->set_location(infile, @$);
9254 | IDentifier '(' error ')'
9256 Value *v = new Value(Value::V_ERROR);
9257 v->set_location(infile, @3);
9258 $$ = new OID_comp($1, v);
9259 $$->set_location(infile, @$);
9264 IDentifier { delete $1; }
9267 /* Rules for error recovery */
9276 | optErrorBlock ErrorBlock optError
9281 | '{' optError ErrorBlock optError '}'
9286 static void ttcn3_error(const char *str)
9288 Location loc(infile, ttcn3_lloc);
9290 // the most recently parsed token is known
9291 loc.error("at or before token `%s': %s", ttcn3_text, str);
9293 // the most recently parsed token is unknown
9294 loc.error("%s", str);
9298 int ttcn3_parse_file(const char* filename, boolean generate_code)
9300 anytype_access = false;
9301 ttcn3_in = fopen(filename, "r");
9302 if (ttcn3_in == NULL) {
9303 ERROR("Cannot open input file `%s': %s", filename, strerror(errno));
9309 is_erroneous_parsed = false;
9310 NOTIFY("Parsing TTCN-3 module `%s'...", filename);
9312 int retval = ttcn3_parse();
9314 free_ttcn3_lex(); // does fclose(ttcn3_in);
9316 if (act_ttcn3_module) {
9317 act_ttcn3_module->set_location(filename);
9318 set_md5_checksum(act_ttcn3_module);
9319 if (generate_code) act_ttcn3_module->set_gen_code();
9320 modules->add_mod(act_ttcn3_module);
9321 act_ttcn3_module = 0;
9329 Ttcn::ErroneousAttributeSpec* ttcn3_parse_erroneous_attr_spec_string(
9330 const char* p_str, const Common::Location& str_loc)
9332 is_erroneous_parsed = true;
9333 act_ttcn3_erroneous_attr_spec = NULL;
9334 string titan_err_str("$#&&&(#TITANERRONEOUS$#&&^#% ");
9335 int hack_str_len = (int)titan_err_str.size();
9336 string *parsed_string = parse_charstring_value(p_str, str_loc);
9337 titan_err_str += *parsed_string;
9338 delete parsed_string;
9339 init_erroneous_lex(str_loc.get_filename(), str_loc.get_first_line(), str_loc.get_first_column()-hack_str_len+1);
9340 yy_buffer_state *flex_buffer = ttcn3__scan_string(titan_err_str.c_str());
9341 if (flex_buffer == NULL) {
9342 ERROR("Flex buffer creation failed.");
9346 ttcn3_lex_destroy();
9347 free_dot_flag_stuff();
9349 return act_ttcn3_erroneous_attr_spec;
9353 static void yyprint(FILE *file, int type, const YYSTYPE& value)
9357 fprintf(file, "``%s''", value.id->get_name().c_str());
9360 fprintf(file, "%s", value.int_val->t_str().c_str());
9363 fprintf(file, "%f", value.float_val);
9368 case BitStringMatch:
9369 case HexStringMatch:
9370 case OctetStringMatch:
9371 fprintf(file, "``%s''", value.string_val->c_str());
9374 fprintf(file, "``%s''", value.str);