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
842 /* Multi-character operators */
844 %token AssignmentChar ":="
846 %token PortRedirectSymbol "->"
854 %token _RR "@>" /* Name clash with bn.h:292 */
856 /*********************************************************************
857 * Semantic types of nonterminals
858 *********************************************************************/
860 %type <bool_val> optAliveKeyword optOptionalKeyword optOverrideKeyword
861 optErrValueRaw optAllKeyword optLazyEval
862 %type <str> FreeText optLanguageSpec PatternChunk PatternChunkList
863 %type <uchar_val> Group Plane Row Cell
864 %type <id> FieldIdentifier FieldReference GlobalModuleId
865 IdentifierOrAddressKeyword StructFieldRef PredefOrIdentifier
866 %type <string_val> CstringList
867 %type <ustring_val> Quadruple
868 %type <uid_list> USI UIDlike
870 %type <typetype> PredefinedType
871 %type <portoperationmode> PortOperationMode
872 %type <operationtype> PredefinedOpKeyword1 PredefinedOpKeyword2 PredefinedOpKeyword3
874 %type <activateop> ActivateOp
875 %type <attribtype> AttribKeyword
877 %type <altguard> CallBodyStatement AltGuard ElseStatement GuardStatement
878 InterleavedGuardElement
879 %type <altguards> AltGuardList CallBodyStatementList InterleavedGuardList
881 %type <arraydimension> ArrayIndex
882 %type <attributespec> AttribSpec
883 %type <compbody> optComponentDefList ComponentElementDefList
884 %type <compfield> StructFieldDef UnionFieldDef
885 %type <compfieldmap> StructFieldDefList optStructFieldDefList UnionFieldDefList
886 %type <definition> AltstepDef ExtFunctionDef FunctionDef TemplateDef TestcaseDef
887 %type <deftype> TypeDefBody StructuredTypeDef SubTypeDef RecordDef UnionDef
888 SetDef RecordOfDef SetOfDef EnumDef PortDef PortDefBody ComponentDef
889 TypeDef SignatureDef FunctionTypeDef AltstepTypeDef TestcaseTypeDef
890 %type <deftimer> SingleTimerInstance
891 %type <enumitem> Enumeration
892 %type <enumitems> EnumerationList
893 %type <fieldorarrayref> ArrayOrBitRef ArrayOrBitRefOrDash FieldOrArrayReference
894 %type <formalpar> FormalValuePar FormalTemplatePar FormalTimerPar
895 TemplateFormalPar FunctionFormalPar TestcaseFormalPar
896 %type <formalparlist> optTemplateFormalParList TemplateFormalParList
897 optFunctionFormalParList FunctionFormalParList optTestcaseFormalParList
898 TestcaseFormalParList optAltstepFormalParList
899 %type <group> GroupDef GroupIdentifier
900 %type <friend_list> FriendModuleDef
901 %type <ifclause> ElseIfClause
902 %type <ifclauses> seqElseIfClause
903 %type <impmod> ImportFromSpec ModuleId ImportDef
904 %type <lenrestr> optStringLength LengthMatch StringLength
905 %type <logarg> LogItem
906 %type <logargs> LogItemList
907 %type <multiwithattrib> MultiWithAttrib WithAttribList WithStatement
908 optWithStatement optWithStatementAndSemiColon
909 %type <namedtempl> FieldSpec
910 %type <namedtempls> seqFieldSpec
911 %type <namedvalue> FieldExpressionSpec
912 %type <namedvalues> seqFieldExpressionSpec
913 %type <indexedtempl> ArraySpec
914 %type <indexedtempls> seqArraySpec
915 %type <indexedvalue> ArrayExpressionSpec
916 %type <oidcomp> NumberForm NameAndNumberForm ObjIdComponent
917 %type <parass> VariableAssignment
918 %type <parasss> AssignmentList
919 %type <parredir> ParamAssignmentList ParamSpec
920 %type <patstr> CharStringMatch
921 %type <qualifier> DefOrFieldRef FullGroupIdentifier
922 %type <qualifiers> DefOrFieldRefList optAttribQualifier
923 %type <selectcase> SelectCase
924 %type <selectcases> seqSelectCase SelectCaseBody
925 %type <signexc> ExceptionTypeList optExceptionSpec
926 %type <signparam> SignatureFormalPar
927 %type <signparamlist> SignatureFormalParList optSignatureFormalParList
928 %type <singlewithattrib> SingleWithAttrib
929 %type <stmt> AltConstruct BasicStatements BreakStatement BehaviourStatements
930 CallBodyOps CallStatement CatchStatement CheckStatement ClearStatement
931 CommunicationStatements ConditionalConstruct ConfigurationStatements
932 ConnectStatement ContinueStatement ControlStatement DeactivateStatement
933 DisconnectStatement DoWhileStatement DoneStatement ForStatement
934 FunctionStatement GetCallStatement GetReplyStatement GotoStatement GuardOp
935 HaltStatement InterleavedConstruct KillTCStatement KilledStatement
936 LabelStatement LogStatement LoopConstruct MapStatement RaiseStatement
937 ReceiveStatement RepeatStatement ReplyStatement ReturnStatement SUTStatements
938 SendStatement SetLocalVerdict StartStatement StartTCStatement
939 StartTimerStatement StopExecutionStatement StopStatement StopTCStatement
940 StopTimerStatement TimeoutStatement TimerStatements TriggerStatement
941 UnmapStatement VerdictStatements WhileStatement SelectCaseConstruct
942 StopTestcaseStatement String2TtcnStatement ProfilerStatement int2enumStatement
943 %type <statementblock> StatementBlock optElseClause FunctionStatementOrDefList
944 ControlStatementOrDefList ModuleControlBody
945 %type <subtypeparse> ValueOrRange
946 %type <templ> MatchingSymbol SingleValueOrAttrib SimpleSpec TemplateBody
947 ArrayElementSpec ArrayValueOrAttrib FieldSpecList ArraySpecList
948 AllElementsFrom TemplateListElem
949 %type <templinst> AddressRef FromClause FunctionActualPar InLineTemplate
950 ReceiveParameter SendParameter TemplateActualPar TemplateInstance
951 /* TestcaseActualPar */ ValueMatchSpec optFromClause optParDefaultValue
953 %type <parsedpar> FunctionActualParList TestcaseActualParList
954 optFunctionActualParList optTestcaseActualParList
955 NamedPart UnnamedPart
956 %type <templinsts> optTemplateActualParList
957 seqTemplateActualPar seqTemplateInstance
958 %type <templs> ValueOrAttribList seqValueOrAttrib ValueList Complement
959 ArrayElementSpecList SubsetMatch SupersetMatch PermutationMatch
960 %type <ass> Assignment Step
961 %type <refbase> DerivedRefWithParList TemplateRefWithParList DecValueArg
962 %type <refpard> FunctionInstance AltstepInstance
963 %type <reference> PortType optDerivedDef DerivedDef Signature VariableRef
964 TimerRef TimerRefOrAny Port PortOrAny PortOrAll ValueSpec
965 SenderSpec ComponentType optRunsOnSpec RunsOnSpec optSystemSpec
966 %type <valuerange> Range
967 %type <type> NestedEnumDef NestedRecordDef NestedRecordOfDef NestedSetDef
968 NestedSetOfDef NestedTypeDef NestedUnionDef PortDefAttribs ReferencedType
969 Type TypeOrNestedTypeDef NestedFunctionTypeDef NestedAltstepTypeDef
970 NestedTestcaseTypeDef
971 %type <types> TypeList AllOrTypeList
972 %type <value> AddressValue AliveOp AllPortsSpec AltGuardChar ArrayBounds
973 ArrayExpression ArrayExpressionList BitStringValue BooleanExpression
974 BooleanValue CharStringValue ComponentRef ComponentReferenceOrLiteral
975 ComponentOrDefaultReference CompoundExpression ConfigurationOps CreateOp
976 DereferOp Expression FieldExpressionList Final GetLocalVerdict HexStringValue
977 IntegerValue LowerBound MTCOp MatchOp NotUsedOrExpression ObjIdComponentList
978 ObjectIdentifierValue OctetStringValue OmitValue OpCall PredefinedOps
979 PredefinedValue ReadTimerOp ReferOp ReferencedValue RunningOp RunningTimerOp
980 SelfOp SingleExpression SingleLowerBound SystemOp TemplateOps TimerOps
981 TimerValue UpperBound Value ValueofOp VerdictOps VerdictValue optReplyValue
982 optTestcaseTimerValue optToClause ProfilerRunningOp
983 %type <values> ArrayElementExpressionList seqArrayExpressionSpec
984 %type <variableentries> VariableList
985 %type <variableentry> VariableEntry
986 %type <subtypeparses> seqValueOrRange AllowedValues optSubTypeSpec
988 %type <arraydimension_list> optArrayDef
989 %type <fieldorarrayref_list> optExtendedFieldReference
990 %type <def_list> AltstepLocalDef AltstepLocalDefList ComponentElementDef
991 ConstDef ExtConstDef FunctionLocalDef FunctionLocalInst ModuleDef ModulePar
992 ModuleParDef MultiTypedModuleParList PortInstance TimerInstance TimerList
994 %type <stmt_list> FunctionStatementOrDef ControlStatementOrDef
996 %type <rangedef> RangeDef
997 %type <returntype> optReturnType
998 %type <returntypeornoblock> optReturnTypeOrNoBlockKeyword
999 %type <structdefbody> StructDefBody UnionDefBody
1000 %type <structofdefbody> StructOfDefBody
1001 %type <portdefbody> PortDefList seqPortDefList PortDefLists
1002 %type <ischosenarg> IschosenArg
1003 %type <extramatchingattrs> optExtraMatchingAttributes
1004 %type <basetemplate> BaseTemplate
1005 %type <templateref> TemplateRef TestcaseRef FunctionRef
1006 %type <testcaseinst> TestcaseInstance
1007 %type <portsendop> PortSendOp
1008 %type <calltimerval> CallTimerValue
1009 %type <portcallop> PortCallOp CallParameters
1010 %type <portreplyop> PortReplyOp
1011 %type <portraiseop> PortRaiseOp
1012 %type <portredirect> optPortRedirect
1013 %type <portredirectwithparam> optPortRedirectWithParam
1014 %type <portredirectwithvalueandparam> optPortRedirectWithValueAndParam
1015 %type <getreplypar> optGetReplyParameter
1016 %type <portreceiveop> PortReceiveOp PortTriggerOp
1017 %type <portgetcallop> PortGetCallOp
1018 %type <portgetreplyop> PortGetReplyOp
1019 %type <catchoppar> optCatchOpParameter CatchOpParameter
1020 %type <portcatchop> PortCatchOp
1021 %type <portcheckop> optCheckParameter CheckParameter CheckPortOpsPresent
1022 FromClausePresent RedirectPresent
1023 %type <portref> PortRef AllConnectionsSpec
1024 %type <connspec> SingleConnectionSpec SingleOrMultiConnectionSpec
1025 %type <donepar> optDoneParameter
1026 %type <reforid> Reference
1027 %type <initial> Initial
1028 %type <configspec> ConfigSpec
1029 %type <createpar> optCreateParameter
1030 %type <applyop> ApplyOp
1031 %type <identifier_list> IdentifierList
1032 %type <singlevarinst> SingleConstDef SingleVarInstance
1033 %type <singlevarinst_list> ConstList VarList
1034 %type <singletempvarinst> SingleTempVarInstance
1035 %type <singletempvarinst_list> TempVarList
1036 %type <singlemodulepar> SingleModulePar
1037 %type <singletemplatemodulepar> SingleTemplateModulePar
1038 %type <singlemodulepar_list> ModuleParList
1039 %type <singletemplatemodulepar_list> TemplateModuleParList
1040 %type <portelement> PortElement
1041 %type <portelement_list> PortElementList
1042 %type <comprefs> optExtendsDef ComponentTypeList
1043 %type <runs_on_compref_or_self> optRunsOnComprefOrSelf
1044 %type <template_restriction> TemplateRestriction optTemplateRestriction
1045 TemplateOptRestricted
1046 %type <visbilitytype> optVisibility ComponentElementVisibility
1047 %type <float_val> FloatOrSpecialFloatValue
1048 %type <erroneous_indicator> ErroneousIndicator
1049 %type <imptype> ImportSpec ImportElement
1051 /*********************************************************************
1053 *********************************************************************/
1056 act_group = $$->get_parent_group();
1061 %destructor {Free($$);}
1070 delete $$.derefered_value;
1075 %destructor {delete $$;}
1089 ArrayElementExpressionList
1091 ArrayElementSpecList
1110 CallBodyStatementList
1117 CommunicationStatements
1120 ComponentElementDefList
1121 ComponentOrDefaultReference
1123 ComponentReferenceOrLiteral
1127 ConditionalConstruct
1129 ConfigurationStatements
1133 ControlStatementOrDefList
1140 DerivedRefWithParList
1154 FieldOrArrayReference
1166 FunctionActualParList
1169 FunctionFormalParList
1172 FunctionStatementOrDefList
1186 IdentifierOrAddressKeyword
1191 InterleavedConstruct
1192 InterleavedGuardElement
1193 InterleavedGuardList
1201 String2TtcnStatement
1213 NestedAltstepTypeDef
1215 NestedFunctionTypeDef
1220 NestedTestcaseTypeDef
1228 ObjectIdentifierValue
1276 SignatureFormalParList
1289 StopExecutionStatement
1290 StopTestcaseStatement
1307 TemplateFormalParList
1310 TemplateRefWithParList
1311 /* TestcaseActualPar */
1312 TestcaseActualParList
1315 TestcaseFormalParList
1352 optAltstepFormalParList
1360 optFunctionActualParList
1361 optFunctionFormalParList
1367 optSignatureFormalParList
1369 optStructFieldDefList
1371 optTemplateActualParList
1372 optTemplateFormalParList
1373 optTestcaseActualParList
1374 optTestcaseFormalParList
1375 optTestcaseTimerValue
1378 optWithStatementAndSemiColon
1380 seqFieldExpressionSpec
1382 seqTemplateActualPar
1388 for (size_t i = 0; i < $$->size(); i++) delete (*$$)[i];
1397 for(size_t i=0; i<$$.nElements; i++) delete $$.elements[i];
1404 ControlStatementOrDef
1408 FunctionStatementOrDef
1412 MultiTypedModuleParList
1418 optExtendedFieldReference
1434 optReturnTypeOrNoBlockKeyword
1452 delete $$.inout_list;
1465 delete $$.len_restr;
1467 optExtraMatchingAttributes
1486 delete $$.derefered_value;
1493 delete $$.templ_inst;
1499 delete $$.calltimerval;
1504 delete $$.templ_inst;
1505 delete $$.calltimerval;
1508 PortCallOp CallParameters
1511 delete $$.templ_inst;
1518 delete $$.signature;
1519 delete $$.templ_inst;
1525 delete $$.redirectval;
1526 delete $$.redirectsender;
1531 delete $$.redirectparam;
1532 delete $$.redirectsender;
1534 optPortRedirectWithParam
1537 delete $$.redirectval;
1538 delete $$.redirectparam;
1539 delete $$.redirectsender;
1541 optPortRedirectWithValueAndParam
1544 delete $$.templ_inst;
1545 delete $$.valuematch;
1547 optGetReplyParameter
1550 delete $$.templ_inst;
1551 delete $$.fromclause;
1552 delete $$.redirectval;
1553 delete $$.redirectsender;
1559 delete $$.templ_inst;
1560 delete $$.fromclause;
1561 delete $$.redirectparam;
1562 delete $$.redirectsender;
1567 delete $$.templ_inst;
1568 delete $$.valuematch;
1569 delete $$.fromclause;
1570 delete $$.redirectval;
1571 delete $$.redirectparam;
1572 delete $$.redirectsender;
1577 delete $$.signature;
1578 delete $$.templ_inst;
1584 delete $$.signature;
1585 delete $$.templ_inst;
1586 delete $$.fromclause;
1587 delete $$.redirectval;
1588 delete $$.redirectsender;
1593 delete $$.signature;
1594 delete $$.templ_inst;
1595 delete $$.valuematch;
1596 delete $$.fromclause;
1597 delete $$.redirectval;
1598 delete $$.redirectparam;
1599 delete $$.redirectsender;
1620 SingleConnectionSpec
1621 SingleOrMultiConnectionSpec
1624 delete $$.donematch;
1630 if ($$.is_ref) delete $$.ref;
1642 delete $$.runsonref;
1643 delete $$.systemref;
1660 for (size_t i = 0; i < $$.nElements; i++) delete $$.elements[i].id;
1667 for (size_t i = 0; i < $$.arrays.nElements; i++)
1668 delete $$.arrays.elements[i];
1669 Free($$.arrays.elements);
1670 delete $$.initial_value;
1674 SingleTempVarInstance
1677 for (size_t i = 0; i < $$.nElements; i++) {
1678 delete $$.elements[i].id;
1679 for (size_t j = 0; i < $$.elements[i].arrays.nElements; j++)
1680 delete $$.elements[i].arrays.elements[j];
1681 Free($$.elements[i].arrays.elements);
1682 delete $$.elements[i].initial_value;
1700 SingleTemplateModulePar
1703 for (size_t i = 0; i < $$.nElements; i++) {
1704 delete $$.elements[i].id;
1705 delete $$.elements[i].defval;
1712 for (size_t i = 0; i < $$.nElements; i++) {
1713 delete $$.elements[i].id;
1714 delete $$.elements[i].deftempl;
1718 TemplateModuleParList
1727 for (size_t i = 0; i < $$.nElements; i++) {
1728 delete $$.elements[i].id;
1729 delete $$.elements[i].dims;
1736 delete $$.reference;
1738 optRunsOnComprefOrSelf
1740 /*********************************************************************
1741 * Operator precedences (lowest first)
1742 *********************************************************************/
1749 %nonassoc '<' '>' GE LE
1756 %left '*' '/' ModKeyword RemKeyword
1764 XXX Source of conflicts (26 S/R):
1766 1.) 9 conflicts in one state
1767 The Expression after 'return' keyword is optional in ReturnStatement.
1768 For 9 tokens the parser cannot decide whether the token is a part of
1769 the return expression (shift) or it is the beginning of the next statement
1772 2.) 9 distinct states, each with one conflict caused by token '['
1773 The local definitions in altsteps can be followed immediately by the guard
1774 expression. When the parser sees the '[' token it cannot decide whether it
1775 belongs to the local definition as array dimension or array subreference
1776 (shift) or it is the beginning of the first guard expression (reduce).
1777 The situations are the following:
1778 - var t v := ref <here> [
1779 - var t v := ref[subref] <here> [
1780 - var t v := ref.integer <here> [
1781 - var t v := ref.subref <here> [
1784 - var t v := ref.objid{...}.subref <here> [
1785 - var template t v <here> [
1786 - var t v := function(...)<subrefs> <here> [
1789 The sequence identifier.objid can be either the beginning of a module name
1790 qualified with a module object identifier (shift) or a reference to an objid
1791 value within an entity of type anytype (reduce).
1794 The '{' token after a call statement can be either the part of the response and
1795 exception handling part (shift) or the beginning of the next statement, which
1796 is a StatementBlock (reduce). Note that StatementBlock as a statement is a
1797 non-standard language extension.
1799 5.) 5 conflicts in in three states, related to named parameters
1801 6.) 1 Conflict due to pattern concatenation
1803 Note that the parser implemented by bison always chooses to shift instead of
1804 reduce in case of conflicts.
1809 /*********************************************************************
1811 *********************************************************************/
1813 /* The grammar of TTCN-3 */
1814 /* The numbers correspond to ES 201 873-1 V4.1.2 (2009-07) */
1819 if (is_erroneous_parsed) {
1820 delete act_ttcn3_module;
1821 act_ttcn3_module = NULL;
1822 Location loc(infile, @1);
1823 loc.error("The erroneous attribute cannot be a TTCN-3 module.");
1826 | TitanErroneousHackKeyword ErroneousAttributeSpec
1828 if (!is_erroneous_parsed) {
1829 delete act_ttcn3_erroneous_attr_spec;
1830 act_ttcn3_erroneous_attr_spec = NULL;
1831 Location loc(infile, @$);
1832 loc.error("File `%s' does not contain a TTCN-3 module.", infile);
1838 ErroneousAttributeSpec:
1839 ErroneousIndicator AssignmentChar TemplateInstance optAllKeyword
1841 act_ttcn3_erroneous_attr_spec = new ErroneousAttributeSpec($1.is_raw, $1.indicator, $3, $4);
1846 ValueKeyword optErrValueRaw
1848 $$.indicator = ErroneousAttributeSpec::I_VALUE;
1851 | IDentifier optErrValueRaw
1853 if ($1->get_ttcnname()=="before") $$.indicator = ErroneousAttributeSpec::I_BEFORE;
1854 else if ($1->get_ttcnname()=="after") $$.indicator = ErroneousAttributeSpec::I_AFTER;
1856 Location loc(infile, @1);
1857 loc.error("Invalid indicator. Valid indicators are: "
1858 "`before', `value' and `after'");
1859 $$.indicator = ErroneousAttributeSpec::I_INVALID;
1867 /* empty */ { $$ = false; }
1868 | AllKeyword { $$ = true; }
1872 /* empty */ { $$ = false; }
1873 | '(' IDentifier ')'
1875 if ($2->get_ttcnname()=="raw") $$ = true;
1877 Location loc(infile, @2);
1878 loc.error("Invalid keyword, only the optional `raw' keyword can be used here.");
1886 /* A.1.6.0 TTCN Module */
1889 TTCN3ModuleId ModuleBody optWithStatementAndSemiColon optError
1891 act_ttcn3_module->set_with_attr($3);
1892 if (anytype_access) {
1893 // If there was an attempted access to an anytype field, artificially
1894 // create a type definition as if the following appeared in TTCN-3:
1895 // type union anytype { /* empty, members added later */ }
1896 // NOTE: anything which looks like usage of an anytype field will bring
1897 // the local anytype to life, which trumps any imported anytype
1898 // (when resolving, the local anytype will be found first).
1899 // TODO: just to be safe, anytype should be removed from the exports.
1900 Type *t = new Type(Type::T_ANYTYPE);
1901 Identifier *anytype_id = new Identifier(Identifier::ID_TTCN, anyname);
1902 Def_Type *anytypedef = new Def_Type(anytype_id, t);
1903 anytypedef->set_parent_path(act_ttcn3_module->get_attrib_path());
1904 act_ttcn3_module->add_ass(anytypedef);
1905 // Def_Type is-a Definition is-a Assignment
1911 optError TTCN3ModuleKeyword IDentifier optDefinitiveIdentifier
1912 optLanguageSpec optError
1914 act_ttcn3_module = new Ttcn::Module($3);
1915 act_ttcn3_module->set_scope_name($3->get_dispname());
1916 act_ttcn3_module->set_language_spec($5);
1922 GlobalModuleId optLanguageSpec
1924 $$ = new ImpMod($1);
1925 $$->set_language_spec($2);
1930 GlobalModuleId: // 5
1931 IDentifier { $$ = $1; }
1932 | IDentifier '.' ObjectIdentifierValue
1933 { $$ = $1; delete $3; }
1937 /* empty */ { $$ = NULL; }
1938 | LanguageKeyword FreeText { $$ = $2; } // sort-of 7 LanguageSpec
1942 '{' optErrorBlock '}'
1943 | '{' ModuleDefinitionsList optErrorBlock '}'
1944 | '{' ModuleDefinitionsList ModuleControlPart optErrorBlock '}'
1945 | '{' ModuleControlPart optErrorBlock '}'
1948 /* A.1.6.1 Module definitions part */
1950 /* A.1.6.1.0 General */
1952 ModuleDefinitionsList: // 10
1953 ModuleDefinition optSemiColon
1954 | error ModuleDefinition optSemiColon
1955 | ModuleDefinitionsList optErrorBlock ModuleDefinition optSemiColon
1958 optVisibility: // 12
1959 // /* empty */ { $$.visibility = PUBLIC;}
1960 /* empty */ { $$.visibility = NOCHANGE;}
1961 | PublicKeyword { $$.visibility = PUBLIC;}
1962 | PrivateKeyword { $$.visibility = PRIVATE;}
1963 | FriendKeyword { $$.visibility = FRIEND;}
1966 /* A definition _in_ the module, not a definition _of_ a module */
1967 ModuleDefinition: // 11
1968 optVisibility ModuleDef optWithStatement
1970 for (size_t i = 0; i < $2.nElements; i++) {
1972 if (i == 0) $2.elements[i]->set_with_attr($3);
1973 else $2.elements[i]->set_with_attr($3->clone());
1975 if ($1.visibility != NOCHANGE) {
1976 $2.elements[i]->set_visibility($1.visibility);
1978 act_ttcn3_module->add_ass($2.elements[i]);
1980 $2.elements[i]->set_parent_path(act_group->get_attrib_path());
1981 act_group->add_ass($2.elements[i]);
1983 $2.elements[i]->set_parent_path(act_ttcn3_module->get_attrib_path());
1988 | optVisibility ImportDef optWithStatement
1990 $2->set_with_attr($3);
1991 if ($1.visibility != NOCHANGE) {
1992 $2->set_visibility($1.visibility);
1995 $2->set_parent_path(act_group->get_attrib_path());
1996 act_group->add_impmod($2);
1998 $2->set_parent_path(act_ttcn3_module->get_attrib_path());
2000 act_ttcn3_module->add_impmod($2);
2002 | PublicKeyword GroupDef optWithStatement
2003 { // only public allowed for group, and it's redundant
2004 $2->set_with_attr($3);
2005 act_group = $2->get_parent_group();
2007 | GroupDef optWithStatement
2008 { // same code as above
2009 $1->set_with_attr($2);
2010 act_group = $1->get_parent_group();
2012 | PrivateKeyword FriendModuleDef optWithStatement
2013 { // only private allowed for "friend module", and it's redundant
2014 for (size_t i = 0; i < $2.nElements; i++) {
2016 if (i == 0) $2.elements[i]->set_with_attr($3);
2017 else $2.elements[i]->set_with_attr($3->clone());
2019 act_ttcn3_module->add_friendmod($2.elements[i]);
2021 $2.elements[i]->set_parent_path(act_group->get_attrib_path());
2022 act_group->add_friendmod($2.elements[i]);
2024 $2.elements[i]->set_parent_path(act_ttcn3_module->get_attrib_path());
2029 | FriendModuleDef optWithStatement
2030 { // same code as above
2031 for (size_t i = 0; i < $1.nElements; i++) {
2033 if (i == 0) $1.elements[i]->set_with_attr($2);
2034 else $1.elements[i]->set_with_attr($2->clone());
2036 act_ttcn3_module->add_friendmod($1.elements[i]);
2038 $1.elements[i]->set_parent_path(act_group->get_attrib_path());
2039 act_group->add_friendmod($1.elements[i]);
2041 $1.elements[i]->set_parent_path(act_ttcn3_module->get_attrib_path());
2049 ConstDef { $$ = $1; }
2050 | ModuleParDef { $$ = $1; }
2054 $$.elements = (Ttcn::Definition**)
2055 Malloc(sizeof(*$$.elements));
2056 $$.elements[0] = $1;
2061 $$.elements = (Ttcn::Definition**)
2062 Malloc(sizeof(*$$.elements));
2063 $$.elements[0] = $1;
2068 $$.elements = (Ttcn::Definition**)
2069 Malloc(sizeof(*$$.elements));
2070 $$.elements[0] = $1;
2075 $$.elements = (Ttcn::Definition**)
2076 Malloc(sizeof(*$$.elements));
2077 $$.elements[0] = $1;
2082 $$.elements = (Ttcn::Definition**)
2083 Malloc(sizeof(*$$.elements));
2084 $$.elements[0] = $1;
2089 $$.elements = (Ttcn::Definition**)
2090 Malloc(sizeof(*$$.elements));
2091 $$.elements[0] = $1;
2096 $$.elements = (Ttcn::Definition**)
2097 Malloc(sizeof(*$$.elements));
2098 $$.elements[0] = $1;
2100 | ExtConstDef { $$ = $1; }
2103 /* A.1.6.1.1 Typedef definitions */
2106 TypeDefKeyword TypeDefBody
2109 $$->set_location(infile, @$);
2114 StructuredTypeDef { $$ = $1; }
2115 | SubTypeDef { $$ = $1; }
2118 StructuredTypeDef: // 16
2119 RecordDef { $$ = $1; }
2120 | UnionDef { $$ = $1; }
2121 | SetDef { $$ = $1; }
2122 | RecordOfDef { $$ = $1; }
2123 | SetOfDef { $$ = $1; }
2124 | EnumDef { $$ = $1; }
2125 | PortDef { $$ = $1; }
2126 | ComponentDef { $$ = $1; }
2127 | FunctionTypeDef { $$ = $1; }
2128 | AltstepTypeDef { $$ = $1; }
2129 | TestcaseTypeDef { $$ = $1; }
2133 RecordKeyword StructDefBody
2135 Type *type = new Type(Type::T_SEQ_T, $2.cfm);
2136 type->set_location(infile, @$);
2137 $$ = new Def_Type($2.id, type);
2141 StructDefBody: // 19
2142 IDentifier optStructDefFormalParList
2143 '{' optStructFieldDefList '}'
2148 | AddressKeyword '{' optStructFieldDefList '}'
2150 $$.id = new Identifier(Identifier::ID_TTCN, string("address"));
2155 optStructDefFormalParList:
2156 /* empty */ optError
2157 | '(' StructDefFormalParList optError ')'
2159 Location loc(infile, @$);
2160 loc.error("Type parameterization is not currently supported");
2164 Location loc(infile, @$);
2165 loc.error("Type parameterization is not currently supported");
2169 StructDefFormalParList: // -> 202 784 "Advanced Parameterization", 9
2170 optError StructDefFormalPar
2171 | StructDefFormalParList optError ',' optError StructDefFormalPar
2172 | StructDefFormalParList optError ',' error
2175 StructDefFormalPar: // -> 202 784 "Advanced Parameterization", 10
2176 FormalValuePar { delete $1; }
2179 optStructFieldDefList:
2180 /* empty */ optError { $$ = new CompFieldMap; }
2181 | StructFieldDefList optError { $$ = $1; }
2185 optError StructFieldDef
2187 $$ = new CompFieldMap;
2190 | StructFieldDefList optError ',' optError StructFieldDef
2195 | StructFieldDefList optError ',' error { $$ = $1; }
2198 StructFieldDef: // 21
2199 TypeOrNestedTypeDef IDentifier optArrayDef optSubTypeSpec optOptionalKeyword
2202 /* The subtype constraint belongs to the innermost embedded type of
2203 * possible nested 'record of' or 'set of' constructs. */
2205 while (t->is_seof()) t = t->get_ofType();
2206 t->set_parsed_restrictions($4);
2209 /* creation of array type(s) if necessary (from right to left) */
2210 for (size_t i = $3.nElements; i > 0; i--) {
2211 type = new Type(Type::T_ARRAY, type, $3.elements[i - 1], true);
2212 type->set_location(*$1);
2215 $$ = new CompField($2, type, $5);
2216 $$->set_location(infile, @$);
2221 /* empty */ { $$ = false; }
2222 | OptionalKeyword { $$ = true; }
2225 TypeOrNestedTypeDef:
2227 | NestedTypeDef { $$ = $1; }
2230 NestedTypeDef: // 22
2231 NestedRecordDef { $$ = $1; }
2232 | NestedUnionDef { $$ = $1; }
2233 | NestedSetDef { $$ = $1; }
2234 | NestedRecordOfDef { $$ = $1; }
2235 | NestedSetOfDef { $$ = $1; }
2236 | NestedEnumDef { $$ = $1; }
2237 | NestedFunctionTypeDef { $$ = $1; }
2238 | NestedAltstepTypeDef { $$ = $1; }
2239 | NestedTestcaseTypeDef { $$ = $1; }
2242 NestedRecordDef: // 23
2243 RecordKeyword '{' optStructFieldDefList '}'
2245 $$ = new Type(Type::T_SEQ_T, $3);
2246 $$->set_location(infile, @$);
2250 NestedUnionDef: // 24
2251 UnionKeyword '{' UnionFieldDefList optError '}'
2253 $$ = new Type(Type::T_CHOICE_T, $3);
2254 $$->set_location(infile, @$);
2259 SetKeyword '{' optStructFieldDefList '}'
2261 $$ = new Type(Type::T_SET_T, $3);
2262 $$->set_location(infile, @$);
2266 NestedRecordOfDef: // 26
2267 RecordKeyword optStringLength OfKeyword TypeOrNestedTypeDef
2269 $$ = new Type(Type::T_SEQOF, $4);
2271 vector<SubTypeParse> *vstp = new vector<SubTypeParse>;
2272 SubTypeParse *stp = new SubTypeParse($2);
2274 $$->set_parsed_restrictions(vstp);
2276 $$->set_location(infile, @$);
2280 NestedSetOfDef: // 27
2281 SetKeyword optStringLength OfKeyword TypeOrNestedTypeDef
2283 $$ = new Type(Type::T_SETOF, $4);
2285 vector<SubTypeParse> *vstp = new vector<SubTypeParse>;
2286 SubTypeParse *stp = new SubTypeParse($2);
2288 $$->set_parsed_restrictions(vstp);
2290 $$->set_location(infile, @$);
2294 NestedEnumDef: // 28
2295 EnumKeyword '{' EnumerationList optError '}'
2297 $$ = new Type(Type::T_ENUM_T, $3);
2298 $$->set_location(infile, @$);
2302 NestedFunctionTypeDef:
2303 FunctionKeyword '(' optFunctionFormalParList ')'
2304 optRunsOnComprefOrSelf optReturnType
2306 $3->set_location(infile, @2, @4);
2307 $$ = new Type(Type::T_FUNCTION, $3, $5.reference, $5.self, $6.type,
2308 $6.returns_template, $6.template_restriction);
2309 $$->set_location(infile, @$);
2313 NestedAltstepTypeDef:
2314 AltstepKeyword '(' optAltstepFormalParList ')'
2315 optRunsOnComprefOrSelf
2317 $3->set_location(infile, @2, @4);
2318 $$ = new Type(Type::T_ALTSTEP, $3, $5.reference, $5.self);
2319 $$->set_location(infile, @$);
2323 NestedTestcaseTypeDef:
2324 TestcaseKeyword '(' optTestcaseFormalParList ')'
2327 $3->set_location(infile, @2, @4);
2328 $$ = new Type(Type::T_TESTCASE, $3, $5.runsonref,
2330 $$->set_location(infile, @$);
2335 UnionKeyword UnionDefBody
2337 Type *type = new Type(Type::T_CHOICE_T, $2.cfm);
2338 type->set_location(infile, @$);
2339 $$ = new Def_Type($2.id, type);
2344 IDentifier optStructDefFormalParList
2345 '{' UnionFieldDefList optError '}'
2350 | AddressKeyword '{' UnionFieldDefList optError '}'
2352 $$.id = new Identifier(Identifier::ID_TTCN, string("address"));
2358 optError UnionFieldDef
2360 $$ = new CompFieldMap;
2363 | UnionFieldDefList optError ',' optError UnionFieldDef
2368 | UnionFieldDefList optError ',' error { $$ = $1; }
2369 | error { $$ = new CompFieldMap; }
2372 UnionFieldDef: // 34
2373 TypeOrNestedTypeDef IDentifier optArrayDef optSubTypeSpec
2376 /* The subtype constraint belongs to the innermost embedded type of
2377 * possible nested 'record of' or 'set of' constructs. */
2379 while (t->is_seof()) t = t->get_ofType();
2380 t->set_parsed_restrictions($4);
2383 /* creation of array type(s) if necessary (from right to left) */
2384 for (size_t i = $3.nElements; i > 0; i--) {
2385 type = new Type(Type::T_ARRAY, type, $3.elements[i - 1], true);
2386 type->set_location(*$1);
2389 $$ = new CompField($2, type, false);
2390 $$->set_location(infile, @$);
2395 SetKeyword StructDefBody
2397 Type *type = new Type(Type::T_SET_T, $2.cfm);
2398 type->set_location(infile, @$);
2399 $$ = new Def_Type($2.id, type);
2404 RecordKeyword optStringLength OfKeyword StructOfDefBody
2406 Type *type = new Type(Type::T_SEQOF, $4.type);
2408 vector<SubTypeParse> *vstp = new vector<SubTypeParse>;
2409 vstp->add(new SubTypeParse($2));
2410 type->set_parsed_restrictions(vstp);
2412 type->set_location(infile, @$);
2413 $$ = new Def_Type($4.id, type);
2417 StructOfDefBody: // 39
2418 TypeOrNestedTypeDef IdentifierOrAddressKeyword optSubTypeSpec
2421 /* The subtype constraint belongs to the innermost embedded type of
2422 * possible nested 'record of' or 'set of' constructs. */
2424 while (t->is_seof()) t = t->get_ofType();
2425 t->set_parsed_restrictions($3);
2432 IdentifierOrAddressKeyword:
2433 IDentifier { $$ = $1; }
2436 $$ = new Identifier(Identifier::ID_TTCN, string("address"));
2441 SetKeyword optStringLength OfKeyword StructOfDefBody
2443 Type *type = new Type(Type::T_SETOF, $4.type);
2445 vector<SubTypeParse> *vstp = new vector<SubTypeParse>;
2446 vstp->add(new SubTypeParse($2));
2447 type->set_parsed_restrictions(vstp);
2449 type->set_location(infile, @$);
2450 $$ = new Def_Type($4.id, type);
2455 EnumKeyword IdentifierOrAddressKeyword
2456 '{' EnumerationList optError '}'
2458 Type *type = new Type(Type::T_ENUM_T, $4);
2459 type->set_location(infile, @$);
2460 $$ = new Def_Type($2, type);
2464 EnumerationList: // 44
2465 optError Enumeration
2470 | EnumerationList optError ',' optError Enumeration
2475 | EnumerationList optError ',' error { $$ = $1; }
2476 | error { $$ = new EnumItems; }
2482 $$ = new EnumItem($1, NULL);
2483 $$->set_location(infile, @$);
2485 | IDentifier '(' Number optError ')'
2487 Value *value = new Value(Value::V_INT, $3);
2488 value->set_location(infile, @3);
2489 $$ = new EnumItem($1, value);
2490 $$->set_location(infile, @$);
2492 | IDentifier '(' '-' Number optError ')'
2495 Value *value = new Value(Value::V_INT, $4);
2496 value->set_location(infile, @3, @4);
2497 $$ = new EnumItem($1, value);
2498 $$->set_location(infile, @$);
2500 | IDentifier '(' error ')'
2502 Value *value = new Value(Value::V_ERROR);
2503 value->set_location(infile, @3);
2504 $$ = new EnumItem($1, value);
2505 $$->set_location(infile, @$);
2510 Type IdentifierOrAddressKeyword optArrayDef optSubTypeSpec
2512 /* the subtype constraint belongs to the innermost type */
2513 if ($4) $1->set_parsed_restrictions($4);
2515 /* creation of array type(s) if necessary (from right to left) */
2516 for (size_t i = $3.nElements; i > 0; i--) {
2517 type = new Type(Type::T_ARRAY, type, $3.elements[i - 1], true);
2518 type->set_location(*$1);
2521 $$ = new Def_Type($2, type);
2525 optSubTypeSpec: // [49]
2526 /* empty */ { $$ = 0; }
2527 | AllowedValues { $$ = $1; }
2528 | AllowedValues StringLength
2531 $$->add(new SubTypeParse($2));
2535 $$ = new vector<SubTypeParse>;
2536 $$->add(new SubTypeParse($1));
2540 AllowedValues: // 50
2541 '(' seqValueOrRange optError ')' { $$ = $2; }
2542 | '(' CharStringMatch optError ')'
2544 $$ = new vector<SubTypeParse>;
2545 $$->add(new SubTypeParse($2));
2547 | '(' error ')' { $$ = new vector<SubTypeParse>; }
2551 optError ValueOrRange
2553 $$ = new vector<SubTypeParse>;
2556 | seqValueOrRange optError ',' optError ValueOrRange
2561 | seqValueOrRange optError ',' error { $$ = $1; }
2565 RangeDef { $$ = new SubTypeParse($1.lower, $1.lower_exclusive, $1.upper, $1.upper_exclusive); }
2566 | Expression { $$ = new SubTypeParse($1); }
2570 LowerBound DotDot UpperBound
2572 $$.lower_exclusive = false;
2574 $$.upper_exclusive = false;
2577 | '!' LowerBound DotDot UpperBound
2579 $$.lower_exclusive = true;
2581 $$.upper_exclusive = false;
2584 | LowerBound DotDot '!' UpperBound
2586 $$.lower_exclusive = false;
2588 $$.upper_exclusive = true;
2591 | '!' LowerBound DotDot '!' UpperBound
2593 $$.lower_exclusive = true;
2595 $$.upper_exclusive = true;
2601 /* empty */ optError { $$ = 0; }
2602 | StringLength { $$ = $1; }
2606 LengthKeyword '(' Expression optError ')'
2608 $$ = new LengthRestriction($3);
2609 $$->set_location(infile, @$);
2611 | LengthKeyword '(' Expression DotDot UpperBound optError ')'
2613 $$ = new LengthRestriction($3, $5);
2614 $$->set_location(infile, @$);
2616 | LengthKeyword '(' error ')'
2618 Value *value = new Value(Value::V_ERROR);
2619 value->set_location(infile, @3);
2620 $$ = new LengthRestriction(value);
2621 $$->set_location(infile, @$);
2628 $$ = new Ttcn::Reference($1);
2629 $$->set_location(infile, @$);
2631 | IDentifier '.' IDentifier
2633 $$ = new Ttcn::Reference($1, $3);
2634 $$->set_location(infile, @$);
2636 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
2638 $$ = new Ttcn::Reference($1, $5);
2639 $$->set_location(infile, @$);
2645 PortKeyword PortDefBody { $$ = $2; }
2649 IDentifier PortDefAttribs
2651 $$ = new Def_Type($1, $2);
2655 PortDefAttribs: // 60
2656 PortOperationMode PortDefLists
2658 PortTypeBody *body = new PortTypeBody($1,
2659 $2.in_list, $2.out_list, $2.inout_list,
2660 $2.in_all, $2.out_all, $2.inout_all);
2661 body->set_location(infile, @$);
2662 $$ = new Type(Type::T_PORT, body);
2663 $$->set_location(infile, @$);
2668 MessageKeyword { $$ = PortTypeBody::PO_MESSAGE; } // 61
2669 | ProcedureKeyword { $$ = PortTypeBody::PO_PROCEDURE; } // 68
2670 | MixedKeyword { $$ = PortTypeBody::PO_MIXED; } // 73
2671 | error { $$ = PortTypeBody::PO_MIXED; }
2675 '{' seqPortDefList '}' { $$ = $2; }
2683 $$.inout_all = false;
2688 optError PortDefList optSemiColon { $$ = $2; }
2689 | seqPortDefList PortDefList optSemiColon
2694 $$.in_list->steal_types($2.in_list);
2696 } else $$.in_list = $2.in_list;
2700 $$.out_list->steal_types($2.out_list);
2702 } else $$.out_list = $2.out_list;
2704 if ($2.inout_list) {
2705 if ($$.inout_list) {
2706 $$.inout_list->steal_types($2.inout_list);
2707 delete $2.inout_list;
2708 } else $$.inout_list = $2.inout_list;
2712 Location loc(infile, @2);
2713 loc.warning("Duplicate directive `in all' in port type definition");
2714 } else $$.in_all = true;
2718 Location loc(infile, @2);
2719 loc.warning("Duplicate directive `out all' in port type definition");
2720 } else $$.out_all = true;
2724 Location loc(infile, @2);
2725 loc.warning("Duplicate directive `inout all' in port type definition");
2726 } else $$.inout_all = true;
2732 InParKeyword AllOrTypeList
2736 $$.in_list->set_location(infile, @$);
2745 $$.inout_all = false;
2747 | OutParKeyword AllOrTypeList
2753 $$.out_list->set_location(infile, @$);
2760 $$.inout_all = false;
2762 | InOutParKeyword AllOrTypeList
2770 $$.inout_list->set_location(infile, @$);
2771 $$.inout_all = false;
2774 $$.inout_all = true;
2777 | InParKeyword error
2784 $$.inout_all = false;
2786 | OutParKeyword error
2793 $$.inout_all = false;
2795 | InOutParKeyword error
2802 $$.inout_all = false;
2806 AllOrTypeList: // 65
2807 AllKeyword { $$ = 0; }
2808 | TypeList { $$ = $1; }
2817 | TypeList optError ',' optError Type
2822 | TypeList optError ',' error { $$ = $1; }
2826 ComponentKeyword IDentifier
2828 '{' optComponentDefList '}'
2831 if ($3) $5->add_extends($3);
2832 $5->set_location(infile, @$);
2833 Type *type = new Type(Type::T_COMPONENT, $5);
2834 type->set_location(infile, @$);
2835 $$ = new Def_Type($2, type);
2840 /* empty */ optError { $$ = 0; }
2841 | ExtendsKeyword ComponentTypeList optError
2844 $$->set_location(infile, @1, @2);
2846 | ExtendsKeyword error { $$ = 0; }
2850 optError ComponentType
2852 $$ = new CompTypeRefList();
2855 | ComponentTypeList optError ',' optError ComponentType
2860 | ComponentTypeList optError ',' error { $$ = $1; }
2863 ComponentType: // 81
2866 $$ = new Ttcn::Reference($1);
2867 $$->set_location(infile, @$);
2869 | IDentifier '.' IDentifier
2871 $$ = new Ttcn::Reference($1, $3);
2872 $$->set_location(infile, @$);
2874 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
2876 $$ = new Ttcn::Reference($1, $5);
2877 $$->set_location(infile, @$);
2882 optComponentDefList:
2883 optError /* empty */ { $$ = new ComponentTypeBody(); }
2884 | ComponentElementDefList optError { $$ = $1; }
2887 ComponentElementDefList:
2888 optError ComponentElementDef optSemiColon
2890 $$ = new ComponentTypeBody();
2891 for (size_t i = 0; i < $2.nElements; i++)
2892 $$->add_ass($2.elements[i]);
2895 | ComponentElementDefList optError ComponentElementDef optSemiColon
2898 for (size_t i = 0; i < $3.nElements; i++)
2899 $$->add_ass($3.elements[i]);
2904 ComponentElementVisibility:
2905 PublicKeyword { $$.visibility = PUBLIC;}
2906 | PrivateKeyword { $$.visibility = PRIVATE;}
2909 ComponentElementDef: // 84
2910 PortInstance { $$ = $1; }
2911 | VarInstance { $$ = $1; }
2912 | TimerInstance { $$ = $1; }
2913 | ConstDef { $$ = $1; }
2914 | ComponentElementVisibility PortInstance
2917 for (size_t i = 0; i < $2.nElements; i++) {
2918 $2.elements[i]->set_visibility($1.visibility);
2921 | ComponentElementVisibility VarInstance
2924 for (size_t i = 0; i < $2.nElements; i++) {
2925 $2.elements[i]->set_visibility($1.visibility);
2928 | ComponentElementVisibility TimerInstance
2931 for (size_t i = 0; i < $2.nElements; i++) {
2932 $2.elements[i]->set_visibility($1.visibility);
2935 | ComponentElementVisibility ConstDef
2938 for (size_t i = 0; i < $2.nElements; i++) {
2939 $2.elements[i]->set_visibility($1.visibility);
2945 PortKeyword PortType PortElementList
2947 $$.nElements = $3.nElements;
2948 $$.elements = (Ttcn::Definition**)
2949 Malloc($$.nElements*sizeof(*$$.elements));
2950 for (size_t i = 0; i < $3.nElements; i++) {
2951 Ttcn::Reference *ref = i > 0 ? $2->clone() : $2;
2952 $$.elements[i] = new Ttcn::Def_Port($3.elements[i].id, ref,
2953 $3.elements[i].dims);
2954 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
2961 optError PortElement
2964 $$.elements = (YYSTYPE::portelement_t*)Malloc(sizeof(*$$.elements));
2965 $$.elements[0] = $2;
2967 | PortElementList ',' optError PortElement
2969 $$.nElements = $1.nElements + 1;
2970 $$.elements = (YYSTYPE::portelement_t*)
2971 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
2972 $$.elements[$$.nElements - 1] = $4;
2974 | PortElementList ',' error { $$ = $1; }
2978 IDentifier optArrayDef
2981 if ($2.nElements > 0) {
2982 $$.dims = new ArrayDimensions;
2983 for (size_t i = 0; i < $2.nElements; i++) $$.dims->add($2.elements[i]);
2990 /* A.1.6.1.2 Constant definitions */
2993 ConstKeyword Type ConstList
2995 $$.nElements = $3.nElements;
2996 $$.elements = (Ttcn::Definition**)
2997 Malloc($$.nElements*sizeof(*$$.elements));
2998 for (size_t i = 0; i < $$.nElements; i++) {
3001 type = new Type(Type::T_REFDSPEC, $2);
3002 type->set_location(*$2);
3004 /* creation of array type(s) if necessary (from right to left) */
3005 for (size_t j = $3.elements[i].arrays.nElements; j > 0; j--) {
3006 type = new Type(Type::T_ARRAY, type,
3007 $3.elements[i].arrays.elements[j - 1], false);
3008 type->set_location(*$2);
3010 Free($3.elements[i].arrays.elements);
3012 /* Create the definition */
3013 $$.elements[i] = new Def_Const($3.elements[i].id,
3014 type, $3.elements[i].initial_value);
3015 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
3022 optError SingleConstDef
3025 $$.elements = (YYSTYPE::singlevarinst_t*)Malloc(sizeof(*$$.elements));
3026 $$.elements[0] = $2;
3028 | ConstList ',' optError SingleConstDef
3030 $$.nElements = $1.nElements + 1;
3031 $$.elements = (YYSTYPE::singlevarinst_t*)
3032 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
3033 $$.elements[$$.nElements - 1] = $4;
3037 SingleConstDef: // 90
3038 IDentifier optArrayDef AssignmentChar Expression
3042 $$.initial_value = $4;
3048 FunctionKeyword IDentifier '(' optFunctionFormalParList ')'
3049 optRunsOnComprefOrSelf optReturnType
3051 $4->set_location(infile, @3, @5);
3052 Type *type = new Type(Type::T_FUNCTION, $4, $6.reference, $6.self, $7.type,
3053 $7.returns_template, $7.template_restriction);
3054 type->set_location(infile, @$);
3055 $$ = new Ttcn::Def_Type($2, type);
3056 $$->set_location(infile, @$);
3061 AltstepKeyword IDentifier '(' optAltstepFormalParList ')'
3062 optRunsOnComprefOrSelf
3064 $4->set_location(infile, @3, @5);
3065 Type *type = new Type(Type::T_ALTSTEP, $4, $6.reference, $6.self);
3066 type->set_location(infile, @$);
3067 $$ = new Ttcn::Def_Type($2, type);
3068 $$->set_location(infile, @$);
3073 TestcaseKeyword IDentifier '(' optTestcaseFormalParList ')'
3076 $4->set_location(infile, @3, @5);
3077 Type *type = new Type(Type::T_TESTCASE, $4, $6.runsonref,
3079 type->set_location(infile, @$);
3080 $$ = new Ttcn::Def_Type($2, type);
3081 $$->set_location(infile, @$);
3085 /* A.1.6.1.3 Template definitions */
3088 TemplateKeyword optTemplateRestriction BaseTemplate
3089 optDerivedDef AssignmentChar TemplateBody
3091 $$ = new Def_Template($2, $3.name, $3.type, $3.fp_list, $4, $6);
3092 $$->set_location(infile, @$);
3097 Type IDentifier optTemplateFormalParList
3103 /* | Signature IDentifier optTemplateFormalParList -- covered by the previous
3108 /* empty */ { $$ = 0; }
3109 | DerivedDef { $$ = $1; }
3113 ModifiesKeyword TemplateRef
3115 $$ = new Ttcn::Reference($2.modid, $2.id);
3116 $$->set_location(infile, @$);
3118 | ModifiesKeyword error { $$ = 0; }
3121 optTemplateFormalParList:
3122 /* empty */ optError { $$ = 0; }
3123 | '(' TemplateFormalParList optError ')'
3126 $$->set_location(infile, @$);
3130 $$ = new FormalParList;
3131 $$->set_location(infile, @$);
3135 TemplateFormalParList: // 99 is a FormalParList*
3136 optError TemplateFormalPar
3138 $$ = new FormalParList;
3141 | TemplateFormalParList optError ',' optError TemplateFormalPar
3146 | TemplateFormalParList optError ',' error { $$ = $1; }
3149 TemplateFormalPar: // 100
3150 FormalValuePar { $$ = $1; }
3151 | FormalTemplatePar { $$ = $1; }
3154 TemplateBody: // 101 is a Template*
3155 SimpleSpec optExtraMatchingAttributes
3158 $$->set_length_restriction($2.len_restr);
3159 $$->set_ifpresent($2.is_ifpresent);
3161 | FieldSpecList optExtraMatchingAttributes
3164 $$->set_length_restriction($2.len_restr);
3165 $$->set_ifpresent($2.is_ifpresent);
3167 | ArraySpecList optExtraMatchingAttributes
3170 $$->set_length_restriction($2.len_restr);
3171 $$->set_ifpresent($2.is_ifpresent);
3173 | ArrayValueOrAttrib optExtraMatchingAttributes
3176 $$->set_length_restriction($2.len_restr);
3177 $$->set_ifpresent($2.is_ifpresent);
3182 SingleValueOrAttrib { $$ = $1; }
3185 FieldSpecList: // 103
3188 $$ = new Template(Template::TEMPLATE_LIST, new Templates());
3189 $$->set_location(infile, @$);
3192 | '{' seqFieldSpec optError '}'
3194 $$ = new Template($2); // NAMED_TEMLATE_LIST
3195 $$->set_location(infile, @$);
3199 $$ = new Template(Template::TEMPLATE_ERROR);
3200 $$->set_location(infile, @$);
3204 /* Sequence of FieldSpec. \note Cannot be empty */
3205 seqFieldSpec: // a NamedTemplates*
3208 $$ = new NamedTemplates();
3213 $$ = new NamedTemplates();
3216 | seqFieldSpec optError ',' optError FieldSpec
3221 | seqFieldSpec optError ',' error { $$ = $1; }
3224 FieldSpec: // 104 a NamedTemplate*
3225 FieldReference AssignmentChar TemplateBody
3227 $$ = new NamedTemplate($1, $3);
3228 $$->set_location(infile, @$);
3230 | FieldReference AssignmentChar NotUsedSymbol
3232 Template* temp = new Template(Template::TEMPLATE_NOTUSED);
3233 temp->set_location(infile, @3);
3234 $$ = new NamedTemplate($1, temp);
3235 $$->set_location(infile, @$);
3239 FieldReference: // 105
3240 StructFieldRef { $$ = $1; }
3241 /* | ArrayOrBitRef -- covered by ArraySpecList */
3242 /* | ParRef -- covered by StructFieldRef */
3245 StructFieldRef: // 106 (and 107. ParRef)
3246 PredefOrIdentifier { $$ = $1; }
3248 Note: Non-parameterized type references are covered by (StructField)Identifier.
3249 Parameterized type references are covered by FunctionInstance */
3252 Location loc(infile, @$);
3253 loc.error("Reference to a parameterized field of type `anytype' is "
3254 "not currently supported");
3256 $$ = new Identifier(Identifier::ID_TTCN, string("<error>"));
3261 '{' seqArraySpec optError '}'
3263 $$ = new Template($2);
3264 $$->set_location(infile, @$);
3271 $$ = new IndexedTemplates();
3274 /* It was optError before. */
3277 $$ = new IndexedTemplates();
3280 | seqArraySpec optError ',' optError ArraySpec
3285 | seqArraySpec optError ',' error { $$ = $1; }
3289 ArrayOrBitRef AssignmentChar TemplateBody
3291 $$ = new IndexedTemplate($1, $3);
3292 $$->set_location(infile, @$);
3296 ArrayOrBitRef: // 109
3299 $$ = new FieldOrArrayRef($2);
3300 $$->set_location(infile, @$);
3304 $$ = new FieldOrArrayRef(new Value(Value::V_ERROR));
3305 $$->set_location(infile, @$);
3309 SingleValueOrAttrib: // 111
3310 MatchingSymbol { $$ = $1; }
3313 if ($1->get_valuetype() == Value::V_OMIT) {
3315 $$ = new Template(Template::OMIT_VALUE);
3316 } else $$ = new Template($1); // SPECIFIC_VALUE; SingleExpr is a Template*
3317 $$->set_location(infile, @$);
3319 /* | TemplateRefWithParList -- covered by SingleExpression */
3322 ArrayValueOrAttrib: // 112
3323 '{' ArrayElementSpecList optError '}'
3325 $$ = new Template(Template::TEMPLATE_LIST, $2);
3326 $$->set_location(infile, @$);
3330 ArrayElementSpecList: // 113
3336 | error ArrayElementSpec
3341 | ArrayElementSpecList optError ',' optError ArrayElementSpec
3346 | ArrayElementSpecList optError ',' error { $$ = $1; }
3349 ArrayElementSpec: // 114 is a Template*
3352 $$ = new Template(Template::TEMPLATE_NOTUSED);
3353 $$->set_location(infile, @$);
3357 $$ = new Template(Template::PERMUTATION_MATCH, $1);
3358 $$->set_location(infile, @$);
3360 | TemplateListElem { $$ = $1; }
3363 NotUsedSymbol: // 115
3367 MatchingSymbol: // 116 is a Template*
3370 $$ = new Template(Template::COMPLEMENTED_LIST, $1);
3371 $$->set_location(infile, @$);
3375 $$ = new Template(Template::ANY_VALUE);
3376 $$->set_location(infile, @$);
3380 $$ = new Template(Template::ANY_OR_OMIT);
3381 $$->set_location(infile, @$);
3385 $$ = new Template(Template::VALUE_LIST, $1);
3386 $$->set_location(infile, @$);
3390 $$ = new Template($1);
3391 $$->set_location(infile, @$);
3395 $$ = new Template(Template::BSTR_PATTERN, $1);
3396 $$->set_location(infile, @$);
3400 $$ = new Template(Template::HSTR_PATTERN, $1);
3401 $$->set_location(infile, @$);
3405 $$ = new Template(Template::OSTR_PATTERN, $1);
3406 $$->set_location(infile, @$);
3410 $$ = new Template($1);
3411 $$->set_location(infile, @$);
3415 $$ = new Template(Template::SUBSET_MATCH, $1);
3416 $$->set_location(infile, @$);
3420 $$ = new Template(Template::SUPERSET_MATCH, $1);
3421 $$->set_location(infile, @$);
3423 | '(' AllElementsFrom ')'
3425 $$ = new Template(Template::VALUE_LIST_ALL_FROM, $2);
3426 $$->set_location(infile, @$);
3430 optExtraMatchingAttributes: // [117]
3433 $$.is_ifpresent = false;
3434 $$.len_restr = NULL;
3439 $$.is_ifpresent = false;
3443 $$.len_restr = NULL;
3444 $$.is_ifpresent = true;
3446 | LengthMatch IfPresentMatch
3449 $$.is_ifpresent = true;
3453 CharStringMatch: // 124
3454 PatternKeyword PatternChunkList
3456 Location loc(infile, @2);
3457 $$ = parse_pattern($2, loc);
3460 | PatternKeyword NocaseKeyword PatternChunkList
3462 // @nocase is ignored for now
3463 Location loc(infile, @3);
3464 $$ = parse_pattern($3, loc);
3474 | PatternChunkList '&' PatternChunk
3477 $$ = mputstr($$, $3);
3489 switch ($1->get_valuetype()) {
3490 case Value::V_REFD: {
3491 /* Pretend to be a reference. Let pstring_la.l discover the
3493 Common::Reference *ref = $1->get_reference();
3494 $$ = mprintf("{%s}", (ref->get_dispname()).c_str());
3496 case Value::V_UNDEF_LOWERID: {
3497 const Common::Identifier *id = $1->get_val_id();
3498 $$ = mprintf("{%s}", (id->get_dispname()).c_str());
3501 FATAL_ERROR("Internal error.");
3503 /* Forget the Node. */
3508 ustring::universal_char& uc = $1->operator[](0);
3509 $$ = mprintf("\\q{%d,%d,%d,%d}", uc.group, uc.plane, uc.row, uc.cell);
3514 Complement: // 130 is a Templates*
3515 ComplementKeyword ValueList { $$ = $2; }
3518 ValueList: // 132 is a Templates*
3519 '(' seqValueOrAttrib optError ')' { $$ = $2; }
3520 | '(' error ')' { $$ = new Templates; }
3523 seqValueOrAttrib: // is a Templates*
3524 optError TemplateListElem
3529 | seqValueOrAttrib optError ',' optError TemplateListElem
3534 | seqValueOrAttrib optError ',' error { $$ = $1; }
3537 SubsetMatch: // 133 is a Templates*
3538 SubsetKeyword ValueList { $$ = $2; }
3541 SupersetMatch: // 135 is a Templates*
3542 SupersetKeyword ValueList { $$ = $2; }
3545 PermutationMatch: // 137 is a Templates*
3546 PermutationKeyword ValueList { $$ = $2; }
3557 TemplateListElem: // is a Template*
3562 AllElementsFrom: // is a Template*
3563 AllKeyword FromKeyword TemplateBody
3564 { // $3 is a Template*
3565 $$ = new Template($3); // Constructs ALL_FROM
3566 $$->set_location(infile, @$);
3570 ValueOrAttribList: // 142 is a Templates*
3571 /* ValueOrAttribList always has two or more elements
3572 * (there's always a comma) and is reduced through
3573 * ValueOrAttribList -> MatchingSymbol -> SingleValueOrAttrib
3575 * The one-element list is reduced through
3576 * '(' SingleExpression ')' -> SingleExpression -> SingleValueOrAttrib */
3577 '(' TemplateListElem optError ',' seqValueOrAttrib optError ')'
3580 $$->add_front_t($2);
3582 | '(' error TemplateListElem optError ',' seqValueOrAttrib optError ')'
3585 $$->add_front_t($3);
3590 StringLength { $$ = $1; }
3593 IfPresentMatch: // 144
3598 '(' SingleLowerBound DotDot UpperBound optError ')'
3599 { $$ = new ValueRange($2, $4); }
3605 if ($1->is_parsed_infinity()==-1) {
3606 /* the conflicting rule alternative faked here: '-' InfinityKeyword */
3618 if ($1->is_parsed_infinity()==-1) {
3619 /* the conflicting rule alternative faked here: '-' InfinityKeyword */
3631 if ($1->is_parsed_infinity()==1) {
3632 /* the conflicting rule alternative faked here: InfinityKeyword */
3641 TemplateInstance: // 151
3642 InLineTemplate { $$ = $1; }
3645 TemplateRefWithParList: /* refbase */ // 153 ?
3646 TemplateRef optTemplateActualParList
3649 $$ = new Ttcn::Ref_pard($1.modid, $1.id, new ParsedActualParameters($2));
3650 $$->set_location(infile, @$);
3652 $$ = new Ttcn::Reference($1.modid, $1.id);
3653 $$->set_location(infile, @$);
3664 | IDentifier '.' IDentifier
3669 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
3677 InLineTemplate: // 155
3680 $$ = new TemplateInstance(0, 0, $1);
3681 $$->set_location(infile, @$);
3683 | Type ':' TemplateBody
3685 $$ = new TemplateInstance($1, 0, $3);
3686 $$->set_location(infile, @$);
3688 /* | Signature ':' TemplateBody -- covered by the previous rule */
3689 | DerivedRefWithParList AssignmentChar TemplateBody
3691 $$ = new TemplateInstance(0, $1, $3);
3692 $$->set_location(infile, @$);
3694 | Type ':' DerivedRefWithParList AssignmentChar TemplateBody
3696 $$ = new TemplateInstance($1, $3, $5);
3697 $$->set_location(infile, @$);
3699 /* | Signature ':' DerivedRefWithParList AssignmentChar TemplateBody
3700 -- covered by the previous rule */
3703 DerivedRefWithParList: // 156
3704 ModifiesKeyword TemplateRefWithParList { $$ = $2; }
3707 optTemplateActualParList: // [157]
3708 /* empty */ optError { $$ = 0; }
3709 | '(' seqTemplateActualPar optError ')'
3712 $$->set_location(infile, @$);
3716 $$ = new TemplateInstances;
3717 $$->set_location(infile, @$);
3721 seqTemplateActualPar:
3722 optError TemplateActualPar
3724 $$ = new TemplateInstances;
3727 | seqTemplateActualPar optError ',' optError TemplateActualPar
3732 | seqTemplateActualPar optError ',' error { $$ = $1; }
3735 TemplateActualPar: // 158
3736 TemplateInstance { $$ = $1; }
3739 Template *t = new Template(Template::TEMPLATE_NOTUSED);
3740 t->set_location(infile, @$);
3741 $$ = new TemplateInstance(0, 0, t);
3742 $$->set_location(infile, @$);
3747 MatchOp { $$ = $1; }
3748 | ValueofOp { $$ = $1; }
3752 MatchKeyword '(' optError Expression optError ',' optError TemplateInstance
3755 $$ = new Value(Value::OPTYPE_MATCH, $4, $8);
3756 $$->set_location(infile, @$);
3758 | MatchKeyword '(' error ')'
3760 Value *v = new Value(Value::V_ERROR);
3761 v->set_location(infile, @3);
3762 Template *t = new Template(Template::TEMPLATE_ERROR);
3763 t->set_location(infile, @3);
3764 TemplateInstance *ti = new TemplateInstance(0, 0, t);
3765 ti->set_location(infile, @3);
3766 $$ = new Value(Value::OPTYPE_MATCH, v, ti);
3767 $$->set_location(infile, @$);
3772 ValueofKeyword '(' optError TemplateInstance optError ')'
3774 $$ = new Value(Value::OPTYPE_VALUEOF, $4);
3775 $$->set_location(infile, @$);
3777 | ValueofKeyword '(' error ')'
3779 Template *t = new Template(Template::TEMPLATE_ERROR);
3780 t->set_location(infile, @3);
3781 TemplateInstance *ti = new TemplateInstance(0, 0, t);
3782 ti->set_location(infile, @3);
3783 $$ = new Value(Value::OPTYPE_VALUEOF, ti);
3784 $$->set_location(infile, @$);
3788 /* A.1.6.1.4 Function definitions */
3791 FunctionKeyword IDentifier '(' optFunctionFormalParList ')'
3792 optRunsOnSpec optReturnType optError StatementBlock
3794 $4->set_location(infile, @3, @5);
3795 $$ = new Def_Function($2, $4, $6, $7.type, $7.returns_template,
3796 $7.template_restriction, $9);
3797 $$->set_location(infile, @$);
3801 optFunctionFormalParList: // [167]
3802 /* empty */ { $$ = new FormalParList; }
3803 | FunctionFormalParList { $$ = $1; }
3804 | error { $$ = new FormalParList; }
3807 FunctionFormalParList: // 167
3808 optError FunctionFormalPar
3810 $$ = new FormalParList;
3813 | FunctionFormalParList optError ',' optError FunctionFormalPar
3818 | FunctionFormalParList optError ',' error { $$ = $1; }
3821 FunctionFormalPar: // 168
3822 FormalValuePar { $$ = $1; }
3823 | FormalTimerPar { $$ = $1; }
3824 | FormalTemplatePar { $$ = $1; }
3825 /*| FormalPortPar -- covered by FormalValuePar */
3828 optReturnType: // [169]
3832 $$.returns_template = false;
3833 $$.template_restriction = TR_NONE;
3835 | ReturnKeyword Type
3838 $$.returns_template = false;
3839 $$.template_restriction = TR_NONE;
3841 | ReturnKeyword TemplateOptRestricted Type
3844 $$.returns_template = true;
3845 $$.template_restriction = $2;
3847 | ReturnKeyword error
3850 $$.returns_template = false;
3851 $$.template_restriction = TR_NONE;
3855 optRunsOnComprefOrSelf:
3861 | RunsKeyword OnKeyword SelfKeyword
3869 /* empty */ { $$ = 0; }
3870 | RunsOnSpec { $$ = $1; }
3871 | RunsKeyword error { $$ = 0; }
3875 RunsKeyword OnKeyword ComponentType { $$ = $3; }
3878 /* StatementBlock changed in 4.1.2 to explicitly prevent statements
3879 * followed by definitions. TITAN still allows them to be mixed. */
3880 StatementBlock: /* StatementBlock *statementblock */ // 175
3883 $$ = new StatementBlock;
3884 $$->set_location(infile, @$);
3886 | '{' FunctionStatementOrDefList optError '}'
3889 $$->set_location(infile, @$);
3893 FunctionStatementOrDefList: // (171 in 3.2.1)
3894 optError FunctionStatementOrDef optSemiColon
3896 $$ = new StatementBlock;
3897 for(size_t i=0; i<$2.nElements; i++) $$->add_stmt($2.elements[i]);
3900 | FunctionStatementOrDefList optError FunctionStatementOrDef optSemiColon
3903 for(size_t i=0; i<$3.nElements; i++) $$->add_stmt($3.elements[i]);
3908 FunctionStatementOrDef: // (172 in 3.2.1)
3909 FunctionLocalDef // constant or template definition
3911 $$.nElements=$1.nElements;
3912 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
3913 for(size_t i=0; i<$1.nElements; i++) {
3914 $$.elements[i]=new Statement(Statement::S_DEF, $1.elements[i]);
3915 $$.elements[i]->set_location(*$1.elements[i]);
3919 | FunctionLocalInst // variable or timer instance
3921 $$.nElements=$1.nElements;
3922 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
3923 for(size_t i=0; i<$1.nElements; i++) {
3924 $$.elements[i]=new Statement(Statement::S_DEF, $1.elements[i]);
3925 $$.elements[i]->set_location(*$1.elements[i]);
3932 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
3937 FunctionLocalInst: // 178
3938 VarInstance { $$=$1; }
3939 | TimerInstance { $$=$1; }
3942 FunctionLocalDef: // 179
3948 $$.elements = (Ttcn::Definition**)Malloc(sizeof(*$$.elements));
3949 $$.elements[0] = $1;
3953 FunctionStatement: // 180
3954 ConfigurationStatements {$$=$1;}
3955 | TimerStatements {$$=$1;}
3956 | CommunicationStatements {$$=$1;}
3957 | BasicStatements {$$=$1;}
3958 | BehaviourStatements {$$=$1;}
3959 | VerdictStatements {$$=$1;}
3960 | SUTStatements {$$=$1;}
3961 | StopExecutionStatement { $$ = $1; }
3962 | StopTestcaseStatement { $$ = $1; }
3963 | ProfilerStatement { $$ = $1; }
3964 | int2enumStatement { $$ = $1; }
3967 FunctionInstance: /* refpard */ // 181
3968 FunctionRef '(' optFunctionActualParList ')'
3969 /* templateref templinsts */
3971 $3->set_location(infile, @2, @4);
3972 $$ = new Ttcn::Ref_pard($1.modid, $1.id, $3);
3973 $$->set_location(infile, @$);
3983 | IDentifier '.' IDentifier
3988 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
3996 optFunctionActualParList: /* parsedpar */ // [185]
3997 /* empty */ optError { $$ = new ParsedActualParameters; }
3998 | FunctionActualParList optError { $$ = $1; }
4001 /* ***** this * can * not * be * empty ****************** */
4002 FunctionActualParList: /* parsedpar */ // 184
4005 | UnnamedPart ',' NamedPart
4006 /* Splitting the NamedPart and UnnamedPart ensures that a named parameter
4007 * followed by an unnamed one causes a syntax error */
4009 /* UnnamedPart becomes the value */
4011 /* append the elements from NamedPart */
4012 const size_t n3 = $3->get_nof_nps();
4013 for (size_t i = 0; i < n3; ++i) {
4014 $$->add_np( $3->extract_np_byIndex(i) );
4020 UnnamedPart: /* parsedpar */
4021 /*optError*/ FunctionActualPar
4023 $$ = new ParsedActualParameters;
4026 | UnnamedPart /*optError*/ ',' /*optError*/ FunctionActualPar
4027 /* These optErrors mess up the parsing of actual parameters.
4028 * After only one FunctionActualPar, it is reduced to UnnamedPart
4029 * and the rest is expected to be the NamedPart */
4034 | UnnamedPart optError ',' error { $$ = $1; }
4037 NamedPart: /* parsedpar */
4038 seqFieldSpec /* namedtempls */
4040 $$ = new ParsedActualParameters(0, new NamedParams);
4041 const size_t n1 = $1->get_nof_nts();
4042 for (size_t i = 0; i < n1; ++i) {
4043 NamedTemplate *pnt = $1->get_nt_byIndex(i);
4044 TemplateInstance *pti = new TemplateInstance(0,0,pnt->extract_template());
4045 NamedParam *pnp = new NamedParam(pnt->get_name().clone(), pti);
4046 pnp->set_location(*pnt);
4050 $$->set_location(infile, @$);
4051 // This call to ParsedActualParameters::set_location copies the same
4052 // location info to the named and unnamed part. We cannot copy
4053 // the location info from the NamedTemplates to the named part,
4054 // because NamedTemplates is not a Location.
4058 FunctionActualPar: /* templinst */ // 185
4060 TemplateInstance { $$ = $1; }
4063 Template *t = new Template(Template::TEMPLATE_NOTUSED);
4064 t->set_location(infile, @$);
4065 $$ = new TemplateInstance(0, 0, t);
4066 $$->set_location(infile, @$);
4069 | ComponentRef -- TemplateInstance covers all the others */
4073 Reference DotApplyKeyword '(' optFunctionActualParList ')'
4075 if($1.is_ref) $$.value = new Value(Value::V_REFD, $1.ref);
4077 Ttcn::Reference *t_ref = new Ttcn::Reference($1.id);
4078 t_ref->set_location(infile, @1);
4079 $$.value = new Value(Value::V_REFD, t_ref);
4081 $$.value->set_location(infile, @1);
4083 $$.ap_list->set_location(infile, @3 , @5);
4085 | FunctionInstance DotApplyKeyword '(' optFunctionActualParList ')'
4087 $$.value = new Value(Value::V_REFD, $1);
4088 $$.value->set_location(infile, @1);
4090 $$.ap_list->set_location(infile, @3 , @5);
4092 | ApplyOp DotApplyKeyword '(' optFunctionActualParList ')'
4094 $$.value = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
4095 $$.value->set_location(infile, @1);
4097 $$.ap_list->set_location(infile, @3 , @5);
4102 DerefersKeyword '(' Expression ')' { $$ = $3; }
4105 /* A.1.6.1.5 Signature definitions */
4107 SignatureDef: // 187
4108 SignatureKeyword IDentifier
4109 '(' optSignatureFormalParList ')' optReturnTypeOrNoBlockKeyword
4112 Type *type = new Type(Type::T_SIGNATURE, $4, $6.type, $6.no_block_kw, $7);
4113 type->set_location(infile, @3, @7);
4114 $$ = new Ttcn::Def_Type($2, type);
4115 $$->set_location(infile, @$);
4119 optSignatureFormalParList: // [190]
4120 /* empty */ { $$ = 0; }
4121 | SignatureFormalParList { $$ = $1; }
4125 SignatureFormalParList: // 190
4126 optError SignatureFormalPar
4128 $$ = new SignatureParamList;
4131 | SignatureFormalParList optError ',' optError SignatureFormalPar
4136 | SignatureFormalParList optError ',' error { $$ = $1; }
4139 SignatureFormalPar: // 191
4142 $$ = new SignatureParam(SignatureParam::PARAM_IN, $1, $2);
4143 $$->set_location(infile, @$);
4145 | InParKeyword Type IDentifier
4147 $$ = new SignatureParam(SignatureParam::PARAM_IN, $2, $3);
4148 $$->set_location(infile, @$);
4150 | InOutParKeyword Type IDentifier
4152 $$ = new SignatureParam(SignatureParam::PARAM_INOUT, $2, $3);
4153 $$->set_location(infile, @$);
4155 | OutParKeyword Type IDentifier
4157 $$ = new SignatureParam(SignatureParam::PARAM_OUT, $2, $3);
4158 $$->set_location(infile, @$);
4162 optReturnTypeOrNoBlockKeyword:
4166 $$.no_block_kw = false;
4168 | ReturnKeyword Type
4171 $$.no_block_kw = false;
4176 $$.no_block_kw = true;
4180 optExceptionSpec: // [192]
4181 /* empty */ { $$ = NULL; }
4182 | ExceptionKeyword '(' error ')' { $$ = NULL; }
4183 | ExceptionKeyword '(' ExceptionTypeList optError ')'
4186 $$->set_location(infile, @$);
4190 ExceptionTypeList: // 194
4193 $$ = new SignatureExceptions;
4196 | ExceptionTypeList optError ',' optError Type
4201 | ExceptionTypeList optError ',' error { $$ = $1; }
4207 $$ = new Ttcn::Reference($1);
4208 $$->set_location(infile, @$);
4210 | IDentifier '.' IDentifier
4212 $$ = new Ttcn::Reference($1, $3);
4213 $$->set_location(infile, @$);
4215 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
4217 $$ = new Ttcn::Reference($1, $5);
4218 $$->set_location(infile, @$);
4223 /* A.1.6.1.6 Testcase definitions */
4226 TestcaseKeyword IDentifier '(' optTestcaseFormalParList ')'
4227 ConfigSpec optError StatementBlock
4229 $4->set_location(infile, @3, @5);
4230 $$ = new Def_Testcase($2, $4, $6.runsonref, $6.systemref, $8);
4231 $$->set_location(infile, @$);
4235 optTestcaseFormalParList: // [200]
4236 /* empty */ { $$ = new FormalParList; }
4237 | TestcaseFormalParList { $$ = $1; }
4238 | error { $$ = new FormalParList; }
4241 TestcaseFormalParList: // 200
4242 optError TestcaseFormalPar
4244 $$ = new FormalParList;
4247 | TestcaseFormalParList optError ',' optError TestcaseFormalPar
4252 | TestcaseFormalParList optError ',' error { $$ = $1; }
4255 TestcaseFormalPar: // 201
4256 FormalValuePar { $$ = $1; }
4257 | FormalTemplatePar { $$ = $1; }
4261 RunsOnSpec optSystemSpec
4268 optSystemSpec: // [203]
4269 /* empty */ { $$ = 0; }
4270 | SystemKeyword ComponentType { $$ = $2; }
4271 | SystemKeyword error { $$ = 0; }
4274 TestcaseInstance: // 205
4275 ExecuteKeyword '(' TestcaseRef '(' optTestcaseActualParList ')'
4276 optTestcaseTimerValue optError ')'
4278 $5->set_location(infile, @4, @6);
4279 $$.ref_pard = new Ttcn::Ref_pard($3.modid, $3.id, $5);
4280 $$.ref_pard->set_location(infile, @3, @6);
4281 $$.derefered_value = 0;
4285 | ExecuteKeyword '(' DereferOp '(' optTestcaseActualParList ')'
4286 optTestcaseTimerValue optError ')'
4288 $5->set_location(infile, @4, @6);
4290 $$.derefered_value = $3;
4294 | ExecuteKeyword '(' error ')'
4297 $$.derefered_value = 0;
4309 | IDentifier '.' IDentifier
4314 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
4322 optTestcaseTimerValue:
4323 /* empty */ { $$ = 0; }
4324 | ',' optError Expression { $$ = $3; }
4327 $$ = new Value(Value::V_ERROR);
4328 $$->set_location(infile, @$);
4332 optTestcaseActualParList: // [202]
4333 /* empty */ optError { $$ = new ParsedActualParameters; }
4334 | TestcaseActualParList optError { $$ = $1; }
4337 TestcaseActualParList: // 208
4340 | UnnamedPart ',' NamedPart
4341 /* Splitting the NamedPart and UnnamedPart ensures that a named parameter
4342 * followed by an unnamed one causes a syntax error */
4344 /* UnnamedPart becomes the value */
4346 /* append the elements from NamedPart */
4347 const size_t n3 = $3->get_nof_nps();
4348 for (size_t i = 0; i < n3; ++i) {
4349 $$->add_np( $3->extract_np_byIndex(i) );
4355 optError TestcaseActualPar
4357 $$ = new TemplateInstances;
4360 | TestcaseActualParList optError ',' optError TestcaseActualPar
4365 | TestcaseActualParList optError ',' error { $$ = $1; }
4371 TemplateInstance { $$ = $1; }
4374 Template *t = new Template(Template::TEMPLATE_NOTUSED);
4375 t->set_location(infile, @$);
4376 $$ = new TemplateInstance(0, 0, t);
4377 $$->set_location(infile, @$);
4382 /* A.1.6.1.7 Altstep definitions */
4385 AltstepKeyword IDentifier '(' optAltstepFormalParList ')' optRunsOnSpec
4386 optError '{' AltstepLocalDefList AltGuardList optError '}'
4388 StatementBlock *sb = new StatementBlock;
4389 for (size_t i = 0; i < $9.nElements; i++) {
4390 Statement *stmt = new Statement(Statement::S_DEF, $9.elements[i]);
4391 stmt->set_location(*$9.elements[i]);
4395 $4->set_location(infile, @4);
4396 $$ = new Def_Altstep($2, $4, $6, sb, $10);
4397 $$->set_location(infile, @$);
4401 optAltstepFormalParList: // [214]
4402 /* empty */ { $$ = new FormalParList; }
4403 | FunctionFormalParList { $$ = $1; }
4404 | error { $$ = new FormalParList; }
4407 AltstepLocalDefList: // 215
4413 | AltstepLocalDefList optError AltstepLocalDef optSemiColon
4415 $$.nElements = $1.nElements + $3.nElements;
4416 $$.elements = (Ttcn::Definition**)
4417 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4418 memcpy($$.elements + $1.nElements, $3.elements,
4419 $3.nElements * sizeof(*$$.elements));
4424 AltstepLocalDef: // 216
4425 VarInstance { $$ = $1; }
4426 | TimerInstance { $$ = $1; }
4427 | ConstDef { $$ = $1; }
4432 $$.elements = (Ttcn::Definition**)Malloc(sizeof(*$$.elements));
4433 $$.elements[0] = $1;
4437 AltstepInstance: /* refpard */ // 217
4438 FunctionRef '(' optFunctionActualParList ')'
4440 $3->set_location(infile, @2, @4);
4441 $$ = new Ttcn::Ref_pard($1.modid, $1.id, $3);
4442 $$->set_location(infile, @$);
4446 /* Taken over by FunctionRef
4449 | IDentifier '.' IDentifier
4450 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
4454 /* A.1.6.1.8 Import definitions */
4457 ImportKeyword ImportFromSpec AllWithExcepts
4459 $2->set_imptype(ImpMod::I_ALL);
4460 $2->set_location(infile, @$);
4464 | ImportKeyword ImportFromSpec '{' ImportSpec '}'
4466 Location loc(infile, @$);
4467 if ( $4 == ImpMod::I_IMPORTSPEC) {
4468 loc.warning("Unsupported selective import statement was treated as "
4471 $2->set_imptype($4);
4472 $2->set_location(infile, @$);
4478 AllWithExcepts: // 221
4480 | AllKeyword ExceptsDef
4482 Location loc(infile, @$);
4483 loc.warning("Unsupported selective import statement was treated as "
4489 ExceptKeyword '{' ExceptSpec '}'
4493 /* empty */ optError
4494 | ExceptSpec ExceptElement optSemiColon
4497 ExceptElement: // 225
4500 | ExceptTemplateSpec
4502 | ExceptTestcaseSpec
4504 | ExceptFunctionSpec
4505 | ExceptSignatureSpec
4506 | ExceptModuleParSpec
4509 ExceptGroupSpec: // 226
4510 GroupKeyword ExceptGroupRefList
4511 | GroupKeyword AllKeyword
4514 ExceptTypeDefSpec: // 227
4515 TypeDefKeyword TypeRefList
4516 | TypeDefKeyword AllKeyword
4519 ExceptTemplateSpec: // 228
4520 TemplateKeyword TemplateRefList
4521 | TemplateKeyword AllKeyword
4524 ExceptConstSpec: // 229
4525 ConstKeyword ConstRefList
4526 | ConstKeyword AllKeyword
4529 ExceptTestcaseSpec: // 230
4530 TestcaseKeyword TestcaseRefList
4531 | TestcaseKeyword AllKeyword
4534 ExceptAltstepSpec: // 231
4535 AltstepKeyword AltstepRefList
4536 | AltstepKeyword AllKeyword
4539 ExceptFunctionSpec: // 232
4540 FunctionKeyword FunctionRefList
4541 | FunctionKeyword AllKeyword
4544 ExceptSignatureSpec: // 233
4545 SignatureKeyword SignatureRefList
4546 | SignatureKeyword AllKeyword
4549 ExceptModuleParSpec: // 234
4550 ModuleParKeyword ModuleParRefList
4551 | ModuleParKeyword AllKeyword
4555 /* empty */ optError
4556 { $$ = ImpMod::I_ALL; }
4557 | ImportSpec ImportElement optSemiColon
4560 case ImpMod::I_ALL: // it was empty before
4564 case ImpMod::I_IMPORTSPEC:
4566 case ImpMod::I_IMPORTSPEC:
4567 // selective import followed by another selective import: NOP
4569 case ImpMod::I_IMPORTIMPORT:
4570 $$ = $2; // import of import wins over selective import
4572 default: // including I_ALL
4573 FATAL_ERROR("Selective import cannot be followed by import all");
4577 case ImpMod::I_IMPORTIMPORT:
4579 case ImpMod::I_IMPORTSPEC:
4580 // import of import followed by selective import: NOP (import of import wins)
4582 case ImpMod::I_IMPORTIMPORT:
4583 // import of import following another import of import: error
4584 Location(infile, @2).error("Import of imports can only be used once");
4586 default: // including I_ALL
4587 FATAL_ERROR("Import of imports cannot be followed by import all");
4592 FATAL_ERROR("Invalid import type");
4597 ImportElement: // 236
4599 { $$ = ImpMod::I_IMPORTSPEC; }
4601 { $$ = ImpMod::I_IMPORTSPEC; }
4602 | ImportTemplateSpec
4603 { $$ = ImpMod::I_IMPORTSPEC; }
4605 { $$ = ImpMod::I_IMPORTSPEC; }
4606 | ImportTestcaseSpec
4607 { $$ = ImpMod::I_IMPORTSPEC; }
4609 { $$ = ImpMod::I_IMPORTSPEC; }
4610 | ImportFunctionSpec
4611 { $$ = ImpMod::I_IMPORTSPEC; }
4612 | ImportSignatureSpec
4613 { $$ = ImpMod::I_IMPORTSPEC; }
4614 | ImportModuleParSpec
4615 { $$ = ImpMod::I_IMPORTSPEC; }
4617 { $$ = ImpMod::I_IMPORTIMPORT; }
4621 ImportKeyword AllKeyword
4623 ImportFromSpec: // 237
4624 FromKeyword ModuleId { $$ = $2; }
4625 | FromKeyword ModuleId RecursiveKeyword // already deprecated in v3.2.1
4628 $$->set_recursive();
4632 ImportGroupSpec: // 239
4633 GroupKeyword GroupRefListWithExcept
4634 | GroupKeyword AllGroupsWithExcept
4635 | GroupKeyword error
4638 GroupRefList: // 240
4639 optError FullGroupIdentifier { delete $2; }
4640 | GroupRefList optError ',' optError FullGroupIdentifier { delete $5; }
4641 | GroupRefList optError ',' error
4644 GroupRefListWithExcept: // 241
4645 optError FullGroupIdentifierWithExcept
4646 | GroupRefListWithExcept optError ',' optError FullGroupIdentifierWithExcept
4647 | GroupRefListWithExcept optError ',' error
4650 AllGroupsWithExcept: // 242
4653 | AllKeyword ExceptKeyword GroupRefList
4654 | AllKeyword ExceptKeyword error
4657 FullGroupIdentifier: // 243
4660 $$ = new Qualifier();
4661 $$->add(new FieldOrArrayRef($1));
4662 $$->set_location(infile, @$);
4664 | FullGroupIdentifier '.' IDentifier
4667 $$->add(new FieldOrArrayRef($3));
4668 $$->set_location(infile, @$);
4672 FullGroupIdentifierWithExcept: // 244
4673 FullGroupIdentifier { delete $1; }
4674 | FullGroupIdentifier ExceptsDef { delete $1; }
4677 ExceptGroupRefList: // 245
4678 optError ExceptFullGroupIdentifier
4679 | ExceptGroupRefList optError ',' optError ExceptFullGroupIdentifier
4680 | ExceptGroupRefList optError ',' error
4683 ExceptFullGroupIdentifier: // 246
4684 FullGroupIdentifier { delete $1;}
4687 ImportTypeDefSpec: // 247
4688 TypeDefKeyword TypeRefList
4689 | TypeDefKeyword AllTypesWithExcept
4690 | TypeDefKeyword error
4694 optError IDentifier { delete $2; }
4695 | TypeRefList optError ',' optError IDentifier { delete $5; }
4696 | TypeRefList optError ',' error
4699 AllTypesWithExcept: // 249
4702 | AllKeyword ExceptKeyword TypeRefList
4703 | AllKeyword ExceptKeyword error
4706 /* 250. TypeDefIdentifier is replaced by IDentifier */
4708 ImportTemplateSpec: // 251
4709 TemplateKeyword TemplateRefList
4710 | TemplateKeyword AllTemplsWithExcept
4711 | TemplateKeyword error
4714 TemplateRefList: // 252
4715 optError IDentifier { delete $2; }
4716 | TemplateRefList optError ',' optError IDentifier { delete $5; }
4717 | TemplateRefList optError ',' error
4720 AllTemplsWithExcept: // 253
4723 | AllKeyword ExceptKeyword TemplateRefList
4724 | AllKeyword ExceptKeyword error
4727 ImportConstSpec: // 254
4728 ConstKeyword ConstRefList
4729 | ConstKeyword AllConstsWithExcept
4730 | ConstKeyword error
4733 ConstRefList: // 255
4734 optError IDentifier { delete $2; }
4735 | ConstRefList optError ',' optError IDentifier { delete $5; }
4736 | ConstRefList optError ',' error
4739 AllConstsWithExcept: // 256
4742 | AllKeyword ExceptKeyword ConstRefList
4743 | AllKeyword ExceptKeyword error
4746 ImportAltstepSpec: // 257
4747 AltstepKeyword AltstepRefList
4748 | AltstepKeyword AllAltstepsWithExcept
4749 | AltstepKeyword error
4752 AltstepRefList: // 258
4753 optError IDentifier { delete $2; }
4754 | AltstepRefList optError ',' optError IDentifier { delete $5; }
4755 | AltstepRefList optError ',' error
4758 AllAltstepsWithExcept: // 259
4761 | AllKeyword ExceptKeyword AltstepRefList
4762 | AllKeyword ExceptKeyword error
4765 ImportTestcaseSpec: // 260
4766 TestcaseKeyword TestcaseRefList
4767 | TestcaseKeyword AllTestcasesWithExcept
4768 | TestcaseKeyword error
4771 TestcaseRefList: // 261
4772 optError IDentifier { delete $2; }
4773 | TestcaseRefList optError ',' optError IDentifier { delete $5; }
4774 | TestcaseRefList optError ',' error
4777 AllTestcasesWithExcept: // 262
4780 | AllKeyword ExceptKeyword TestcaseRefList
4781 | AllKeyword ExceptKeyword error
4784 ImportFunctionSpec: // 263
4785 FunctionKeyword FunctionRefList
4786 | FunctionKeyword AllFunctionsWithExcept
4787 | FunctionKeyword error
4790 FunctionRefList: // 264
4791 optError IDentifier { delete $2; }
4792 | FunctionRefList optError ',' optError IDentifier { delete $5; }
4793 | FunctionRefList optError ',' error
4796 AllFunctionsWithExcept: // 265
4799 | AllKeyword ExceptKeyword FunctionRefList
4800 | AllKeyword ExceptKeyword error
4803 ImportSignatureSpec: // 266
4804 SignatureKeyword SignatureRefList
4805 | SignatureKeyword AllSignaturesWithExcept
4806 | SignatureKeyword error
4809 SignatureRefList: // 267
4810 optError IDentifier { delete $2; }
4811 | SignatureRefList optError ',' optError IDentifier { delete $5; }
4812 | SignatureRefList optError ',' error
4815 AllSignaturesWithExcept: // 268
4818 | AllKeyword ExceptKeyword SignatureRefList
4819 | AllKeyword ExceptKeyword error
4822 ImportModuleParSpec: // 269
4823 ModuleParKeyword ModuleParRefList
4824 | ModuleParKeyword AllModuleParWithExcept
4825 | ModuleParKeyword error
4828 ModuleParRefList: // 270
4829 optError IDentifier { delete $2; }
4830 | ModuleParRefList optError ',' optError IDentifier { delete $5; }
4831 | ModuleParRefList optError ',' error
4834 AllModuleParWithExcept: // 271
4837 | AllKeyword ExceptKeyword ModuleParRefList
4838 | AllKeyword ExceptKeyword error
4841 // 272 ImportImportSpec: ImportKeyword AllKeyword
4843 /* A.1.6.1.9 Group definitions */
4846 GroupIdentifier '{' optErrorBlock '}'
4849 $$->set_location(infile, @$);
4851 | GroupIdentifier '{' ModuleDefinitionsList optErrorBlock '}'
4854 $$->set_location(infile, @$);
4858 GroupIdentifier: // 274 (followed by) 275.
4859 GroupKeyword IDentifier
4862 $$->set_parent_group(act_group);
4863 $$->set_location(infile, @$);
4865 act_group->add_group($$);
4866 $$->set_parent_path(act_group->get_attrib_path());
4868 act_ttcn3_module->add_group($$);
4869 $$->set_parent_path(act_ttcn3_module->get_attrib_path());
4875 /* A.1.6.1.10 External function definitions */
4877 ExtFunctionDef: // 276
4878 ExtKeyword FunctionKeyword IDentifier
4879 '(' optFunctionFormalParList ')' optReturnType
4881 $5->set_location(infile, @4, @6);
4882 $$ = new Def_ExtFunction($3, $5, $7.type, $7.returns_template,
4883 $7.template_restriction);
4884 $$->set_location(infile, @$);
4888 /* A.1.6.1.11 External constant definitions */
4891 ExtKeyword ConstKeyword Type IdentifierList
4893 $$.nElements = $4.nElements;
4894 $$.elements = (Ttcn::Definition**)
4895 Malloc($$.nElements * sizeof(*$$.elements));
4896 for (size_t i = 0; i < $$.nElements; i++) {
4899 type = new Type(Type::T_REFDSPEC, $3);
4900 type->set_location(*$3);
4902 $$.elements[i] = new Ttcn::Def_ExtConst($4.elements[i].id, type);
4903 $$.elements[i]->set_location(infile, $4.elements[i].yyloc);
4909 IdentifierList: // 280 ExtConstIdentifierList
4913 $$.elements = (YYSTYPE::extconstidentifier_t*)Malloc(sizeof(*$$.elements));
4914 $$.elements[0].id = $2;
4915 $$.elements[0].yyloc = @2;
4917 | IdentifierList ',' optError IDentifier
4919 $$.nElements = $1.nElements + 1;
4920 $$.elements = (YYSTYPE::extconstidentifier_t*)
4921 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4922 $$.elements[$1.nElements].id = $4;
4923 $$.elements[$1.nElements].yyloc = @4;
4925 | IdentifierList ',' error { $$ = $1; }
4928 /* A.1.6.1.12 Module parameter definitions */
4930 ModuleParDef: // 282
4931 ModuleParKeyword ModulePar { $$ = $2; }
4932 | ModuleParKeyword '{' MultiTypedModuleParList optError '}' { $$ = $3; }
4933 | ModuleParKeyword '{' error '}' { $$.nElements = 0; $$.elements = NULL; }
4936 MultiTypedModuleParList: // 284
4937 optError ModulePar optSemiColon { $$ = $2; }
4938 | MultiTypedModuleParList optError ModulePar optSemiColon
4940 $$.nElements = $1.nElements + $3.nElements;
4941 $$.elements = (Ttcn::Definition**)
4942 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4943 memcpy($$.elements + $1.nElements, $3.elements,
4944 $3.nElements * sizeof(*$$.elements));
4952 $$.nElements = $2.nElements;
4953 $$.elements = (Ttcn::Definition**)
4954 Malloc($$.nElements * sizeof(*$$.elements));
4955 for(size_t i = 0; i < $2.nElements; i++) {
4958 type = new Type(Type::T_REFDSPEC, $1);
4959 type->set_location(*$1);
4961 $$.elements[i] = new Def_Modulepar($2.elements[i].id, type,
4962 $2.elements[i].defval);
4963 $$.elements[i]->set_location(infile, $2.elements[i].yyloc);
4967 | TemplateKeyword Type TemplateModuleParList
4969 $$.nElements = $3.nElements;
4970 $$.elements = (Ttcn::Definition**)Malloc($$.nElements * sizeof(*$$.elements));
4971 for(size_t i = 0; i < $3.nElements; i++) {
4974 type = new Type(Type::T_REFDSPEC, $2);
4975 type->set_location(*$2);
4977 $$.elements[i] = new Def_Modulepar_Template($3.elements[i].id, type, $3.elements[i].deftempl);
4978 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
4984 ModuleParList: // 287
4985 optError SingleModulePar
4988 $$.elements = (YYSTYPE::singlemodulepar_t*)Malloc(sizeof(*$$.elements));
4989 $$.elements[0] = $2;
4991 | ModuleParList ',' optError SingleModulePar
4993 $$.nElements = $1.nElements + 1;
4994 $$.elements = (YYSTYPE::singlemodulepar_t*)
4995 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4996 $$.elements[$$.nElements - 1] = $4;
5000 TemplateModuleParList: // 287
5001 optError SingleTemplateModulePar
5004 $$.elements = (YYSTYPE::singletemplatemodulepar_t*)Malloc(sizeof(*$$.elements));
5005 $$.elements[0] = $2;
5007 | TemplateModuleParList ',' optError SingleTemplateModulePar
5009 $$.nElements = $1.nElements + 1;
5010 $$.elements = (YYSTYPE::singletemplatemodulepar_t*)
5011 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
5012 $$.elements[$$.nElements - 1] = $4;
5023 | IDentifier AssignmentChar Expression
5031 SingleTemplateModulePar:
5038 | IDentifier AssignmentChar TemplateBody
5047 FriendModuleDef: // 289
5048 FriendKeyword TTCN3ModuleKeyword IdentifierList optSemiColon
5050 $$.nElements = $3.nElements;
5051 $$.elements = (Ttcn::FriendMod**)
5052 Malloc($$.nElements*sizeof(*$$.elements));
5053 for (size_t i = 0; i < $$.nElements; i++) {
5054 $$.elements[i] = new FriendMod($3.elements[i].id);
5055 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
5061 /* A.1.6.2 Control part */
5063 /* A.1.6.2.0 General */
5065 ModuleControlPart: // 290
5066 optError ControlKeyword
5067 '{' ModuleControlBody '}'
5068 optWithStatementAndSemiColon
5070 ControlPart* controlpart = new ControlPart($4);
5071 controlpart->set_location(infile, @2, @6);
5072 controlpart->set_with_attr($6);
5073 controlpart->set_parent_path(act_ttcn3_module->get_attrib_path());
5074 act_ttcn3_module->add_controlpart(controlpart);
5078 ModuleControlBody: // 292
5079 /* empty */ optError { $$=new StatementBlock(); }
5080 | ControlStatementOrDefList { $$ = $1; }
5083 ControlStatementOrDefList: // 293
5084 optError ControlStatementOrDef optSemiColon
5086 $$=new StatementBlock();
5087 for(size_t i=0; i<$2.nElements; i++) $$->add_stmt($2.elements[i]);
5090 | ControlStatementOrDefList optError ControlStatementOrDef optSemiColon
5093 for(size_t i=0; i<$3.nElements; i++) $$->add_stmt($3.elements[i]);
5098 ControlStatementOrDef: // 294
5101 $$.nElements=$1.nElements;
5102 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
5103 for(size_t i=0; i<$1.nElements; i++) {
5104 $$.elements[i]=new Statement(Statement::S_DEF, $1.elements[i]);
5105 $$.elements[i]->set_location(*$1.elements[i]);
5111 $$.nElements=$1.nElements;
5112 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
5113 for(size_t i=0; i<$1.nElements; i++) {
5114 $$.elements[i]=new Statement(Statement::S_DEF, $1.elements[i]);
5115 $$.elements[i]->set_location(*$1.elements[i]);
5122 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
5127 ControlStatement: /* Statement *stmt */ // 295
5128 TimerStatements { $$ = $1; }
5129 | BasicStatements { $$ = $1; }
5130 | BehaviourStatements { $$ = $1; }
5131 | SUTStatements { $$ = $1; }
5132 | StopExecutionStatement { $$ = $1; }
5133 | ProfilerStatement { $$ = $1; }
5134 | int2enumStatement { $$ = $1; }
5137 /* A.1.6.2.1 Variable instantiation */
5140 VarKeyword Type VarList
5142 $$.nElements = $3.nElements;
5143 $$.elements = (Ttcn::Definition**)
5144 Malloc($$.nElements*sizeof(*$$.elements));
5145 for (size_t i = 0; i < $$.nElements; i++) {
5148 type = new Type(Type::T_REFDSPEC, $2);
5149 type->set_location(*$2);
5151 /* creation of array type(s) if necessary (from right to left) */
5152 for (size_t j = $3.elements[i].arrays.nElements; j > 0; j--) {
5153 type = new Type(Type::T_ARRAY, type,
5154 $3.elements[i].arrays.elements[j - 1], false);
5155 type->set_location(*$2);
5157 Free($3.elements[i].arrays.elements);
5159 /* Create the definition */
5160 $$.elements[i] = new Def_Var($3.elements[i].id,
5161 type, $3.elements[i].initial_value);
5162 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
5166 | VarKeyword TemplateOptRestricted Type TempVarList
5168 $$.nElements = $4.nElements;
5169 $$.elements = (Ttcn::Definition**)
5170 Malloc($$.nElements * sizeof(*$$.elements));
5171 for (size_t i = 0; i < $$.nElements; i++) {
5174 type = new Type(Type::T_REFDSPEC, $3);
5175 type->set_location(*$3);
5177 /* creation of array type(s) if necessary (from right to left) */
5178 for (size_t j = $4.elements[i].arrays.nElements; j > 0; j--) {
5179 type = new Type(Type::T_ARRAY, type,
5180 $4.elements[i].arrays.elements[j - 1], false);
5181 type->set_location(*$3);
5183 Free($4.elements[i].arrays.elements);
5185 /* Create the definition */
5186 $$.elements[i] = new Def_Var_Template($4.elements[i].id, type,
5187 $4.elements[i].initial_value, $2);
5188 $$.elements[i]->set_location(infile, $4.elements[i].yyloc);
5196 optError SingleVarInstance
5199 $$.elements = (YYSTYPE::singlevarinst_t*)Malloc(sizeof(*$$.elements));
5200 $$.elements[0] = $2;
5202 | VarList ',' optError SingleVarInstance
5204 $$.nElements = $1.nElements + 1;
5205 $$.elements = (YYSTYPE::singlevarinst_t*)
5206 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
5207 $$.elements[$$.nElements - 1] = $4;
5211 SingleVarInstance: // 298
5212 IDentifier optArrayDef
5216 $$.initial_value = 0;
5219 | IDentifier optArrayDef AssignmentChar Expression
5223 $$.initial_value = $4;
5229 optError SingleTempVarInstance
5232 $$.elements = (YYSTYPE::singletempvarinst_t*)Malloc(sizeof(*$$.elements));
5233 $$.elements[0] = $2;
5235 | TempVarList ',' optError SingleTempVarInstance
5237 $$.nElements = $1.nElements + 1;
5238 $$.elements = (YYSTYPE::singletempvarinst_t*)
5239 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
5240 $$.elements[$$.nElements - 1] = $4;
5244 SingleTempVarInstance: // 303
5245 IDentifier optArrayDef
5249 $$.initial_value = NULL;
5252 | IDentifier optArrayDef AssignmentChar TemplateBody
5256 $$.initial_value = $4;
5264 if ($1.is_ref) $$ = $1.ref;
5266 $$ = new Ttcn::Reference($1.id);
5267 $$->set_location(infile, @$);
5272 /* A.1.6.2.2 Timer instantiation */
5274 TimerInstance: // 306
5275 TimerKeyword TimerList { $$ = $2; }
5279 optError SingleTimerInstance
5282 $$.elements = (Ttcn::Definition**)Malloc(sizeof(*$$.elements));
5283 $$.elements[0] = $2;
5285 | TimerList ',' optError SingleTimerInstance
5287 $$.nElements = $1.nElements + 1;
5288 $$.elements = (Ttcn::Definition**)
5289 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
5290 $$.elements[$$.nElements - 1] = $4;
5294 SingleTimerInstance: // 308
5295 IDentifier optArrayDef
5297 ArrayDimensions *dims;
5298 if ($2.nElements > 0) {
5299 dims = new ArrayDimensions;
5300 for (size_t i = 0; i < $2.nElements; i++) dims->add($2.elements[i]);
5303 $$ = new Ttcn::Def_Timer($1, dims, 0);
5304 $$->set_location(infile, @$);
5306 | IDentifier optArrayDef AssignmentChar TimerValue
5308 ArrayDimensions *dims;
5309 if ($2.nElements > 0) {
5310 dims = new ArrayDimensions;
5311 for (size_t i = 0; i < $2.nElements; i++) dims->add($2.elements[i]);
5314 $$ = new Ttcn::Def_Timer($1, dims, $4);
5315 $$->set_location(infile, @$);
5320 Expression { $$ = $1; }
5324 VariableRef { $$ = $1; }
5327 /* A.1.6.2.3 Component operations */
5329 ConfigurationStatements: // 313
5330 ConnectStatement { $$ = $1; }
5331 | MapStatement { $$ = $1; }
5332 | DisconnectStatement { $$ = $1; }
5333 | UnmapStatement { $$ = $1; }
5334 | DoneStatement { $$ = $1; }
5335 | KilledStatement { $$ = $1; }
5336 | StartTCStatement { $$ = $1; }
5337 | StopTCStatement { $$ = $1; }
5338 | KillTCStatement { $$ = $1; }
5341 ConfigurationOps: // 314
5346 | RunningOp {$$=$1;}
5347 | AliveOp { $$ = $1; }
5351 VariableRef DotCreateKeyword optCreateParameter optAliveKeyword
5353 $$ = new Value(Value::OPTYPE_COMP_CREATE, $1, $3.name, $3.loc, $4);
5354 $$->set_location(infile, @$);
5364 | '(' optError Expression optError ')'
5369 | '(' optError Expression optError ',' optError Expression optError ')'
5374 | '(' optError NotUsedSymbol optError ',' optError Expression optError ')'
5386 optAliveKeyword: // [328]
5387 /* empty */ { $$ = false; }
5388 | AliveKeyword { $$ = true; }
5394 $$=new Value(Value::OPTYPE_COMP_SYSTEM);
5395 $$->set_location(infile, @$);
5402 $$=new Value(Value::OPTYPE_COMP_SELF);
5403 $$->set_location(infile, @$);
5410 $$=new Value(Value::OPTYPE_COMP_MTC);
5411 $$->set_location(infile, @$);
5415 DoneStatement: // 319
5416 ComponentOrDefaultReference DotDoneKeyword optDoneParameter
5418 $$ = new Statement(Statement::S_DONE, $1, $3.donematch, $3.redirect);
5419 $$->set_location(infile, @$);
5421 | AnyKeyword ComponentKeyword DotDoneKeyword
5423 $$ = new Statement(Statement::S_DONE, Statement::C_ANY);
5424 $$->set_location(infile, @$);
5426 | AllKeyword ComponentKeyword DotDoneKeyword
5428 $$ = new Statement(Statement::S_DONE, Statement::C_ALL);
5429 $$->set_location(infile, @$);
5439 | optReceiveParameter PortRedirectSymbol ValueSpec
5446 KilledStatement: // 320
5447 ComponentOrDefaultReference DotKilledKeyword
5449 $$ = new Statement(Statement::S_KILLED, $1);
5450 $$->set_location(infile, @$);
5452 | AnyKeyword ComponentKeyword DotKilledKeyword
5454 $$ = new Statement(Statement::S_KILLED, Statement::C_ANY);
5455 $$->set_location(infile, @$);
5457 | AllKeyword ComponentKeyword DotKilledKeyword
5459 $$ = new Statement(Statement::S_KILLED, Statement::C_ALL);
5460 $$->set_location(infile, @$);
5466 ComponentOrDefaultReference
5467 | AnyKeyword ComponentKeyword
5468 | AllKeyword ComponentKeyword
5473 /* VariableRef DotRunningKeyword -- covered by RunningTimerOp */
5474 FunctionInstance DotRunningKeyword
5476 Value *t_val = new Value(Value::V_REFD, $1);
5477 t_val->set_location(infile, @1);
5478 $$ = new Value(Value::OPTYPE_COMP_RUNNING, t_val);
5479 $$->set_location(infile, @$);
5481 | ApplyOp DotRunningKeyword
5483 Value *t_val = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5484 t_val->set_location(infile, @1);
5485 $$ = new Value(Value::OPTYPE_COMP_RUNNING, t_val);
5486 $$->set_location(infile, @$);
5488 | AnyKeyword ComponentKeyword DotRunningKeyword
5490 $$ = new Value(Value::OPTYPE_COMP_RUNNING_ANY);
5491 $$->set_location(infile, @$);
5493 | AllKeyword ComponentKeyword DotRunningKeyword
5495 $$ = new Value(Value::OPTYPE_COMP_RUNNING_ALL);
5496 $$->set_location(infile, @$);
5501 ComponentOrDefaultReference DotAliveKeyword
5503 $$ = new Value(Value::OPTYPE_COMP_ALIVE, $1);
5504 $$->set_location(infile, @$);
5506 | AnyKeyword ComponentKeyword DotAliveKeyword
5508 $$ = new Value(Value::OPTYPE_COMP_ALIVE_ANY);
5509 $$->set_location(infile, @$);
5511 | AllKeyword ComponentKeyword DotAliveKeyword
5513 $$ = new Value(Value::OPTYPE_COMP_ALIVE_ALL);
5514 $$->set_location(infile, @$);
5518 ConnectStatement: // 329
5519 ConnectKeyword SingleConnectionSpec
5521 $$=new Statement(Statement::S_CONNECT,
5522 $2.compref1, $2.portref1, $2.compref2, $2.portref2);
5523 $$->set_location(infile, @$);
5527 SingleConnectionSpec: // 331
5528 '(' PortRef optError ',' optError PortRef optError ')'
5530 $$.compref1 = $2.compref;
5531 $$.portref1 = $2.portref;
5532 $$.compref2 = $6.compref;
5533 $$.portref2 = $6.portref;
5538 ComponentRef ':' Port
5545 ComponentRef: // 333
5546 ComponentOrDefaultReference { $$ = $1; }
5547 | SystemOp { $$ = $1; }
5548 | SelfOp { $$ = $1; }
5549 | MTCOp { $$ = $1; }
5552 DisconnectStatement: // 335
5555 Location loc(infile, @$);
5556 loc.error("Disconnect operation on multiple connections is "
5557 "not currently supported");
5558 $$ = new Statement(Statement::S_ERROR);
5559 $$->set_location(infile, @$);
5561 | DisconnectKeyword SingleOrMultiConnectionSpec
5563 if ($2.portref1 && $2.portref2 && $2.compref1 && $2.compref2) {
5564 $$ = new Statement(Statement::S_DISCONNECT,
5565 $2.compref1, $2.portref1, $2.compref2, $2.portref2);
5567 Location loc(infile, @$);
5568 loc.error("Disconnect operation on multiple connections is "
5569 "not currently supported");
5574 $$ = new Statement(Statement::S_ERROR);
5576 $$->set_location(infile, @$);
5580 SingleOrMultiConnectionSpec: // 336
5581 SingleConnectionSpec { $$ = $1; }
5582 | AllConnectionsSpec
5584 $$.compref1 = $1.compref;
5585 $$.portref1 = $1.portref;
5596 | AllCompsAllPortsSpec
5605 AllConnectionsSpec: // 337
5606 '(' PortRef optError ')' { $$ = $2; }
5609 AllPortsSpec: // 338
5610 '(' ComponentRef ':' AllKeyword PortKeyword optError ')' { $$ = $2; }
5613 AllCompsAllPortsSpec: // 339
5614 '(' AllKeyword ComponentKeyword ':' AllKeyword PortKeyword optError ')'
5617 MapStatement: // 341
5618 MapKeyword SingleConnectionSpec
5620 $$=new Statement(Statement::S_MAP,
5621 $2.compref1, $2.portref1,
5622 $2.compref2, $2.portref2);
5623 $$->set_location(infile, @$);
5627 UnmapStatement: // 343
5630 $$ = new Statement(Statement::S_ERROR);
5631 $$->set_location(infile, @$);
5632 Location loc(infile, @$);
5633 loc.error("Unmap operation on multiple mappings is "
5634 "not currently supported");
5636 | UnmapKeyword SingleOrMultiConnectionSpec
5638 if ($2.compref1 && $2.portref1 && $2.compref1 && $2.compref2) {
5639 $$ = new Statement(Statement::S_UNMAP,
5640 $2.compref1, $2.portref1, $2.compref2, $2.portref2);
5642 Location loc(infile, @$);
5643 loc.error("Unmap operation on multiple mappings is "
5644 "not currently supported");
5649 $$ = new Statement(Statement::S_ERROR);
5651 $$->set_location(infile, @$);
5655 StartTCStatement: // 345
5656 /* VariableRef DotStartKeyword '(' FunctionInstance ')'
5657 -- covered by StartTimerStatement */
5658 VariableRef DotStartKeyword '(' DereferOp '(' optFunctionActualParList ')'
5661 Value *t_val = new Value(Value::V_REFD, $1);
5662 t_val->set_location(infile, @1);
5663 $6->set_location(infile, @5, @7);
5664 //ParsedActualParameters *pap = new ParsedActualParameters($6);
5665 $$ = new Statement(Statement::S_START_COMP_REFD, t_val, $4, $6);
5666 $$->set_location(infile, @$);
5668 | FunctionInstance DotStartKeyword '(' FunctionInstance optError ')'
5670 Value *t_val = new Value(Value::V_REFD, $1);
5671 t_val->set_location(infile, @1);
5672 $$ = new Statement(Statement::S_START_COMP, t_val, $4);
5673 $$->set_location(infile, @$);
5675 | FunctionInstance DotStartKeyword '(' DereferOp '('
5676 optFunctionActualParList ')' optError ')'
5678 Value *t_val = new Value(Value::V_REFD, $1);
5679 t_val->set_location(infile, @1);
5680 $6->set_location(infile, @5 , @7);
5681 $$ = new Statement(Statement::S_START_COMP_REFD, t_val, $4, $6);
5682 $$->set_location(infile, @$);
5684 | FunctionInstance DotStartKeyword '(' error ')'
5687 $$ = new Statement(Statement::S_ERROR);
5688 $$->set_location(infile, @$);
5690 | ApplyOp DotStartKeyword '(' FunctionInstance ')'
5692 Value *t_val = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5693 t_val->set_location(infile, @1);
5694 $$ = new Statement(Statement::S_START_COMP, t_val, $4);
5695 $$->set_location(infile, @$);
5697 | ApplyOp DotStartKeyword '(' DereferOp '(' optFunctionActualParList ')'
5700 Value *t_val = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5701 t_val->set_location(infile, @1);
5702 $6->set_location(infile, @5 , @7);
5703 $$ = new Statement(Statement::S_START_COMP_REFD, t_val, $4, $6);
5704 $$->set_location(infile, @$);
5706 | ApplyOp DotStartKeyword '(' error ')'
5710 $$ = new Statement(Statement::S_ERROR);
5711 $$->set_location(infile, @$);
5715 StopTCStatement: // 337
5716 /* VariableRef DotStopKeyword -- covered by StopTimerStatement */
5717 FunctionInstance DotStopKeyword
5719 Value *t_val = new Value(Value::V_REFD, $1);
5720 t_val->set_location(infile, @1);
5721 $$ = new Statement(Statement::S_STOP_COMP, t_val);
5722 $$->set_location(infile, @$);
5724 | ApplyOp DotStopKeyword
5726 Value *t_val = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5727 t_val->set_location(infile, @1);
5728 $$ = new Statement(Statement::S_STOP_COMP, t_val);
5729 $$->set_location(infile, @$);
5731 | MTCOp DotStopKeyword
5733 $$ = new Statement(Statement::S_STOP_COMP, $1);
5734 $$->set_location(infile, @$);
5736 | SelfOp DotStopKeyword
5738 $$ = new Statement(Statement::S_STOP_COMP, $1);
5739 $$->set_location(infile, @$);
5741 | AllKeyword ComponentKeyword DotStopKeyword
5743 $$ = new Statement(Statement::S_STOP_COMP, (Value*)0);
5744 $$->set_location(infile, @$);
5748 ComponentReferenceOrLiteral: // 348
5749 ComponentOrDefaultReference { $$ = $1; }
5750 | MTCOp { $$ = $1; }
5751 | SelfOp { $$ = $1; }
5754 KillTCStatement: // 349
5757 Value *self = new Value(Value::OPTYPE_COMP_SELF);
5758 self->set_location(infile, @1);
5759 $$ = new Statement(Statement::S_KILL, self);
5760 $$->set_location(infile, @$);
5762 | ComponentReferenceOrLiteral DotKillKeyword
5764 $$ = new Statement(Statement::S_KILL, $1);
5765 $$->set_location(infile, @$);
5767 | AllKeyword ComponentKeyword DotKillKeyword
5769 $$ = new Statement(Statement::S_KILL, (Value*)0);
5770 $$->set_location(infile, @$);
5774 ComponentOrDefaultReference: // 350
5777 $$ = new Value(Value::V_REFD, $1);
5778 $$->set_location(infile, @$);
5782 $$ = new Value(Value::V_REFD, $1);
5783 $$->set_location(infile, @$);
5787 $$ = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5788 $$->set_location(infile, @$);
5792 /* A.1.6.2.4 Port operations */
5795 VariableRef { $$ = $1; }
5798 CommunicationStatements: // 353
5799 SendStatement {$$ = $1;}
5800 | CallStatement {$$ = $1;}
5801 | ReplyStatement {$$ = $1;}
5802 | RaiseStatement {$$ = $1;}
5803 | ReceiveStatement {$$ = $1;}
5804 | TriggerStatement {$$ = $1;}
5805 | GetCallStatement {$$ = $1;}
5806 | GetReplyStatement {$$ = $1;}
5807 | CatchStatement {$$ = $1;}
5808 | CheckStatement {$$ = $1;}
5809 | ClearStatement {$$ = $1;}
5810 | StartStatement {$$ = $1;}
5811 | StopStatement {$$ = $1;}
5812 | HaltStatement {$$ = $1;}
5815 SendStatement: // 354
5816 Port DotSendOpKeyword PortSendOp
5818 $$ = new Statement(Statement::S_SEND, $1, $3.templ_inst, $3.val);
5819 $$->set_location(infile, @$);
5824 '(' SendParameter optError ')' optToClause
5829 | '(' error ')' optToClause
5831 Template *t = new Template(Template::TEMPLATE_ERROR);
5832 t->set_location(infile, @2);
5833 $$.templ_inst = new TemplateInstance(0, 0, t);
5834 $$.templ_inst->set_location(infile, @2);
5839 SendParameter: // 357
5840 TemplateInstance { $$=$1; }
5843 optToClause: // [3583]
5844 /* empty */ { $$ = 0; }
5845 | ToKeyword AddressRef
5847 Template *templ = $2->get_Template();
5848 if (!$2->get_Type() && !$2->get_DerivedRef() && templ->is_Value()) {
5849 $$ = templ->get_Value();
5851 Location loc(infile, @$);
5852 loc.error("Multicast communication is not currently supported");
5857 /* | ToKeyword AddressRefList -- covered by the previous rule
5858 (as ValueOrAttribList) */
5859 | ToKeyword AllKeyword ComponentKeyword
5861 Location loc(infile, @$);
5862 loc.error("Broadcast communication is not currently supported");
5865 | ToKeyword error { $$ = 0; }
5869 AddressRefList: // 359
5870 '(' seqAddressRef ')'
5875 | seqAddressRef ',' AddressRef
5880 TemplateInstance { $$ = $1; }
5883 CallStatement: // 362
5884 Port DotCallOpKeyword PortCallOp optPortCallBody
5886 $$ = new Statement(Statement::S_CALL, $1, $3.templ_inst,
5887 $3.calltimerval, $3.nowait, $3.val, $4);
5888 $$->set_location(infile, @$);
5893 '(' CallParameters optError ')' optToClause
5895 $$.templ_inst = $2.templ_inst;
5896 $$.calltimerval = $2.calltimerval;
5897 $$.nowait = $2.nowait;
5900 | '(' error ')' optToClause
5902 Template *t = new Template(Template::TEMPLATE_ERROR);
5903 t->set_location(infile, @2);
5904 $$.templ_inst = new TemplateInstance(0, 0, t);
5905 $$.templ_inst->set_location(infile, @2);
5906 $$.calltimerval = 0;
5912 CallParameters: // 365
5919 | TemplateInstance ',' optError CallTimerValue
5922 $$.calltimerval=$4.calltimerval;
5923 $$.nowait=$4.nowait;
5927 CallTimerValue: // 366
5940 optPortCallBody: // [368]
5941 /* empty */ { $$=0; }
5942 | '{' CallBodyStatementList optError '}' { $$=$2; }
5943 | '{' error '}' { $$ = new AltGuards; }
5946 CallBodyStatementList: // 369
5947 optError CallBodyStatement
5952 | CallBodyStatementList optError CallBodyStatement
5959 CallBodyStatement: // 370 and 371. rolled into one.
5960 AltGuardChar CallBodyOps ';' // This alternative is a TITAN extension
5962 $$=new AltGuard($1, $2, new StatementBlock());
5963 $$->set_location(infile, @$);
5965 | AltGuardChar CallBodyOps optSemiColon StatementBlock optSemiColon
5967 $$=new AltGuard($1, $2, $4);
5968 $$->set_location(infile, @$);
5973 GetReplyStatement {$$=$1;}
5974 | CatchStatement {$$=$1;}
5977 ReplyStatement: // 373
5978 Port DotReplyKeyword PortReplyOp
5980 $$ = new Statement(Statement::S_REPLY, $1, $3.templ_inst,
5981 $3.replyval, $3.toclause);
5982 $$->set_location(infile, @$);
5987 '(' TemplateInstance optReplyValue optError ')' optToClause
5993 | '(' error ')' optToClause
5995 Template *t = new Template(Template::TEMPLATE_ERROR);
5996 t->set_location(infile, @2);
5997 $$.templ_inst = new TemplateInstance(0, 0, t);
5998 $$.templ_inst->set_location(infile, @2);
6004 optReplyValue: // [376]
6005 /* empty */ { $$=0; }
6006 | ValueKeyword Expression { $$=$2; }
6007 | ValueKeyword error { $$ = 0; }
6010 RaiseStatement: // 377
6011 Port DotRaiseKeyword PortRaiseOp
6013 if ($3.signature) $$ = new Statement(Statement::S_RAISE, $1,
6014 $3.signature, $3.templ_inst, $3.toclause);
6016 $$ = new Statement(Statement::S_ERROR);
6018 delete $3.signature;
6019 delete $3.templ_inst;
6022 $$->set_location(infile, @$);
6027 '(' Signature optError ',' optError TemplateInstance optError ')' optToClause
6033 | '(' error ')' optToClause
6042 ReceiveStatement: // 380
6043 PortOrAny DotReceiveOpKeyword PortReceiveOp
6045 $$ = new Statement(Statement::S_RECEIVE, $1, $3.templ_inst,
6046 $3.fromclause, $3.redirectval, $3.redirectsender);
6047 $$->set_location(infile, @$);
6053 | AnyKeyword PortKeyword { $$ = 0; }
6056 PortReceiveOp: // 382
6057 optReceiveParameter optFromClause optPortRedirect
6061 $$.redirectval = $3.redirectval;
6062 $$.redirectsender = $3.redirectsender;
6066 optReceiveParameter: // [384]
6067 /* empty */ { $$ = 0; }
6068 | '(' ReceiveParameter optError ')' { $$ = $2; }
6071 Template *t = new Template(Template::TEMPLATE_ERROR);
6072 t->set_location(infile, @2);
6073 $$ = new TemplateInstance(0, 0, t);
6074 $$->set_location(infile, @$);
6078 ReceiveParameter: // 384
6079 TemplateInstance { $$ = $1; }
6082 optFromClause: // [385]
6083 /* empty */ { $$=0; }
6084 | FromClause { $$=$1; }
6088 FromKeyword AddressRef { $$=$2; }
6089 | FromKeyword error { $$ = 0; }
6092 optPortRedirect: // [387]
6096 $$.redirectsender=0;
6098 | PortRedirectSymbol ValueSpec
6101 $$.redirectsender=0;
6103 | PortRedirectSymbol SenderSpec
6106 $$.redirectsender=$2;
6108 | PortRedirectSymbol ValueSpec SenderSpec
6111 $$.redirectsender=$3;
6113 | PortRedirectSymbol error
6116 $$.redirectsender=0;
6121 ValueKeyword VariableRef { $$ = $2; }
6122 | ValueKeyword error { $$ = 0; }
6126 SenderKeyword VariableRef { $$ = $2; }
6127 | SenderKeyword error { $$ = 0; }
6130 TriggerStatement: // 393
6131 PortOrAny DotTriggerOpKeyword PortTriggerOp
6133 $$ = new Statement(Statement::S_TRIGGER, $1, $3.templ_inst,
6134 $3.fromclause, $3.redirectval, $3.redirectsender);
6135 $$->set_location(infile, @$);
6139 PortTriggerOp: // 394
6140 optReceiveParameter optFromClause optPortRedirect
6144 $$.redirectval = $3.redirectval;
6145 $$.redirectsender = $3.redirectsender;
6149 GetCallStatement: // 396
6150 PortOrAny DotGetCallOpKeyword PortGetCallOp
6152 $$ = new Statement(Statement::S_GETCALL, $1, $3.templ_inst,
6153 $3.fromclause, $3.redirectparam, $3.redirectsender);
6154 $$->set_location(infile, @$);
6158 PortGetCallOp: // 397
6159 optReceiveParameter optFromClause optPortRedirectWithParam
6163 $$.redirectparam = $3.redirectparam;
6164 $$.redirectsender = $3.redirectsender;
6168 optPortRedirectWithParam: // [399]
6172 $$.redirectsender=0;
6174 | PortRedirectSymbol ParamSpec
6176 $$.redirectparam=$2;
6177 $$.redirectsender=0;
6179 | PortRedirectSymbol ParamSpec SenderSpec
6181 $$.redirectparam=$2;
6182 $$.redirectsender=$3;
6184 | PortRedirectSymbol SenderSpec
6187 $$.redirectsender=$2;
6189 | PortRedirectSymbol error
6192 $$.redirectsender=0;
6197 ParamKeyword ParamAssignmentList { $$ = $2; }
6198 | ParamKeyword error { $$ = 0; }
6201 ParamAssignmentList: // 403
6202 '(' AssignmentList optError ')'
6204 $$=new ParamRedirect($2);
6205 $$->set_location(infile, @$);
6207 | '(' VariableList optError ')'
6209 $$=new ParamRedirect($2);
6210 $$->set_location(infile, @$);
6214 $$=new ParamRedirect(new ParamAssignments());
6215 $$->set_location(infile, @$);
6219 AssignmentList: // 404
6222 $$ = new ParamAssignments();
6225 | error VariableAssignment
6227 $$ = new ParamAssignments();
6230 | AssignmentList optError ',' optError VariableAssignment
6235 | AssignmentList optError ',' error { $$ = $1; }
6238 VariableAssignment: // 405
6239 VariableRef AssignmentChar IDentifier
6241 $$ = new ParamAssignment($3, $1);
6242 $$->set_location(infile, @$);
6246 VariableList: // 407
6249 $$ = new VariableEntries();
6252 | error VariableEntry
6254 $$ = new VariableEntries();
6257 | VariableList optError ',' optError VariableEntry
6262 | VariableList optError ',' error { $$ = $1; }
6265 VariableEntry: // 408
6268 $$ = new VariableEntry($1);
6269 $$->set_location(infile, @$);
6273 $$ = new VariableEntry;
6274 $$->set_location(infile, @$);
6278 GetReplyStatement: // 409
6279 PortOrAny DotGetReplyOpKeyword PortGetReplyOp
6281 $$ = new Statement(Statement::S_GETREPLY, $1, $3.templ_inst,
6282 $3.valuematch, $3.fromclause, $3.redirectval,
6283 $3.redirectparam, $3.redirectsender);
6284 $$->set_location(infile, @$);
6288 PortGetReplyOp: // 410
6289 optGetReplyParameter optFromClause optPortRedirectWithValueAndParam
6291 $$.templ_inst = $1.templ_inst;
6292 $$.valuematch = $1.valuematch;
6294 $$.redirectval = $3.redirectval;
6295 $$.redirectparam = $3.redirectparam;
6296 $$.redirectsender = $3.redirectsender;
6300 optPortRedirectWithValueAndParam: // [411]
6305 $$.redirectsender=0;
6307 | PortRedirectSymbol ValueSpec
6311 $$.redirectsender=0;
6313 | PortRedirectSymbol ValueSpec ParamSpec
6316 $$.redirectparam=$3;
6317 $$.redirectsender=0;
6319 | PortRedirectSymbol ValueSpec SenderSpec
6323 $$.redirectsender=$3;
6325 | PortRedirectSymbol ValueSpec ParamSpec SenderSpec
6328 $$.redirectparam=$3;
6329 $$.redirectsender=$4;
6331 | PortRedirectSymbol ParamSpec
6334 $$.redirectparam=$2;
6335 $$.redirectsender=0;
6337 | PortRedirectSymbol SenderSpec
6341 $$.redirectsender=$2;
6343 | PortRedirectSymbol ParamSpec SenderSpec
6346 $$.redirectparam=$2;
6347 $$.redirectsender=$3;
6349 | PortRedirectSymbol error
6353 $$.redirectsender=0;
6357 optGetReplyParameter:
6363 | '(' ReceiveParameter optError ')'
6368 | '(' ReceiveParameter ValueMatchSpec optError ')'
6375 Template *t = new Template(Template::TEMPLATE_ERROR);
6376 t->set_location(infile, @2);
6377 $$.templ_inst = new TemplateInstance(0, 0, t);
6378 $$.templ_inst->set_location(infile, @2);
6383 ValueMatchSpec: // 414
6384 ValueKeyword TemplateInstance { $$=$2; }
6385 | ValueKeyword error { $$ = 0; }
6388 CheckStatement: // 415
6389 PortOrAny DotCheckOpKeyword optCheckParameter
6391 switch ($3.statementtype) {
6392 case Statement::S_CHECK:
6393 $$ = new Statement(Statement::S_CHECK, $1, $3.templ_inst,
6396 case Statement::S_CHECK_RECEIVE:
6397 $$ = new Statement(Statement::S_CHECK_RECEIVE, $1, $3.templ_inst,
6398 $3.fromclause, $3.redirectval, $3.redirectsender);
6400 case Statement::S_CHECK_GETCALL:
6401 $$ = new Statement(Statement::S_CHECK_GETCALL, $1, $3.templ_inst,
6402 $3.fromclause, $3.redirectparam, $3.redirectsender);
6404 case Statement::S_CHECK_GETREPLY:
6405 $$ = new Statement(Statement::S_CHECK_GETREPLY, $1, $3.templ_inst,
6406 $3.valuematch, $3.fromclause, $3.redirectval,
6407 $3.redirectparam, $3.redirectsender);
6409 case Statement::S_CHECK_CATCH:
6410 $$ = new Statement(Statement::S_CHECK_CATCH, $1, $3.signature,
6411 $3.templ_inst, $3.timeout, $3.fromclause,
6412 $3.redirectval, $3.redirectsender);
6415 FATAL_ERROR("Internal error.");
6417 $$->set_location(infile, @$);
6421 optCheckParameter: // [418]
6424 $$.statementtype = Statement::S_CHECK;
6431 $$.redirectparam = 0;
6432 $$.redirectsender = 0;
6434 | '(' CheckParameter optError ')' { $$ = $2; }
6437 $$.statementtype = Statement::S_CHECK;
6444 $$.redirectparam = 0;
6445 $$.redirectsender = 0;
6449 CheckParameter: // 418
6450 CheckPortOpsPresent { $$ = $1; }
6451 | FromClausePresent { $$ = $1; }
6452 | RedirectPresent { $$ = $1; }
6455 FromClausePresent: // 419
6458 $$.statementtype = Statement::S_CHECK;
6465 $$.redirectparam = 0;
6466 $$.redirectsender = 0;
6468 | FromClause PortRedirectSymbol SenderSpec
6470 $$.statementtype = Statement::S_CHECK;
6477 $$.redirectparam = 0;
6478 $$.redirectsender = $3;
6482 RedirectPresent: // 420
6483 PortRedirectSymbol SenderSpec
6485 $$.statementtype = Statement::S_CHECK;
6492 $$.redirectparam = 0;
6493 $$.redirectsender = $2;
6497 CheckPortOpsPresent: // 421
6498 ReceiveOpKeyword PortReceiveOp
6500 $$.statementtype = Statement::S_CHECK_RECEIVE;
6502 $$.templ_inst = $2.templ_inst;
6505 $$.fromclause = $2.fromclause;
6506 $$.redirectval = $2.redirectval;
6507 $$.redirectparam = 0;
6508 $$.redirectsender = $2.redirectsender;
6510 | GetCallOpKeyword PortGetCallOp
6512 $$.statementtype = Statement::S_CHECK_GETCALL;
6514 $$.templ_inst = $2.templ_inst;
6517 $$.fromclause = $2.fromclause;
6519 $$.redirectparam = $2.redirectparam;
6520 $$.redirectsender = $2.redirectsender;
6522 | GetReplyOpKeyword PortGetReplyOp
6524 $$.statementtype = Statement::S_CHECK_GETREPLY;
6526 $$.templ_inst = $2.templ_inst;
6527 $$.valuematch = $2.valuematch;
6529 $$.fromclause = $2.fromclause;
6530 $$.redirectval = $2.redirectval;
6531 $$.redirectparam = $2.redirectparam;
6532 $$.redirectsender = $2.redirectsender;
6534 | CatchOpKeyword PortCatchOp
6536 $$.statementtype = Statement::S_CHECK_CATCH;
6537 $$.signature = $2.signature;
6538 $$.templ_inst = $2.templ_inst;
6540 $$.timeout = $2.timeout;
6541 $$.fromclause = $2.fromclause;
6542 $$.redirectval = $2.redirectval;
6543 $$.redirectparam = 0;
6544 $$.redirectsender = $2.redirectsender;
6548 CatchStatement: // 422
6549 PortOrAny DotCatchOpKeyword PortCatchOp
6551 $$ = new Statement(Statement::S_CATCH, $1, $3.signature, $3.templ_inst,
6552 $3.timeout, $3.fromclause, $3.redirectval,
6554 $$->set_location(infile, @$);
6559 optCatchOpParameter optFromClause optPortRedirect
6561 $$.signature = $1.signature;
6562 $$.templ_inst = $1.templ_inst;
6563 $$.timeout = $1.timeout;
6565 $$.redirectval = $3.redirectval;
6566 $$.redirectsender = $3.redirectsender;
6570 optCatchOpParameter: // [425]
6577 | '(' CatchOpParameter optError ')' { $$ = $2; }
6586 CatchOpParameter: // 425
6587 Signature optError ',' optError TemplateInstance
6601 ClearStatement: // 426
6602 PortOrAll DotClearOpKeyword
6604 $$ = new Statement(Statement::S_CLEAR, $1);
6605 $$->set_location(infile, @$);
6611 | AllKeyword PortKeyword { $$ = 0; }
6614 StartStatement: // 430
6615 /* Port DotPortStartKeyword -- covered by StartTimerStatement */
6616 AllKeyword PortKeyword DotStartKeyword
6618 $$=new Statement(Statement::S_START_PORT, (Ttcn::Reference*)0);
6619 $$->set_location(infile, @$);
6623 StopStatement: // 432
6624 /* Port DotPortStopKeyword -- covered by StopTimerStatement */
6625 AllKeyword PortKeyword DotStopKeyword
6627 $$=new Statement(Statement::S_STOP_PORT, (Ttcn::Reference*)0);
6628 $$->set_location(infile, @$);
6632 HaltStatement: // 435
6633 PortOrAll DotHaltKeyword
6635 $$ = new Statement(Statement::S_HALT, $1);
6636 $$->set_location(infile, @$);
6640 /* A.1.6.2.5 Timer operations */
6642 TimerStatements: // 439
6643 StartTimerStatement { $$ = $1; }
6644 | StopTimerStatement { $$ = $1; }
6645 | TimeoutStatement { $$ = $1; }
6649 ReadTimerOp { $$ = $1; }
6650 | RunningTimerOp { $$ = $1; }
6653 StartTimerStatement: // 441
6654 VariableRef DotStartKeyword
6656 $$ = new Statement(Statement::S_START_UNDEF, $1, (Value*)0);
6657 $$->set_location(infile, @$);
6659 | VariableRef DotStartKeyword '(' Expression optError ')'
6661 $$ = new Statement(Statement::S_START_UNDEF, $1, $4);
6662 $$->set_location(infile, @$);
6664 | VariableRef DotStartKeyword '(' error ')'
6666 Value *v = new Value(Value::V_ERROR);
6667 v->set_location(infile, @4);
6668 $$ = new Statement(Statement::S_START_UNDEF, $1, v);
6669 $$->set_location(infile, @$);
6673 StopTimerStatement: // 442
6674 TimerRef DotStopKeyword
6676 $$ = new Statement(Statement::S_STOP_UNDEF, $1, (Value*)0);
6677 $$->set_location(infile, @$);
6679 | AllKeyword TimerKeyword DotStopKeyword
6681 $$ = new Statement(Statement::S_STOP_TIMER, (Ttcn::Reference*)0);
6682 $$->set_location(infile, @$);
6686 /* no separate rule, folded into StopTimerStatement
6687 TimerRefOrAll: // 443
6689 | AllKeyword TimerKeyword
6694 TimerRef DotReadKeyword
6696 $$ = new Value(Value::OPTYPE_TMR_READ, $1);
6697 $$->set_location(infile, @$);
6701 RunningTimerOp: // 446
6702 TimerRef DotRunningKeyword
6704 $$ = new Value(Value::OPTYPE_UNDEF_RUNNING, $1);
6705 $$->set_location(infile, @$);
6707 | AnyKeyword TimerKeyword DotRunningKeyword
6709 $$ = new Value(Value::OPTYPE_TMR_RUNNING_ANY);
6710 $$->set_location(infile, @$);
6714 TimeoutStatement: // 447
6715 TimerRefOrAny DotTimeoutKeyword
6717 $$ = new Statement(Statement::S_TIMEOUT, $1);
6718 $$->set_location(infile, @$);
6722 TimerRefOrAny: // 448
6723 TimerRef { $$ = $1; }
6724 | AnyKeyword TimerKeyword { $$ = 0; }
6733 $$->set_location(infile, @$);
6735 | AnyTypeKeyword /* a predefined type with special treatment */
6737 anytype_access = true;
6738 Identifier *id = new Identifier(Identifier::ID_TTCN, string("anytype"));
6739 Ttcn::Reference *ref = new Ttcn::Reference(id);
6740 ref->set_location(infile, @1);
6741 $$ = new Type(Type::T_REFD, ref);
6743 | ReferencedType { $$ = $1; }
6747 PredefinedType: // 451, but see below
6748 BitStringKeyword { $$ = Type::T_BSTR; }
6749 | BooleanKeyword { $$ = Type::T_BOOL; }
6750 | CharStringKeyword { $$ = Type::T_CSTR; }
6751 | UniversalCharString { $$ = Type::T_USTR; }
6752 | CharKeyword // not in the standard anymore
6754 Location loc(infile, @$);
6755 loc.warning("Obsolete type `char' was substituted with `charstring'");
6758 | UniversalChar // not in the standard anymore
6760 Location loc(infile, @$);
6761 loc.warning("Obsolete type `universal char' was substituted with "
6762 "`universal charstring'");
6765 | IntegerKeyword { $$ = Type::T_INT; }
6766 | OctetStringKeyword { $$ = Type::T_OSTR; }
6767 | HexStringKeyword { $$ = Type::T_HSTR; }
6768 | VerdictTypeKeyword { $$ = Type::T_VERDICT; }
6769 | FloatKeyword { $$ = Type::T_REAL; }
6770 | AddressKeyword { $$ = Type::T_ADDRESS; }
6771 | DefaultKeyword { $$ = Type::T_DEFAULT; }
6772 | ObjectIdentifierKeyword { $$ = Type::T_OID; }
6774 * AnyTypeKeyword is not part of PredefinedType (this differs from the BNF
6775 * in the TTCN-3 standard).
6776 * PredefinedType is used in two contexts:
6777 * - as a RHS for Type, above (where AnyTypeKeyword needs special treatment,
6778 * and it's easier to appear as an alternative to PredefinedType)
6779 * - as field name for the anytype (where anytype is not permitted)
6783 UniversalCharString: // 463
6784 UniversalKeyword CharStringKeyword
6788 UniversalKeyword CharKeyword
6791 ReferencedType: // 465
6794 if ($1.is_ref) $$ = new Type(Type::T_REFD, $1.ref);
6796 Ttcn::Reference *ref = new Ttcn::Reference($1.id);
6797 ref->set_location(infile, @1);
6798 $$ = new Type(Type::T_REFD, ref);
6800 $$->set_location(infile, @$);
6802 | FunctionInstance optExtendedFieldReference
6803 /* covers all parameterized type references */
6805 Location loc(infile, @1);
6806 loc.error("Reference to parameterized type is not currently supported");
6808 for (size_t i = 0; i < $2.nElements; i++) delete $2.elements[i];
6810 $$ = new Type(Type::T_ERROR);
6811 $$->set_location(infile, @$);
6816 TypeReference: // 466
6818 | IDentifier TypeActualParList
6822 TypeActualParList: // -> 202 784 "Advanced Parameterization"
6823 '(' seqTypeActualPar optError ')'
6827 seqTypeActualPar: // -> 202 784 "Advanced Parameterization"
6828 optError TypeActualPar
6829 | seqTypeActualPar optError ',' optError TypeActualPar
6830 | seqTypeActualPar optError ',' error
6833 TypeActualPar: // -> 202 784 "Advanced Parameterization"
6834 Expression { delete $1; }
6837 optArrayDef: // [467]
6843 | optArrayDef ArrayIndex
6845 $$.nElements = $1.nElements + 1;
6846 $$.elements = (ArrayDimension**)
6847 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
6848 $$.elements[$1.nElements] = $2;
6855 $$ = new ArrayDimension($2);
6856 $$->set_location(infile, @$);
6858 | '[' ArrayBounds DotDot ArrayBounds ']'
6860 $$ = new ArrayDimension($2, $4);
6861 $$->set_location(infile, @$);
6865 Value *v = new Value(Value::V_ERROR);
6866 v->set_location(infile, @2);
6867 $$ = new ArrayDimension(v);
6868 $$->set_location(infile, @$);
6873 Expression { $$ = $1; }
6879 PredefinedValue { $$ = $1; }
6880 | ReferencedValue { $$ = $1; }
6883 PredefinedValue: // 470
6884 BitStringValue { $$ = $1; }
6885 | BooleanValue { $$ = $1; }
6886 | CharStringValue { $$ = $1; }
6887 | IntegerValue { $$ = $1; }
6888 | OctetStringValue { $$ = $1; }
6889 | HexStringValue { $$ = $1; }
6890 | VerdictValue { $$ = $1; }
6891 /* | EnumeratedValue -- covered by ReferencedValue */
6892 | FloatOrSpecialFloatValue
6894 $$ = new Value(Value::V_REAL, $1);
6895 $$->set_location(infile, @$);
6897 | AddressValue { $$ = $1; }
6898 | OmitValue { $$ = $1; }
6901 $$ = new Value(Value::V_NULL);
6902 $$->set_location(infile, @$);
6906 $$ = new Value(Value::V_MACRO, $1);
6907 $$->set_location(infile, @$);
6909 | ObjectIdentifierValue { $$ = $1; }
6912 $$=new Value(Value::V_ERROR);
6913 $$->set_location(infile, @$);
6917 BitStringValue: // 471
6920 $$ = new Value(Value::V_BSTR, $1);
6921 $$->set_location(infile, @$);
6925 BooleanValue: // 472
6928 $$ = new Value(Value::V_BOOL, true);
6929 $$->set_location(infile, @$);
6933 $$ = new Value(Value::V_BOOL, false);
6934 $$->set_location(infile, @$);
6938 /* TTCN-3 core language V4.2.1 */
6939 FloatOrSpecialFloatValue:
6954 IntegerValue: // 473
6957 $$ = new Value(Value::V_INT, $1);
6958 $$->set_location(infile, @$);
6962 OctetStringValue: // 474
6965 $$ = new Value(Value::V_OSTR, $1);
6966 $$->set_location(infile, @$);
6970 HexStringValue: // 475
6973 $$ = new Value(Value::V_HSTR, $1);
6974 $$->set_location(infile, @$);
6978 VerdictValue: // 476 VerdictTypeValue
6981 $$ = new Value(Value::V_VERDICT, Value::Verdict_NONE);
6982 $$->set_location(infile, @$);
6986 $$ = new Value(Value::V_VERDICT, Value::Verdict_PASS);
6987 $$->set_location(infile, @$);
6991 $$ = new Value(Value::V_VERDICT, Value::Verdict_INCONC);
6992 $$->set_location(infile, @$);
6996 $$ = new Value(Value::V_VERDICT, Value::Verdict_FAIL);
6997 $$->set_location(infile, @$);
7001 $$ = new Value(Value::V_VERDICT, Value::Verdict_ERROR);
7002 $$->set_location(infile, @$);
7006 CharStringValue: // 478
7009 if ($1->is_cstr()) $$ = new Value(Value::V_CSTR, $1);
7011 $$ = new Value(Value::V_USTR, new ustring(*$1));
7014 $$->set_location(infile, @$);
7018 $$ = new Value(Value::V_USTR, new ustring(*$1));
7020 $$->set_location(infile, @$);
7024 $$ = new Value(Value::V_USTR, new ustring($1.elements, $1.nElements));
7025 for(size_t i = 0; i < $1.nElements; ++i) {
7026 Free((char*)$1.elements[i]);
7029 $$->set_location(infile, @$);
7036 Location loc(infile, @1);
7037 $$ = parse_charstring_value($1, loc);
7043 CharKeyword '(' optError UIDlike optError ')'
7053 $$.elements = (const char**)
7054 Realloc($$.elements, ($$.nElements) * sizeof(*$$.elements));
7055 $$.elements[$$.nElements-1] = $1;
7057 | UIDlike optError ',' optError Cstring {
7058 $$.nElements = $1.nElements + 1;
7059 $$.elements = (const char**)
7060 Realloc($1.elements, ($$.nElements) * sizeof(*$$.elements));
7061 $$.elements[$$.nElements-1] = $5;
7066 CharKeyword '(' optError Group optError ',' optError Plane optError ','
7067 optError Row optError ',' optError Cell optError ')'
7068 { $$ = new ustring($4, $8, $12, $16); }
7069 | CharKeyword '(' error ')' { $$ = new ustring; }
7075 if (*$1 < 0 || *$1 > 127) {
7076 Location loc(infile, @1);
7077 loc.error("The first number of quadruple (group) must be within the "
7078 "range 0 .. 127 instead of %s", $1->t_str().c_str());
7079 $$ = *$1 < 0 ? 0 : 127;
7090 if (*$1 < 0 || *$1 > 255) {
7091 Location loc(infile, @1);
7092 loc.error("The second number of quadruple (plane) must be within the "
7093 "range 0 .. 255 instead of %s", $1->t_str().c_str());
7094 $$ = *$1 < 0 ? 0 : 255;
7105 if (*$1 < 0 || *$1 > 255) {
7106 Location loc(infile, @1);
7107 loc.error("The third number of quadruple (row) must be within the "
7108 "range 0 .. 255 instead of %s", $1->t_str().c_str());
7109 $$ = *$1 < 0 ? 0 : 255;
7120 if (*$1 < 0 || *$1 > 255) {
7121 Location loc(infile, @1);
7122 loc.error("The fourth number of quadruple (cell) must be within the "
7123 "range 0 .. 255 instead of %s", $1->t_str().c_str());
7124 $$ = *$1 < 0 ? 0 : 255;
7133 Cstring { $$ = $1; }
7136 $$ = mputstr($1, $2);
7141 AddressValue: // 510
7144 $$ = new Value(Value::V_TTCN3_NULL);
7145 $$->set_location(infile, @$);
7152 $$ = new Value(Value::V_OMIT);
7153 $$->set_location(infile, @$);
7157 ReferencedValue: // 489
7160 if ($1.is_ref) $$ = new Value(Value::V_REFD, $1.ref);
7161 else $$ = new Value(Value::V_UNDEF_LOWERID, $1.id);
7162 $$->set_location(infile, @$);
7165 Reference: // 490 ValueReference
7171 | IDentifier '.' PredefOrIdentifier optExtendedFieldReference
7174 $$.ref = new Ttcn::Reference($1);
7175 FieldOrArrayRef *fieldref = new FieldOrArrayRef($3);
7176 fieldref->set_location(infile, @3);
7177 $$.ref->add(fieldref);
7178 for (size_t i = 0; i < $4.nElements; i++) $$.ref->add($4.elements[i]);
7180 $$.ref->set_location(infile, @$);
7182 | IDentifier ArrayOrBitRef optExtendedFieldReference
7185 $$.ref = new Ttcn::Reference($1);
7187 for (size_t i = 0; i < $3.nElements; i++) $$.ref->add($3.elements[i]);
7189 $$.ref->set_location(infile, @$);
7191 | IDentifier '[' NotUsedSymbol ']'
7194 $$.ref = new Ttcn::Reference($1);
7195 Value* novalue = new Value(Value::V_NOTUSED);
7196 novalue->set_location(infile, @3);
7197 $$.ref->add(new FieldOrArrayRef(novalue));
7198 $$.ref->set_location(infile, @$);
7200 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
7201 optExtendedFieldReference
7204 $$.ref = new Ttcn::Reference($1, $5);
7206 for (size_t i = 0; i < $6.nElements; i++) $$.ref->add($6.elements[i]);
7208 $$.ref->set_location(infile, @$);
7212 /* A.1.6.5 Parameterization */
7215 /* empty */ { $$ = false; }
7216 | LazyKeyword { $$ = true; }
7219 FormalValuePar: // 516
7220 optLazyEval Type IDentifier optParDefaultValue
7222 $$ = new FormalPar(Common::Assignment::A_PAR_VAL, $2, $3, $4, $1);
7223 $$->set_location(infile, @$);
7225 | InParKeyword optLazyEval Type IDentifier optParDefaultValue
7227 $$ = new FormalPar(Common::Assignment::A_PAR_VAL_IN, $3, $4, $5, $2);
7228 $$->set_location(infile, @$);
7230 | InOutParKeyword Type IDentifier optParDefaultValue
7232 $$ = new FormalPar(Common::Assignment::A_PAR_VAL_INOUT, $2, $3, $4);
7233 $$->set_location(infile, @$);
7235 | OutParKeyword Type IDentifier optParDefaultValue
7237 $$ = new FormalPar(Common::Assignment::A_PAR_VAL_OUT, $2, $3, $4);
7238 $$->set_location(infile, @$);
7243 FormalPortPar: // 518
7244 IDentifier IDentifier
7245 | InOutParKeyword IDentifier IDentifier
7249 FormalTimerPar: // 520
7250 TimerKeyword IDentifier optParDefaultValue
7252 $$ = new FormalPar(Common::Assignment::A_PAR_TIMER, $2, $3);
7253 $$->set_location(infile, @$);
7255 | InOutParKeyword TimerKeyword IDentifier optParDefaultValue
7257 $$ = new FormalPar(Common::Assignment::A_PAR_TIMER, $3, $4);
7258 $$->set_location(infile, @$);
7262 FormalTemplatePar: // 522
7263 TemplateOptRestricted optLazyEval Type IDentifier optParDefaultValue
7265 $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_IN, $1, $3, $4, $5, $2);
7266 $$->set_location(infile, @$);
7268 | InParKeyword TemplateOptRestricted optLazyEval Type IDentifier optParDefaultValue
7270 $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_IN, $2, $4, $5, $6, $3);
7271 $$->set_location(infile, @$);
7273 | InOutParKeyword TemplateOptRestricted Type IDentifier optParDefaultValue
7275 $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_INOUT, $2, $3, $4, $5);
7276 $$->set_location(infile, @$);
7278 | OutParKeyword TemplateOptRestricted Type IDentifier optParDefaultValue
7280 $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_OUT, $2, $3, $4, $5);
7281 $$->set_location(infile, @$);
7285 /* template with optional restriction */
7286 TemplateOptRestricted:
7287 TemplateKeyword optTemplateRestriction
7297 optTemplateRestriction:
7298 /* none */ { $$ = TR_NONE; }
7299 | TemplateRestriction { $$ = $1; }
7301 TemplateRestriction:
7302 '(' OmitKeyword ')' { $$ = TR_OMIT; }
7303 | '(' ValueKeyword ')' { $$ = TR_VALUE; }
7304 | '(' PresentKeyword ')' { $$ = TR_PRESENT; }
7308 /* empty */ { $$ = NULL; }
7309 | AssignmentChar TemplateInstance { $$ = $2; }
7310 | AssignmentChar NotUsedSymbol
7312 Template *t = new Template(Template::TEMPLATE_NOTUSED);
7313 t->set_location(infile, @$);
7314 $$ = new TemplateInstance(0, 0, t);
7315 $$->set_location(infile, @$);
7319 /* A.1.6.6 With statement */
7321 optWithStatement: // [526]
7322 /* empty */ { $$ = NULL; }
7323 | WithStatement { $$ = $1; }
7326 optWithStatementAndSemiColon:
7327 /* empty */ { $$ = NULL; }
7328 | WithStatement { $$ = $1; }
7329 | ';' { $$ = NULL; }
7330 | WithStatement ';' { $$ = $1; }
7333 WithStatement: // 526
7334 WithKeyword WithAttribList { $$ = $2; }
7337 WithAttribList: // 528
7338 '{' MultiWithAttrib optError '}' { $$ = $2; }
7339 | '{' error '}' { $$ = NULL; }
7342 MultiWithAttrib: // 529
7343 optError SingleWithAttrib optSemiColon
7345 $$ = new MultiWithAttrib;
7346 $$->set_location(infile, @$);
7347 $$->add_element($2);
7349 | MultiWithAttrib optError SingleWithAttrib optSemiColon
7352 $$->add_element($3);
7356 SingleWithAttrib: // 530
7357 AttribKeyword optOverrideKeyword optAttribQualifier AttribSpec
7359 $$ = new SingleWithAttrib($1,$2,$3,$4);
7360 $$->set_location(infile, @$);
7364 AttribKeyword: // 531
7365 EncodeKeyword { $$ = SingleWithAttrib::AT_ENCODE; }
7366 | VariantKeyword { $$ = SingleWithAttrib::AT_VARIANT; }
7367 | DisplayKeyword { $$ = SingleWithAttrib::AT_DISPLAY; }
7368 | ExtensionKeyword { $$ = SingleWithAttrib::AT_EXTENSION; }
7369 | OptionalKeyword { $$ = SingleWithAttrib::AT_OPTIONAL; }
7372 /* workaround to get rid of ErroneousKeyword which would clash with
7373 * existing TTCN-3 source code */
7374 if ($1->get_ttcnname()=="erroneous") $$ = SingleWithAttrib::AT_ERRONEOUS;
7376 Location loc(infile, @1);
7377 loc.error("Invalid attribute. Valid attributes are: "
7378 "`encode', `variant' , `display' , `extension', `optional' and `erroneous'");
7379 if ($1->get_ttcnname()=="titan")
7381 " ________ _____ ________ ____ __ _ \n"
7382 "(___ ___) (_ _) (___ ___) ( ) / \\ / ) \n"
7383 " ) ) | | ) ) / /\\ \\ / /\\ \\ / / \n"
7384 " ( ( | | ( ( ( (__) ) ) ) ) ) ) ) \n"
7385 " ) ) | | ) ) ) ( ( ( ( ( ( ( \n"
7386 " ( ( _| |__ ( ( / /\\ \\ / / \\ \\/ / \n"
7387 " /__\\ /_____( /__\\ /__( )__\\ (_/ \\__/ \n");
7388 $$ = SingleWithAttrib::AT_INVALID;
7394 optOverrideKeyword: // [536]
7395 /* empty */ { $$ = false; }
7396 | OverrideKeyword { $$ = true; }
7399 optAttribQualifier: // [537]
7400 /* empty */ { $$ = NULL; }
7401 | '(' DefOrFieldRefList optError ')' { $$ = $2; }
7402 | '(' error ')' { $$ = NULL; }
7405 DefOrFieldRefList: // 538
7406 optError DefOrFieldRef
7408 $$ = new Qualifiers();
7409 if ($2) $$->add_qualifier($2);
7411 | DefOrFieldRefList optError ',' optError DefOrFieldRef
7414 if ($5) $$->add_qualifier($5);
7416 | DefOrFieldRefList optError ',' error { $$ = $1; }
7419 ArrayOrBitRefOrDash:
7420 ArrayOrBitRef { $$ = $1; }
7421 | '[' NotUsedSymbol ']'
7423 Value* novalue = new Value(Value::V_NOTUSED);
7424 novalue->set_location(infile, @2);
7425 $$ = new FieldOrArrayRef(novalue);
7426 $$->set_location(infile, @$);
7429 DefOrFieldRef: // 539
7432 $$ = new Qualifier();
7433 $$->add(new FieldOrArrayRef($1));
7434 $$->set_location(infile, @1);
7436 | IDentifier '.' IDentifier optExtendedFieldReference
7438 $$ = new Qualifier();
7439 $$->add(new FieldOrArrayRef($1));
7440 $$->add(new FieldOrArrayRef($3));
7441 for(size_t i=0; i<$4.nElements; i++) {
7442 $$->add($4.elements[i]);
7445 $$->set_location(infile, @$);
7447 | IDentifier ArrayOrBitRefOrDash optExtendedFieldReference
7449 $$ = new Qualifier();
7450 $$->add(new FieldOrArrayRef($1));
7452 for(size_t i=0; i<$3.nElements; i++) {
7453 $$->add($3.elements[i]);
7456 $$->set_location(infile, @$);
7458 | ArrayOrBitRefOrDash optExtendedFieldReference
7460 $$ = new Qualifier();
7462 for(size_t i=0; i<$2.nElements; i++) {
7463 $$->add($2.elements[i]);
7466 $$->set_location(infile, @$);
7470 Location loc(infile, @$);
7471 loc.error("Reference to multiple definitions in attribute qualifiers is "
7472 "not currently supported");
7478 GroupKeyword AllKeyword
7479 | GroupKeyword AllKeyword ExceptKeyword '{' GroupRefList optError '}'
7480 | TypeDefKeyword AllKeyword
7481 | TypeDefKeyword AllKeyword ExceptKeyword '{' TypeRefList optError '}'
7482 | TemplateKeyword AllKeyword
7483 | TemplateKeyword AllKeyword ExceptKeyword '{' TemplateRefList optError '}'
7484 | ConstKeyword AllKeyword
7485 | ConstKeyword AllKeyword ExceptKeyword '{' ConstRefList optError '}'
7486 | AltstepKeyword AllKeyword
7487 | AltstepKeyword AllKeyword ExceptKeyword '{' AltstepRefList optError '}'
7488 | TestcaseKeyword AllKeyword
7489 | TestcaseKeyword AllKeyword ExceptKeyword '{' TestcaseRefList optError '}'
7490 | FunctionKeyword AllKeyword
7491 | FunctionKeyword AllKeyword ExceptKeyword '{' FunctionRefList optError '}'
7492 | SignatureKeyword AllKeyword
7493 | SignatureKeyword AllKeyword ExceptKeyword '{' SignatureRefList optError '}'
7494 | ModuleParKeyword AllKeyword
7495 | ModuleParKeyword AllKeyword ExceptKeyword '{' ModuleParRefList optError '}'
7501 $$ = new AttributeSpec(string($1));
7502 $$->set_location(infile, @$);
7507 /* A.1.6.7 Behaviour statements */
7509 BehaviourStatements: // 543
7512 if ($1.ref_pard) $$ = new Statement(Statement::S_TESTCASE_INSTANCE,
7513 $1.ref_pard, $1.value);
7514 else if($1.derefered_value) {
7515 $$ = new Statement(Statement::S_TESTCASE_INSTANCE_REFD,
7516 $1.derefered_value, $1.ap_list->steal_tis(), $1. value);
7519 else $$ = new Statement(Statement::S_ERROR);
7520 $$->set_location(infile, @$);
7524 $$ = new Statement(Statement::S_UNKNOWN_INSTANCE, $1);
7525 $$->set_location(infile, @$);
7529 $$ = new Statement(Statement::S_UNKNOWN_INVOKED, $1.value, $1.ap_list);
7530 $$->set_location(infile, @$);
7532 | ReturnStatement { $$ = $1; }
7533 | AltConstruct { $$ = $1; }
7534 | InterleavedConstruct { $$ = $1; }
7535 | LabelStatement { $$ = $1; }
7536 | GotoStatement { $$=$1; }
7537 | RepeatStatement { $$ = $1; }
7538 | BreakStatement { $$ = $1; }
7539 | ContinueStatement { $$ = $1; }
7540 | DeactivateStatement { $$ = $1; }
7541 /* | AltstepInstance -- covered by FunctionInstance */
7544 if ($1.ref_pard) $$ = new Statement(Statement::S_ACTIVATE, $1.ref_pard);
7545 else if($1.derefered_value) $$ = new Statement(Statement::S_ACTIVATE_REFD,
7546 $1.derefered_value, new ParsedActualParameters($1.ap_list));
7547 else $$ = new Statement(Statement::S_ERROR);
7548 $$->set_location(infile, @$);
7552 VerdictStatements: // 544
7553 SetLocalVerdict { $$ = $1; }
7557 GetLocalVerdict { $$ = $1; }
7560 SetLocalVerdict: // 546
7561 SetVerdictKeyword '(' Expression optError ',' LogItemList optError ')'
7563 $$=new Statement(Statement::S_SETVERDICT, $3, $6);
7564 $$->set_location(infile, @$);
7566 | SetVerdictKeyword '(' Expression optError ')'
7568 $$=new Statement(Statement::S_SETVERDICT, $3, (LogArguments*)0);
7569 $$->set_location(infile, @$);
7571 | SetVerdictKeyword '(' error ')'
7573 Value *v = new Value(Value::V_ERROR);
7574 v->set_location(infile, @3);
7575 $$ = new Statement(Statement::S_SETVERDICT, v);
7576 $$->set_location(infile, @$);
7580 GetLocalVerdict: // 548
7583 $$=new Value(Value::OPTYPE_GETVERDICT);
7584 $$->set_location(infile, @$);
7588 SUTStatements: // 549
7589 ActionKeyword '(' ')'
7591 $$=new Statement(Statement::S_ACTION, (LogArguments*)0);
7592 $$->set_location(infile, @$);
7594 | ActionKeyword '(' LogItemList optError ')'
7596 $$=new Statement(Statement::S_ACTION, $3);
7597 $$->set_location(infile, @$);
7599 | ActionKeyword '(' error ')'
7601 $$=new Statement(Statement::S_ACTION, new LogArguments());
7602 $$->set_location(infile, @$);
7606 StopExecutionStatement:
7609 $$=new Statement(Statement::S_STOP_EXEC);
7610 $$->set_location(infile, @$);
7614 StopTestcaseStatement:
7615 TestcaseKeyword DotStopKeyword
7617 $$ = new Statement(Statement::S_STOP_TESTCASE, (LogArguments*)0);
7618 $$->set_location(infile, @$);
7620 | TestcaseKeyword DotStopKeyword '(' LogItemList optError ')'
7622 $$ = new Statement(Statement::S_STOP_TESTCASE, $4);
7623 $$->set_location(infile, @$);
7627 /* these deliberately don't have their locations set */
7629 TitanSpecificProfilerKeyword DotStartKeyword
7631 $$ = new Statement(Statement::S_START_PROFILER);
7633 | TitanSpecificProfilerKeyword DotStopKeyword
7635 $$ = new Statement(Statement::S_STOP_PROFILER);
7640 int2enumKeyword '(' optError Expression optError ',' optError Reference optError ')'
7642 Ttcn::Reference* out_ref;
7643 if ($8.is_ref) out_ref = $8.ref;
7645 out_ref = new Ttcn::Reference($8.id);
7646 out_ref->set_location(infile, @8);
7648 $$ = new Statement(Statement::S_INT2ENUM, $4, out_ref);
7649 $$->set_location(infile, @$);
7654 TitanSpecificProfilerKeyword DotRunningKeyword
7656 $$ = new Value(Value::OPTYPE_PROF_RUNNING);
7657 $$->set_location(infile, @$);
7661 ReturnStatement: // 552
7664 $$=new Statement(Statement::S_RETURN, (Template*)0);
7665 $$->set_location(infile, @$);
7667 | ReturnKeyword TemplateBody
7669 $$=new Statement(Statement::S_RETURN, $2);
7670 $$->set_location(infile, @$);
7674 AltConstruct: // 553
7675 AltKeyword '{' AltGuardList optError '}'
7677 $$=new Statement(Statement::S_ALT, $3);
7678 $$->set_location(infile, @$);
7680 | AltKeyword '{' error '}'
7682 $$=new Statement(Statement::S_ALT, new AltGuards());
7683 $$->set_location(infile, @$);
7687 AltGuardList: // 555
7693 | AltGuardList optError AltGuard
7701 GuardStatement { $$ = $1; }
7702 | ElseStatement { $$ = $1; }
7705 GuardStatement: // 556
7706 AltGuardChar AltstepInstance optSemiColon
7708 $$=new AltGuard($1, $2, 0);
7709 $$->set_location(infile, @$);
7711 | AltGuardChar ApplyOp optSemiColon
7713 $$=new AltGuard($1, $2.value, $2.ap_list->steal_tis(), 0);
7714 $$->set_location(infile, @$);
7717 | AltGuardChar AltstepInstance optSemiColon StatementBlock optSemiColon
7719 $$=new AltGuard($1, $2, $4);
7720 $$->set_location(infile, @$);
7722 | AltGuardChar ApplyOp optSemiColon StatementBlock optSemiColon
7724 $$= new AltGuard($1, $2.value, $2.ap_list->steal_tis(), $4);
7725 $$->set_location(infile, @$);
7728 | AltGuardChar GuardOp ';'
7730 $$=new AltGuard($1, $2, new StatementBlock());
7731 $$->set_location(infile, @$);
7733 | AltGuardChar GuardOp optSemiColon StatementBlock optSemiColon
7735 $$=new AltGuard($1, $2, $4);
7736 $$->set_location(infile, @$);
7740 ElseStatement: // 557
7741 '[' ElseKeyword ']' StatementBlock optSemiColon
7743 $$=new AltGuard($4);
7744 $$->set_location(infile, @$);
7748 AltGuardChar: // 558
7750 | '[' BooleanExpression ']' { $$ = $2; }
7754 TimeoutStatement { $$=$1; }
7755 | ReceiveStatement { $$=$1; }
7756 | TriggerStatement { $$=$1; }
7757 | GetCallStatement { $$=$1; }
7758 | CatchStatement { $$=$1; }
7759 | CheckStatement { $$=$1; }
7760 | GetReplyStatement { $$=$1; }
7761 | DoneStatement { $$=$1; }
7762 | KilledStatement { $$ = $1; }
7765 InterleavedConstruct: // 560
7766 InterleavedKeyword '{' InterleavedGuardList optError '}'
7768 $$ = new Statement(Statement::S_INTERLEAVE, $3);
7769 $$->set_location(infile, @$);
7771 | InterleavedKeyword '{' error '}'
7773 $$ = new Statement(Statement::S_INTERLEAVE, new AltGuards());
7774 $$->set_location(infile, @$);
7778 InterleavedGuardList: // 562
7779 optError InterleavedGuardElement
7781 $$ = new AltGuards();
7784 | InterleavedGuardList optError InterleavedGuardElement
7785 { $$ = $1; $$->add_ag($3); }
7788 InterleavedGuardElement: // 563
7789 '[' optError ']' GuardOp ';'
7791 $$ = new AltGuard(0, $4, new StatementBlock());
7792 $$->set_location(infile, @$);
7794 | '[' optError ']' GuardOp optSemiColon StatementBlock optSemiColon
7796 $$ = new AltGuard(0, $4, $6);
7797 $$->set_location(infile, @$);
7801 /* The following were folded into the above rule:
7803 InterleavedGuardElement: // 563
7804 InterleavedGuard InterleavedAction
7807 InterleavedGuard: // 564
7811 InterleavedAction: // 565
7816 LabelStatement: // 566
7817 LabelKeyword IDentifier
7819 $$=new Statement(Statement::S_LABEL, $2);
7820 $$->set_location(infile, @$);
7824 GotoStatement: // 569
7825 GotoKeyword IDentifier
7827 $$=new Statement(Statement::S_GOTO, $2);
7828 $$->set_location(infile, @$);
7830 | GotoKeyword AltKeyword
7832 Location loc(infile, @$);
7833 loc.warning("Obsolete statement `goto alt' was substituted with `repeat'");
7834 $$=new Statement(Statement::S_REPEAT);
7835 $$->set_location(infile, @$);
7839 RepeatStatement: // 571
7842 $$=new Statement(Statement::S_REPEAT);
7843 $$->set_location(infile, @$);
7848 ActivateKeyword '(' AltstepInstance optError ')'
7851 $$.derefered_value = 0;
7854 | ActivateKeyword '(' DereferOp '(' optFunctionActualParList ')' optError ')'
7856 $5->set_location(infile, @4, @6);
7858 $$.derefered_value = $3;
7859 $$.ap_list = $5->steal_tis(); /* XXX perhaps propagate the datatype instead ? */
7862 | ActivateKeyword '(' error ')'
7865 $$.derefered_value = 0;
7871 RefersKeyword '(' FunctionRef ')'
7873 Ttcn::Reference* t_ref = new Ttcn::Reference($3.modid, $3.id);
7874 t_ref->set_location(infile, @3);
7875 $$ = new Value(Value::V_REFER, t_ref);
7876 $$->set_location(infile, @$);
7880 DeactivateStatement: // 574
7883 $$=new Statement(Statement::S_DEACTIVATE, (Value*)0);
7884 $$->set_location(infile, @$);
7886 | DeactivateKeyword '(' Expression optError ')'
7888 $$=new Statement(Statement::S_DEACTIVATE, $3);
7889 $$->set_location(infile, @$);
7891 | DeactivateKeyword '(' error ')'
7893 Value *v = new Value(Value::V_ERROR);
7894 v->set_location(infile, @3);
7895 $$ = new Statement(Statement::S_DEACTIVATE, v);
7896 $$->set_location(infile, @$);
7900 BreakStatement: // 576
7903 $$=new Statement(Statement::S_BREAK);
7904 $$->set_location(infile, @$);
7908 ContinueStatement: // 577
7911 $$=new Statement(Statement::S_CONTINUE);
7912 $$->set_location(infile, @$);
7916 /* A.1.6.8 Basic statements */
7918 BasicStatements: // 578
7921 $$=new Statement(Statement::S_ASSIGNMENT, $1);
7922 $$->set_location(infile, @$);
7924 | LogStatement { $$ = $1; }
7925 | String2TtcnStatement { $$ = $1; }
7928 $$ = new Statement(Statement::S_BLOCK, $1);
7929 $$->set_location(infile, @$);
7931 | TitanSpecificTryKeyword StatementBlock
7933 $$ = new Statement(Statement::S_BLOCK, $2);
7934 $2->set_exception_handling(StatementBlock::EH_TRY);
7935 $$->set_location(infile, @$);
7937 | TitanSpecificCatchKeyword '(' IDentifier ')' StatementBlock
7939 $$ = new Statement(Statement::S_BLOCK, $5);
7940 $5->set_exception_handling(StatementBlock::EH_CATCH);
7941 /* add a newly constructed first statement which will contain the error message,
7942 same as: 'var charstring IDentifier;' */
7943 Type* str_type = new Type(Type::T_CSTR);
7944 str_type->set_location(infile, @3);
7945 Def_Var* str_def = new Def_Var($3, str_type, 0);
7946 str_def->set_location(infile, @3);
7947 Statement* str_stmt = new Statement(Statement::S_DEF, str_def);
7948 str_stmt->set_location(infile, @3);
7949 $5->add_stmt(str_stmt, true);
7950 $$->set_location(infile, @$);
7952 | LoopConstruct { $$ = $1; }
7953 | ConditionalConstruct { $$ = $1; }
7954 | SelectCaseConstruct { $$ = $1; }
7958 '(' optError Expression optError ')' { $$ = $3; }
7961 $$ = new Value(Value::V_ERROR);
7962 $$->set_location(infile, @$);
7964 | '+' Expression %prec UnarySign
7966 $$ = new Value(Value::OPTYPE_UNARYPLUS, $2);
7967 $$->set_location(infile, @$);
7969 | '-' Expression %prec UnarySign
7971 $$ = new Value(Value::OPTYPE_UNARYMINUS, $2);
7972 $$->set_location(infile, @$);
7974 | Expression '*' Expression
7976 $$ = new Value(Value::OPTYPE_MULTIPLY, $1, $3);
7977 $$->set_location(infile, @$);
7979 | Expression '/' Expression
7981 $$ = new Value(Value::OPTYPE_DIVIDE, $1, $3);
7982 $$->set_location(infile, @$);
7984 | Expression ModKeyword Expression
7986 $$ = new Value(Value::OPTYPE_MOD, $1, $3);
7987 $$->set_location(infile, @$);
7989 | Expression RemKeyword Expression
7991 $$ = new Value(Value::OPTYPE_REM, $1, $3);
7992 $$->set_location(infile, @$);
7994 | Expression '+' Expression
7996 $$ = new Value(Value::OPTYPE_ADD, $1, $3);
7997 $$->set_location(infile, @$);
7999 | Expression '-' Expression
8001 $$ = new Value(Value::OPTYPE_SUBTRACT, $1, $3);
8002 $$->set_location(infile, @$);
8004 | Expression '&' Expression
8006 $$ = new Value(Value::OPTYPE_CONCAT, $1, $3);
8007 $$->set_location(infile, @$);
8009 | Not4bKeyword Expression
8011 $$ = new Value(Value::OPTYPE_NOT4B, $2);
8012 $$->set_location(infile, @$);
8014 | Expression And4bKeyword Expression
8016 $$ = new Value(Value::OPTYPE_AND4B, $1, $3);
8017 $$->set_location(infile, @$);
8019 | Expression Xor4bKeyword Expression
8021 $$ = new Value(Value::OPTYPE_XOR4B, $1, $3);
8022 $$->set_location(infile, @$);
8024 | Expression Or4bKeyword Expression
8026 $$ = new Value(Value::OPTYPE_OR4B, $1, $3);
8027 $$->set_location(infile, @$);
8029 | Expression SL Expression
8031 $$ = new Value(Value::OPTYPE_SHL, $1, $3);
8032 $$->set_location(infile, @$);
8034 | Expression SR Expression
8036 $$ = new Value(Value::OPTYPE_SHR, $1, $3);
8037 $$->set_location(infile, @$);
8039 | Expression RL Expression
8041 $$ = new Value(Value::OPTYPE_ROTL, $1, $3);
8042 $$->set_location(infile, @$);
8044 | Expression _RR Expression
8046 $$ = new Value(Value::OPTYPE_ROTR, $1, $3);
8047 $$->set_location(infile, @$);
8049 | Expression '<' Expression
8051 $$ = new Value(Value::OPTYPE_LT, $1, $3);
8052 $$->set_location(infile, @$);
8054 | Expression '>' Expression
8056 $$ = new Value(Value::OPTYPE_GT, $1, $3);
8057 $$->set_location(infile, @$);
8059 | Expression LE Expression
8061 $$ = new Value(Value::OPTYPE_LE, $1, $3);
8062 $$->set_location(infile, @$);
8064 | Expression GE Expression
8066 $$ = new Value(Value::OPTYPE_GE, $1, $3);
8067 $$->set_location(infile, @$);
8069 | Expression EQ Expression
8071 $$ = new Value(Value::OPTYPE_EQ, $1, $3);
8072 $$->set_location(infile, @$);
8074 | Expression NE Expression
8076 $$ = new Value(Value::OPTYPE_NE, $1, $3);
8077 $$->set_location(infile, @$);
8079 | NotKeyword Expression
8081 $$ = new Value(Value::OPTYPE_NOT, $2);
8082 $$->set_location(infile, @$);
8084 | Expression AndKeyword Expression
8086 $$ = new Value(Value::OPTYPE_AND, $1, $3);
8087 $$->set_location(infile, @$);
8089 | Expression XorKeyword Expression
8091 $$ = new Value(Value::OPTYPE_XOR, $1, $3);
8092 $$->set_location(infile, @$);
8094 | Expression OrKeyword Expression
8096 $$ = new Value(Value::OPTYPE_OR, $1, $3);
8097 $$->set_location(infile, @$);
8099 | OpCall { $$ = $1; }
8100 | Value { $$ = $1; }
8101 | CompoundExpression { $$ = $1; }
8104 CompoundExpression: // 565
8105 FieldExpressionList { $$ = $1; }
8106 | ArrayExpressionList { $$ = $1; }
8107 | ArrayExpression { $$ = $1; }
8110 FieldExpressionList: // 581
8111 '{' seqFieldExpressionSpec optError '}'
8113 $$ = new Value(Value::V_SEQ, $2);
8114 $$->set_location(infile, @$);
8118 seqFieldExpressionSpec:
8121 $$ = new NamedValues();
8124 | error FieldExpressionSpec
8126 $$ = new NamedValues();
8129 | seqFieldExpressionSpec optError ',' optError FieldExpressionSpec
8134 | seqFieldExpressionSpec optError ',' error { $$ = $1; }
8137 FieldExpressionSpec: // 582
8138 FieldReference AssignmentChar NotUsedOrExpression
8140 $$ = new NamedValue($1, $3);
8141 $$->set_location(infile, @$);
8145 ArrayExpressionList:
8146 '{' seqArrayExpressionSpec optError '}'
8148 $$ = new Value(Value::V_SEQOF, $2);
8149 $$->set_location(infile, @$);
8153 seqArrayExpressionSpec:
8154 optError ArrayExpressionSpec
8156 // The only place for indexed-list notation.
8157 $$ = new Values(true);
8160 | seqArrayExpressionSpec optError ',' optError ArrayExpressionSpec
8165 | seqArrayExpressionSpec optError ',' error { $$ = $1; }
8168 ArrayExpressionSpec:
8169 ArrayOrBitRef AssignmentChar Expression
8171 $$ = new IndexedValue($1, $3);
8172 $$->set_location(infile, @$);
8176 ArrayExpression: // 583
8179 $$ = new Value(Value::V_SEQOF, new Values);
8180 $$->set_location(infile, @$);
8182 | '{' ArrayElementExpressionList optError '}'
8184 $$ = new Value(Value::V_SEQOF, $2);
8185 $$->set_location(infile, @$);
8189 $$ = new Value(Value::V_ERROR);
8190 $$->set_location(infile, @$);
8194 ArrayElementExpressionList: // 584
8200 | error NotUsedOrExpression
8205 | ArrayElementExpressionList optError ',' optError NotUsedOrExpression
8210 | ArrayElementExpressionList optError ',' error { $$ = $1; }
8213 NotUsedOrExpression: // 585
8214 Expression { $$ = $1; }
8217 $$ = new Value(Value::V_NOTUSED);
8218 $$->set_location(infile, @$);
8222 BooleanExpression: // 588
8223 Expression { $$ = $1; }
8226 $$ = new Value(Value::V_ERROR);
8227 $$->set_location(infile, @$);
8232 VariableRef AssignmentChar TemplateBody
8234 $$ = new Ttcn::Assignment($1, $3);
8235 $$->set_location(infile, @$);
8239 /* This can not be a single CompoundExpression (as opposed to Expression) */
8240 SingleExpression: // 595
8241 '(' SingleExpression ')' { $$ = $2; }
8242 | '(' error SingleExpression ')' { $$ = $3; }
8245 $$ = new Value(Value::V_ERROR);
8246 $$->set_location(infile, @$);
8248 | '+' Expression %prec UnarySign
8250 $$ = new Value(Value::OPTYPE_UNARYPLUS, $2);
8251 $$->set_location(infile, @$);
8253 | '-' Expression %prec UnarySign
8255 $$ = new Value(Value::OPTYPE_UNARYMINUS, $2);
8256 $$->set_location(infile, @$);
8258 | SingleExpression '*' Expression
8260 $$ = new Value(Value::OPTYPE_MULTIPLY, $1, $3);
8261 $$->set_location(infile, @$);
8263 | SingleExpression '/' Expression
8265 $$ = new Value(Value::OPTYPE_DIVIDE, $1, $3);
8266 $$->set_location(infile, @$);
8268 | SingleExpression ModKeyword Expression
8270 $$ = new Value(Value::OPTYPE_MOD, $1, $3);
8271 $$->set_location(infile, @$);
8273 | SingleExpression RemKeyword Expression
8275 $$ = new Value(Value::OPTYPE_REM, $1, $3);
8276 $$->set_location(infile, @$);
8278 | SingleExpression '+' Expression
8280 $$ = new Value(Value::OPTYPE_ADD, $1, $3);
8281 $$->set_location(infile, @$);
8283 | SingleExpression '-' Expression
8285 $$ = new Value(Value::OPTYPE_SUBTRACT, $1, $3);
8286 $$->set_location(infile, @$);
8288 | SingleExpression '&' Expression
8290 $$ = new Value(Value::OPTYPE_CONCAT, $1, $3);
8291 $$->set_location(infile, @$);
8293 | Not4bKeyword Expression
8295 $$ = new Value(Value::OPTYPE_NOT4B, $2);
8296 $$->set_location(infile, @$);
8298 | SingleExpression And4bKeyword Expression
8300 $$ = new Value(Value::OPTYPE_AND4B, $1, $3);
8301 $$->set_location(infile, @$);
8303 | SingleExpression Xor4bKeyword Expression
8305 $$ = new Value(Value::OPTYPE_XOR4B, $1, $3);
8306 $$->set_location(infile, @$);
8308 | SingleExpression Or4bKeyword Expression
8310 $$ = new Value(Value::OPTYPE_OR4B, $1, $3);
8311 $$->set_location(infile, @$);
8313 | SingleExpression SL Expression
8315 $$ = new Value(Value::OPTYPE_SHL, $1, $3);
8316 $$->set_location(infile, @$);
8318 | SingleExpression SR Expression
8320 $$ = new Value(Value::OPTYPE_SHR, $1, $3);
8321 $$->set_location(infile, @$);
8323 | SingleExpression RL Expression
8325 $$ = new Value(Value::OPTYPE_ROTL, $1, $3);
8326 $$->set_location(infile, @$);
8328 | SingleExpression _RR Expression
8330 $$ = new Value(Value::OPTYPE_ROTR, $1, $3);
8331 $$->set_location(infile, @$);
8333 | SingleExpression '<' Expression
8335 $$ = new Value(Value::OPTYPE_LT, $1, $3);
8336 $$->set_location(infile, @$);
8338 | SingleExpression '>' Expression
8340 $$ = new Value(Value::OPTYPE_GT, $1, $3);
8341 $$->set_location(infile, @$);
8343 | SingleExpression LE Expression
8345 $$ = new Value(Value::OPTYPE_LE, $1, $3);
8346 $$->set_location(infile, @$);
8348 | SingleExpression GE Expression
8350 $$ = new Value(Value::OPTYPE_GE, $1, $3);
8351 $$->set_location(infile, @$);
8353 | SingleExpression EQ Expression
8355 $$ = new Value(Value::OPTYPE_EQ, $1, $3);
8356 $$->set_location(infile, @$);
8358 | SingleExpression NE Expression
8360 $$ = new Value(Value::OPTYPE_NE, $1, $3);
8361 $$->set_location(infile, @$);
8363 | NotKeyword Expression
8365 $$ = new Value(Value::OPTYPE_NOT, $2);
8366 $$->set_location(infile, @$);
8368 | SingleExpression AndKeyword Expression
8370 $$ = new Value(Value::OPTYPE_AND, $1, $3);
8371 $$->set_location(infile, @$);
8373 | SingleExpression XorKeyword Expression
8375 $$ = new Value(Value::OPTYPE_XOR, $1, $3);
8376 $$->set_location(infile, @$);
8378 | SingleExpression OrKeyword Expression
8380 $$ = new Value(Value::OPTYPE_OR, $1, $3);
8381 $$->set_location(infile, @$);
8383 | OpCall { $$ = $1; }
8384 | Value { $$ = $1; }
8387 optExtendedFieldReference:
8388 // perhaps this should be called seqExtendedFieldReference,
8389 // but the convention appears to be that seq... can not be empty
8395 | optExtendedFieldReference FieldOrArrayReference
8397 $$.nElements = $1.nElements + 1;
8398 $$.elements = (FieldOrArrayRef**)
8399 Realloc($1.elements, ($$.nElements) * sizeof(*$$.elements));
8400 $$.elements[$1.nElements] = $2;
8404 FieldOrArrayReference:
8407 $$ = new FieldOrArrayRef($2);
8408 $$->set_location(infile, @$);
8410 | ArrayOrBitRefOrDash { $$ = $1; }
8414 PredefOrIdentifier { $$ = $1; }
8415 | IDentifier /* maybe PredefOrIdentifier here too */ TypeActualParList
8417 Location loc(infile, @$);
8418 loc.error("Reference to a parameterized field of type `anytype' is "
8419 "not currently supported");
8425 ConfigurationOps { $$ = $1; }
8426 | VerdictOps { $$ = $1; }
8427 | TimerOps { $$ = $1; }
8430 if ($1.ref_pard) $$ = new Value(Value::OPTYPE_EXECUTE, $1.ref_pard,
8432 else if($1.derefered_value)
8433 $$ = new Value(Value::OPTYPE_EXECUTE_REFD, $1.derefered_value, $1.ap_list,
8435 else $$ = new Value(Value::V_ERROR);
8436 $$->set_location(infile, @$);
8438 | FunctionInstance optExtendedFieldReference
8440 for (size_t i = 0; i < $2.nElements; i++) $1->add($2.elements[i]);
8442 $$ = new Value(Value::V_REFD, $1);
8443 $$->set_location(infile, @$);
8447 $$ = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
8448 $$->set_location(infile, @$);
8450 | TemplateOps { $$ = $1; }
8451 | PredefinedOps { $$ = $1; }
8452 | ReferOp { $$ = $1; }
8455 if ($1.ref_pard) $$ = new Value(Value::OPTYPE_ACTIVATE, $1.ref_pard);
8456 else if($1.derefered_value) $$ = new Value(Value::OPTYPE_ACTIVATE_REFD,
8457 $1.derefered_value, new ParsedActualParameters($1.ap_list));
8458 else $$ = new Value(Value::V_ERROR);
8459 $$->set_location(infile, @$);
8461 | ProfilerRunningOp { $$ = $1; }
8462 | PortOrAny DotCheckStateKeyword '(' SingleExpression ')'
8464 $$ = new Value(Value::OPTYPE_CHECKSTATE_ANY, $1, $4);
8465 $$->set_location(infile, @$);
8467 // PortOrAll would cause a conflict
8468 | AllKeyword PortKeyword DotCheckStateKeyword '(' SingleExpression ')'
8470 Ttcn::Reference *r = NULL;
8471 $$ = new Value(Value::OPTYPE_CHECKSTATE_ALL, r, $5);
8472 $$->set_location(infile, @$);
8477 PredefinedOpKeyword1 '(' optError Expression optError ')'
8479 $$ = new Value($1, $4);
8480 $$->set_location(infile, @$);
8482 | PredefinedOpKeyword1 '(' error ')'
8484 Value *v1 = new Value(Value::V_ERROR);
8485 v1->set_location(infile, @3);
8486 $$ = new Value($1, v1);
8487 $$->set_location(infile, @$);
8489 | PredefinedOpKeyword2 '(' optError Expression optError ',' optError
8490 Expression optError ')'
8492 $$ = new Value($1, $4, $8);
8493 $$->set_location(infile, @$);
8495 | PredefinedOpKeyword2 '(' error ')'
8497 Value *v1 = new Value(Value::V_ERROR);
8498 v1->set_location(infile, @3);
8499 Value *v2 = new Value(Value::V_ERROR);
8500 v2->set_location(infile, @3);
8501 $$ = new Value($1, v1, v2);
8502 $$->set_location(infile, @$);
8504 | PredefinedOpKeyword3 '(' optError Expression optError ',' optError
8505 Expression optError ')'
8507 $$ = new Value($1, $4, $8);
8508 $$->set_location(infile, @$);
8510 | PredefinedOpKeyword3 '(' optError Expression optError ')'
8512 $$ = new Value($1, $4, (Common::Value*)NULL);
8513 $$->set_location(infile, @$);
8515 | PredefinedOpKeyword3 '(' error ')'
8517 Value *v1 = new Value(Value::V_ERROR);
8518 v1->set_location(infile, @3);
8519 Value *v2 = new Value(Value::V_ERROR);
8520 v2->set_location(infile, @3);
8521 $$ = new Value($1, v1, v2);
8522 $$->set_location(infile, @$);
8524 | decompKeyword '(' optError Expression optError ',' optError
8525 Expression optError ',' optError Expression optError ')'
8527 $$ = new Value(Value::OPTYPE_DECOMP, $4, $8, $12);
8528 $$->set_location(infile, @$);
8530 | decompKeyword '(' error ')'
8532 Value *v1 = new Value(Value::V_ERROR);
8533 v1->set_location(infile, @3);
8534 Value *v2 = new Value(Value::V_ERROR);
8535 v2->set_location(infile, @3);
8536 Value *v3 = new Value(Value::V_ERROR);
8537 v3->set_location(infile, @3);
8538 $$ = new Value(Value::OPTYPE_DECOMP, v1, v2, v3);
8539 $$->set_location(infile, @$);
8541 | regexpKeyword '(' optError TemplateInstance optError ',' optError
8542 TemplateInstance optError ',' optError Expression optError ')'
8544 $$ = new Value(Value::OPTYPE_REGEXP, $4, $8, $12);
8545 $$->set_location(infile, @$);
8547 | regexpKeyword NocaseKeyword '(' optError TemplateInstance optError ',' optError
8548 TemplateInstance optError ',' optError Expression optError ')'
8550 $$ = new Value(Value::OPTYPE_REGEXP, $5, $9, $13);
8551 $$->set_location(infile, @$);
8553 | regexpKeyword '(' error ')'
8555 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8556 t1->set_location(infile, @3);
8557 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8558 ti1->set_location(infile, @3);
8559 Template *t2 = new Template(Template::TEMPLATE_ERROR);
8560 t2->set_location(infile, @3);
8561 TemplateInstance *ti2 = new TemplateInstance(0, 0, t2);
8562 ti2->set_location(infile, @3);
8563 Value *v3 = new Value(Value::V_ERROR);
8564 v3->set_location(infile, @3);
8565 $$ = new Value(Value::OPTYPE_REGEXP, ti1, ti2, v3);
8566 $$->set_location(infile, @$);
8568 | regexpKeyword NocaseKeyword '(' error ')'
8570 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8571 t1->set_location(infile, @4);
8572 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8573 ti1->set_location(infile, @4);
8574 Template *t2 = new Template(Template::TEMPLATE_ERROR);
8575 t2->set_location(infile, @4);
8576 TemplateInstance *ti2 = new TemplateInstance(0, 0, t2);
8577 ti2->set_location(infile, @4);
8578 Value *v3 = new Value(Value::V_ERROR);
8579 v3->set_location(infile, @4);
8580 $$ = new Value(Value::OPTYPE_REGEXP, ti1, ti2, v3);
8581 $$->set_location(infile, @$);
8583 | encvalueKeyword '(' optError TemplateInstance optError ')'
8585 $$ = new Value(Value::OPTYPE_ENCODE, $4);
8586 $$->set_location(infile, @$);
8588 | encvalueKeyword '(' error ')'
8590 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8591 t1->set_location(infile, @3);
8592 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8593 ti1->set_location(infile, @3);
8594 $$ = new Value(Value::OPTYPE_ENCODE, ti1);
8595 $$->set_location(infile, @$);
8597 | substrKeyword '(' optError TemplateInstance optError ',' optError
8598 Expression optError ',' optError Expression optError ')'
8600 $$ = new Value(Value::OPTYPE_SUBSTR, $4, $8, $12);
8601 $$->set_location(infile, @$);
8603 | substrKeyword '(' error ')'
8605 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8606 t1->set_location(infile, @3);
8607 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8608 ti1->set_location(infile, @3);
8609 Value *v2 = new Value(Value::V_ERROR);
8610 v2->set_location(infile, @3);
8611 Value *v3 = new Value(Value::V_ERROR);
8612 v3->set_location(infile, @3);
8613 $$ = new Value(Value::OPTYPE_SUBSTR, ti1, v2, v3);
8614 $$->set_location(infile, @$);
8616 | replaceKeyword '(' optError TemplateInstance optError ',' optError
8617 Expression optError ',' optError Expression optError ',' optError
8618 TemplateInstance optError ')'
8620 $$ = new Value(Value::OPTYPE_REPLACE, $4, $8, $12, $16);
8621 $$->set_location(infile, @$);
8623 | replaceKeyword '(' error ')'
8625 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8626 t1->set_location(infile, @3);
8627 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8628 ti1->set_location(infile, @3);
8629 Value *v2 = new Value(Value::V_ERROR);
8630 v2->set_location(infile, @3);
8631 Value *v3 = new Value(Value::V_ERROR);
8632 v3->set_location(infile, @3);
8633 Template *t4 = new Template(Template::TEMPLATE_ERROR);
8634 t4->set_location(infile, @3);
8635 TemplateInstance *ti4 = new TemplateInstance(0, 0, t4);
8636 ti4->set_location(infile, @3);
8637 $$ = new Value(Value::OPTYPE_REPLACE, ti1, v2, v3, ti4);
8638 $$->set_location(infile, @$);
8640 | decvalueKeyword '(' optError DecValueArg optError ',' optError DecValueArg optError ')'
8642 $$ = new Value(Value::OPTYPE_DECODE, $4, $8);
8643 $$->set_location(infile, @$);
8645 | decvalueKeyword '(' error ')'
8647 /*Value *v1 = new Value(Value::V_ERROR);
8648 v1->set_location(infile, @3);
8649 TemplateInstance *t2 = new TemplateInstance(Type::T_ERROR);*/
8650 $$ = new Value(Value::V_ERROR);
8651 $$->set_location(infile, @$);
8653 | isvalueKeyword '(' optError TemplateInstance optError ')'
8655 $$ = new Value(Value::OPTYPE_ISVALUE, $4);
8656 $$->set_location(infile, @$);
8658 | isvalueKeyword '(' error ')'
8660 $$ = new Value(Value::V_ERROR);
8661 $$->set_location(infile, @$);
8663 | isboundKeyword '(' optError TemplateInstance optError ')'
8665 $$ = new Value(Value::OPTYPE_ISBOUND, $4);
8666 $$->set_location(infile, @$);
8668 | isboundKeyword '(' error ')'
8670 $$ = new Value(Value::V_ERROR);
8671 $$->set_location(infile, @$);
8673 | ischosenKeyword '(' optError IschosenArg optError ')'
8675 $$ = new Value(Value::OPTYPE_ISCHOSEN, $4.ref, $4.id);
8676 $$->set_location(infile, @$);
8678 | ischosenKeyword '(' error ')'
8680 $$ = new Value(Value::V_ERROR);
8681 $$->set_location(infile, @$);
8683 | ispresentKeyword '(' optError TemplateInstance optError ')'
8685 $$ = new Value(Value::OPTYPE_ISPRESENT, $4);
8686 $$->set_location(infile, @$);
8688 | ispresentKeyword '(' error ')'
8690 $$ = new Value(Value::V_ERROR);
8691 $$->set_location(infile, @$);
8693 | lengthofKeyword '(' optError TemplateInstance optError ')'
8695 $$ = new Value(Value::OPTYPE_LENGTHOF, $4);
8696 $$->set_location(infile, @$);
8698 | lengthofKeyword '(' error ')'
8700 $$ = new Value(Value::V_ERROR);
8701 $$->set_location(infile, @$);
8703 | rndKeyword '(' ')'
8705 $$ = new Value(Value::OPTYPE_RND);
8706 $$->set_location(infile, @$);
8708 | rndKeyword '(' optError Expression optError ')'
8710 $$ = new Value(Value::OPTYPE_RNDWITHVAL, $4);
8711 $$->set_location(infile, @$);
8713 | rndKeyword '(' error ')'
8715 Value *v = new Value(Value::V_ERROR);
8716 v->set_location(infile, @3);
8717 $$ = new Value(Value::OPTYPE_RNDWITHVAL, v);
8718 $$->set_location(infile, @$);
8720 | sizeofKeyword '(' optError TemplateInstance optError ')'
8722 $$ = new Value(Value::OPTYPE_SIZEOF, $4);
8723 $$->set_location(infile, @$);
8725 | sizeofKeyword '(' error ')'
8727 $$ = new Value(Value::V_ERROR);
8728 $$->set_location(infile, @$);
8730 | log2strKeyword '(' ')'
8732 $$ = new Value(Value::OPTYPE_LOG2STR, new LogArguments());
8733 $$->set_location(infile, @$);
8735 | log2strKeyword '(' LogItemList optError ')'
8737 $$ = new Value(Value::OPTYPE_LOG2STR, $3);
8738 $$->set_location(infile, @$);
8740 | log2strKeyword '(' error ')'
8742 $$ = new Value(Value::OPTYPE_LOG2STR, new LogArguments());
8743 $$->set_location(infile, @$);
8745 | any2unistrKeyWord '(' LogItemList optError ')'
8747 if ($3->get_nof_logargs() != 1) {
8748 Location loc(infile, @1);
8749 loc.error("The any2unistr function takes exactly one argument, not %lu.",
8750 $3->get_nof_logargs());
8752 $$ = new Value(Value::OPTYPE_ANY2UNISTR, new LogArguments());
8753 $$->set_location(infile, @$);
8755 $$ = new Value(Value::OPTYPE_ANY2UNISTR, $3);
8756 $$->set_location(infile, @$);
8759 | testcasenameKeyword '(' ')'
8761 $$ = new Value(Value::OPTYPE_TESTCASENAME);
8762 $$->set_location(infile, @$);
8764 | ttcn2stringKeyword '(' optError TemplateInstance optError ')'
8766 $$ = new Value(Value::OPTYPE_TTCN2STRING, $4);
8767 $$->set_location(infile, @$);
8769 | ttcn2stringKeyword '(' error ')'
8771 $$ = new Value(Value::V_ERROR);
8772 $$->set_location(infile, @$);
8774 | encvalue_unicharKeyWord '(' optError TemplateInstance optError ',' optError
8775 Expression optError ')'
8777 $$ = new Value(Value::OPTYPE_ENCVALUE_UNICHAR, $4, $8);
8778 $$->set_location(infile, @$);
8780 | encvalue_unicharKeyWord '(' optError TemplateInstance optError ')'
8782 $$ = new Value(Value::OPTYPE_ENCVALUE_UNICHAR, $4);
8783 $$->set_location(infile, @$);
8785 | encvalue_unicharKeyWord '(' error ')'
8787 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8788 t1->set_location(infile, @3);
8789 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8790 ti1->set_location(infile, @3);
8791 $$ = new Value(Value::OPTYPE_ENCVALUE_UNICHAR, ti1);
8792 $$->set_location(infile, @$);
8794 | decvalue_unicharKeyWord '(' optError DecValueArg optError ',' optError
8795 DecValueArg optError ')'
8797 $$ = new Value(Value::OPTYPE_DECVALUE_UNICHAR, $4, $8);
8798 $$->set_location(infile, @$);
8800 | decvalue_unicharKeyWord '(' optError DecValueArg optError ',' optError
8801 DecValueArg optError ',' optError Expression optError ')'
8803 $$ = new Value(Value::OPTYPE_DECVALUE_UNICHAR, $4, $8, $12);
8804 $$->set_location(infile, @$);
8806 | decvalue_unicharKeyWord '(' error ')'
8808 $$ = new Value(Value::V_ERROR);
8809 $$->set_location(infile, @$);
8811 | hostidKeyWord '(' ')'
8813 Value *null_value = NULL;
8814 $$ = new Value(Value::OPTYPE_HOSTID, null_value);
8815 $$->set_location(infile, @$);
8817 | hostidKeyWord '(' optError Expression optError ')'
8819 $$ = new Value(Value::OPTYPE_HOSTID, $4);
8820 $$->set_location(infile, @$);
8827 if ($1.is_ref) $$ = $1.ref;
8829 $$ = new Ttcn::Reference($1.id);
8830 $$->set_location(infile, @$);
8833 | FunctionInstance { $$ = $1; }
8837 IDentifier { $$ = $1; }
8838 | PredefinedType /* shall not be "anytype" */
8840 // Construct an identifier "on the fly" ($1 here is just a typetype_t)
8841 const char* builtin_typename = Type::get_typename_builtin($1);
8842 if (0 == builtin_typename) FATAL_ERROR("Unexpected type %d", $1);
8843 const string& at_field = anytype_field(string(builtin_typename));
8845 $$ = new Identifier(Identifier::ID_TTCN, at_field);
8849 $$ = new Identifier(Identifier::ID_NAME, string("NULL"));
8852 IschosenArg: /* see also Reference... */
8853 IDentifier '.' PredefOrIdentifier
8855 $$.ref = new Ttcn::Reference($1);
8856 $$.ref->set_location(infile, @1);
8859 | IDentifier '.' PredefOrIdentifier optExtendedFieldReference '.' PredefOrIdentifier
8861 $$.ref = new Ttcn::Reference($1);
8862 FieldOrArrayRef *fieldref = new FieldOrArrayRef($3);
8863 fieldref->set_location(infile, @3);
8864 $$.ref->add(fieldref);
8865 for(size_t i=0; i<$4.nElements; i++) $$.ref->add($4.elements[i]);
8867 $$.ref->set_location(infile, @1, @4);
8870 | IDentifier ArrayOrBitRef optExtendedFieldReference '.' PredefOrIdentifier
8872 $$.ref = new Ttcn::Reference($1);
8874 for(size_t i=0; i<$3.nElements; i++) $$.ref->add($3.elements[i]);
8876 $$.ref->set_location(infile, @1, @3);
8879 | IDentifier '.' ObjectIdentifierValue '.' IDentifier optExtendedFieldReference
8880 '.' PredefOrIdentifier
8882 $$.ref = new Ttcn::Reference($1, $5);
8884 for(size_t i=0; i<$6.nElements; i++) $$.ref->add($6.elements[i]);
8886 $$.ref->set_location(infile, @1, @6);
8891 PredefinedOpKeyword1:
8892 bit2hexKeyword { $$ = Value::OPTYPE_BIT2HEX; }
8893 | bit2intKeyword { $$ = Value::OPTYPE_BIT2INT; }
8894 | bit2octKeyword { $$ = Value::OPTYPE_BIT2OCT; }
8895 | bit2strKeyword { $$ = Value::OPTYPE_BIT2STR; }
8896 | char2intKeyword { $$ = Value::OPTYPE_CHAR2INT; }
8897 | char2octKeyword { $$ = Value::OPTYPE_CHAR2OCT; }
8898 | float2intKeyword { $$ = Value::OPTYPE_FLOAT2INT; }
8899 | float2strKeyword { $$ = Value::OPTYPE_FLOAT2STR; }
8900 | hex2bitKeyword { $$ = Value::OPTYPE_HEX2BIT; }
8901 | hex2intKeyword { $$ = Value::OPTYPE_HEX2INT; }
8902 | hex2octKeyword { $$ = Value::OPTYPE_HEX2OCT; }
8903 | hex2strKeyword { $$ = Value::OPTYPE_HEX2STR; }
8904 | int2charKeyword { $$ = Value::OPTYPE_INT2CHAR; }
8905 | int2floatKeyword { $$ = Value::OPTYPE_INT2FLOAT; }
8906 | int2strKeyword { $$ = Value::OPTYPE_INT2STR; }
8907 | int2unicharKeyword { $$ = Value::OPTYPE_INT2UNICHAR; }
8908 | oct2bitKeyword { $$ = Value::OPTYPE_OCT2BIT; }
8909 | oct2charKeyword { $$ = Value::OPTYPE_OCT2CHAR; }
8910 | oct2hexKeyword { $$ = Value::OPTYPE_OCT2HEX; }
8911 | oct2intKeyword { $$ = Value::OPTYPE_OCT2INT; }
8912 | oct2strKeyword { $$ = Value::OPTYPE_OCT2STR; }
8913 | str2bitKeyword { $$ = Value::OPTYPE_STR2BIT; }
8914 | str2floatKeyword { $$ = Value::OPTYPE_STR2FLOAT; }
8915 | str2hexKeyword { $$ = Value::OPTYPE_STR2HEX; }
8916 | str2intKeyword { $$ = Value::OPTYPE_STR2INT; }
8917 | str2octKeyword { $$ = Value::OPTYPE_STR2OCT; }
8918 | unichar2intKeyword { $$ = Value::OPTYPE_UNICHAR2INT; }
8919 | unichar2charKeyword { $$ = Value::OPTYPE_UNICHAR2CHAR; }
8920 | enum2intKeyword { $$ = Value::OPTYPE_ENUM2INT; }
8921 | remove_bomKeyWord { $$ = Value::OPTYPE_REMOVE_BOM; }
8922 | get_stringencodingKeyWord { $$ = Value::OPTYPE_GET_STRINGENCODING; }
8923 | decode_base64KeyWord { $$ = Value::OPTYPE_DECODE_BASE64; }
8926 PredefinedOpKeyword2:
8927 int2bitKeyword { $$ = Value::OPTYPE_INT2BIT; }
8928 | int2hexKeyword { $$ = Value::OPTYPE_INT2HEX; }
8929 | int2octKeyword { $$ = Value::OPTYPE_INT2OCT; }
8932 PredefinedOpKeyword3:
8933 unichar2octKeyword { $$ = Value::OPTYPE_UNICHAR2OCT; }
8934 | oct2unicharKeyword { $$ = Value::OPTYPE_OCT2UNICHAR; }
8935 | encode_base64KeyWord { $$ = Value::OPTYPE_ENCODE_BASE64; }
8938 String2TtcnStatement:
8939 string2ttcnKeyword '(' optError Expression optError ',' optError Reference optError ')'
8941 Ttcn::Reference* out_ref;
8942 if ($8.is_ref) out_ref = $8.ref;
8944 out_ref = new Ttcn::Reference($8.id);
8945 out_ref->set_location(infile, @8);
8947 $$ = new Statement(Statement::S_STRING2TTCN, $4, out_ref);
8948 $$->set_location(infile, @$);
8952 LogStatement: // 619
8955 $$=new Statement(Statement::S_LOG, (LogArguments*)0);
8956 $$->set_location(infile, @$);
8958 | LogKeyword '(' LogItemList optError ')'
8960 $$=new Statement(Statement::S_LOG, $3);
8961 $$->set_location(infile, @$);
8963 | LogKeyword '(' error ')'
8965 $$=new Statement(Statement::S_LOG, new LogArguments());
8966 $$->set_location(infile, @$);
8973 $$ = new LogArguments();
8976 | LogItemList optError ',' optError LogItem
8981 | LogItemList optError ',' error { $$ = $1; }
8987 $$ = new LogArgument($1);
8988 $$->set_location(infile, @$);
8992 LoopConstruct: // 622
8993 ForStatement { $$ = $1; }
8994 | WhileStatement { $$ = $1; }
8995 | DoWhileStatement { $$ = $1; }
8998 ForStatement: // 623
8999 ForKeyword '(' Initial ';' Final ';' Step optError ')'
9002 $$ = new Statement(Statement::S_FOR, $3.defs, $3.ass, $5, $7, $10);
9003 $$->set_location(infile, @$);
9010 $$.defs = new Definitions;
9011 for (size_t i = 0; i < $1.nElements; i++) $$.defs->add_ass($1.elements[i]);
9022 $$.defs = new Definitions;
9028 BooleanExpression { $$ = $1; }
9032 Assignment { $$ = $1; }
9033 /** \todo for-ban nem lehet null a step
9034 | error { $$=NULL; }
9038 WhileStatement: // 628
9039 WhileKeyword '(' BooleanExpression ')' StatementBlock
9041 $$=new Statement(Statement::S_WHILE, $3, $5);
9042 $$->set_location(infile, @$);
9046 DoWhileStatement: // 630
9047 DoKeyword StatementBlock
9048 WhileKeyword '(' BooleanExpression ')'
9050 $$=new Statement(Statement::S_DOWHILE, $5, $2);
9051 $$->set_location(infile, @$);
9055 ConditionalConstruct: // 632
9056 IfKeyword '(' BooleanExpression ')'
9058 seqElseIfClause optElseClause
9060 IfClause *ic=new IfClause($3, $5);
9061 ic->set_location(infile, @1, @5);
9062 $6->add_front_ic(ic);
9063 $$=new Statement(Statement::S_IF, $6, $7,
9064 $7 ? new Location(infile, @7) : 0);
9065 $$->set_location(infile, @$);
9070 /* empty */ { $$=new IfClauses(); }
9071 | seqElseIfClause ElseIfClause
9078 ElseIfClause: // 634
9079 ElseKeyword IfKeyword '(' BooleanExpression ')' StatementBlock
9081 $$=new IfClause($4, $6);
9082 $$->set_location(infile, @$);
9086 optElseClause: // [636]
9087 /* empty */ { $$=0; }
9088 | ElseKeyword StatementBlock { $$=$2; }
9091 SelectCaseConstruct: // 637
9092 SelectKeyword '(' Expression optError ')' SelectCaseBody
9094 $$=new Statement(Statement::S_SELECT, $3, $6);
9095 $$->set_location(infile, @$);
9097 | SelectKeyword '(' error ')' SelectCaseBody
9099 Value *v = new Value(Value::V_ERROR);
9100 v->set_location(infile, @3);
9101 $$=new Statement(Statement::S_SELECT, v, $5);
9102 $$->set_location(infile, @$);
9106 SelectCaseBody: // 639
9107 '{' seqSelectCase optError '}' {$$=$2;}
9108 | '{' error '}' {$$=new SelectCases;}
9117 | seqSelectCase optError SelectCase
9125 CaseKeyword '(' seqTemplateInstance optError ')' StatementBlock optSemiColon
9127 $3->set_location(infile, @2, @5);
9128 $$=new SelectCase($3, $6);
9129 $$->set_location(infile, @$);
9131 | CaseKeyword '(' error ')' StatementBlock optSemiColon
9133 TemplateInstances *tis = new TemplateInstances;
9134 tis->set_location(infile, @2, @4);
9135 $$ = new SelectCase(tis, $5);
9136 $$->set_location(infile, @$);
9138 | CaseKeyword ElseKeyword StatementBlock optSemiColon
9140 $$=new SelectCase(0, $3);
9141 $$->set_location(infile, @$);
9145 seqTemplateInstance:
9146 optError TemplateInstance
9148 $$ = new TemplateInstances;
9151 | seqTemplateInstance optError ',' optError TemplateInstance
9156 | seqTemplateInstance optError ',' error { $$ = $1; }
9159 /* A.1.6.9 Miscellaneous productions */
9161 optSemiColon: // [645]
9166 /* A.1 ASN.1 support, from ES 201 873-7 V3.1.1 (2005-06) */
9168 optDefinitiveIdentifier:
9170 | DefinitiveIdentifier
9173 DefinitiveIdentifier:
9174 '.' ObjectIdentifierKeyword '{' DefinitiveObjIdComponentList optError '}'
9175 | '.' ObjectIdentifierKeyword '{' error '}'
9178 DefinitiveObjIdComponentList:
9179 optError DefinitiveObjIdComponent
9180 | DefinitiveObjIdComponentList optError DefinitiveObjIdComponent
9183 DefinitiveObjIdComponent:
9185 | DefinitiveNumberForm
9186 | DefinitiveNameAndNumberForm
9189 DefinitiveNumberForm:
9190 Number { delete $1; }
9193 DefinitiveNameAndNumberForm:
9194 IDentifier '(' Number optError ')' { delete $1; delete $3; }
9195 | IDentifier '(' error ')' { delete $1; }
9198 ObjectIdentifierValue:
9199 ObjectIdentifierKeyword '{' ObjIdComponentList optError '}'
9202 $$->set_location(infile, @$);
9204 | ObjectIdentifierKeyword '{' error '}'
9206 $$ = new Value(Value::V_ERROR);
9207 $$->set_location(infile, @$);
9212 optError ObjIdComponent
9214 $$ = new Value(Value::V_OID);
9215 $$->add_oid_comp($2);
9217 | ObjIdComponentList optError ObjIdComponent
9220 $$->add_oid_comp($3);
9225 /* NameForm -- covered by NumberForm (as ReferencedValue) */
9226 NumberForm { $$ = $1; }
9227 | NameAndNumberForm { $$ = $1; }
9233 Value *v = new Value(Value::V_INT, $1);
9234 v->set_location(infile, @1);
9235 $$ = new OID_comp(0, v);
9236 $$->set_location(infile, @$);
9241 /* it can be only a referenced value */
9242 Value *v = new Value(Value::V_REFD, $1.ref);
9243 v->set_location(infile, @1);
9244 $$ = new OID_comp(v);
9246 /* it can be either a name form or a referenced value */
9247 $$ = new OID_comp($1.id, 0);
9249 $$->set_location(infile, @$);
9254 IDentifier '(' Number optError ')'
9256 Value *v = new Value(Value::V_INT, $3);
9257 v->set_location(infile, @3);
9258 $$ = new OID_comp($1, v);
9259 $$->set_location(infile, @$);
9261 | IDentifier '(' ReferencedValue optError ')'
9263 $$ = new OID_comp($1, $3);
9264 $$->set_location(infile, @$);
9266 | IDentifier '(' error ')'
9268 Value *v = new Value(Value::V_ERROR);
9269 v->set_location(infile, @3);
9270 $$ = new OID_comp($1, v);
9271 $$->set_location(infile, @$);
9276 IDentifier { delete $1; }
9279 /* Rules for error recovery */
9288 | optErrorBlock ErrorBlock optError
9293 | '{' optError ErrorBlock optError '}'
9298 static void ttcn3_error(const char *str)
9300 Location loc(infile, ttcn3_lloc);
9302 // the most recently parsed token is known
9303 loc.error("at or before token `%s': %s", ttcn3_text, str);
9305 // the most recently parsed token is unknown
9306 loc.error("%s", str);
9310 int ttcn3_parse_file(const char* filename, boolean generate_code)
9312 anytype_access = false;
9313 ttcn3_in = fopen(filename, "r");
9314 if (ttcn3_in == NULL) {
9315 ERROR("Cannot open input file `%s': %s", filename, strerror(errno));
9321 is_erroneous_parsed = false;
9322 NOTIFY("Parsing TTCN-3 module `%s'...", filename);
9324 int retval = ttcn3_parse();
9326 free_ttcn3_lex(); // does fclose(ttcn3_in);
9328 if (act_ttcn3_module) {
9329 act_ttcn3_module->set_location(filename);
9330 set_md5_checksum(act_ttcn3_module);
9331 if (generate_code) act_ttcn3_module->set_gen_code();
9332 modules->add_mod(act_ttcn3_module);
9333 act_ttcn3_module = 0;
9341 Ttcn::ErroneousAttributeSpec* ttcn3_parse_erroneous_attr_spec_string(
9342 const char* p_str, const Common::Location& str_loc)
9344 is_erroneous_parsed = true;
9345 act_ttcn3_erroneous_attr_spec = NULL;
9346 string titan_err_str("$#&&&(#TITANERRONEOUS$#&&^#% ");
9347 int hack_str_len = (int)titan_err_str.size();
9348 string *parsed_string = parse_charstring_value(p_str, str_loc);
9349 titan_err_str += *parsed_string;
9350 delete parsed_string;
9351 init_erroneous_lex(str_loc.get_filename(), str_loc.get_first_line(), str_loc.get_first_column()-hack_str_len+1);
9352 yy_buffer_state *flex_buffer = ttcn3__scan_string(titan_err_str.c_str());
9353 if (flex_buffer == NULL) {
9354 ERROR("Flex buffer creation failed.");
9358 ttcn3_lex_destroy();
9359 free_dot_flag_stuff();
9361 return act_ttcn3_erroneous_attr_spec;
9365 static void yyprint(FILE *file, int type, const YYSTYPE& value)
9369 fprintf(file, "``%s''", value.id->get_name().c_str());
9372 fprintf(file, "%s", value.int_val->t_str().c_str());
9375 fprintf(file, "%f", value.float_val);
9380 case BitStringMatch:
9381 case HexStringMatch:
9382 case OctetStringMatch:
9383 fprintf(file, "``%s''", value.string_val->c_str());
9386 fprintf(file, "``%s''", value.str);