1 /******************************************************************************
2 * Copyright (c) 2000-2014 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
7 ******************************************************************************/
8 /* Syntax check parser and compiler for TTCN-3 */
10 /* BNF compliance: v3.2.1 with extensions */
21 #include "../../common/dbgnew.hh"
22 #include "../../common/memory.h"
24 #include "../datatypes.h"
25 #include "Attributes.hh"
29 #include "../Identifier.hh"
30 #include "Templatestuff.hh"
31 #include "AST_ttcn3.hh"
33 #include "../CompType.hh"
34 #include "../CompField.hh"
35 #include "../EnumItem.hh"
36 #include "../SigParam.hh"
38 #include "../subtype.hh"
39 #include "../Value.hh"
40 #include "../Valuestuff.hh"
41 #include "../ustring.hh"
42 #include "Ttcnstuff.hh"
43 #include "TtcnTemplate.hh"
44 #include "Templatestuff.hh"
45 #include "ArrayDimensions.hh"
46 #include "PatternString.hh"
47 #include "Statement.hh"
50 using namespace Common;
52 const char *infile = NULL;
54 static Ttcn::Module *act_ttcn3_module = NULL;
55 static Ttcn::ErroneousAttributeSpec *act_ttcn3_erroneous_attr_spec = NULL;
56 bool is_erroneous_parsed = false;
57 static void ttcn3_error(const char *str);
58 static Group* act_group = NULL;
59 extern string anytype_field(const string& type_name);
60 static bool anytype_access = false;
65 static void yyprint(FILE *file, int type, const YYSTYPE& value);
66 #define YYPRINT(f,t,v) yyprint(f,t,v)
70 extern Modules *modules;
72 extern FILE *ttcn3_in;
73 extern char *ttcn3_text;
74 extern int ttcn3_lex();
75 extern void init_ttcn3_lex();
76 extern void free_ttcn3_lex();
77 extern void set_md5_checksum(Ttcn::Module *m);
79 extern void init_erroneous_lex(const char* p_infile, int p_line, int p_column);
80 struct yy_buffer_state;
81 extern int ttcn3_lex_destroy(void);
82 extern yy_buffer_state *ttcn3__scan_string(const char *yy_str);
83 extern void free_dot_flag_stuff();
85 extern string *parse_charstring_value(const char *str, const Location& loc);
86 extern PatternString* parse_pattern(const char *str, const Location& loc);
88 static const string anyname("anytype");
90 /* Various C macros */
92 #define YYERROR_VERBOSE
97 /* Bison declarations */
99 /*********************************************************************
101 *********************************************************************/
104 /* NOTE: the union is written to compiler.tab.hh, which is #included
105 * into compiler.l; therefore all types used here must be declared
106 * in compiler.l (forward declared or #included) */
107 bool bool_val; /* boolean value */
108 char *str; /* simple string value */
109 unsigned char uchar_val;
111 int_val_t *int_val; /* integer value */
112 Real float_val; /* float value */
115 ustring *ustring_val;
117 Type::typetype_t typetype;
118 PortTypeBody::PortOperationMode_t portoperationmode;
119 Value::operationtype_t operationtype;
120 Value::macrotype_t macrotype;
121 SingleWithAttrib::attribtype_t attribtype;
122 ImpMod::imptype_t imptype;
125 AltGuards *altguards;
126 ArrayDimension *arraydimension;
127 AttributeSpec *attributespec;
128 CompField *compfield;
129 CompFieldMap *compfieldmap;
132 Definition *definition;
135 EnumItems *enumitems;
136 FieldOrArrayRef *fieldorarrayref;
137 FormalPar *formalpar;
138 FormalParList *formalparlist;
140 FriendMod *friendMod;
142 IfClauses *ifclauses;
144 LengthRestriction *lenrestr;
146 LogArguments *logargs;
147 NamedTemplate *namedtempl;
148 NamedTemplates *namedtempls;
149 NamedValue *namedvalue;
150 NamedValues *namedvalues;
151 IndexedTemplate *indexedtempl;
152 IndexedTemplates *indexedtempls;
153 IndexedValue *indexedvalue;
154 MultiWithAttrib *multiwithattrib;
156 ParamAssignment *parass;
157 ParamAssignments *parasss;
158 ParamRedirect *parredir;
159 ParsedActualParameters *parsedpar;
160 PatternString *patstr;
161 Qualifier *qualifier;
162 Qualifiers *qualifiers;
163 SelectCase *selectcase;
164 SelectCases *selectcases;
165 SignatureExceptions *signexc;
166 SignatureParam *signparam;
167 SignatureParamList *signparamlist;
168 SingleWithAttrib *singlewithattrib;
170 StatementBlock *statementblock;
171 SubTypeParse *subtypeparse;
173 TemplateInstance *templinst;
174 TemplateInstances *templinsts;
176 Ttcn::Assignment *ass;
177 Ttcn::Ref_base *refbase;
178 Ttcn::Ref_pard *refpard;
179 Ttcn::Reference *reference;
180 ValueRange *valuerange;
185 VariableEntries *variableentries;
186 VariableEntry *variableentry;
187 vector<SubTypeParse> *subtypeparses;
188 CompTypeRefList *comprefs;
189 ComponentTypeBody *compbody;
190 template_restriction_t template_restriction;
194 ErroneousAttributeSpec::indicator_t indicator;
195 } erroneous_indicator;
197 struct arraydimension_list_t {
199 ArrayDimension **elements;
200 } arraydimension_list;
204 FieldOrArrayRef **elements;
205 } fieldorarrayref_list;
209 Ttcn::Definition **elements;
214 Ttcn::FriendMod **elements;
219 Statement **elements;
225 bool lower_exclusive;
227 bool upper_exclusive;
232 bool returns_template;
233 template_restriction_t template_restriction;
239 } returntypeornoblock;
252 Ttcn::Types *in_list, *out_list, *inout_list;
253 bool in_all, out_all, inout_all;
257 Ttcn::Reference *ref;
263 LengthRestriction *len_restr;
264 } extramatchingattrs;
269 FormalParList *fp_list;
278 Ttcn::Ref_pard *ref_pard;
279 Value *derefered_value;
280 ParsedActualParameters *ap_list;
285 Ttcn::Ref_pard *ref_pard;
286 Value *derefered_value;
287 TemplateInstances *ap_list;
291 TemplateInstance *templ_inst;
296 Value *calltimerval; // if NULL: see nowait
301 TemplateInstance *templ_inst;
302 Value *calltimerval; // if NULL: see nowait
304 Value *val; // not used in callparams
308 TemplateInstance *templ_inst;
314 Ttcn::Reference *signature;
315 TemplateInstance *templ_inst;
320 Ttcn::Reference *redirectval;
321 Ttcn::Reference *redirectsender;
325 ParamRedirect *redirectparam;
326 Ttcn::Reference *redirectsender;
327 } portredirectwithparam;
330 Ttcn::Reference *redirectval;
331 ParamRedirect *redirectparam;
332 Ttcn::Reference *redirectsender;
333 } portredirectwithvalueandparam;
336 TemplateInstance *templ_inst;
337 TemplateInstance *valuematch;
341 TemplateInstance *templ_inst;
342 TemplateInstance *fromclause;
343 Ttcn::Reference *redirectval;
344 Ttcn::Reference *redirectsender;
348 TemplateInstance *templ_inst;
349 TemplateInstance *fromclause;
350 ParamRedirect *redirectparam;
351 Ttcn::Reference *redirectsender;
355 TemplateInstance *templ_inst;
356 TemplateInstance *valuematch;
357 TemplateInstance *fromclause;
358 Ttcn::Reference *redirectval;
359 ParamRedirect *redirectparam;
360 Ttcn::Reference *redirectsender;
364 Ttcn::Reference *signature;
365 TemplateInstance *templ_inst;
370 Ttcn::Reference *signature;
371 TemplateInstance *templ_inst;
373 TemplateInstance *fromclause;
374 Ttcn::Reference *redirectval;
375 Ttcn::Reference *redirectsender;
379 Statement::statementtype_t statementtype;
380 Ttcn::Reference *signature;
381 TemplateInstance *templ_inst;
382 TemplateInstance *valuematch;
384 TemplateInstance *fromclause;
385 Ttcn::Reference *redirectval;
386 ParamRedirect *redirectparam;
387 Ttcn::Reference *redirectsender;
392 Ttcn::Reference *portref;
397 Ttcn::Reference *portref1;
399 Ttcn::Reference *portref2;
403 TemplateInstance *donematch;
404 Ttcn::Reference *redirect;
410 Ttcn::Reference *ref;
417 Ttcn::Assignment *ass;
421 Ttcn::Reference *runsonref;
422 Ttcn::Reference *systemref;
432 ParsedActualParameters *ap_list;
436 struct extconstidentifier_t {
439 } extconstidentifier;
443 extconstidentifier_t *elements;
446 struct singlevarinst_t {
448 arraydimension_list_t arrays;
449 Value *initial_value;
453 struct singlevarinst_list_t {
455 struct singlevarinst_t *elements;
456 } singlevarinst_list;
458 struct singletempvarinst_t {
460 arraydimension_list_t arrays;
461 Template *initial_value;
465 struct singletempvarinst_list_t {
467 singletempvarinst_t *elements;
468 } singletempvarinst_list;
470 struct singlemodulepar_t {
476 struct singletemplatemodulepar_t {
480 } singletemplatemodulepar;
482 struct singlemodulepar_list_t {
484 singlemodulepar_t *elements;
485 } singlemodulepar_list;
487 struct singletemplatemodulepar_list_t {
489 singletemplatemodulepar_t *elements;
490 } singletemplatemodulepar_list;
492 struct portelement_t {
494 ArrayDimensions *dims;
498 struct portelement_list_t {
500 portelement_t *elements;
503 struct runs_on_compref_or_self_t {
505 Ttcn::Reference *reference;
506 } runs_on_compref_or_self;
509 visibility_t visibility;
513 /* Tokens of TTCN-3 */
515 /*********************************************************************
516 * Tokens with semantic value
517 *********************************************************************/
519 /* Terminals with semantic value */
521 %token <int_val> Number
522 %token <float_val> FloatValue
523 %token <id> IDentifier "Identifier"
525 %token <string_val> Bstring
532 %token NullValue "ASN.1_NULL_value"
533 %token <macrotype> MacroValue
535 /*********************************************************************
536 * Tokens without semantic value
537 *********************************************************************/
539 /* Terminals without semantic value - keywords, operators, etc. */
541 %token TOK_errval "erroneous_value"
543 /* A number of terminals (including ApplyKeyword, CallOpKeyword, etc)
544 * are listed as unused by Bison. They do not appear in any rule,
545 * because the lexer does some magic to combine them with the preceding dot
546 * and returns a (DotApplyKeyword, DotCallOpKeyword, etc) instead.
547 * This magic requires the presence of the unused keywords.
548 * (It can return an ApplyKeyword if not preceded by a dot) */
549 %token TitanErroneousHackKeyword
551 %token ActivateKeyword
552 %token AddressKeyword
556 %token AltstepKeyword
560 %token AnyTypeKeyword
562 %token BitStringKeyword
563 %token BooleanKeyword
567 %token CatchOpKeyword
569 %token CharStringKeyword
570 %token CheckOpKeyword
571 %token ClearOpKeyword
572 %token ComplementKeyword
573 %token ComponentKeyword
574 %token ConnectKeyword
576 %token ContinueKeyword
577 %token ControlKeyword
579 %token DeactivateKeyword
580 %token DefaultKeyword
581 %token DerefersKeyword
582 %token DisconnectKeyword
583 %token DisplayKeyword
591 %token ExceptionKeyword
592 %token ExecuteKeyword
593 %token ExtendsKeyword
594 %token ExtensionKeyword
602 %token FunctionKeyword
603 %token GetCallOpKeyword
604 %token GetReplyOpKeyword
605 %token GetVerdictKeyword
609 %token HexStringKeyword
611 %token IfPresentKeyword
614 %token InfinityKeyword
615 %token InOutParKeyword
617 %token IntegerKeyword
618 %token InterleavedKeyword
622 %token LanguageKeyword
627 %token MessageKeyword
630 %token ModifiesKeyword
631 %token ModuleParKeyword
634 %token NoBlockKeyword
640 %token ObjectIdentifierKeyword
641 %token OctetStringKeyword
645 %token OptionalKeyword
649 %token OverrideKeyword
652 %token PatternKeyword
653 %token PermutationKeyword
654 %token PresentKeyword
656 %token PrivateKeyword
657 %token ProcedureKeyword
661 %token ReceiveOpKeyword
663 %token RecursiveKeyword
669 %token RunningKeyword
676 %token SetVerdictKeyword
677 %token SignatureKeyword
681 %token SupersetKeyword
683 %token TemplateKeyword
684 %token TestcaseKeyword
685 %token TimeoutKeyword
688 %token TriggerOpKeyword
690 %token TTCN3ModuleKeyword
691 %token TypeDefKeyword
693 %token UniversalKeyword
696 %token ValueofKeyword
698 %token VariantKeyword
699 %token VerdictTypeKeyword
705 /* TITAN specific keywords */
706 %token TitanSpecificTryKeyword
707 %token TitanSpecificCatchKeyword
708 %token TitanSpecificLazyKeyword
710 /* Keywords combined with a leading dot */
712 /* If a '.' (dot) character is followed by one of the keywords below the
713 * lexical analyzer shall return one combined token instead of two distinct
714 * tokens. This eliminates the ambiguity that causes additional shift/reduce
715 * conflicts because the dot can be either the part of a field reference or a
716 * built-in operation denoted by a keyword. */
718 %token DotAliveKeyword
719 %token DotApplyKeyword
720 %token DotCallOpKeyword
721 %token DotCatchOpKeyword
722 %token DotCheckOpKeyword
723 %token DotClearOpKeyword
724 %token DotCreateKeyword
725 %token DotDoneKeyword
726 %token DotGetCallOpKeyword
727 %token DotGetReplyOpKeyword
728 %token DotHaltKeyword
729 %token DotKillKeyword
730 %token DotKilledKeyword
731 %token DotRaiseKeyword
732 %token DotReadKeyword
733 %token DotReceiveOpKeyword
734 %token DotReplyKeyword
735 %token DotRunningKeyword
736 %token DotSendOpKeyword
737 %token DotStartKeyword
738 %token DotStopKeyword
739 %token DotTimeoutKeyword
740 %token DotTriggerOpKeyword
742 /* Predefined function identifiers */
744 %token bit2hexKeyword
745 %token bit2intKeyword
746 %token bit2octKeyword
747 %token bit2strKeyword
748 %token char2intKeyword
749 %token char2octKeyword
751 %token float2intKeyword
752 %token hex2bitKeyword
753 %token hex2intKeyword
754 %token hex2octKeyword
755 %token hex2strKeyword
756 %token int2bitKeyword
757 %token int2charKeyword
758 %token int2floatKeyword
759 %token int2hexKeyword
760 %token int2octKeyword
761 %token int2strKeyword
762 %token int2unicharKeyword
763 %token isvalueKeyword
764 %token isboundKeyword
765 %token ischosenKeyword
766 %token ispresentKeyword
767 %token lengthofKeyword
768 %token oct2bitKeyword
769 %token oct2charKeyword
770 %token oct2hexKeyword
771 %token oct2intKeyword
772 %token oct2strKeyword
773 %token oct2unicharKeyword
775 %token replaceKeyword
777 %token testcasenameKeyword
779 %token str2floatKeyword
780 %token str2intKeyword
781 %token str2octKeyword
783 %token unichar2intKeyword
784 %token unichar2charKeyword
785 %token unichar2octKeyword
787 %token float2strKeyword
788 %token str2bitKeyword
789 %token str2hexKeyword
791 %token log2strKeyword
792 %token enum2intKeyword
794 %token encvalueKeyword
795 %token decvalueKeyword
797 %token ttcn2stringKeyword
798 %token string2ttcnKeyword
799 %token remove_bomKeyWord
800 %token get_stringencodingKeyWord
801 %token encode_base64KeyWord
802 %token decode_base64KeyWord
804 /* Multi-character operators */
806 %token AssignmentChar ":="
808 %token PortRedirectSymbol "->"
816 %token _RR "@>" /* Name clash with bn.h:292 */
818 /*********************************************************************
819 * Semantic types of nonterminals
820 *********************************************************************/
822 %type <bool_val> optAliveKeyword optOptionalKeyword optOverrideKeyword
823 optErrValueRaw optAllKeyword optLazyEval
824 %type <str> FreeText optLanguageSpec PatternChunk PatternChunkList
825 %type <uchar_val> Group Plane Row Cell
826 %type <id> FieldIdentifier FieldReference GlobalModuleId
827 IdentifierOrAddressKeyword StructFieldRef PredefOrIdentifier
828 %type <string_val> CstringList
829 %type <ustring_val> Quadruple
831 %type <typetype> PredefinedType
832 %type <portoperationmode> PortOperationMode
833 %type <operationtype> PredefinedOpKeyword1 PredefinedOpKeyword2 PredefinedOpKeyword3
835 %type <activateop> ActivateOp
836 %type <attribtype> AttribKeyword
838 %type <altguard> CallBodyStatement AltGuard ElseStatement GuardStatement
839 InterleavedGuardElement
840 %type <altguards> AltGuardList CallBodyStatementList InterleavedGuardList
842 %type <arraydimension> ArrayIndex
843 %type <attributespec> AttribSpec
844 %type <compbody> optComponentDefList ComponentElementDefList
845 %type <compfield> StructFieldDef UnionFieldDef
846 %type <compfieldmap> StructFieldDefList optStructFieldDefList UnionFieldDefList
847 %type <definition> AltstepDef ExtFunctionDef FunctionDef TemplateDef TestcaseDef
848 %type <deftype> TypeDefBody StructuredTypeDef SubTypeDef RecordDef UnionDef
849 SetDef RecordOfDef SetOfDef EnumDef PortDef PortDefBody ComponentDef
850 TypeDef SignatureDef FunctionTypeDef AltstepTypeDef TestcaseTypeDef
851 %type <deftimer> SingleTimerInstance
852 %type <enumitem> Enumeration
853 %type <enumitems> EnumerationList
854 %type <fieldorarrayref> ArrayOrBitRef ArrayOrBitRefOrDash FieldOrArrayReference
855 %type <formalpar> FormalValuePar FormalTemplatePar FormalTimerPar
856 TemplateFormalPar FunctionFormalPar TestcaseFormalPar
857 %type <formalparlist> optTemplateFormalParList TemplateFormalParList
858 optFunctionFormalParList FunctionFormalParList optTestcaseFormalParList
859 TestcaseFormalParList optAltstepFormalParList
860 %type <group> GroupDef GroupIdentifier
861 %type <friend_list> FriendModuleDef
862 %type <ifclause> ElseIfClause
863 %type <ifclauses> seqElseIfClause
864 %type <impmod> ImportFromSpec ModuleId ImportDef
865 %type <lenrestr> optStringLength LengthMatch StringLength
866 %type <logarg> LogItem
867 %type <logargs> LogItemList
868 %type <multiwithattrib> MultiWithAttrib WithAttribList WithStatement
869 optWithStatement optWithStatementAndSemiColon
870 %type <namedtempl> FieldSpec
871 %type <namedtempls> seqFieldSpec
872 %type <namedvalue> FieldExpressionSpec
873 %type <namedvalues> seqFieldExpressionSpec
874 %type <indexedtempl> ArraySpec
875 %type <indexedtempls> seqArraySpec
876 %type <indexedvalue> ArrayExpressionSpec
877 %type <oidcomp> NumberForm NameAndNumberForm ObjIdComponent
878 %type <parass> VariableAssignment
879 %type <parasss> AssignmentList
880 %type <parredir> ParamAssignmentList ParamSpec
881 %type <patstr> CharStringMatch
882 %type <qualifier> DefOrFieldRef FullGroupIdentifier
883 %type <qualifiers> DefOrFieldRefList optAttribQualifier
884 %type <selectcase> SelectCase
885 %type <selectcases> seqSelectCase SelectCaseBody
886 %type <signexc> ExceptionTypeList optExceptionSpec
887 %type <signparam> SignatureFormalPar
888 %type <signparamlist> SignatureFormalParList optSignatureFormalParList
889 %type <singlewithattrib> SingleWithAttrib
890 %type <stmt> AltConstruct BasicStatements BreakStatement BehaviourStatements
891 CallBodyOps CallStatement CatchStatement CheckStatement ClearStatement
892 CommunicationStatements ConditionalConstruct ConfigurationStatements
893 ConnectStatement ContinueStatement ControlStatement DeactivateStatement
894 DisconnectStatement DoWhileStatement DoneStatement ForStatement
895 FunctionStatement GetCallStatement GetReplyStatement GotoStatement GuardOp
896 HaltStatement InterleavedConstruct KillTCStatement KilledStatement
897 LabelStatement LogStatement LoopConstruct MapStatement RaiseStatement
898 ReceiveStatement RepeatStatement ReplyStatement ReturnStatement SUTStatements
899 SendStatement SetLocalVerdict StartStatement StartTCStatement
900 StartTimerStatement StopExecutionStatement StopStatement StopTCStatement
901 StopTimerStatement TimeoutStatement TimerStatements TriggerStatement
902 UnmapStatement VerdictStatements WhileStatement SelectCaseConstruct
903 StopTestcaseStatement String2TtcnStatement
904 %type <statementblock> StatementBlock optElseClause FunctionStatementOrDefList
905 ControlStatementOrDefList ModuleControlBody
906 %type <subtypeparse> ValueOrRange
907 %type <templ> MatchingSymbol SingleValueOrAttrib SimpleSpec TemplateBody
908 ArrayElementSpec ArrayValueOrAttrib FieldSpecList ArraySpecList
909 AllElementsFrom TemplateListElem
910 %type <templinst> AddressRef FromClause FunctionActualPar InLineTemplate
911 ReceiveParameter SendParameter TemplateActualPar TemplateInstance
912 /* TestcaseActualPar */ ValueMatchSpec optFromClause optParDefaultValue
914 %type <parsedpar> FunctionActualParList TestcaseActualParList
915 optFunctionActualParList optTestcaseActualParList
916 NamedPart UnnamedPart
917 %type <templinsts> optTemplateActualParList
918 seqTemplateActualPar seqTemplateInstance
919 %type <templs> ValueOrAttribList seqValueOrAttrib ValueList Complement
920 ArrayElementSpecList SubsetMatch SupersetMatch PermutationMatch
921 %type <ass> Assignment Step
922 %type <refbase> DerivedRefWithParList TemplateRefWithParList DecValueArg
923 %type <refpard> FunctionInstance AltstepInstance
924 %type <reference> PortType optDerivedDef DerivedDef Signature VariableRef
925 TimerRef TimerRefOrAny Port PortOrAny PortOrAll ValueSpec
926 SenderSpec ComponentType optRunsOnSpec RunsOnSpec optSystemSpec
927 %type <valuerange> Range
928 %type <type> NestedEnumDef NestedRecordDef NestedRecordOfDef NestedSetDef
929 NestedSetOfDef NestedTypeDef NestedUnionDef PortDefAttribs ReferencedType
930 Type TypeOrNestedTypeDef NestedFunctionTypeDef NestedAltstepTypeDef
931 NestedTestcaseTypeDef
932 %type <types> TypeList AllOrTypeList
933 %type <value> AddressValue AliveOp AllPortsSpec AltGuardChar ArrayBounds
934 ArrayExpression ArrayExpressionList BitStringValue BooleanExpression
935 BooleanValue CharStringValue ComponentRef ComponentReferenceOrLiteral
936 ComponentOrDefaultReference CompoundExpression ConfigurationOps CreateOp
937 DereferOp Expression FieldExpressionList Final GetLocalVerdict HexStringValue
938 IntegerValue LowerBound MTCOp MatchOp NotUsedOrExpression ObjIdComponentList
939 ObjectIdentifierValue OctetStringValue OmitValue OpCall PredefinedOps
940 PredefinedValue ReadTimerOp ReferOp ReferencedValue RunningOp RunningTimerOp
941 SelfOp SingleExpression SingleLowerBound SystemOp TemplateOps TimerOps
942 TimerValue UpperBound Value ValueofOp VerdictOps VerdictValue optReplyValue
943 optTestcaseTimerValue optToClause
944 %type <values> ArrayElementExpressionList seqArrayExpressionSpec
945 %type <variableentries> VariableList
946 %type <variableentry> VariableEntry
947 %type <subtypeparses> seqValueOrRange AllowedValues optSubTypeSpec
949 %type <arraydimension_list> optArrayDef
950 %type <fieldorarrayref_list> optExtendedFieldReference
951 %type <def_list> AltstepLocalDef AltstepLocalDefList ComponentElementDef
952 ConstDef ExtConstDef FunctionLocalDef FunctionLocalInst ModuleDef ModulePar
953 ModuleParDef MultiTypedModuleParList PortInstance TimerInstance TimerList
955 %type <stmt_list> FunctionStatementOrDef ControlStatementOrDef
957 %type <rangedef> RangeDef
958 %type <returntype> optReturnType
959 %type <returntypeornoblock> optReturnTypeOrNoBlockKeyword
960 %type <structdefbody> StructDefBody UnionDefBody
961 %type <structofdefbody> StructOfDefBody
962 %type <portdefbody> PortDefList seqPortDefList PortDefLists
963 %type <ischosenarg> IschosenArg
964 %type <extramatchingattrs> optExtraMatchingAttributes
965 %type <basetemplate> BaseTemplate
966 %type <templateref> TemplateRef TestcaseRef FunctionRef
967 %type <testcaseinst> TestcaseInstance
968 %type <portsendop> PortSendOp
969 %type <calltimerval> CallTimerValue
970 %type <portcallop> PortCallOp CallParameters
971 %type <portreplyop> PortReplyOp
972 %type <portraiseop> PortRaiseOp
973 %type <portredirect> optPortRedirect
974 %type <portredirectwithparam> optPortRedirectWithParam
975 %type <portredirectwithvalueandparam> optPortRedirectWithValueAndParam
976 %type <getreplypar> optGetReplyParameter
977 %type <portreceiveop> PortReceiveOp PortTriggerOp
978 %type <portgetcallop> PortGetCallOp
979 %type <portgetreplyop> PortGetReplyOp
980 %type <catchoppar> optCatchOpParameter CatchOpParameter
981 %type <portcatchop> PortCatchOp
982 %type <portcheckop> optCheckParameter CheckParameter CheckPortOpsPresent
983 FromClausePresent RedirectPresent
984 %type <portref> PortRef AllConnectionsSpec
985 %type <connspec> SingleConnectionSpec SingleOrMultiConnectionSpec
986 %type <donepar> optDoneParameter
987 %type <reforid> Reference
988 %type <initial> Initial
989 %type <configspec> ConfigSpec
990 %type <createpar> optCreateParameter
991 %type <applyop> ApplyOp
992 %type <identifier_list> IdentifierList
993 %type <singlevarinst> SingleConstDef SingleVarInstance
994 %type <singlevarinst_list> ConstList VarList
995 %type <singletempvarinst> SingleTempVarInstance
996 %type <singletempvarinst_list> TempVarList
997 %type <singlemodulepar> SingleModulePar
998 %type <singletemplatemodulepar> SingleTemplateModulePar
999 %type <singlemodulepar_list> ModuleParList
1000 %type <singletemplatemodulepar_list> TemplateModuleParList
1001 %type <portelement> PortElement
1002 %type <portelement_list> PortElementList
1003 %type <comprefs> optExtendsDef ComponentTypeList
1004 %type <runs_on_compref_or_self> optRunsOnComprefOrSelf
1005 %type <template_restriction> TemplateRestriction optTemplateRestriction
1006 TemplateOptRestricted
1007 %type <visbilitytype> optVisibility ComponentElementVisibility
1008 %type <float_val> FloatOrSpecialFloatValue
1009 %type <erroneous_indicator> ErroneousIndicator
1010 %type <imptype> ImportSpec ImportElement
1012 /*********************************************************************
1014 *********************************************************************/
1017 act_group = $$->get_parent_group();
1022 %destructor {Free($$);}
1031 delete $$.derefered_value;
1036 %destructor {delete $$;}
1050 ArrayElementExpressionList
1052 ArrayElementSpecList
1071 CallBodyStatementList
1078 CommunicationStatements
1081 ComponentElementDefList
1082 ComponentOrDefaultReference
1084 ComponentReferenceOrLiteral
1088 ConditionalConstruct
1090 ConfigurationStatements
1094 ControlStatementOrDefList
1101 DerivedRefWithParList
1115 FieldOrArrayReference
1127 FunctionActualParList
1130 FunctionFormalParList
1133 FunctionStatementOrDefList
1147 IdentifierOrAddressKeyword
1151 InterleavedConstruct
1152 InterleavedGuardElement
1153 InterleavedGuardList
1161 String2TtcnStatement
1173 NestedAltstepTypeDef
1175 NestedFunctionTypeDef
1180 NestedTestcaseTypeDef
1188 ObjectIdentifierValue
1234 SignatureFormalParList
1247 StopExecutionStatement
1248 StopTestcaseStatement
1265 TemplateFormalParList
1268 TemplateRefWithParList
1269 /* TestcaseActualPar */
1270 TestcaseActualParList
1273 TestcaseFormalParList
1310 optAltstepFormalParList
1318 optFunctionActualParList
1319 optFunctionFormalParList
1325 optSignatureFormalParList
1327 optStructFieldDefList
1329 optTemplateActualParList
1330 optTemplateFormalParList
1331 optTestcaseActualParList
1332 optTestcaseFormalParList
1333 optTestcaseTimerValue
1336 optWithStatementAndSemiColon
1338 seqFieldExpressionSpec
1340 seqTemplateActualPar
1346 for (size_t i = 0; i < $$->size(); i++) delete (*$$)[i];
1355 for(size_t i=0; i<$$.nElements; i++) delete $$.elements[i];
1362 ControlStatementOrDef
1366 FunctionStatementOrDef
1370 MultiTypedModuleParList
1376 optExtendedFieldReference
1389 optReturnTypeOrNoBlockKeyword
1407 delete $$.inout_list;
1420 delete $$.len_restr;
1422 optExtraMatchingAttributes
1441 delete $$.derefered_value;
1448 delete $$.templ_inst;
1454 delete $$.calltimerval;
1459 delete $$.templ_inst;
1460 delete $$.calltimerval;
1463 PortCallOp CallParameters
1466 delete $$.templ_inst;
1473 delete $$.signature;
1474 delete $$.templ_inst;
1480 delete $$.redirectval;
1481 delete $$.redirectsender;
1486 delete $$.redirectparam;
1487 delete $$.redirectsender;
1489 optPortRedirectWithParam
1492 delete $$.redirectval;
1493 delete $$.redirectparam;
1494 delete $$.redirectsender;
1496 optPortRedirectWithValueAndParam
1499 delete $$.templ_inst;
1500 delete $$.valuematch;
1502 optGetReplyParameter
1505 delete $$.templ_inst;
1506 delete $$.fromclause;
1507 delete $$.redirectval;
1508 delete $$.redirectsender;
1514 delete $$.templ_inst;
1515 delete $$.fromclause;
1516 delete $$.redirectparam;
1517 delete $$.redirectsender;
1522 delete $$.templ_inst;
1523 delete $$.valuematch;
1524 delete $$.fromclause;
1525 delete $$.redirectval;
1526 delete $$.redirectparam;
1527 delete $$.redirectsender;
1532 delete $$.signature;
1533 delete $$.templ_inst;
1539 delete $$.signature;
1540 delete $$.templ_inst;
1541 delete $$.fromclause;
1542 delete $$.redirectval;
1543 delete $$.redirectsender;
1548 delete $$.signature;
1549 delete $$.templ_inst;
1550 delete $$.valuematch;
1551 delete $$.fromclause;
1552 delete $$.redirectval;
1553 delete $$.redirectparam;
1554 delete $$.redirectsender;
1575 SingleConnectionSpec
1576 SingleOrMultiConnectionSpec
1579 delete $$.donematch;
1585 if ($$.is_ref) delete $$.ref;
1597 delete $$.runsonref;
1598 delete $$.systemref;
1615 for (size_t i = 0; i < $$.nElements; i++) delete $$.elements[i].id;
1622 for (size_t i = 0; i < $$.arrays.nElements; i++)
1623 delete $$.arrays.elements[i];
1624 Free($$.arrays.elements);
1625 delete $$.initial_value;
1629 SingleTempVarInstance
1632 for (size_t i = 0; i < $$.nElements; i++) {
1633 delete $$.elements[i].id;
1634 for (size_t j = 0; i < $$.elements[i].arrays.nElements; j++)
1635 delete $$.elements[i].arrays.elements[j];
1636 Free($$.elements[i].arrays.elements);
1637 delete $$.elements[i].initial_value;
1655 SingleTemplateModulePar
1658 for (size_t i = 0; i < $$.nElements; i++) {
1659 delete $$.elements[i].id;
1660 delete $$.elements[i].defval;
1667 for (size_t i = 0; i < $$.nElements; i++) {
1668 delete $$.elements[i].id;
1669 delete $$.elements[i].deftempl;
1673 TemplateModuleParList
1682 for (size_t i = 0; i < $$.nElements; i++) {
1683 delete $$.elements[i].id;
1684 delete $$.elements[i].dims;
1691 delete $$.reference;
1693 optRunsOnComprefOrSelf
1695 /*********************************************************************
1696 * Operator precedences (lowest first)
1697 *********************************************************************/
1704 %nonassoc '<' '>' GE LE
1711 %left '*' '/' ModKeyword RemKeyword
1719 XXX Source of conflicts (24 S/R):
1721 1.) 8 conflicts in one state
1722 The Expression after 'return' keyword is optional in ReturnStatement.
1723 For 8 tokens the parser cannot decide whether the token is a part of
1724 the return expression (shift) or it is the beginning of the next statement
1727 2.) 8 distinct states, each with one conflict caused by token '['
1728 The local definitions in altsteps can be followed immediately by the guard
1729 expression. When the parser sees the '[' token it cannot decide whether it
1730 belongs to the local definition as array dimension or array subreference
1731 (shift) or it is the beginning of the first guard expression (reduce).
1732 The situations are the following:
1733 - var t v := ref <here> [
1734 - var t v := ref[subref] <here> [
1735 - var t v := ref.integer <here> [
1736 - var t v := ref.subref <here> [
1739 - var t v := ref.objid{...}.subref <here> [
1740 - var template t v <here> [
1743 The sequence identifier.objid can be either the beginning of a module name
1744 qualified with a module object identifier (shift) or a reference to an objid
1745 value within an entity of type anytype (reduce).
1748 The '{' token after a call statement can be either the part of the response and
1749 exception handling part (shift) or the beginning of the next statement, which
1750 is a StatementBlock (reduce). Note that StatementBlock as a statement is a
1751 non-standard language extension.
1753 5.) 5 conflicts in in three states, related to named parameters
1755 6.) 1 Conflict due to pattern concatenation
1757 Note that the parser implemented by bison always chooses to shift instead of
1758 reduce in case of conflicts. This is the desired behaviour in situations 1.),
1759 2.) and 4.) since the opposite alternative can be forced by the correct usage
1760 of semi-colons. Situation 3.) does not cause any problems as anytype is not
1761 supported at the moment.
1766 /*********************************************************************
1768 *********************************************************************/
1770 /* The grammar of TTCN-3 */
1771 /* The numbers correspond to ES 201 873-1 V4.1.2 (2009-07) */
1776 if (is_erroneous_parsed) {
1777 delete act_ttcn3_module;
1778 act_ttcn3_module = NULL;
1779 Location loc(infile, @1);
1780 loc.error("The erroneous attribute cannot be a TTCN-3 module.");
1783 | TitanErroneousHackKeyword ErroneousAttributeSpec
1785 if (!is_erroneous_parsed) {
1786 delete act_ttcn3_erroneous_attr_spec;
1787 act_ttcn3_erroneous_attr_spec = NULL;
1788 Location loc(infile, @$);
1789 loc.error("File `%s' does not contain a TTCN-3 module.", infile);
1795 ErroneousAttributeSpec:
1796 ErroneousIndicator AssignmentChar TemplateInstance optAllKeyword
1798 act_ttcn3_erroneous_attr_spec = new ErroneousAttributeSpec($1.is_raw, $1.indicator, $3, $4);
1803 ValueKeyword optErrValueRaw
1805 $$.indicator = ErroneousAttributeSpec::I_VALUE;
1808 | IDentifier optErrValueRaw
1810 if ($1->get_ttcnname()=="before") $$.indicator = ErroneousAttributeSpec::I_BEFORE;
1811 else if ($1->get_ttcnname()=="after") $$.indicator = ErroneousAttributeSpec::I_AFTER;
1813 Location loc(infile, @1);
1814 loc.error("Invalid indicator. Valid indicators are: "
1815 "`before', `value' and `after'");
1816 $$.indicator = ErroneousAttributeSpec::I_INVALID;
1824 /* empty */ { $$ = false; }
1825 | AllKeyword { $$ = true; }
1829 /* empty */ { $$ = false; }
1830 | '(' IDentifier ')'
1832 if ($2->get_ttcnname()=="raw") $$ = true;
1834 Location loc(infile, @2);
1835 loc.error("Invalid keyword, only the optional `raw' keyword can be used here.");
1843 /* A.1.6.0 TTCN Module */
1846 TTCN3ModuleId ModuleBody optWithStatementAndSemiColon optError
1848 act_ttcn3_module->set_with_attr($3);
1849 if (anytype_access) {
1850 // If there was an attempted access to an anytype field, artificially
1851 // create a type definition as if the following appeared in TTCN-3:
1852 // type union anytype { /* empty, members added later */ }
1853 // NOTE: anything which looks like usage of an anytype field will bring
1854 // the local anytype to life, which trumps any imported anytype
1855 // (when resolving, the local anytype will be found first).
1856 // TODO: just to be safe, anytype should be removed from the exports.
1857 Type *t = new Type(Type::T_ANYTYPE);
1858 Identifier *anytype_id = new Identifier(Identifier::ID_TTCN, anyname);
1859 Def_Type *anytypedef = new Def_Type(anytype_id, t);
1860 anytypedef->set_parent_path(act_ttcn3_module->get_attrib_path());
1861 act_ttcn3_module->add_ass(anytypedef);
1862 // Def_Type is-a Definition is-a Assignment
1868 optError TTCN3ModuleKeyword IDentifier optDefinitiveIdentifier
1869 optLanguageSpec optError
1871 act_ttcn3_module = new Ttcn::Module($3);
1872 act_ttcn3_module->set_scope_name($3->get_dispname());
1873 act_ttcn3_module->set_language_spec($5);
1879 GlobalModuleId optLanguageSpec
1881 $$ = new ImpMod($1);
1882 $$->set_language_spec($2);
1887 GlobalModuleId: // 5
1888 IDentifier { $$ = $1; }
1889 | IDentifier '.' ObjectIdentifierValue
1890 { $$ = $1; delete $3; }
1894 /* empty */ { $$ = NULL; }
1895 | LanguageKeyword FreeText { $$ = $2; } // sort-of 7 LanguageSpec
1899 '{' optErrorBlock '}'
1900 | '{' ModuleDefinitionsList optErrorBlock '}'
1901 | '{' ModuleDefinitionsList ModuleControlPart optErrorBlock '}'
1902 | '{' ModuleControlPart optErrorBlock '}'
1905 /* A.1.6.1 Module definitions part */
1907 /* A.1.6.1.0 General */
1909 ModuleDefinitionsList: // 10
1910 ModuleDefinition optSemiColon
1911 | error ModuleDefinition optSemiColon
1912 | ModuleDefinitionsList optErrorBlock ModuleDefinition optSemiColon
1915 optVisibility: // 12
1916 // /* empty */ { $$.visibility = PUBLIC;}
1917 /* empty */ { $$.visibility = NOCHANGE;}
1918 | PublicKeyword { $$.visibility = PUBLIC;}
1919 | PrivateKeyword { $$.visibility = PRIVATE;}
1920 | FriendKeyword { $$.visibility = FRIEND;}
1923 /* A definition _in_ the module, not a definition _of_ a module */
1924 ModuleDefinition: // 11
1925 optVisibility ModuleDef optWithStatement
1927 for (size_t i = 0; i < $2.nElements; i++) {
1929 if (i == 0) $2.elements[i]->set_with_attr($3);
1930 else $2.elements[i]->set_with_attr($3->clone());
1932 if ($1.visibility != NOCHANGE) {
1933 $2.elements[i]->set_visibility($1.visibility);
1935 act_ttcn3_module->add_ass($2.elements[i]);
1937 $2.elements[i]->set_parent_path(act_group->get_attrib_path());
1938 act_group->add_ass($2.elements[i]);
1940 $2.elements[i]->set_parent_path(act_ttcn3_module->get_attrib_path());
1945 | optVisibility ImportDef optWithStatement
1947 $2->set_with_attr($3);
1948 if ($1.visibility != NOCHANGE) {
1949 $2->set_visibility($1.visibility);
1952 $2->set_parent_path(act_group->get_attrib_path());
1953 act_group->add_impmod($2);
1955 $2->set_parent_path(act_ttcn3_module->get_attrib_path());
1957 act_ttcn3_module->add_impmod($2);
1959 | PublicKeyword GroupDef optWithStatement
1960 { // only public allowed for group, and it's redundant
1961 $2->set_with_attr($3);
1962 act_group = $2->get_parent_group();
1964 | GroupDef optWithStatement
1965 { // same code as above
1966 $1->set_with_attr($2);
1967 act_group = $1->get_parent_group();
1969 | PrivateKeyword FriendModuleDef optWithStatement
1970 { // only private allowed for "friend module", and it's redundant
1971 for (size_t i = 0; i < $2.nElements; i++) {
1973 if (i == 0) $2.elements[i]->set_with_attr($3);
1974 else $2.elements[i]->set_with_attr($3->clone());
1976 act_ttcn3_module->add_friendmod($2.elements[i]);
1978 $2.elements[i]->set_parent_path(act_group->get_attrib_path());
1979 act_group->add_friendmod($2.elements[i]);
1981 $2.elements[i]->set_parent_path(act_ttcn3_module->get_attrib_path());
1986 | FriendModuleDef optWithStatement
1987 { // same code as above
1988 for (size_t i = 0; i < $1.nElements; i++) {
1990 if (i == 0) $1.elements[i]->set_with_attr($2);
1991 else $1.elements[i]->set_with_attr($2->clone());
1993 act_ttcn3_module->add_friendmod($1.elements[i]);
1995 $1.elements[i]->set_parent_path(act_group->get_attrib_path());
1996 act_group->add_friendmod($1.elements[i]);
1998 $1.elements[i]->set_parent_path(act_ttcn3_module->get_attrib_path());
2006 ConstDef { $$ = $1; }
2007 | ModuleParDef { $$ = $1; }
2011 $$.elements = (Ttcn::Definition**)
2012 Malloc(sizeof(*$$.elements));
2013 $$.elements[0] = $1;
2018 $$.elements = (Ttcn::Definition**)
2019 Malloc(sizeof(*$$.elements));
2020 $$.elements[0] = $1;
2025 $$.elements = (Ttcn::Definition**)
2026 Malloc(sizeof(*$$.elements));
2027 $$.elements[0] = $1;
2032 $$.elements = (Ttcn::Definition**)
2033 Malloc(sizeof(*$$.elements));
2034 $$.elements[0] = $1;
2039 $$.elements = (Ttcn::Definition**)
2040 Malloc(sizeof(*$$.elements));
2041 $$.elements[0] = $1;
2046 $$.elements = (Ttcn::Definition**)
2047 Malloc(sizeof(*$$.elements));
2048 $$.elements[0] = $1;
2053 $$.elements = (Ttcn::Definition**)
2054 Malloc(sizeof(*$$.elements));
2055 $$.elements[0] = $1;
2057 | ExtConstDef { $$ = $1; }
2060 /* A.1.6.1.1 Typedef definitions */
2063 TypeDefKeyword TypeDefBody
2066 $$->set_location(infile, @$);
2071 StructuredTypeDef { $$ = $1; }
2072 | SubTypeDef { $$ = $1; }
2075 StructuredTypeDef: // 16
2076 RecordDef { $$ = $1; }
2077 | UnionDef { $$ = $1; }
2078 | SetDef { $$ = $1; }
2079 | RecordOfDef { $$ = $1; }
2080 | SetOfDef { $$ = $1; }
2081 | EnumDef { $$ = $1; }
2082 | PortDef { $$ = $1; }
2083 | ComponentDef { $$ = $1; }
2084 | FunctionTypeDef { $$ = $1; }
2085 | AltstepTypeDef { $$ = $1; }
2086 | TestcaseTypeDef { $$ = $1; }
2090 RecordKeyword StructDefBody
2092 Type *type = new Type(Type::T_SEQ_T, $2.cfm);
2093 type->set_location(infile, @$);
2094 $$ = new Def_Type($2.id, type);
2098 StructDefBody: // 19
2099 IDentifier optStructDefFormalParList
2100 '{' optStructFieldDefList '}'
2105 | AddressKeyword '{' optStructFieldDefList '}'
2107 $$.id = new Identifier(Identifier::ID_TTCN, string("address"));
2112 optStructDefFormalParList:
2113 /* empty */ optError
2114 | '(' StructDefFormalParList optError ')'
2116 Location loc(infile, @$);
2117 loc.error("Type parameterization is not currently supported");
2121 Location loc(infile, @$);
2122 loc.error("Type parameterization is not currently supported");
2126 StructDefFormalParList: // -> 202 784 "Advanced Parameterization", 9
2127 optError StructDefFormalPar
2128 | StructDefFormalParList optError ',' optError StructDefFormalPar
2129 | StructDefFormalParList optError ',' error
2132 StructDefFormalPar: // -> 202 784 "Advanced Parameterization", 10
2133 FormalValuePar { delete $1; }
2136 optStructFieldDefList:
2137 /* empty */ optError { $$ = new CompFieldMap; }
2138 | StructFieldDefList optError { $$ = $1; }
2142 optError StructFieldDef
2144 $$ = new CompFieldMap;
2147 | StructFieldDefList optError ',' optError StructFieldDef
2152 | StructFieldDefList optError ',' error { $$ = $1; }
2155 StructFieldDef: // 21
2156 TypeOrNestedTypeDef IDentifier optArrayDef optSubTypeSpec optOptionalKeyword
2159 /* The subtype constraint belongs to the innermost embedded type of
2160 * possible nested 'record of' or 'set of' constructs. */
2162 while (t->is_seof()) t = t->get_ofType();
2163 t->set_parsed_restrictions($4);
2166 /* creation of array type(s) if necessary (from right to left) */
2167 for (size_t i = $3.nElements; i > 0; i--) {
2168 type = new Type(Type::T_ARRAY, type, $3.elements[i - 1], true);
2169 type->set_location(*$1);
2172 $$ = new CompField($2, type, $5);
2173 $$->set_location(infile, @$);
2178 /* empty */ { $$ = false; }
2179 | OptionalKeyword { $$ = true; }
2182 TypeOrNestedTypeDef:
2184 | NestedTypeDef { $$ = $1; }
2187 NestedTypeDef: // 22
2188 NestedRecordDef { $$ = $1; }
2189 | NestedUnionDef { $$ = $1; }
2190 | NestedSetDef { $$ = $1; }
2191 | NestedRecordOfDef { $$ = $1; }
2192 | NestedSetOfDef { $$ = $1; }
2193 | NestedEnumDef { $$ = $1; }
2194 | NestedFunctionTypeDef { $$ = $1; }
2195 | NestedAltstepTypeDef { $$ = $1; }
2196 | NestedTestcaseTypeDef { $$ = $1; }
2199 NestedRecordDef: // 23
2200 RecordKeyword '{' optStructFieldDefList '}'
2202 $$ = new Type(Type::T_SEQ_T, $3);
2203 $$->set_location(infile, @$);
2207 NestedUnionDef: // 24
2208 UnionKeyword '{' UnionFieldDefList optError '}'
2210 $$ = new Type(Type::T_CHOICE_T, $3);
2211 $$->set_location(infile, @$);
2216 SetKeyword '{' optStructFieldDefList '}'
2218 $$ = new Type(Type::T_SET_T, $3);
2219 $$->set_location(infile, @$);
2223 NestedRecordOfDef: // 26
2224 RecordKeyword optStringLength OfKeyword TypeOrNestedTypeDef
2226 $$ = new Type(Type::T_SEQOF, $4);
2228 vector<SubTypeParse> *vstp = new vector<SubTypeParse>;
2229 SubTypeParse *stp = new SubTypeParse($2);
2231 $$->set_parsed_restrictions(vstp);
2233 $$->set_location(infile, @$);
2237 NestedSetOfDef: // 27
2238 SetKeyword optStringLength OfKeyword TypeOrNestedTypeDef
2240 $$ = new Type(Type::T_SETOF, $4);
2242 vector<SubTypeParse> *vstp = new vector<SubTypeParse>;
2243 SubTypeParse *stp = new SubTypeParse($2);
2245 $$->set_parsed_restrictions(vstp);
2247 $$->set_location(infile, @$);
2251 NestedEnumDef: // 28
2252 EnumKeyword '{' EnumerationList optError '}'
2254 $$ = new Type(Type::T_ENUM_T, $3);
2255 $$->set_location(infile, @$);
2259 NestedFunctionTypeDef:
2260 FunctionKeyword '(' optFunctionFormalParList ')'
2261 optRunsOnComprefOrSelf optReturnType
2263 $3->set_location(infile, @2, @4);
2264 $$ = new Type(Type::T_FUNCTION, $3, $5.reference, $5.self, $6.type,
2265 $6.returns_template, $6.template_restriction);
2266 $$->set_location(infile, @$);
2270 NestedAltstepTypeDef:
2271 AltstepKeyword '(' optAltstepFormalParList ')'
2272 optRunsOnComprefOrSelf
2274 $3->set_location(infile, @2, @4);
2275 $$ = new Type(Type::T_ALTSTEP, $3, $5.reference, $5.self);
2276 $$->set_location(infile, @$);
2280 NestedTestcaseTypeDef:
2281 TestcaseKeyword '(' optTestcaseFormalParList ')'
2284 $3->set_location(infile, @2, @4);
2285 $$ = new Type(Type::T_TESTCASE, $3, $5.runsonref,
2287 $$->set_location(infile, @$);
2292 UnionKeyword UnionDefBody
2294 Type *type = new Type(Type::T_CHOICE_T, $2.cfm);
2295 type->set_location(infile, @$);
2296 $$ = new Def_Type($2.id, type);
2301 IDentifier optStructDefFormalParList
2302 '{' UnionFieldDefList optError '}'
2307 | AddressKeyword '{' UnionFieldDefList optError '}'
2309 $$.id = new Identifier(Identifier::ID_TTCN, string("address"));
2315 optError UnionFieldDef
2317 $$ = new CompFieldMap;
2320 | UnionFieldDefList optError ',' optError UnionFieldDef
2325 | UnionFieldDefList optError ',' error { $$ = $1; }
2326 | error { $$ = new CompFieldMap; }
2329 UnionFieldDef: // 34
2330 TypeOrNestedTypeDef IDentifier optArrayDef optSubTypeSpec
2333 /* The subtype constraint belongs to the innermost embedded type of
2334 * possible nested 'record of' or 'set of' constructs. */
2336 while (t->is_seof()) t = t->get_ofType();
2337 t->set_parsed_restrictions($4);
2340 /* creation of array type(s) if necessary (from right to left) */
2341 for (size_t i = $3.nElements; i > 0; i--) {
2342 type = new Type(Type::T_ARRAY, type, $3.elements[i - 1], true);
2343 type->set_location(*$1);
2346 $$ = new CompField($2, type, false);
2347 $$->set_location(infile, @$);
2352 SetKeyword StructDefBody
2354 Type *type = new Type(Type::T_SET_T, $2.cfm);
2355 type->set_location(infile, @$);
2356 $$ = new Def_Type($2.id, type);
2361 RecordKeyword optStringLength OfKeyword StructOfDefBody
2363 Type *type = new Type(Type::T_SEQOF, $4.type);
2365 vector<SubTypeParse> *vstp = new vector<SubTypeParse>;
2366 vstp->add(new SubTypeParse($2));
2367 type->set_parsed_restrictions(vstp);
2369 type->set_location(infile, @$);
2370 $$ = new Def_Type($4.id, type);
2374 StructOfDefBody: // 39
2375 TypeOrNestedTypeDef IdentifierOrAddressKeyword optSubTypeSpec
2378 /* The subtype constraint belongs to the innermost embedded type of
2379 * possible nested 'record of' or 'set of' constructs. */
2381 while (t->is_seof()) t = t->get_ofType();
2382 t->set_parsed_restrictions($3);
2389 IdentifierOrAddressKeyword:
2390 IDentifier { $$ = $1; }
2393 $$ = new Identifier(Identifier::ID_TTCN, string("address"));
2398 SetKeyword optStringLength OfKeyword StructOfDefBody
2400 Type *type = new Type(Type::T_SETOF, $4.type);
2402 vector<SubTypeParse> *vstp = new vector<SubTypeParse>;
2403 vstp->add(new SubTypeParse($2));
2404 type->set_parsed_restrictions(vstp);
2406 type->set_location(infile, @$);
2407 $$ = new Def_Type($4.id, type);
2412 EnumKeyword IdentifierOrAddressKeyword
2413 '{' EnumerationList optError '}'
2415 Type *type = new Type(Type::T_ENUM_T, $4);
2416 type->set_location(infile, @$);
2417 $$ = new Def_Type($2, type);
2421 EnumerationList: // 44
2422 optError Enumeration
2427 | EnumerationList optError ',' optError Enumeration
2432 | EnumerationList optError ',' error { $$ = $1; }
2433 | error { $$ = new EnumItems; }
2439 $$ = new EnumItem($1, NULL);
2440 $$->set_location(infile, @$);
2442 | IDentifier '(' Number optError ')'
2444 Value *value = new Value(Value::V_INT, $3);
2445 value->set_location(infile, @3);
2446 $$ = new EnumItem($1, value);
2447 $$->set_location(infile, @$);
2449 | IDentifier '(' '-' Number optError ')'
2452 Value *value = new Value(Value::V_INT, $4);
2453 value->set_location(infile, @3, @4);
2454 $$ = new EnumItem($1, value);
2455 $$->set_location(infile, @$);
2457 | IDentifier '(' error ')'
2459 Value *value = new Value(Value::V_ERROR);
2460 value->set_location(infile, @3);
2461 $$ = new EnumItem($1, value);
2462 $$->set_location(infile, @$);
2467 Type IdentifierOrAddressKeyword optArrayDef optSubTypeSpec
2469 /* the subtype constraint belongs to the innermost type */
2470 if ($4) $1->set_parsed_restrictions($4);
2472 /* creation of array type(s) if necessary (from right to left) */
2473 for (size_t i = $3.nElements; i > 0; i--) {
2474 type = new Type(Type::T_ARRAY, type, $3.elements[i - 1], true);
2475 type->set_location(*$1);
2478 $$ = new Def_Type($2, type);
2482 optSubTypeSpec: // [49]
2483 /* empty */ { $$ = 0; }
2484 | AllowedValues { $$ = $1; }
2485 | AllowedValues StringLength
2488 $$->add(new SubTypeParse($2));
2492 $$ = new vector<SubTypeParse>;
2493 $$->add(new SubTypeParse($1));
2497 AllowedValues: // 50
2498 '(' seqValueOrRange optError ')' { $$ = $2; }
2499 | '(' CharStringMatch optError ')'
2501 $$ = new vector<SubTypeParse>;
2502 $$->add(new SubTypeParse($2));
2504 | '(' error ')' { $$ = new vector<SubTypeParse>; }
2508 optError ValueOrRange
2510 $$ = new vector<SubTypeParse>;
2513 | seqValueOrRange optError ',' optError ValueOrRange
2518 | seqValueOrRange optError ',' error { $$ = $1; }
2522 RangeDef { $$ = new SubTypeParse($1.lower, $1.lower_exclusive, $1.upper, $1.upper_exclusive); }
2523 | Expression { $$ = new SubTypeParse($1); }
2527 LowerBound DotDot UpperBound
2529 $$.lower_exclusive = false;
2531 $$.upper_exclusive = false;
2534 | '!' LowerBound DotDot UpperBound
2536 $$.lower_exclusive = true;
2538 $$.upper_exclusive = false;
2541 | LowerBound DotDot '!' UpperBound
2543 $$.lower_exclusive = false;
2545 $$.upper_exclusive = true;
2548 | '!' LowerBound DotDot '!' UpperBound
2550 $$.lower_exclusive = true;
2552 $$.upper_exclusive = true;
2558 /* empty */ optError { $$ = 0; }
2559 | StringLength { $$ = $1; }
2563 LengthKeyword '(' Expression optError ')'
2565 $$ = new LengthRestriction($3);
2566 $$->set_location(infile, @$);
2568 | LengthKeyword '(' Expression DotDot UpperBound optError ')'
2570 $$ = new LengthRestriction($3, $5);
2571 $$->set_location(infile, @$);
2573 | LengthKeyword '(' error ')'
2575 Value *value = new Value(Value::V_ERROR);
2576 value->set_location(infile, @3);
2577 $$ = new LengthRestriction(value);
2578 $$->set_location(infile, @$);
2585 $$ = new Ttcn::Reference($1);
2586 $$->set_location(infile, @$);
2588 | IDentifier '.' IDentifier
2590 $$ = new Ttcn::Reference($1, $3);
2591 $$->set_location(infile, @$);
2593 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
2595 $$ = new Ttcn::Reference($1, $5);
2596 $$->set_location(infile, @$);
2602 PortKeyword PortDefBody { $$ = $2; }
2606 IDentifier PortDefAttribs
2608 $$ = new Def_Type($1, $2);
2612 PortDefAttribs: // 60
2613 PortOperationMode PortDefLists
2615 PortTypeBody *body = new PortTypeBody($1,
2616 $2.in_list, $2.out_list, $2.inout_list,
2617 $2.in_all, $2.out_all, $2.inout_all);
2618 body->set_location(infile, @$);
2619 $$ = new Type(Type::T_PORT, body);
2620 $$->set_location(infile, @$);
2625 MessageKeyword { $$ = PortTypeBody::PO_MESSAGE; } // 61
2626 | ProcedureKeyword { $$ = PortTypeBody::PO_PROCEDURE; } // 68
2627 | MixedKeyword { $$ = PortTypeBody::PO_MIXED; } // 73
2628 | error { $$ = PortTypeBody::PO_MIXED; }
2632 '{' seqPortDefList '}' { $$ = $2; }
2640 $$.inout_all = false;
2645 optError PortDefList optSemiColon { $$ = $2; }
2646 | seqPortDefList PortDefList optSemiColon
2651 $$.in_list->steal_types($2.in_list);
2653 } else $$.in_list = $2.in_list;
2657 $$.out_list->steal_types($2.out_list);
2659 } else $$.out_list = $2.out_list;
2661 if ($2.inout_list) {
2662 if ($$.inout_list) {
2663 $$.inout_list->steal_types($2.inout_list);
2664 delete $2.inout_list;
2665 } else $$.inout_list = $2.inout_list;
2669 Location loc(infile, @2);
2670 loc.warning("Duplicate directive `in all' in port type definition");
2671 } else $$.in_all = true;
2675 Location loc(infile, @2);
2676 loc.warning("Duplicate directive `out all' in port type definition");
2677 } else $$.out_all = true;
2681 Location loc(infile, @2);
2682 loc.warning("Duplicate directive `inout all' in port type definition");
2683 } else $$.inout_all = true;
2689 InParKeyword AllOrTypeList
2693 $$.in_list->set_location(infile, @$);
2702 $$.inout_all = false;
2704 | OutParKeyword AllOrTypeList
2710 $$.out_list->set_location(infile, @$);
2717 $$.inout_all = false;
2719 | InOutParKeyword AllOrTypeList
2727 $$.inout_list->set_location(infile, @$);
2728 $$.inout_all = false;
2731 $$.inout_all = true;
2734 | InParKeyword error
2741 $$.inout_all = false;
2743 | OutParKeyword error
2750 $$.inout_all = false;
2752 | InOutParKeyword error
2759 $$.inout_all = false;
2763 AllOrTypeList: // 65
2764 AllKeyword { $$ = 0; }
2765 | TypeList { $$ = $1; }
2774 | TypeList optError ',' optError Type
2779 | TypeList optError ',' error { $$ = $1; }
2783 ComponentKeyword IDentifier
2785 '{' optComponentDefList '}'
2788 if ($3) $5->add_extends($3);
2789 $5->set_location(infile, @$);
2790 Type *type = new Type(Type::T_COMPONENT, $5);
2791 type->set_location(infile, @$);
2792 $$ = new Def_Type($2, type);
2797 /* empty */ optError { $$ = 0; }
2798 | ExtendsKeyword ComponentTypeList optError
2801 $$->set_location(infile, @1, @2);
2803 | ExtendsKeyword error { $$ = 0; }
2807 optError ComponentType
2809 $$ = new CompTypeRefList();
2812 | ComponentTypeList optError ',' optError ComponentType
2817 | ComponentTypeList optError ',' error { $$ = $1; }
2820 ComponentType: // 81
2823 $$ = new Ttcn::Reference($1);
2824 $$->set_location(infile, @$);
2826 | IDentifier '.' IDentifier
2828 $$ = new Ttcn::Reference($1, $3);
2829 $$->set_location(infile, @$);
2831 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
2833 $$ = new Ttcn::Reference($1, $5);
2834 $$->set_location(infile, @$);
2839 optComponentDefList:
2840 optError /* empty */ { $$ = new ComponentTypeBody(); }
2841 | ComponentElementDefList optError { $$ = $1; }
2844 ComponentElementDefList:
2845 optError ComponentElementDef optSemiColon
2847 $$ = new ComponentTypeBody();
2848 for (size_t i = 0; i < $2.nElements; i++)
2849 $$->add_ass($2.elements[i]);
2852 | ComponentElementDefList optError ComponentElementDef optSemiColon
2855 for (size_t i = 0; i < $3.nElements; i++)
2856 $$->add_ass($3.elements[i]);
2861 ComponentElementVisibility:
2862 PublicKeyword { $$.visibility = PUBLIC;}
2863 | PrivateKeyword { $$.visibility = PRIVATE;}
2866 ComponentElementDef: // 84
2867 PortInstance { $$ = $1; }
2868 | VarInstance { $$ = $1; }
2869 | TimerInstance { $$ = $1; }
2870 | ConstDef { $$ = $1; }
2871 | ComponentElementVisibility PortInstance
2874 for (size_t i = 0; i < $2.nElements; i++) {
2875 $2.elements[i]->set_visibility($1.visibility);
2878 | ComponentElementVisibility VarInstance
2881 for (size_t i = 0; i < $2.nElements; i++) {
2882 $2.elements[i]->set_visibility($1.visibility);
2885 | ComponentElementVisibility TimerInstance
2888 for (size_t i = 0; i < $2.nElements; i++) {
2889 $2.elements[i]->set_visibility($1.visibility);
2892 | ComponentElementVisibility ConstDef
2895 for (size_t i = 0; i < $2.nElements; i++) {
2896 $2.elements[i]->set_visibility($1.visibility);
2902 PortKeyword PortType PortElementList
2904 $$.nElements = $3.nElements;
2905 $$.elements = (Ttcn::Definition**)
2906 Malloc($$.nElements*sizeof(*$$.elements));
2907 for (size_t i = 0; i < $3.nElements; i++) {
2908 Ttcn::Reference *ref = i > 0 ? $2->clone() : $2;
2909 $$.elements[i] = new Ttcn::Def_Port($3.elements[i].id, ref,
2910 $3.elements[i].dims);
2911 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
2918 optError PortElement
2921 $$.elements = (YYSTYPE::portelement_t*)Malloc(sizeof(*$$.elements));
2922 $$.elements[0] = $2;
2924 | PortElementList ',' optError PortElement
2926 $$.nElements = $1.nElements + 1;
2927 $$.elements = (YYSTYPE::portelement_t*)
2928 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
2929 $$.elements[$$.nElements - 1] = $4;
2931 | PortElementList ',' error { $$ = $1; }
2935 IDentifier optArrayDef
2938 if ($2.nElements > 0) {
2939 $$.dims = new ArrayDimensions;
2940 for (size_t i = 0; i < $2.nElements; i++) $$.dims->add($2.elements[i]);
2947 /* A.1.6.1.2 Constant definitions */
2950 ConstKeyword Type ConstList
2952 $$.nElements = $3.nElements;
2953 $$.elements = (Ttcn::Definition**)
2954 Malloc($$.nElements*sizeof(*$$.elements));
2955 for (size_t i = 0; i < $$.nElements; i++) {
2958 type = new Type(Type::T_REFDSPEC, $2);
2959 type->set_location(*$2);
2961 /* creation of array type(s) if necessary (from right to left) */
2962 for (size_t j = $3.elements[i].arrays.nElements; j > 0; j--) {
2963 type = new Type(Type::T_ARRAY, type,
2964 $3.elements[i].arrays.elements[j - 1], false);
2965 type->set_location(*$2);
2967 Free($3.elements[i].arrays.elements);
2969 /* Create the definition */
2970 $$.elements[i] = new Def_Const($3.elements[i].id,
2971 type, $3.elements[i].initial_value);
2972 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
2979 optError SingleConstDef
2982 $$.elements = (YYSTYPE::singlevarinst_t*)Malloc(sizeof(*$$.elements));
2983 $$.elements[0] = $2;
2985 | ConstList ',' optError SingleConstDef
2987 $$.nElements = $1.nElements + 1;
2988 $$.elements = (YYSTYPE::singlevarinst_t*)
2989 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
2990 $$.elements[$$.nElements - 1] = $4;
2994 SingleConstDef: // 90
2995 IDentifier optArrayDef AssignmentChar Expression
2999 $$.initial_value = $4;
3005 FunctionKeyword IDentifier '(' optFunctionFormalParList ')'
3006 optRunsOnComprefOrSelf optReturnType
3008 $4->set_location(infile, @3, @5);
3009 Type *type = new Type(Type::T_FUNCTION, $4, $6.reference, $6.self, $7.type,
3010 $7.returns_template, $7.template_restriction);
3011 type->set_location(infile, @$);
3012 $$ = new Ttcn::Def_Type($2, type);
3013 $$->set_location(infile, @$);
3018 AltstepKeyword IDentifier '(' optAltstepFormalParList ')'
3019 optRunsOnComprefOrSelf
3021 $4->set_location(infile, @3, @5);
3022 Type *type = new Type(Type::T_ALTSTEP, $4, $6.reference, $6.self);
3023 type->set_location(infile, @$);
3024 $$ = new Ttcn::Def_Type($2, type);
3025 $$->set_location(infile, @$);
3030 TestcaseKeyword IDentifier '(' optTestcaseFormalParList ')'
3033 $4->set_location(infile, @3, @5);
3034 Type *type = new Type(Type::T_TESTCASE, $4, $6.runsonref,
3036 type->set_location(infile, @$);
3037 $$ = new Ttcn::Def_Type($2, type);
3038 $$->set_location(infile, @$);
3042 /* A.1.6.1.3 Template definitions */
3045 TemplateKeyword optTemplateRestriction BaseTemplate
3046 optDerivedDef AssignmentChar TemplateBody
3048 $$ = new Def_Template($2, $3.name, $3.type, $3.fp_list, $4, $6);
3049 $$->set_location(infile, @$);
3054 Type IDentifier optTemplateFormalParList
3060 /* | Signature IDentifier optTemplateFormalParList -- covered by the previous
3065 /* empty */ { $$ = 0; }
3066 | DerivedDef { $$ = $1; }
3070 ModifiesKeyword TemplateRef
3072 $$ = new Ttcn::Reference($2.modid, $2.id);
3073 $$->set_location(infile, @$);
3075 | ModifiesKeyword error { $$ = 0; }
3078 optTemplateFormalParList:
3079 /* empty */ optError { $$ = 0; }
3080 | '(' TemplateFormalParList optError ')'
3083 $$->set_location(infile, @$);
3087 $$ = new FormalParList;
3088 $$->set_location(infile, @$);
3092 TemplateFormalParList: // 99 is a FormalParList*
3093 optError TemplateFormalPar
3095 $$ = new FormalParList;
3098 | TemplateFormalParList optError ',' optError TemplateFormalPar
3103 | TemplateFormalParList optError ',' error { $$ = $1; }
3106 TemplateFormalPar: // 100
3107 FormalValuePar { $$ = $1; }
3108 | FormalTemplatePar { $$ = $1; }
3111 TemplateBody: // 101 is a Template*
3112 SimpleSpec optExtraMatchingAttributes
3115 $$->set_length_restriction($2.len_restr);
3116 $$->set_ifpresent($2.is_ifpresent);
3118 | FieldSpecList optExtraMatchingAttributes
3121 $$->set_length_restriction($2.len_restr);
3122 $$->set_ifpresent($2.is_ifpresent);
3124 | ArraySpecList optExtraMatchingAttributes
3127 $$->set_length_restriction($2.len_restr);
3128 $$->set_ifpresent($2.is_ifpresent);
3130 | ArrayValueOrAttrib optExtraMatchingAttributes
3133 $$->set_length_restriction($2.len_restr);
3134 $$->set_ifpresent($2.is_ifpresent);
3139 SingleValueOrAttrib { $$ = $1; }
3142 FieldSpecList: // 103
3145 $$ = new Template(Template::TEMPLATE_LIST, new Templates());
3146 $$->set_location(infile, @$);
3149 | '{' seqFieldSpec optError '}'
3151 $$ = new Template($2); // NAMED_TEMLATE_LIST
3152 $$->set_location(infile, @$);
3156 $$ = new Template(Template::TEMPLATE_ERROR);
3157 $$->set_location(infile, @$);
3161 /* Sequence of FieldSpec. \note Cannot be empty */
3162 seqFieldSpec: // a NamedTemplates*
3165 $$ = new NamedTemplates();
3170 $$ = new NamedTemplates();
3173 | seqFieldSpec optError ',' optError FieldSpec
3178 | seqFieldSpec optError ',' error { $$ = $1; }
3181 FieldSpec: // 104 a NamedTemplate*
3182 FieldReference AssignmentChar TemplateBody
3184 $$ = new NamedTemplate($1, $3);
3185 $$->set_location(infile, @$);
3187 | FieldReference AssignmentChar NotUsedSymbol
3189 Template* temp = new Template(Template::TEMPLATE_NOTUSED);
3190 temp->set_location(infile, @3);
3191 $$ = new NamedTemplate($1, temp);
3192 $$->set_location(infile, @$);
3196 FieldReference: // 105
3197 StructFieldRef { $$ = $1; }
3198 /* | ArrayOrBitRef -- covered by ArraySpecList */
3199 /* | ParRef -- covered by StructFieldRef */
3202 StructFieldRef: // 106 (and 107. ParRef)
3203 PredefOrIdentifier { $$ = $1; }
3205 Note: Non-parameterized type references are covered by (StructField)Identifier.
3206 Parameterized type references are covered by FunctionInstance */
3209 Location loc(infile, @$);
3210 loc.error("Reference to a parameterized field of type `anytype' is "
3211 "not currently supported");
3213 $$ = new Identifier(Identifier::ID_TTCN, string("<error>"));
3218 '{' seqArraySpec optError '}'
3220 $$ = new Template($2);
3221 $$->set_location(infile, @$);
3228 $$ = new IndexedTemplates();
3231 /* It was optError before. */
3234 $$ = new IndexedTemplates();
3237 | seqArraySpec optError ',' optError ArraySpec
3242 | seqArraySpec optError ',' error { $$ = $1; }
3246 ArrayOrBitRef AssignmentChar TemplateBody
3248 $$ = new IndexedTemplate($1, $3);
3249 $$->set_location(infile, @$);
3253 ArrayOrBitRef: // 109
3256 $$ = new FieldOrArrayRef($2);
3257 $$->set_location(infile, @$);
3261 $$ = new FieldOrArrayRef(new Value(Value::V_ERROR));
3262 $$->set_location(infile, @$);
3266 SingleValueOrAttrib: // 111
3267 MatchingSymbol { $$ = $1; }
3270 if ($1->get_valuetype() == Value::V_OMIT) {
3272 $$ = new Template(Template::OMIT_VALUE);
3273 } else $$ = new Template($1); // SPECIFIC_VALUE; SingleExpr is a Template*
3274 $$->set_location(infile, @$);
3276 /* | TemplateRefWithParList -- covered by SingleExpression */
3279 ArrayValueOrAttrib: // 112
3280 '{' ArrayElementSpecList optError '}'
3282 $$ = new Template(Template::TEMPLATE_LIST, $2);
3283 $$->set_location(infile, @$);
3287 ArrayElementSpecList: // 113
3293 | error ArrayElementSpec
3298 | ArrayElementSpecList optError ',' optError ArrayElementSpec
3303 | ArrayElementSpecList optError ',' error { $$ = $1; }
3306 ArrayElementSpec: // 114 is a Template*
3309 $$ = new Template(Template::TEMPLATE_NOTUSED);
3310 $$->set_location(infile, @$);
3314 $$ = new Template(Template::PERMUTATION_MATCH, $1);
3315 $$->set_location(infile, @$);
3317 | TemplateListElem { $$ = $1; }
3320 NotUsedSymbol: // 115
3324 MatchingSymbol: // 116 is a Template*
3327 $$ = new Template(Template::COMPLEMENTED_LIST, $1);
3328 $$->set_location(infile, @$);
3332 $$ = new Template(Template::ANY_VALUE);
3333 $$->set_location(infile, @$);
3337 $$ = new Template(Template::ANY_OR_OMIT);
3338 $$->set_location(infile, @$);
3342 $$ = new Template(Template::VALUE_LIST, $1);
3343 $$->set_location(infile, @$);
3347 $$ = new Template($1);
3348 $$->set_location(infile, @$);
3352 $$ = new Template(Template::BSTR_PATTERN, $1);
3353 $$->set_location(infile, @$);
3357 $$ = new Template(Template::HSTR_PATTERN, $1);
3358 $$->set_location(infile, @$);
3362 $$ = new Template(Template::OSTR_PATTERN, $1);
3363 $$->set_location(infile, @$);
3367 $$ = new Template($1);
3368 $$->set_location(infile, @$);
3372 $$ = new Template(Template::SUBSET_MATCH, $1);
3373 $$->set_location(infile, @$);
3377 $$ = new Template(Template::SUPERSET_MATCH, $1);
3378 $$->set_location(infile, @$);
3380 | '(' AllElementsFrom ')'
3382 $$ = new Template(Template::VALUE_LIST_ALL_FROM, $2);
3383 $$->set_location(infile, @$);
3387 optExtraMatchingAttributes: // [117]
3390 $$.is_ifpresent = false;
3391 $$.len_restr = NULL;
3396 $$.is_ifpresent = false;
3400 $$.len_restr = NULL;
3401 $$.is_ifpresent = true;
3403 | LengthMatch IfPresentMatch
3406 $$.is_ifpresent = true;
3410 CharStringMatch: // 124
3411 PatternKeyword PatternChunkList
3413 Location loc(infile, @2);
3414 $$ = parse_pattern($2, loc);
3424 | PatternChunkList '&' PatternChunk
3427 $$ = mputstr($$, $3);
3439 switch ($1->get_valuetype()) {
3440 case Value::V_REFD: {
3441 /* Pretend to be a reference. Let pstring_la.l discover the
3443 Common::Reference *ref = $1->get_reference();
3444 $$ = mprintf("{%s}", (ref->get_dispname()).c_str());
3446 case Value::V_UNDEF_LOWERID: {
3447 const Common::Identifier *id = $1->get_val_id();
3448 $$ = mprintf("{%s}", (id->get_dispname()).c_str());
3451 FATAL_ERROR("Internal error.");
3453 /* Forget the Node. */
3458 ustring::universal_char& uc = $1->operator[](0);
3459 $$ = mprintf("\\q{%d,%d,%d,%d}", uc.group, uc.plane, uc.row, uc.cell);
3464 Complement: // 130 is a Templates*
3465 ComplementKeyword ValueList { $$ = $2; }
3468 ValueList: // 132 is a Templates*
3469 '(' seqValueOrAttrib optError ')' { $$ = $2; }
3470 | '(' error ')' { $$ = new Templates; }
3473 seqValueOrAttrib: // is a Templates*
3474 optError TemplateListElem
3479 | seqValueOrAttrib optError ',' optError TemplateListElem
3484 | seqValueOrAttrib optError ',' error { $$ = $1; }
3487 SubsetMatch: // 133 is a Templates*
3488 SubsetKeyword ValueList { $$ = $2; }
3491 SupersetMatch: // 135 is a Templates*
3492 SupersetKeyword ValueList { $$ = $2; }
3495 PermutationMatch: // 137 is a Templates*
3496 PermutationKeyword ValueList { $$ = $2; }
3507 TemplateListElem: // is a Template*
3512 AllElementsFrom: // is a Template*
3513 AllKeyword FromKeyword TemplateBody
3514 { // $3 is a Template*
3515 $$ = new Template($3); // Constructs ALL_FROM
3516 $$->set_location(infile, @$);
3520 ValueOrAttribList: // 142 is a Templates*
3521 /* ValueOrAttribList always has two or more elements
3522 * (there's always a comma) and is reduced through
3523 * ValueOrAttribList -> MatchingSymbol -> SingleValueOrAttrib
3525 * The one-element list is reduced through
3526 * '(' SingleExpression ')' -> SingleExpression -> SingleValueOrAttrib */
3527 '(' TemplateListElem optError ',' seqValueOrAttrib optError ')'
3530 $$->add_front_t($2);
3532 | '(' error TemplateListElem optError ',' seqValueOrAttrib optError ')'
3535 $$->add_front_t($3);
3540 StringLength { $$ = $1; }
3543 IfPresentMatch: // 144
3548 '(' SingleLowerBound DotDot UpperBound optError ')'
3549 { $$ = new ValueRange($2, $4); }
3555 if ($1->is_parsed_infinity()==-1) {
3556 /* the conflicting rule alternative faked here: '-' InfinityKeyword */
3568 if ($1->is_parsed_infinity()==-1) {
3569 /* the conflicting rule alternative faked here: '-' InfinityKeyword */
3581 if ($1->is_parsed_infinity()==1) {
3582 /* the conflicting rule alternative faked here: InfinityKeyword */
3591 TemplateInstance: // 151
3592 InLineTemplate { $$ = $1; }
3595 TemplateRefWithParList: /* refbase */ // 153 ?
3596 TemplateRef optTemplateActualParList
3599 $$ = new Ttcn::Ref_pard($1.modid, $1.id, new ParsedActualParameters($2));
3600 $$->set_location(infile, @$);
3602 $$ = new Ttcn::Reference($1.modid, $1.id);
3603 $$->set_location(infile, @$);
3614 | IDentifier '.' IDentifier
3619 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
3627 InLineTemplate: // 155
3630 $$ = new TemplateInstance(0, 0, $1);
3631 $$->set_location(infile, @$);
3633 | Type ':' TemplateBody
3635 $$ = new TemplateInstance($1, 0, $3);
3636 $$->set_location(infile, @$);
3638 /* | Signature ':' TemplateBody -- covered by the previous rule */
3639 | DerivedRefWithParList AssignmentChar TemplateBody
3641 $$ = new TemplateInstance(0, $1, $3);
3642 $$->set_location(infile, @$);
3644 | Type ':' DerivedRefWithParList AssignmentChar TemplateBody
3646 $$ = new TemplateInstance($1, $3, $5);
3647 $$->set_location(infile, @$);
3649 /* | Signature ':' DerivedRefWithParList AssignmentChar TemplateBody
3650 -- covered by the previous rule */
3653 DerivedRefWithParList: // 156
3654 ModifiesKeyword TemplateRefWithParList { $$ = $2; }
3657 optTemplateActualParList: // [157]
3658 /* empty */ optError { $$ = 0; }
3659 | '(' seqTemplateActualPar optError ')'
3662 $$->set_location(infile, @$);
3666 $$ = new TemplateInstances;
3667 $$->set_location(infile, @$);
3671 seqTemplateActualPar:
3672 optError TemplateActualPar
3674 $$ = new TemplateInstances;
3677 | seqTemplateActualPar optError ',' optError TemplateActualPar
3682 | seqTemplateActualPar optError ',' error { $$ = $1; }
3685 TemplateActualPar: // 158
3686 TemplateInstance { $$ = $1; }
3689 Template *t = new Template(Template::TEMPLATE_NOTUSED);
3690 t->set_location(infile, @$);
3691 $$ = new TemplateInstance(0, 0, t);
3692 $$->set_location(infile, @$);
3697 MatchOp { $$ = $1; }
3698 | ValueofOp { $$ = $1; }
3702 MatchKeyword '(' optError Expression optError ',' optError TemplateInstance
3705 $$ = new Value(Value::OPTYPE_MATCH, $4, $8);
3706 $$->set_location(infile, @$);
3708 | MatchKeyword '(' error ')'
3710 Value *v = new Value(Value::V_ERROR);
3711 v->set_location(infile, @3);
3712 Template *t = new Template(Template::TEMPLATE_ERROR);
3713 t->set_location(infile, @3);
3714 TemplateInstance *ti = new TemplateInstance(0, 0, t);
3715 ti->set_location(infile, @3);
3716 $$ = new Value(Value::OPTYPE_MATCH, v, ti);
3717 $$->set_location(infile, @$);
3722 ValueofKeyword '(' optError TemplateInstance optError ')'
3724 $$ = new Value(Value::OPTYPE_VALUEOF, $4);
3725 $$->set_location(infile, @$);
3727 | ValueofKeyword '(' error ')'
3729 Template *t = new Template(Template::TEMPLATE_ERROR);
3730 t->set_location(infile, @3);
3731 TemplateInstance *ti = new TemplateInstance(0, 0, t);
3732 ti->set_location(infile, @3);
3733 $$ = new Value(Value::OPTYPE_VALUEOF, ti);
3734 $$->set_location(infile, @$);
3738 /* A.1.6.1.4 Function definitions */
3741 FunctionKeyword IDentifier '(' optFunctionFormalParList ')'
3742 optRunsOnSpec optReturnType optError StatementBlock
3744 $4->set_location(infile, @3, @5);
3745 $$ = new Def_Function($2, $4, $6, $7.type, $7.returns_template,
3746 $7.template_restriction, $9);
3747 $$->set_location(infile, @$);
3751 optFunctionFormalParList: // [167]
3752 /* empty */ { $$ = new FormalParList; }
3753 | FunctionFormalParList { $$ = $1; }
3754 | error { $$ = new FormalParList; }
3757 FunctionFormalParList: // 167
3758 optError FunctionFormalPar
3760 $$ = new FormalParList;
3763 | FunctionFormalParList optError ',' optError FunctionFormalPar
3768 | FunctionFormalParList optError ',' error { $$ = $1; }
3771 FunctionFormalPar: // 168
3772 FormalValuePar { $$ = $1; }
3773 | FormalTimerPar { $$ = $1; }
3774 | FormalTemplatePar { $$ = $1; }
3775 /*| FormalPortPar -- covered by FormalValuePar */
3778 optReturnType: // [169]
3782 $$.returns_template = false;
3783 $$.template_restriction = TR_NONE;
3785 | ReturnKeyword Type
3788 $$.returns_template = false;
3789 $$.template_restriction = TR_NONE;
3791 | ReturnKeyword TemplateOptRestricted Type
3794 $$.returns_template = true;
3795 $$.template_restriction = $2;
3797 | ReturnKeyword error
3800 $$.returns_template = false;
3801 $$.template_restriction = TR_NONE;
3805 optRunsOnComprefOrSelf:
3811 | RunsKeyword OnKeyword SelfKeyword
3819 /* empty */ { $$ = 0; }
3820 | RunsOnSpec { $$ = $1; }
3821 | RunsKeyword error { $$ = 0; }
3825 RunsKeyword OnKeyword ComponentType { $$ = $3; }
3828 /* StatementBlock changed in 4.1.2 to explicitly prevent statements
3829 * followed by definitions. TITAN still allows them to be mixed. */
3830 StatementBlock: /* StatementBlock *statementblock */ // 175
3833 $$ = new StatementBlock;
3834 $$->set_location(infile, @$);
3836 | '{' FunctionStatementOrDefList optError '}'
3839 $$->set_location(infile, @$);
3843 FunctionStatementOrDefList: // (171 in 3.2.1)
3844 optError FunctionStatementOrDef optSemiColon
3846 $$ = new StatementBlock;
3847 for(size_t i=0; i<$2.nElements; i++) $$->add_stmt($2.elements[i]);
3850 | FunctionStatementOrDefList optError FunctionStatementOrDef optSemiColon
3853 for(size_t i=0; i<$3.nElements; i++) $$->add_stmt($3.elements[i]);
3858 FunctionStatementOrDef: // (172 in 3.2.1)
3859 FunctionLocalDef // constant or template definition
3861 $$.nElements=$1.nElements;
3862 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
3863 for(size_t i=0; i<$1.nElements; i++) {
3864 $$.elements[i]=new Statement(Statement::S_DEF, $1.elements[i]);
3865 $$.elements[i]->set_location(*$1.elements[i]);
3869 | FunctionLocalInst // variable or timer instance
3871 $$.nElements=$1.nElements;
3872 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
3873 for(size_t i=0; i<$1.nElements; i++) {
3874 $$.elements[i]=new Statement(Statement::S_DEF, $1.elements[i]);
3875 $$.elements[i]->set_location(*$1.elements[i]);
3882 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
3887 FunctionLocalInst: // 178
3888 VarInstance { $$=$1; }
3889 | TimerInstance { $$=$1; }
3892 FunctionLocalDef: // 179
3898 $$.elements = (Ttcn::Definition**)Malloc(sizeof(*$$.elements));
3899 $$.elements[0] = $1;
3903 FunctionStatement: // 180
3904 ConfigurationStatements {$$=$1;}
3905 | TimerStatements {$$=$1;}
3906 | CommunicationStatements {$$=$1;}
3907 | BasicStatements {$$=$1;}
3908 | BehaviourStatements {$$=$1;}
3909 | VerdictStatements {$$=$1;}
3910 | SUTStatements {$$=$1;}
3911 | StopExecutionStatement { $$ = $1; }
3912 | StopTestcaseStatement { $$ = $1; }
3915 FunctionInstance: /* refpard */ // 181
3916 FunctionRef '(' optFunctionActualParList ')'
3917 /* templateref templinsts */
3919 $3->set_location(infile, @2, @4);
3920 $$ = new Ttcn::Ref_pard($1.modid, $1.id, $3);
3921 $$->set_location(infile, @$);
3931 | IDentifier '.' IDentifier
3936 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
3944 optFunctionActualParList: /* parsedpar */ // [185]
3945 /* empty */ optError { $$ = new ParsedActualParameters; }
3946 | FunctionActualParList optError { $$ = $1; }
3949 /* ***** this * can * not * be * empty ****************** */
3950 FunctionActualParList: /* parsedpar */ // 184
3953 | UnnamedPart ',' NamedPart
3954 /* Splitting the NamedPart and UnnamedPart ensures that a named parameter
3955 * followed by an unnamed one causes a syntax error */
3957 /* UnnamedPart becomes the value */
3959 /* append the elements from NamedPart */
3960 const size_t n3 = $3->get_nof_nps();
3961 for (size_t i = 0; i < n3; ++i) {
3962 $$->add_np( $3->extract_np_byIndex(i) );
3968 UnnamedPart: /* parsedpar */
3969 /*optError*/ FunctionActualPar
3971 $$ = new ParsedActualParameters;
3974 | UnnamedPart /*optError*/ ',' /*optError*/ FunctionActualPar
3975 /* These optErrors mess up the parsing of actual parameters.
3976 * After only one FunctionActualPar, it is reduced to UnnamedPart
3977 * and the rest is expected to be the NamedPart */
3982 | UnnamedPart optError ',' error { $$ = $1; }
3985 NamedPart: /* parsedpar */
3986 seqFieldSpec /* namedtempls */
3988 $$ = new ParsedActualParameters(0, new NamedParams);
3989 const size_t n1 = $1->get_nof_nts();
3990 for (size_t i = 0; i < n1; ++i) {
3991 NamedTemplate *pnt = $1->get_nt_byIndex(i);
3992 TemplateInstance *pti = new TemplateInstance(0,0,pnt->extract_template());
3993 NamedParam *pnp = new NamedParam(pnt->get_name().clone(), pti);
3994 pnp->set_location(*pnt);
3998 $$->set_location(infile, @$);
3999 // This call to ParsedActualParameters::set_location copies the same
4000 // location info to the named and unnamed part. We cannot copy
4001 // the location info from the NamedTemplates to the named part,
4002 // because NamedTemplates is not a Location.
4006 FunctionActualPar: /* templinst */ // 185
4008 TemplateInstance { $$ = $1; }
4011 Template *t = new Template(Template::TEMPLATE_NOTUSED);
4012 t->set_location(infile, @$);
4013 $$ = new TemplateInstance(0, 0, t);
4014 $$->set_location(infile, @$);
4017 | ComponentRef -- TemplateInstance covers all the others */
4021 Reference DotApplyKeyword '(' optFunctionActualParList ')'
4023 if($1.is_ref) $$.value = new Value(Value::V_REFD, $1.ref);
4025 Ttcn::Reference *t_ref = new Ttcn::Reference($1.id);
4026 t_ref->set_location(infile, @1);
4027 $$.value = new Value(Value::V_REFD, t_ref);
4029 $$.value->set_location(infile, @1);
4031 $$.ap_list->set_location(infile, @3 , @5);
4033 | FunctionInstance DotApplyKeyword '(' optFunctionActualParList ')'
4035 $$.value = new Value(Value::V_REFD, $1);
4036 $$.value->set_location(infile, @1);
4038 $$.ap_list->set_location(infile, @3 , @5);
4040 | ApplyOp DotApplyKeyword '(' optFunctionActualParList ')'
4042 $$.value = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
4043 $$.value->set_location(infile, @1);
4045 $$.ap_list->set_location(infile, @3 , @5);
4050 DerefersKeyword '(' Expression ')' { $$ = $3; }
4053 /* A.1.6.1.5 Signature definitions */
4055 SignatureDef: // 187
4056 SignatureKeyword IDentifier
4057 '(' optSignatureFormalParList ')' optReturnTypeOrNoBlockKeyword
4060 Type *type = new Type(Type::T_SIGNATURE, $4, $6.type, $6.no_block_kw, $7);
4061 type->set_location(infile, @3, @7);
4062 $$ = new Ttcn::Def_Type($2, type);
4063 $$->set_location(infile, @$);
4067 optSignatureFormalParList: // [190]
4068 /* empty */ { $$ = 0; }
4069 | SignatureFormalParList { $$ = $1; }
4073 SignatureFormalParList: // 190
4074 optError SignatureFormalPar
4076 $$ = new SignatureParamList;
4079 | SignatureFormalParList optError ',' optError SignatureFormalPar
4084 | SignatureFormalParList optError ',' error { $$ = $1; }
4087 SignatureFormalPar: // 191
4090 $$ = new SignatureParam(SignatureParam::PARAM_IN, $1, $2);
4091 $$->set_location(infile, @$);
4093 | InParKeyword Type IDentifier
4095 $$ = new SignatureParam(SignatureParam::PARAM_IN, $2, $3);
4096 $$->set_location(infile, @$);
4098 | InOutParKeyword Type IDentifier
4100 $$ = new SignatureParam(SignatureParam::PARAM_INOUT, $2, $3);
4101 $$->set_location(infile, @$);
4103 | OutParKeyword Type IDentifier
4105 $$ = new SignatureParam(SignatureParam::PARAM_OUT, $2, $3);
4106 $$->set_location(infile, @$);
4110 optReturnTypeOrNoBlockKeyword:
4114 $$.no_block_kw = false;
4116 | ReturnKeyword Type
4119 $$.no_block_kw = false;
4124 $$.no_block_kw = true;
4128 optExceptionSpec: // [192]
4129 /* empty */ { $$ = NULL; }
4130 | ExceptionKeyword '(' error ')' { $$ = NULL; }
4131 | ExceptionKeyword '(' ExceptionTypeList optError ')'
4134 $$->set_location(infile, @$);
4138 ExceptionTypeList: // 194
4141 $$ = new SignatureExceptions;
4144 | ExceptionTypeList optError ',' optError Type
4149 | ExceptionTypeList optError ',' error { $$ = $1; }
4155 $$ = new Ttcn::Reference($1);
4156 $$->set_location(infile, @$);
4158 | IDentifier '.' IDentifier
4160 $$ = new Ttcn::Reference($1, $3);
4161 $$->set_location(infile, @$);
4163 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
4165 $$ = new Ttcn::Reference($1, $5);
4166 $$->set_location(infile, @$);
4171 /* A.1.6.1.6 Testcase definitions */
4174 TestcaseKeyword IDentifier '(' optTestcaseFormalParList ')'
4175 ConfigSpec optError StatementBlock
4177 $4->set_location(infile, @3, @5);
4178 $$ = new Def_Testcase($2, $4, $6.runsonref, $6.systemref, $8);
4179 $$->set_location(infile, @$);
4183 optTestcaseFormalParList: // [200]
4184 /* empty */ { $$ = new FormalParList; }
4185 | TestcaseFormalParList { $$ = $1; }
4186 | error { $$ = new FormalParList; }
4189 TestcaseFormalParList: // 200
4190 optError TestcaseFormalPar
4192 $$ = new FormalParList;
4195 | TestcaseFormalParList optError ',' optError TestcaseFormalPar
4200 | TestcaseFormalParList optError ',' error { $$ = $1; }
4203 TestcaseFormalPar: // 201
4204 FormalValuePar { $$ = $1; }
4205 | FormalTemplatePar { $$ = $1; }
4209 RunsOnSpec optSystemSpec
4216 optSystemSpec: // [203]
4217 /* empty */ { $$ = 0; }
4218 | SystemKeyword ComponentType { $$ = $2; }
4219 | SystemKeyword error { $$ = 0; }
4222 TestcaseInstance: // 205
4223 ExecuteKeyword '(' TestcaseRef '(' optTestcaseActualParList ')'
4224 optTestcaseTimerValue optError ')'
4226 $5->set_location(infile, @4, @6);
4227 $$.ref_pard = new Ttcn::Ref_pard($3.modid, $3.id, $5);
4228 $$.ref_pard->set_location(infile, @3, @6);
4229 $$.derefered_value = 0;
4233 | ExecuteKeyword '(' DereferOp '(' optTestcaseActualParList ')'
4234 optTestcaseTimerValue optError ')'
4236 $5->set_location(infile, @4, @6);
4238 $$.derefered_value = $3;
4242 | ExecuteKeyword '(' error ')'
4245 $$.derefered_value = 0;
4257 | IDentifier '.' IDentifier
4262 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
4270 optTestcaseTimerValue:
4271 /* empty */ { $$ = 0; }
4272 | ',' optError Expression { $$ = $3; }
4275 $$ = new Value(Value::V_ERROR);
4276 $$->set_location(infile, @$);
4280 optTestcaseActualParList: // [202]
4281 /* empty */ optError { $$ = new ParsedActualParameters; }
4282 | TestcaseActualParList optError { $$ = $1; }
4285 TestcaseActualParList: // 208
4288 | UnnamedPart ',' NamedPart
4289 /* Splitting the NamedPart and UnnamedPart ensures that a named parameter
4290 * followed by an unnamed one causes a syntax error */
4292 /* UnnamedPart becomes the value */
4294 /* append the elements from NamedPart */
4295 const size_t n3 = $3->get_nof_nps();
4296 for (size_t i = 0; i < n3; ++i) {
4297 $$->add_np( $3->extract_np_byIndex(i) );
4303 optError TestcaseActualPar
4305 $$ = new TemplateInstances;
4308 | TestcaseActualParList optError ',' optError TestcaseActualPar
4313 | TestcaseActualParList optError ',' error { $$ = $1; }
4319 TemplateInstance { $$ = $1; }
4322 Template *t = new Template(Template::TEMPLATE_NOTUSED);
4323 t->set_location(infile, @$);
4324 $$ = new TemplateInstance(0, 0, t);
4325 $$->set_location(infile, @$);
4330 /* A.1.6.1.7 Altstep definitions */
4333 AltstepKeyword IDentifier '(' optAltstepFormalParList ')' optRunsOnSpec
4334 optError '{' AltstepLocalDefList AltGuardList optError '}'
4336 StatementBlock *sb = new StatementBlock;
4337 for (size_t i = 0; i < $9.nElements; i++) {
4338 Statement *stmt = new Statement(Statement::S_DEF, $9.elements[i]);
4339 stmt->set_location(*$9.elements[i]);
4343 $4->set_location(infile, @4);
4344 $$ = new Def_Altstep($2, $4, $6, sb, $10);
4345 $$->set_location(infile, @$);
4349 optAltstepFormalParList: // [214]
4350 /* empty */ { $$ = new FormalParList; }
4351 | FunctionFormalParList { $$ = $1; }
4352 | error { $$ = new FormalParList; }
4355 AltstepLocalDefList: // 215
4361 | AltstepLocalDefList optError AltstepLocalDef optSemiColon
4363 $$.nElements = $1.nElements + $3.nElements;
4364 $$.elements = (Ttcn::Definition**)
4365 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4366 memcpy($$.elements + $1.nElements, $3.elements,
4367 $3.nElements * sizeof(*$$.elements));
4372 AltstepLocalDef: // 216
4373 VarInstance { $$ = $1; }
4374 | TimerInstance { $$ = $1; }
4375 | ConstDef { $$ = $1; }
4380 $$.elements = (Ttcn::Definition**)Malloc(sizeof(*$$.elements));
4381 $$.elements[0] = $1;
4385 AltstepInstance: /* refpard */ // 217
4386 FunctionRef '(' optFunctionActualParList ')'
4388 $3->set_location(infile, @2, @4);
4389 $$ = new Ttcn::Ref_pard($1.modid, $1.id, $3);
4390 $$->set_location(infile, @$);
4394 /* Taken over by FunctionRef
4397 | IDentifier '.' IDentifier
4398 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
4402 /* A.1.6.1.8 Import definitions */
4405 ImportKeyword ImportFromSpec AllWithExcepts
4407 $2->set_imptype(ImpMod::I_ALL);
4408 $2->set_location(infile, @$);
4412 | ImportKeyword ImportFromSpec '{' ImportSpec '}'
4414 Location loc(infile, @$);
4415 if ( $4 == ImpMod::I_IMPORTSPEC) {
4416 loc.warning("Unsupported selective import statement was treated as "
4419 $2->set_imptype($4);
4420 $2->set_location(infile, @$);
4426 AllWithExcepts: // 221
4428 | AllKeyword ExceptsDef
4430 Location loc(infile, @$);
4431 loc.warning("Unsupported selective import statement was treated as "
4437 ExceptKeyword '{' ExceptSpec '}'
4441 /* empty */ optError
4442 | ExceptSpec ExceptElement optSemiColon
4445 ExceptElement: // 225
4448 | ExceptTemplateSpec
4450 | ExceptTestcaseSpec
4452 | ExceptFunctionSpec
4453 | ExceptSignatureSpec
4454 | ExceptModuleParSpec
4457 ExceptGroupSpec: // 226
4458 GroupKeyword ExceptGroupRefList
4459 | GroupKeyword AllKeyword
4462 ExceptTypeDefSpec: // 227
4463 TypeDefKeyword TypeRefList
4464 | TypeDefKeyword AllKeyword
4467 ExceptTemplateSpec: // 228
4468 TemplateKeyword TemplateRefList
4469 | TemplateKeyword AllKeyword
4472 ExceptConstSpec: // 229
4473 ConstKeyword ConstRefList
4474 | ConstKeyword AllKeyword
4477 ExceptTestcaseSpec: // 230
4478 TestcaseKeyword TestcaseRefList
4479 | TestcaseKeyword AllKeyword
4482 ExceptAltstepSpec: // 231
4483 AltstepKeyword AltstepRefList
4484 | AltstepKeyword AllKeyword
4487 ExceptFunctionSpec: // 232
4488 FunctionKeyword FunctionRefList
4489 | FunctionKeyword AllKeyword
4492 ExceptSignatureSpec: // 233
4493 SignatureKeyword SignatureRefList
4494 | SignatureKeyword AllKeyword
4497 ExceptModuleParSpec: // 234
4498 ModuleParKeyword ModuleParRefList
4499 | ModuleParKeyword AllKeyword
4503 /* empty */ optError
4504 { $$ = ImpMod::I_ALL; }
4505 | ImportSpec ImportElement optSemiColon
4508 case ImpMod::I_ALL: // it was empty before
4512 case ImpMod::I_IMPORTSPEC:
4514 case ImpMod::I_IMPORTSPEC:
4515 // selective import followed by another selective import: NOP
4517 case ImpMod::I_IMPORTIMPORT:
4518 $$ = $2; // import of import wins over selective import
4520 default: // including I_ALL
4521 FATAL_ERROR("Selective import cannot be followed by import all");
4525 case ImpMod::I_IMPORTIMPORT:
4527 case ImpMod::I_IMPORTSPEC:
4528 // import of import followed by selective import: NOP (import of import wins)
4530 case ImpMod::I_IMPORTIMPORT:
4531 // import of import following another import of import: error
4532 Location(infile, @2).error("Import of imports can only be used once");
4534 default: // including I_ALL
4535 FATAL_ERROR("Import of imports cannot be followed by import all");
4540 FATAL_ERROR("Invalid import type");
4545 ImportElement: // 236
4547 { $$ = ImpMod::I_IMPORTSPEC; }
4549 { $$ = ImpMod::I_IMPORTSPEC; }
4550 | ImportTemplateSpec
4551 { $$ = ImpMod::I_IMPORTSPEC; }
4553 { $$ = ImpMod::I_IMPORTSPEC; }
4554 | ImportTestcaseSpec
4555 { $$ = ImpMod::I_IMPORTSPEC; }
4557 { $$ = ImpMod::I_IMPORTSPEC; }
4558 | ImportFunctionSpec
4559 { $$ = ImpMod::I_IMPORTSPEC; }
4560 | ImportSignatureSpec
4561 { $$ = ImpMod::I_IMPORTSPEC; }
4562 | ImportModuleParSpec
4563 { $$ = ImpMod::I_IMPORTSPEC; }
4565 { $$ = ImpMod::I_IMPORTIMPORT; }
4569 ImportKeyword AllKeyword
4571 ImportFromSpec: // 237
4572 FromKeyword ModuleId { $$ = $2; }
4573 | FromKeyword ModuleId RecursiveKeyword // already deprecated in v3.2.1
4576 $$->set_recursive();
4580 ImportGroupSpec: // 239
4581 GroupKeyword GroupRefListWithExcept
4582 | GroupKeyword AllGroupsWithExcept
4583 | GroupKeyword error
4586 GroupRefList: // 240
4587 optError FullGroupIdentifier { delete $2; }
4588 | GroupRefList optError ',' optError FullGroupIdentifier { delete $5; }
4589 | GroupRefList optError ',' error
4592 GroupRefListWithExcept: // 241
4593 optError FullGroupIdentifierWithExcept
4594 | GroupRefListWithExcept optError ',' optError FullGroupIdentifierWithExcept
4595 | GroupRefListWithExcept optError ',' error
4598 AllGroupsWithExcept: // 242
4601 | AllKeyword ExceptKeyword GroupRefList
4602 | AllKeyword ExceptKeyword error
4605 FullGroupIdentifier: // 243
4608 $$ = new Qualifier();
4609 $$->add(new FieldOrArrayRef($1));
4610 $$->set_location(infile, @$);
4612 | FullGroupIdentifier '.' IDentifier
4615 $$->add(new FieldOrArrayRef($3));
4616 $$->set_location(infile, @$);
4620 FullGroupIdentifierWithExcept: // 244
4621 FullGroupIdentifier { delete $1; }
4622 | FullGroupIdentifier ExceptsDef { delete $1; }
4625 ExceptGroupRefList: // 245
4626 optError ExceptFullGroupIdentifier
4627 | ExceptGroupRefList optError ',' optError ExceptFullGroupIdentifier
4628 | ExceptGroupRefList optError ',' error
4631 ExceptFullGroupIdentifier: // 246
4632 FullGroupIdentifier { delete $1;}
4635 ImportTypeDefSpec: // 247
4636 TypeDefKeyword TypeRefList
4637 | TypeDefKeyword AllTypesWithExcept
4638 | TypeDefKeyword error
4642 optError IDentifier { delete $2; }
4643 | TypeRefList optError ',' optError IDentifier { delete $5; }
4644 | TypeRefList optError ',' error
4647 AllTypesWithExcept: // 249
4650 | AllKeyword ExceptKeyword TypeRefList
4651 | AllKeyword ExceptKeyword error
4654 /* 250. TypeDefIdentifier is replaced by IDentifier */
4656 ImportTemplateSpec: // 251
4657 TemplateKeyword TemplateRefList
4658 | TemplateKeyword AllTemplsWithExcept
4659 | TemplateKeyword error
4662 TemplateRefList: // 252
4663 optError IDentifier { delete $2; }
4664 | TemplateRefList optError ',' optError IDentifier { delete $5; }
4665 | TemplateRefList optError ',' error
4668 AllTemplsWithExcept: // 253
4671 | AllKeyword ExceptKeyword TemplateRefList
4672 | AllKeyword ExceptKeyword error
4675 ImportConstSpec: // 254
4676 ConstKeyword ConstRefList
4677 | ConstKeyword AllConstsWithExcept
4678 | ConstKeyword error
4681 ConstRefList: // 255
4682 optError IDentifier { delete $2; }
4683 | ConstRefList optError ',' optError IDentifier { delete $5; }
4684 | ConstRefList optError ',' error
4687 AllConstsWithExcept: // 256
4690 | AllKeyword ExceptKeyword ConstRefList
4691 | AllKeyword ExceptKeyword error
4694 ImportAltstepSpec: // 257
4695 AltstepKeyword AltstepRefList
4696 | AltstepKeyword AllAltstepsWithExcept
4697 | AltstepKeyword error
4700 AltstepRefList: // 258
4701 optError IDentifier { delete $2; }
4702 | AltstepRefList optError ',' optError IDentifier { delete $5; }
4703 | AltstepRefList optError ',' error
4706 AllAltstepsWithExcept: // 259
4709 | AllKeyword ExceptKeyword AltstepRefList
4710 | AllKeyword ExceptKeyword error
4713 ImportTestcaseSpec: // 260
4714 TestcaseKeyword TestcaseRefList
4715 | TestcaseKeyword AllTestcasesWithExcept
4716 | TestcaseKeyword error
4719 TestcaseRefList: // 261
4720 optError IDentifier { delete $2; }
4721 | TestcaseRefList optError ',' optError IDentifier { delete $5; }
4722 | TestcaseRefList optError ',' error
4725 AllTestcasesWithExcept: // 262
4728 | AllKeyword ExceptKeyword TestcaseRefList
4729 | AllKeyword ExceptKeyword error
4732 ImportFunctionSpec: // 263
4733 FunctionKeyword FunctionRefList
4734 | FunctionKeyword AllFunctionsWithExcept
4735 | FunctionKeyword error
4738 FunctionRefList: // 264
4739 optError IDentifier { delete $2; }
4740 | FunctionRefList optError ',' optError IDentifier { delete $5; }
4741 | FunctionRefList optError ',' error
4744 AllFunctionsWithExcept: // 265
4747 | AllKeyword ExceptKeyword FunctionRefList
4748 | AllKeyword ExceptKeyword error
4751 ImportSignatureSpec: // 266
4752 SignatureKeyword SignatureRefList
4753 | SignatureKeyword AllSignaturesWithExcept
4754 | SignatureKeyword error
4757 SignatureRefList: // 267
4758 optError IDentifier { delete $2; }
4759 | SignatureRefList optError ',' optError IDentifier { delete $5; }
4760 | SignatureRefList optError ',' error
4763 AllSignaturesWithExcept: // 268
4766 | AllKeyword ExceptKeyword SignatureRefList
4767 | AllKeyword ExceptKeyword error
4770 ImportModuleParSpec: // 269
4771 ModuleParKeyword ModuleParRefList
4772 | ModuleParKeyword AllModuleParWithExcept
4773 | ModuleParKeyword error
4776 ModuleParRefList: // 270
4777 optError IDentifier { delete $2; }
4778 | ModuleParRefList optError ',' optError IDentifier { delete $5; }
4779 | ModuleParRefList optError ',' error
4782 AllModuleParWithExcept: // 271
4785 | AllKeyword ExceptKeyword ModuleParRefList
4786 | AllKeyword ExceptKeyword error
4789 // 272 ImportImportSpec: ImportKeyword AllKeyword
4791 /* A.1.6.1.9 Group definitions */
4794 GroupIdentifier '{' optErrorBlock '}'
4797 $$->set_location(infile, @$);
4799 | GroupIdentifier '{' ModuleDefinitionsList optErrorBlock '}'
4802 $$->set_location(infile, @$);
4806 GroupIdentifier: // 274 (followed by) 275.
4807 GroupKeyword IDentifier
4810 $$->set_parent_group(act_group);
4811 $$->set_location(infile, @$);
4813 act_group->add_group($$);
4814 $$->set_parent_path(act_group->get_attrib_path());
4816 act_ttcn3_module->add_group($$);
4817 $$->set_parent_path(act_ttcn3_module->get_attrib_path());
4823 /* A.1.6.1.10 External function definitions */
4825 ExtFunctionDef: // 276
4826 ExtKeyword FunctionKeyword IDentifier
4827 '(' optFunctionFormalParList ')' optReturnType
4829 $5->set_location(infile, @4, @6);
4830 $$ = new Def_ExtFunction($3, $5, $7.type, $7.returns_template,
4831 $7.template_restriction);
4832 $$->set_location(infile, @$);
4836 /* A.1.6.1.11 External constant definitions */
4839 ExtKeyword ConstKeyword Type IdentifierList
4841 $$.nElements = $4.nElements;
4842 $$.elements = (Ttcn::Definition**)
4843 Malloc($$.nElements * sizeof(*$$.elements));
4844 for (size_t i = 0; i < $$.nElements; i++) {
4847 type = new Type(Type::T_REFDSPEC, $3);
4848 type->set_location(*$3);
4850 $$.elements[i] = new Ttcn::Def_ExtConst($4.elements[i].id, type);
4851 $$.elements[i]->set_location(infile, $4.elements[i].yyloc);
4857 IdentifierList: // 280 ExtConstIdentifierList
4861 $$.elements = (YYSTYPE::extconstidentifier_t*)Malloc(sizeof(*$$.elements));
4862 $$.elements[0].id = $2;
4863 $$.elements[0].yyloc = @2;
4865 | IdentifierList ',' optError IDentifier
4867 $$.nElements = $1.nElements + 1;
4868 $$.elements = (YYSTYPE::extconstidentifier_t*)
4869 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4870 $$.elements[$1.nElements].id = $4;
4871 $$.elements[$1.nElements].yyloc = @4;
4873 | IdentifierList ',' error { $$ = $1; }
4876 /* A.1.6.1.12 Module parameter definitions */
4878 ModuleParDef: // 282
4879 ModuleParKeyword ModulePar { $$ = $2; }
4880 | ModuleParKeyword '{' MultiTypedModuleParList optError '}' { $$ = $3; }
4881 | ModuleParKeyword '{' error '}' { $$.nElements = 0; $$.elements = NULL; }
4884 MultiTypedModuleParList: // 284
4885 optError ModulePar optSemiColon { $$ = $2; }
4886 | MultiTypedModuleParList optError ModulePar optSemiColon
4888 $$.nElements = $1.nElements + $3.nElements;
4889 $$.elements = (Ttcn::Definition**)
4890 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4891 memcpy($$.elements + $1.nElements, $3.elements,
4892 $3.nElements * sizeof(*$$.elements));
4900 $$.nElements = $2.nElements;
4901 $$.elements = (Ttcn::Definition**)
4902 Malloc($$.nElements * sizeof(*$$.elements));
4903 for(size_t i = 0; i < $2.nElements; i++) {
4906 type = new Type(Type::T_REFDSPEC, $1);
4907 type->set_location(*$1);
4909 $$.elements[i] = new Def_Modulepar($2.elements[i].id, type,
4910 $2.elements[i].defval);
4911 $$.elements[i]->set_location(infile, $2.elements[i].yyloc);
4915 | TemplateKeyword Type TemplateModuleParList
4917 $$.nElements = $3.nElements;
4918 $$.elements = (Ttcn::Definition**)Malloc($$.nElements * sizeof(*$$.elements));
4919 for(size_t i = 0; i < $3.nElements; i++) {
4922 type = new Type(Type::T_REFDSPEC, $2);
4923 type->set_location(*$2);
4925 $$.elements[i] = new Def_Modulepar_Template($3.elements[i].id, type, $3.elements[i].deftempl);
4926 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
4932 ModuleParList: // 287
4933 optError SingleModulePar
4936 $$.elements = (YYSTYPE::singlemodulepar_t*)Malloc(sizeof(*$$.elements));
4937 $$.elements[0] = $2;
4939 | ModuleParList ',' optError SingleModulePar
4941 $$.nElements = $1.nElements + 1;
4942 $$.elements = (YYSTYPE::singlemodulepar_t*)
4943 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4944 $$.elements[$$.nElements - 1] = $4;
4948 TemplateModuleParList: // 287
4949 optError SingleTemplateModulePar
4952 $$.elements = (YYSTYPE::singletemplatemodulepar_t*)Malloc(sizeof(*$$.elements));
4953 $$.elements[0] = $2;
4955 | TemplateModuleParList ',' optError SingleTemplateModulePar
4957 $$.nElements = $1.nElements + 1;
4958 $$.elements = (YYSTYPE::singletemplatemodulepar_t*)
4959 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4960 $$.elements[$$.nElements - 1] = $4;
4971 | IDentifier AssignmentChar Expression
4979 SingleTemplateModulePar:
4986 | IDentifier AssignmentChar TemplateBody
4995 FriendModuleDef: // 289
4996 FriendKeyword TTCN3ModuleKeyword IdentifierList optSemiColon
4998 $$.nElements = $3.nElements;
4999 $$.elements = (Ttcn::FriendMod**)
5000 Malloc($$.nElements*sizeof(*$$.elements));
5001 for (size_t i = 0; i < $$.nElements; i++) {
5002 $$.elements[i] = new FriendMod($3.elements[i].id);
5003 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
5009 /* A.1.6.2 Control part */
5011 /* A.1.6.2.0 General */
5013 ModuleControlPart: // 290
5014 optError ControlKeyword
5015 '{' ModuleControlBody '}'
5016 optWithStatementAndSemiColon
5018 ControlPart* controlpart = new ControlPart($4);
5019 controlpart->set_location(infile, @2, @6);
5020 controlpart->set_with_attr($6);
5021 controlpart->set_parent_path(act_ttcn3_module->get_attrib_path());
5022 act_ttcn3_module->add_controlpart(controlpart);
5026 ModuleControlBody: // 292
5027 /* empty */ optError { $$=new StatementBlock(); }
5028 | ControlStatementOrDefList { $$ = $1; }
5031 ControlStatementOrDefList: // 293
5032 optError ControlStatementOrDef optSemiColon
5034 $$=new StatementBlock();
5035 for(size_t i=0; i<$2.nElements; i++) $$->add_stmt($2.elements[i]);
5038 | ControlStatementOrDefList optError ControlStatementOrDef optSemiColon
5041 for(size_t i=0; i<$3.nElements; i++) $$->add_stmt($3.elements[i]);
5046 ControlStatementOrDef: // 294
5049 $$.nElements=$1.nElements;
5050 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
5051 for(size_t i=0; i<$1.nElements; i++) {
5052 $$.elements[i]=new Statement(Statement::S_DEF, $1.elements[i]);
5053 $$.elements[i]->set_location(*$1.elements[i]);
5059 $$.nElements=$1.nElements;
5060 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
5061 for(size_t i=0; i<$1.nElements; i++) {
5062 $$.elements[i]=new Statement(Statement::S_DEF, $1.elements[i]);
5063 $$.elements[i]->set_location(*$1.elements[i]);
5070 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
5075 ControlStatement: /* Statement *stmt */ // 295
5076 TimerStatements { $$ = $1; }
5077 | BasicStatements { $$ = $1; }
5078 | BehaviourStatements { $$ = $1; }
5079 | SUTStatements { $$ = $1; }
5080 | StopExecutionStatement { $$ = $1; }
5083 /* A.1.6.2.1 Variable instantiation */
5086 VarKeyword Type VarList
5088 $$.nElements = $3.nElements;
5089 $$.elements = (Ttcn::Definition**)
5090 Malloc($$.nElements*sizeof(*$$.elements));
5091 for (size_t i = 0; i < $$.nElements; i++) {
5094 type = new Type(Type::T_REFDSPEC, $2);
5095 type->set_location(*$2);
5097 /* creation of array type(s) if necessary (from right to left) */
5098 for (size_t j = $3.elements[i].arrays.nElements; j > 0; j--) {
5099 type = new Type(Type::T_ARRAY, type,
5100 $3.elements[i].arrays.elements[j - 1], false);
5101 type->set_location(*$2);
5103 Free($3.elements[i].arrays.elements);
5105 /* Create the definition */
5106 $$.elements[i] = new Def_Var($3.elements[i].id,
5107 type, $3.elements[i].initial_value);
5108 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
5112 | VarKeyword TemplateOptRestricted Type TempVarList
5114 $$.nElements = $4.nElements;
5115 $$.elements = (Ttcn::Definition**)
5116 Malloc($$.nElements * sizeof(*$$.elements));
5117 for (size_t i = 0; i < $$.nElements; i++) {
5120 type = new Type(Type::T_REFDSPEC, $3);
5121 type->set_location(*$3);
5123 /* creation of array type(s) if necessary (from right to left) */
5124 for (size_t j = $4.elements[i].arrays.nElements; j > 0; j--) {
5125 type = new Type(Type::T_ARRAY, type,
5126 $4.elements[i].arrays.elements[j - 1], false);
5127 type->set_location(*$3);
5129 Free($4.elements[i].arrays.elements);
5131 /* Create the definition */
5132 $$.elements[i] = new Def_Var_Template($4.elements[i].id, type,
5133 $4.elements[i].initial_value, $2);
5134 $$.elements[i]->set_location(infile, $4.elements[i].yyloc);
5142 optError SingleVarInstance
5145 $$.elements = (YYSTYPE::singlevarinst_t*)Malloc(sizeof(*$$.elements));
5146 $$.elements[0] = $2;
5148 | VarList ',' optError SingleVarInstance
5150 $$.nElements = $1.nElements + 1;
5151 $$.elements = (YYSTYPE::singlevarinst_t*)
5152 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
5153 $$.elements[$$.nElements - 1] = $4;
5157 SingleVarInstance: // 298
5158 IDentifier optArrayDef
5162 $$.initial_value = 0;
5165 | IDentifier optArrayDef AssignmentChar Expression
5169 $$.initial_value = $4;
5175 optError SingleTempVarInstance
5178 $$.elements = (YYSTYPE::singletempvarinst_t*)Malloc(sizeof(*$$.elements));
5179 $$.elements[0] = $2;
5181 | TempVarList ',' optError SingleTempVarInstance
5183 $$.nElements = $1.nElements + 1;
5184 $$.elements = (YYSTYPE::singletempvarinst_t*)
5185 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
5186 $$.elements[$$.nElements - 1] = $4;
5190 SingleTempVarInstance: // 303
5191 IDentifier optArrayDef
5195 $$.initial_value = NULL;
5198 | IDentifier optArrayDef AssignmentChar TemplateBody
5202 $$.initial_value = $4;
5210 if ($1.is_ref) $$ = $1.ref;
5212 $$ = new Ttcn::Reference($1.id);
5213 $$->set_location(infile, @$);
5218 /* A.1.6.2.2 Timer instantiation */
5220 TimerInstance: // 306
5221 TimerKeyword TimerList { $$ = $2; }
5225 optError SingleTimerInstance
5228 $$.elements = (Ttcn::Definition**)Malloc(sizeof(*$$.elements));
5229 $$.elements[0] = $2;
5231 | TimerList ',' optError SingleTimerInstance
5233 $$.nElements = $1.nElements + 1;
5234 $$.elements = (Ttcn::Definition**)
5235 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
5236 $$.elements[$$.nElements - 1] = $4;
5240 SingleTimerInstance: // 308
5241 IDentifier optArrayDef
5243 ArrayDimensions *dims;
5244 if ($2.nElements > 0) {
5245 dims = new ArrayDimensions;
5246 for (size_t i = 0; i < $2.nElements; i++) dims->add($2.elements[i]);
5249 $$ = new Ttcn::Def_Timer($1, dims, 0);
5250 $$->set_location(infile, @$);
5252 | IDentifier optArrayDef AssignmentChar TimerValue
5254 ArrayDimensions *dims;
5255 if ($2.nElements > 0) {
5256 dims = new ArrayDimensions;
5257 for (size_t i = 0; i < $2.nElements; i++) dims->add($2.elements[i]);
5260 $$ = new Ttcn::Def_Timer($1, dims, $4);
5261 $$->set_location(infile, @$);
5266 Expression { $$ = $1; }
5270 VariableRef { $$ = $1; }
5273 /* A.1.6.2.3 Component operations */
5275 ConfigurationStatements: // 313
5276 ConnectStatement { $$ = $1; }
5277 | MapStatement { $$ = $1; }
5278 | DisconnectStatement { $$ = $1; }
5279 | UnmapStatement { $$ = $1; }
5280 | DoneStatement { $$ = $1; }
5281 | KilledStatement { $$ = $1; }
5282 | StartTCStatement { $$ = $1; }
5283 | StopTCStatement { $$ = $1; }
5284 | KillTCStatement { $$ = $1; }
5287 ConfigurationOps: // 314
5292 | RunningOp {$$=$1;}
5293 | AliveOp { $$ = $1; }
5297 VariableRef DotCreateKeyword optCreateParameter optAliveKeyword
5299 $$ = new Value(Value::OPTYPE_COMP_CREATE, $1, $3.name, $3.loc, $4);
5300 $$->set_location(infile, @$);
5310 | '(' optError Expression optError ')'
5315 | '(' optError Expression optError ',' optError Expression optError ')'
5320 | '(' optError NotUsedSymbol optError ',' optError Expression optError ')'
5332 optAliveKeyword: // [328]
5333 /* empty */ { $$ = false; }
5334 | AliveKeyword { $$ = true; }
5340 $$=new Value(Value::OPTYPE_COMP_SYSTEM);
5341 $$->set_location(infile, @$);
5348 $$=new Value(Value::OPTYPE_COMP_SELF);
5349 $$->set_location(infile, @$);
5356 $$=new Value(Value::OPTYPE_COMP_MTC);
5357 $$->set_location(infile, @$);
5361 DoneStatement: // 319
5362 ComponentOrDefaultReference DotDoneKeyword optDoneParameter
5364 $$ = new Statement(Statement::S_DONE, $1, $3.donematch, $3.redirect);
5365 $$->set_location(infile, @$);
5367 | AnyKeyword ComponentKeyword DotDoneKeyword
5369 $$ = new Statement(Statement::S_DONE, Statement::C_ANY);
5370 $$->set_location(infile, @$);
5372 | AllKeyword ComponentKeyword DotDoneKeyword
5374 $$ = new Statement(Statement::S_DONE, Statement::C_ALL);
5375 $$->set_location(infile, @$);
5385 | optReceiveParameter PortRedirectSymbol ValueSpec
5392 KilledStatement: // 320
5393 ComponentOrDefaultReference DotKilledKeyword
5395 $$ = new Statement(Statement::S_KILLED, $1);
5396 $$->set_location(infile, @$);
5398 | AnyKeyword ComponentKeyword DotKilledKeyword
5400 $$ = new Statement(Statement::S_KILLED, Statement::C_ANY);
5401 $$->set_location(infile, @$);
5403 | AllKeyword ComponentKeyword DotKilledKeyword
5405 $$ = new Statement(Statement::S_KILLED, Statement::C_ALL);
5406 $$->set_location(infile, @$);
5412 ComponentOrDefaultReference
5413 | AnyKeyword ComponentKeyword
5414 | AllKeyword ComponentKeyword
5419 /* VariableRef DotRunningKeyword -- covered by RunningTimerOp */
5420 FunctionInstance DotRunningKeyword
5422 Value *t_val = new Value(Value::V_REFD, $1);
5423 t_val->set_location(infile, @1);
5424 $$ = new Value(Value::OPTYPE_COMP_RUNNING, t_val);
5425 $$->set_location(infile, @$);
5427 | ApplyOp DotRunningKeyword
5429 Value *t_val = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5430 t_val->set_location(infile, @1);
5431 $$ = new Value(Value::OPTYPE_COMP_RUNNING, t_val);
5432 $$->set_location(infile, @$);
5434 | AnyKeyword ComponentKeyword DotRunningKeyword
5436 $$ = new Value(Value::OPTYPE_COMP_RUNNING_ANY);
5437 $$->set_location(infile, @$);
5439 | AllKeyword ComponentKeyword DotRunningKeyword
5441 $$ = new Value(Value::OPTYPE_COMP_RUNNING_ALL);
5442 $$->set_location(infile, @$);
5447 ComponentOrDefaultReference DotAliveKeyword
5449 $$ = new Value(Value::OPTYPE_COMP_ALIVE, $1);
5450 $$->set_location(infile, @$);
5452 | AnyKeyword ComponentKeyword DotAliveKeyword
5454 $$ = new Value(Value::OPTYPE_COMP_ALIVE_ANY);
5455 $$->set_location(infile, @$);
5457 | AllKeyword ComponentKeyword DotAliveKeyword
5459 $$ = new Value(Value::OPTYPE_COMP_ALIVE_ALL);
5460 $$->set_location(infile, @$);
5464 ConnectStatement: // 329
5465 ConnectKeyword SingleConnectionSpec
5467 $$=new Statement(Statement::S_CONNECT,
5468 $2.compref1, $2.portref1, $2.compref2, $2.portref2);
5469 $$->set_location(infile, @$);
5473 SingleConnectionSpec: // 331
5474 '(' PortRef optError ',' optError PortRef optError ')'
5476 $$.compref1 = $2.compref;
5477 $$.portref1 = $2.portref;
5478 $$.compref2 = $6.compref;
5479 $$.portref2 = $6.portref;
5484 ComponentRef ':' Port
5491 ComponentRef: // 333
5492 ComponentOrDefaultReference { $$ = $1; }
5493 | SystemOp { $$ = $1; }
5494 | SelfOp { $$ = $1; }
5495 | MTCOp { $$ = $1; }
5498 DisconnectStatement: // 335
5501 Location loc(infile, @$);
5502 loc.error("Disconnect operation on multiple connections is "
5503 "not currently supported");
5504 $$ = new Statement(Statement::S_ERROR);
5505 $$->set_location(infile, @$);
5507 | DisconnectKeyword SingleOrMultiConnectionSpec
5509 if ($2.compref1 && $2.portref1 && $2.compref1 && $2.compref2) {
5510 $$ = new Statement(Statement::S_DISCONNECT,
5511 $2.compref1, $2.portref1, $2.compref2, $2.portref2);
5513 Location loc(infile, @$);
5514 loc.error("Disconnect operation on multiple connections is "
5515 "not currently supported");
5520 $$ = new Statement(Statement::S_ERROR);
5522 $$->set_location(infile, @$);
5526 SingleOrMultiConnectionSpec: // 336
5527 SingleConnectionSpec { $$ = $1; }
5528 | AllConnectionsSpec
5530 $$.compref1 = $1.compref;
5531 $$.portref1 = $1.portref;
5542 | AllCompsAllPortsSpec
5551 AllConnectionsSpec: // 337
5552 '(' PortRef optError ')' { $$ = $2; }
5555 AllPortsSpec: // 338
5556 '(' ComponentRef ':' AllKeyword PortKeyword optError ')' { $$ = $2; }
5559 AllCompsAllPortsSpec: // 339
5560 '(' AllKeyword ComponentKeyword ':' AllKeyword PortKeyword optError ')'
5563 MapStatement: // 341
5564 MapKeyword SingleConnectionSpec
5566 $$=new Statement(Statement::S_MAP,
5567 $2.compref1, $2.portref1,
5568 $2.compref2, $2.portref2);
5569 $$->set_location(infile, @$);
5573 UnmapStatement: // 343
5576 $$ = new Statement(Statement::S_ERROR);
5577 $$->set_location(infile, @$);
5578 Location loc(infile, @$);
5579 loc.error("Unmap operation on multiple mappings is "
5580 "not currently supported");
5582 | UnmapKeyword SingleOrMultiConnectionSpec
5584 if ($2.compref1 && $2.portref1 && $2.compref1 && $2.compref2) {
5585 $$ = new Statement(Statement::S_UNMAP,
5586 $2.compref1, $2.portref1, $2.compref2, $2.portref2);
5588 Location loc(infile, @$);
5589 loc.error("Unmap operation on multiple mappings is "
5590 "not currently supported");
5595 $$ = new Statement(Statement::S_ERROR);
5597 $$->set_location(infile, @$);
5601 StartTCStatement: // 345
5602 /* VariableRef DotStartKeyword '(' FunctionInstance ')'
5603 -- covered by StartTimerStatement */
5604 VariableRef DotStartKeyword '(' DereferOp '(' optFunctionActualParList ')'
5607 Value *t_val = new Value(Value::V_REFD, $1);
5608 t_val->set_location(infile, @1);
5609 $6->set_location(infile, @5, @7);
5610 //ParsedActualParameters *pap = new ParsedActualParameters($6);
5611 $$ = new Statement(Statement::S_START_COMP_REFD, t_val, $4, $6);
5612 $$->set_location(infile, @$);
5614 | FunctionInstance DotStartKeyword '(' FunctionInstance optError ')'
5616 Value *t_val = new Value(Value::V_REFD, $1);
5617 t_val->set_location(infile, @1);
5618 $$ = new Statement(Statement::S_START_COMP, t_val, $4);
5619 $$->set_location(infile, @$);
5621 | FunctionInstance DotStartKeyword '(' DereferOp '('
5622 optFunctionActualParList ')' optError ')'
5624 Value *t_val = new Value(Value::V_REFD, $1);
5625 t_val->set_location(infile, @1);
5626 $6->set_location(infile, @5 , @7);
5627 $$ = new Statement(Statement::S_START_COMP_REFD, t_val, $4, $6);
5628 $$->set_location(infile, @$);
5630 | FunctionInstance DotStartKeyword '(' error ')'
5633 $$ = new Statement(Statement::S_ERROR);
5634 $$->set_location(infile, @$);
5636 | ApplyOp DotStartKeyword '(' FunctionInstance ')'
5638 Value *t_val = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5639 t_val->set_location(infile, @1);
5640 $$ = new Statement(Statement::S_START_COMP, t_val, $4);
5641 $$->set_location(infile, @$);
5643 | ApplyOp DotStartKeyword '(' DereferOp '(' optFunctionActualParList ')'
5646 Value *t_val = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5647 t_val->set_location(infile, @1);
5648 $6->set_location(infile, @5 , @7);
5649 $$ = new Statement(Statement::S_START_COMP_REFD, t_val, $4, $6);
5650 $$->set_location(infile, @$);
5652 | ApplyOp DotStartKeyword '(' error ')'
5656 $$ = new Statement(Statement::S_ERROR);
5657 $$->set_location(infile, @$);
5661 StopTCStatement: // 337
5662 /* VariableRef DotStopKeyword -- covered by StopTimerStatement */
5663 FunctionInstance DotStopKeyword
5665 Value *t_val = new Value(Value::V_REFD, $1);
5666 t_val->set_location(infile, @1);
5667 $$ = new Statement(Statement::S_STOP_COMP, t_val);
5668 $$->set_location(infile, @$);
5670 | ApplyOp DotStopKeyword
5672 Value *t_val = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5673 t_val->set_location(infile, @1);
5674 $$ = new Statement(Statement::S_STOP_COMP, t_val);
5675 $$->set_location(infile, @$);
5677 | MTCOp DotStopKeyword
5679 $$ = new Statement(Statement::S_STOP_COMP, $1);
5680 $$->set_location(infile, @$);
5682 | SelfOp DotStopKeyword
5684 $$ = new Statement(Statement::S_STOP_COMP, $1);
5685 $$->set_location(infile, @$);
5687 | AllKeyword ComponentKeyword DotStopKeyword
5689 $$ = new Statement(Statement::S_STOP_COMP, (Value*)0);
5690 $$->set_location(infile, @$);
5694 ComponentReferenceOrLiteral: // 348
5695 ComponentOrDefaultReference { $$ = $1; }
5696 | MTCOp { $$ = $1; }
5697 | SelfOp { $$ = $1; }
5700 KillTCStatement: // 349
5703 Value *self = new Value(Value::OPTYPE_COMP_SELF);
5704 self->set_location(infile, @1);
5705 $$ = new Statement(Statement::S_KILL, self);
5706 $$->set_location(infile, @$);
5708 | ComponentReferenceOrLiteral DotKillKeyword
5710 $$ = new Statement(Statement::S_KILL, $1);
5711 $$->set_location(infile, @$);
5713 | AllKeyword ComponentKeyword DotKillKeyword
5715 $$ = new Statement(Statement::S_KILL, (Value*)0);
5716 $$->set_location(infile, @$);
5720 ComponentOrDefaultReference: // 350
5723 $$ = new Value(Value::V_REFD, $1);
5724 $$->set_location(infile, @$);
5728 $$ = new Value(Value::V_REFD, $1);
5729 $$->set_location(infile, @$);
5733 $$ = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5734 $$->set_location(infile, @$);
5738 /* A.1.6.2.4 Port operations */
5741 VariableRef { $$ = $1; }
5744 CommunicationStatements: // 353
5745 SendStatement {$$ = $1;}
5746 | CallStatement {$$ = $1;}
5747 | ReplyStatement {$$ = $1;}
5748 | RaiseStatement {$$ = $1;}
5749 | ReceiveStatement {$$ = $1;}
5750 | TriggerStatement {$$ = $1;}
5751 | GetCallStatement {$$ = $1;}
5752 | GetReplyStatement {$$ = $1;}
5753 | CatchStatement {$$ = $1;}
5754 | CheckStatement {$$ = $1;}
5755 | ClearStatement {$$ = $1;}
5756 | StartStatement {$$ = $1;}
5757 | StopStatement {$$ = $1;}
5758 | HaltStatement { $$ = $1; }
5761 SendStatement: // 354
5762 Port DotSendOpKeyword PortSendOp
5764 $$ = new Statement(Statement::S_SEND, $1, $3.templ_inst, $3.val);
5765 $$->set_location(infile, @$);
5770 '(' SendParameter optError ')' optToClause
5775 | '(' error ')' optToClause
5777 Template *t = new Template(Template::TEMPLATE_ERROR);
5778 t->set_location(infile, @2);
5779 $$.templ_inst = new TemplateInstance(0, 0, t);
5780 $$.templ_inst->set_location(infile, @2);
5785 SendParameter: // 357
5786 TemplateInstance { $$=$1; }
5789 optToClause: // [3583]
5790 /* empty */ { $$ = 0; }
5791 | ToKeyword AddressRef
5793 Template *templ = $2->get_Template();
5794 if (!$2->get_Type() && !$2->get_DerivedRef() && templ->is_Value()) {
5795 $$ = templ->get_Value();
5797 Location loc(infile, @$);
5798 loc.error("Multicast communication is not currently supported");
5803 /* | ToKeyword AddressRefList -- covered by the previous rule
5804 (as ValueOrAttribList) */
5805 | ToKeyword AllKeyword ComponentKeyword
5807 Location loc(infile, @$);
5808 loc.error("Broadcast communication is not currently supported");
5811 | ToKeyword error { $$ = 0; }
5815 AddressRefList: // 359
5816 '(' seqAddressRef ')'
5821 | seqAddressRef ',' AddressRef
5826 TemplateInstance { $$ = $1; }
5829 CallStatement: // 362
5830 Port DotCallOpKeyword PortCallOp optPortCallBody
5832 $$ = new Statement(Statement::S_CALL, $1, $3.templ_inst,
5833 $3.calltimerval, $3.nowait, $3.val, $4);
5834 $$->set_location(infile, @$);
5839 '(' CallParameters optError ')' optToClause
5841 $$.templ_inst = $2.templ_inst;
5842 $$.calltimerval = $2.calltimerval;
5843 $$.nowait = $2.nowait;
5846 | '(' error ')' optToClause
5848 Template *t = new Template(Template::TEMPLATE_ERROR);
5849 t->set_location(infile, @2);
5850 $$.templ_inst = new TemplateInstance(0, 0, t);
5851 $$.templ_inst->set_location(infile, @2);
5852 $$.calltimerval = 0;
5858 CallParameters: // 365
5865 | TemplateInstance ',' optError CallTimerValue
5868 $$.calltimerval=$4.calltimerval;
5869 $$.nowait=$4.nowait;
5873 CallTimerValue: // 366
5886 optPortCallBody: // [368]
5887 /* empty */ { $$=0; }
5888 | '{' CallBodyStatementList optError '}' { $$=$2; }
5889 | '{' error '}' { $$ = new AltGuards; }
5892 CallBodyStatementList: // 369
5893 optError CallBodyStatement
5898 | CallBodyStatementList optError CallBodyStatement
5905 CallBodyStatement: // 370 and 371. rolled into one.
5906 AltGuardChar CallBodyOps ';' // This alternative is a TITAN extension
5908 $$=new AltGuard($1, $2, new StatementBlock());
5909 $$->set_location(infile, @$);
5911 | AltGuardChar CallBodyOps optSemiColon StatementBlock optSemiColon
5913 $$=new AltGuard($1, $2, $4);
5914 $$->set_location(infile, @$);
5919 GetReplyStatement {$$=$1;}
5920 | CatchStatement {$$=$1;}
5923 ReplyStatement: // 373
5924 Port DotReplyKeyword PortReplyOp
5926 $$ = new Statement(Statement::S_REPLY, $1, $3.templ_inst,
5927 $3.replyval, $3.toclause);
5928 $$->set_location(infile, @$);
5933 '(' TemplateInstance optReplyValue optError ')' optToClause
5939 | '(' error ')' optToClause
5941 Template *t = new Template(Template::TEMPLATE_ERROR);
5942 t->set_location(infile, @2);
5943 $$.templ_inst = new TemplateInstance(0, 0, t);
5944 $$.templ_inst->set_location(infile, @2);
5950 optReplyValue: // [376]
5951 /* empty */ { $$=0; }
5952 | ValueKeyword Expression { $$=$2; }
5953 | ValueKeyword error { $$ = 0; }
5956 RaiseStatement: // 377
5957 Port DotRaiseKeyword PortRaiseOp
5959 if ($3.signature) $$ = new Statement(Statement::S_RAISE, $1,
5960 $3.signature, $3.templ_inst, $3.toclause);
5962 $$ = new Statement(Statement::S_ERROR);
5964 delete $3.signature;
5965 delete $3.templ_inst;
5968 $$->set_location(infile, @$);
5973 '(' Signature optError ',' optError TemplateInstance optError ')' optToClause
5979 | '(' error ')' optToClause
5988 ReceiveStatement: // 380
5989 PortOrAny DotReceiveOpKeyword PortReceiveOp
5991 $$ = new Statement(Statement::S_RECEIVE, $1, $3.templ_inst,
5992 $3.fromclause, $3.redirectval, $3.redirectsender);
5993 $$->set_location(infile, @$);
5999 | AnyKeyword PortKeyword { $$ = 0; }
6002 PortReceiveOp: // 382
6003 optReceiveParameter optFromClause optPortRedirect
6007 $$.redirectval = $3.redirectval;
6008 $$.redirectsender = $3.redirectsender;
6012 optReceiveParameter: // [384]
6013 /* empty */ { $$ = 0; }
6014 | '(' ReceiveParameter optError ')' { $$ = $2; }
6017 Template *t = new Template(Template::TEMPLATE_ERROR);
6018 t->set_location(infile, @2);
6019 $$ = new TemplateInstance(0, 0, t);
6020 $$->set_location(infile, @$);
6024 ReceiveParameter: // 384
6025 TemplateInstance { $$ = $1; }
6028 optFromClause: // [385]
6029 /* empty */ { $$=0; }
6030 | FromClause { $$=$1; }
6034 FromKeyword AddressRef { $$=$2; }
6035 | FromKeyword error { $$ = 0; }
6038 optPortRedirect: // [387]
6042 $$.redirectsender=0;
6044 | PortRedirectSymbol ValueSpec
6047 $$.redirectsender=0;
6049 | PortRedirectSymbol SenderSpec
6052 $$.redirectsender=$2;
6054 | PortRedirectSymbol ValueSpec SenderSpec
6057 $$.redirectsender=$3;
6059 | PortRedirectSymbol error
6062 $$.redirectsender=0;
6067 ValueKeyword VariableRef { $$ = $2; }
6068 | ValueKeyword error { $$ = 0; }
6072 SenderKeyword VariableRef { $$ = $2; }
6073 | SenderKeyword error { $$ = 0; }
6076 TriggerStatement: // 393
6077 PortOrAny DotTriggerOpKeyword PortTriggerOp
6079 $$ = new Statement(Statement::S_TRIGGER, $1, $3.templ_inst,
6080 $3.fromclause, $3.redirectval, $3.redirectsender);
6081 $$->set_location(infile, @$);
6085 PortTriggerOp: // 394
6086 optReceiveParameter optFromClause optPortRedirect
6090 $$.redirectval = $3.redirectval;
6091 $$.redirectsender = $3.redirectsender;
6095 GetCallStatement: // 396
6096 PortOrAny DotGetCallOpKeyword PortGetCallOp
6098 $$ = new Statement(Statement::S_GETCALL, $1, $3.templ_inst,
6099 $3.fromclause, $3.redirectparam, $3.redirectsender);
6100 $$->set_location(infile, @$);
6104 PortGetCallOp: // 397
6105 optReceiveParameter optFromClause optPortRedirectWithParam
6109 $$.redirectparam = $3.redirectparam;
6110 $$.redirectsender = $3.redirectsender;
6114 optPortRedirectWithParam: // [399]
6118 $$.redirectsender=0;
6120 | PortRedirectSymbol ParamSpec
6122 $$.redirectparam=$2;
6123 $$.redirectsender=0;
6125 | PortRedirectSymbol ParamSpec SenderSpec
6127 $$.redirectparam=$2;
6128 $$.redirectsender=$3;
6130 | PortRedirectSymbol SenderSpec
6133 $$.redirectsender=$2;
6135 | PortRedirectSymbol error
6138 $$.redirectsender=0;
6143 ParamKeyword ParamAssignmentList { $$ = $2; }
6144 | ParamKeyword error { $$ = 0; }
6147 ParamAssignmentList: // 403
6148 '(' AssignmentList optError ')'
6150 $$=new ParamRedirect($2);
6151 $$->set_location(infile, @$);
6153 | '(' VariableList optError ')'
6155 $$=new ParamRedirect($2);
6156 $$->set_location(infile, @$);
6160 $$=new ParamRedirect(new ParamAssignments());
6161 $$->set_location(infile, @$);
6165 AssignmentList: // 404
6168 $$ = new ParamAssignments();
6171 | error VariableAssignment
6173 $$ = new ParamAssignments();
6176 | AssignmentList optError ',' optError VariableAssignment
6181 | AssignmentList optError ',' error { $$ = $1; }
6184 VariableAssignment: // 405
6185 VariableRef AssignmentChar IDentifier
6187 $$ = new ParamAssignment($3, $1);
6188 $$->set_location(infile, @$);
6192 VariableList: // 407
6195 $$ = new VariableEntries();
6198 | error VariableEntry
6200 $$ = new VariableEntries();
6203 | VariableList optError ',' optError VariableEntry
6208 | VariableList optError ',' error { $$ = $1; }
6211 VariableEntry: // 408
6214 $$ = new VariableEntry($1);
6215 $$->set_location(infile, @$);
6219 $$ = new VariableEntry;
6220 $$->set_location(infile, @$);
6224 GetReplyStatement: // 409
6225 PortOrAny DotGetReplyOpKeyword PortGetReplyOp
6227 $$ = new Statement(Statement::S_GETREPLY, $1, $3.templ_inst,
6228 $3.valuematch, $3.fromclause, $3.redirectval,
6229 $3.redirectparam, $3.redirectsender);
6230 $$->set_location(infile, @$);
6234 PortGetReplyOp: // 410
6235 optGetReplyParameter optFromClause optPortRedirectWithValueAndParam
6237 $$.templ_inst = $1.templ_inst;
6238 $$.valuematch = $1.valuematch;
6240 $$.redirectval = $3.redirectval;
6241 $$.redirectparam = $3.redirectparam;
6242 $$.redirectsender = $3.redirectsender;
6246 optPortRedirectWithValueAndParam: // [411]
6251 $$.redirectsender=0;
6253 | PortRedirectSymbol ValueSpec
6257 $$.redirectsender=0;
6259 | PortRedirectSymbol ValueSpec ParamSpec
6262 $$.redirectparam=$3;
6263 $$.redirectsender=0;
6265 | PortRedirectSymbol ValueSpec SenderSpec
6269 $$.redirectsender=$3;
6271 | PortRedirectSymbol ValueSpec ParamSpec SenderSpec
6274 $$.redirectparam=$3;
6275 $$.redirectsender=$4;
6277 | PortRedirectSymbol ParamSpec
6280 $$.redirectparam=$2;
6281 $$.redirectsender=0;
6283 | PortRedirectSymbol SenderSpec
6287 $$.redirectsender=$2;
6289 | PortRedirectSymbol ParamSpec SenderSpec
6292 $$.redirectparam=$2;
6293 $$.redirectsender=$3;
6295 | PortRedirectSymbol error
6299 $$.redirectsender=0;
6303 optGetReplyParameter:
6309 | '(' ReceiveParameter optError ')'
6314 | '(' ReceiveParameter ValueMatchSpec optError ')'
6321 Template *t = new Template(Template::TEMPLATE_ERROR);
6322 t->set_location(infile, @2);
6323 $$.templ_inst = new TemplateInstance(0, 0, t);
6324 $$.templ_inst->set_location(infile, @2);
6329 ValueMatchSpec: // 414
6330 ValueKeyword TemplateInstance { $$=$2; }
6331 | ValueKeyword error { $$ = 0; }
6334 CheckStatement: // 415
6335 PortOrAny DotCheckOpKeyword optCheckParameter
6337 switch ($3.statementtype) {
6338 case Statement::S_CHECK:
6339 $$ = new Statement(Statement::S_CHECK, $1, $3.templ_inst,
6342 case Statement::S_CHECK_RECEIVE:
6343 $$ = new Statement(Statement::S_CHECK_RECEIVE, $1, $3.templ_inst,
6344 $3.fromclause, $3.redirectval, $3.redirectsender);
6346 case Statement::S_CHECK_GETCALL:
6347 $$ = new Statement(Statement::S_CHECK_GETCALL, $1, $3.templ_inst,
6348 $3.fromclause, $3.redirectparam, $3.redirectsender);
6350 case Statement::S_CHECK_GETREPLY:
6351 $$ = new Statement(Statement::S_CHECK_GETREPLY, $1, $3.templ_inst,
6352 $3.valuematch, $3.fromclause, $3.redirectval,
6353 $3.redirectparam, $3.redirectsender);
6355 case Statement::S_CHECK_CATCH:
6356 $$ = new Statement(Statement::S_CHECK_CATCH, $1, $3.signature,
6357 $3.templ_inst, $3.timeout, $3.fromclause,
6358 $3.redirectval, $3.redirectsender);
6361 FATAL_ERROR("Internal error.");
6363 $$->set_location(infile, @$);
6367 optCheckParameter: // [418]
6370 $$.statementtype = Statement::S_CHECK;
6377 $$.redirectparam = 0;
6378 $$.redirectsender = 0;
6380 | '(' CheckParameter optError ')' { $$ = $2; }
6383 $$.statementtype = Statement::S_CHECK;
6390 $$.redirectparam = 0;
6391 $$.redirectsender = 0;
6395 CheckParameter: // 418
6396 CheckPortOpsPresent { $$ = $1; }
6397 | FromClausePresent { $$ = $1; }
6398 | RedirectPresent { $$ = $1; }
6401 FromClausePresent: // 419
6404 $$.statementtype = Statement::S_CHECK;
6411 $$.redirectparam = 0;
6412 $$.redirectsender = 0;
6414 | FromClause PortRedirectSymbol SenderSpec
6416 $$.statementtype = Statement::S_CHECK;
6423 $$.redirectparam = 0;
6424 $$.redirectsender = $3;
6428 RedirectPresent: // 420
6429 PortRedirectSymbol SenderSpec
6431 $$.statementtype = Statement::S_CHECK;
6438 $$.redirectparam = 0;
6439 $$.redirectsender = $2;
6443 CheckPortOpsPresent: // 421
6444 ReceiveOpKeyword PortReceiveOp
6446 $$.statementtype = Statement::S_CHECK_RECEIVE;
6448 $$.templ_inst = $2.templ_inst;
6451 $$.fromclause = $2.fromclause;
6452 $$.redirectval = $2.redirectval;
6453 $$.redirectparam = 0;
6454 $$.redirectsender = $2.redirectsender;
6456 | GetCallOpKeyword PortGetCallOp
6458 $$.statementtype = Statement::S_CHECK_GETCALL;
6460 $$.templ_inst = $2.templ_inst;
6463 $$.fromclause = $2.fromclause;
6465 $$.redirectparam = $2.redirectparam;
6466 $$.redirectsender = $2.redirectsender;
6468 | GetReplyOpKeyword PortGetReplyOp
6470 $$.statementtype = Statement::S_CHECK_GETREPLY;
6472 $$.templ_inst = $2.templ_inst;
6473 $$.valuematch = $2.valuematch;
6475 $$.fromclause = $2.fromclause;
6476 $$.redirectval = $2.redirectval;
6477 $$.redirectparam = $2.redirectparam;
6478 $$.redirectsender = $2.redirectsender;
6480 | CatchOpKeyword PortCatchOp
6482 $$.statementtype = Statement::S_CHECK_CATCH;
6483 $$.signature = $2.signature;
6484 $$.templ_inst = $2.templ_inst;
6486 $$.timeout = $2.timeout;
6487 $$.fromclause = $2.fromclause;
6488 $$.redirectval = $2.redirectval;
6489 $$.redirectparam = 0;
6490 $$.redirectsender = $2.redirectsender;
6494 CatchStatement: // 422
6495 PortOrAny DotCatchOpKeyword PortCatchOp
6497 $$ = new Statement(Statement::S_CATCH, $1, $3.signature, $3.templ_inst,
6498 $3.timeout, $3.fromclause, $3.redirectval,
6500 $$->set_location(infile, @$);
6505 optCatchOpParameter optFromClause optPortRedirect
6507 $$.signature = $1.signature;
6508 $$.templ_inst = $1.templ_inst;
6509 $$.timeout = $1.timeout;
6511 $$.redirectval = $3.redirectval;
6512 $$.redirectsender = $3.redirectsender;
6516 optCatchOpParameter: // [425]
6523 | '(' CatchOpParameter optError ')' { $$ = $2; }
6532 CatchOpParameter: // 425
6533 Signature optError ',' optError TemplateInstance
6547 ClearStatement: // 426
6548 PortOrAll DotClearOpKeyword
6550 $$ = new Statement(Statement::S_CLEAR, $1);
6551 $$->set_location(infile, @$);
6557 | AllKeyword PortKeyword { $$ = 0; }
6560 StartStatement: // 430
6561 /* Port DotPortStartKeyword -- covered by StartTimerStatement */
6562 AllKeyword PortKeyword DotStartKeyword
6564 $$=new Statement(Statement::S_START_PORT, (Ttcn::Reference*)0);
6565 $$->set_location(infile, @$);
6569 StopStatement: // 432
6570 /* Port DotPortStopKeyword -- covered by StopTimerStatement */
6571 AllKeyword PortKeyword DotStopKeyword
6573 $$=new Statement(Statement::S_STOP_PORT, (Ttcn::Reference*)0);
6574 $$->set_location(infile, @$);
6578 HaltStatement: // 435
6579 PortOrAll DotHaltKeyword
6581 $$ = new Statement(Statement::S_HALT, $1);
6582 $$->set_location(infile, @$);
6586 /* A.1.6.2.5 Timer operations */
6588 TimerStatements: // 439
6589 StartTimerStatement { $$ = $1; }
6590 | StopTimerStatement { $$ = $1; }
6591 | TimeoutStatement { $$ = $1; }
6595 ReadTimerOp { $$ = $1; }
6596 | RunningTimerOp { $$ = $1; }
6599 StartTimerStatement: // 441
6600 VariableRef DotStartKeyword
6602 $$ = new Statement(Statement::S_START_UNDEF, $1, (Value*)0);
6603 $$->set_location(infile, @$);
6605 | VariableRef DotStartKeyword '(' Expression optError ')'
6607 $$ = new Statement(Statement::S_START_UNDEF, $1, $4);
6608 $$->set_location(infile, @$);
6610 | VariableRef DotStartKeyword '(' error ')'
6612 Value *v = new Value(Value::V_ERROR);
6613 v->set_location(infile, @4);
6614 $$ = new Statement(Statement::S_START_UNDEF, $1, v);
6615 $$->set_location(infile, @$);
6619 StopTimerStatement: // 442
6620 TimerRef DotStopKeyword
6622 $$ = new Statement(Statement::S_STOP_UNDEF, $1, (Value*)0);
6623 $$->set_location(infile, @$);
6625 | AllKeyword TimerKeyword DotStopKeyword
6627 $$ = new Statement(Statement::S_STOP_TIMER, (Ttcn::Reference*)0);
6628 $$->set_location(infile, @$);
6632 /* no separate rule, folded into StopTimerStatement
6633 TimerRefOrAll: // 443
6635 | AllKeyword TimerKeyword
6640 TimerRef DotReadKeyword
6642 $$ = new Value(Value::OPTYPE_TMR_READ, $1);
6643 $$->set_location(infile, @$);
6647 RunningTimerOp: // 446
6648 TimerRef DotRunningKeyword
6650 $$ = new Value(Value::OPTYPE_UNDEF_RUNNING, $1);
6651 $$->set_location(infile, @$);
6653 | AnyKeyword TimerKeyword DotRunningKeyword
6655 $$ = new Value(Value::OPTYPE_TMR_RUNNING_ANY);
6656 $$->set_location(infile, @$);
6660 TimeoutStatement: // 447
6661 TimerRefOrAny DotTimeoutKeyword
6663 $$ = new Statement(Statement::S_TIMEOUT, $1);
6664 $$->set_location(infile, @$);
6668 TimerRefOrAny: // 448
6669 TimerRef { $$ = $1; }
6670 | AnyKeyword TimerKeyword { $$ = 0; }
6679 $$->set_location(infile, @$);
6681 | AnyTypeKeyword /* a predefined type with special treatment */
6683 anytype_access = true;
6684 Identifier *id = new Identifier(Identifier::ID_TTCN, string("anytype"));
6685 Ttcn::Reference *ref = new Ttcn::Reference(id);
6686 ref->set_location(infile, @1);
6687 $$ = new Type(Type::T_REFD, ref);
6689 | ReferencedType { $$ = $1; }
6693 PredefinedType: // 451, but see below
6694 BitStringKeyword { $$ = Type::T_BSTR; }
6695 | BooleanKeyword { $$ = Type::T_BOOL; }
6696 | CharStringKeyword { $$ = Type::T_CSTR; }
6697 | UniversalCharString { $$ = Type::T_USTR; }
6698 | CharKeyword // not in the standard anymore
6700 Location loc(infile, @$);
6701 loc.warning("Obsolete type `char' was substituted with `charstring'");
6704 | UniversalChar // not in the standard anymore
6706 Location loc(infile, @$);
6707 loc.warning("Obsolete type `universal char' was substituted with "
6708 "`universal charstring'");
6711 | IntegerKeyword { $$ = Type::T_INT; }
6712 | OctetStringKeyword { $$ = Type::T_OSTR; }
6713 | HexStringKeyword { $$ = Type::T_HSTR; }
6714 | VerdictTypeKeyword { $$ = Type::T_VERDICT; }
6715 | FloatKeyword { $$ = Type::T_REAL; }
6716 | AddressKeyword { $$ = Type::T_ADDRESS; }
6717 | DefaultKeyword { $$ = Type::T_DEFAULT; }
6718 | ObjectIdentifierKeyword { $$ = Type::T_OID; }
6720 * AnyTypeKeyword is not part of PredefinedType (this differs from the BNF
6721 * in the TTCN-3 standard).
6722 * PredefinedType is used in two contexts:
6723 * - as a RHS for Type, above (where AnyTypeKeyword needs special treatment,
6724 * and it's easier to appear as an alternative to PredefinedType)
6725 * - as field name for the anytype (where anytype is not permitted)
6729 UniversalCharString: // 463
6730 UniversalKeyword CharStringKeyword
6734 UniversalKeyword CharKeyword
6737 ReferencedType: // 465
6740 if ($1.is_ref) $$ = new Type(Type::T_REFD, $1.ref);
6742 Ttcn::Reference *ref = new Ttcn::Reference($1.id);
6743 ref->set_location(infile, @1);
6744 $$ = new Type(Type::T_REFD, ref);
6746 $$->set_location(infile, @$);
6748 | FunctionInstance optExtendedFieldReference
6749 /* covers all parameterized type references */
6751 Location loc(infile, @1);
6752 loc.error("Reference to parameterized type is not currently supported");
6754 for (size_t i = 0; i < $2.nElements; i++) delete $2.elements[i];
6756 $$ = new Type(Type::T_ERROR);
6757 $$->set_location(infile, @$);
6762 TypeReference: // 466
6764 | IDentifier TypeActualParList
6768 TypeActualParList: // -> 202 784 "Advanced Parameterization"
6769 '(' seqTypeActualPar optError ')'
6773 seqTypeActualPar: // -> 202 784 "Advanced Parameterization"
6774 optError TypeActualPar
6775 | seqTypeActualPar optError ',' optError TypeActualPar
6776 | seqTypeActualPar optError ',' error
6779 TypeActualPar: // -> 202 784 "Advanced Parameterization"
6780 Expression { delete $1; }
6783 optArrayDef: // [467]
6789 | optArrayDef ArrayIndex
6791 $$.nElements = $1.nElements + 1;
6792 $$.elements = (ArrayDimension**)
6793 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
6794 $$.elements[$1.nElements] = $2;
6801 $$ = new ArrayDimension($2);
6802 $$->set_location(infile, @$);
6804 | '[' ArrayBounds DotDot ArrayBounds ']'
6806 $$ = new ArrayDimension($2, $4);
6807 $$->set_location(infile, @$);
6811 Value *v = new Value(Value::V_ERROR);
6812 v->set_location(infile, @2);
6813 $$ = new ArrayDimension(v);
6814 $$->set_location(infile, @$);
6819 Expression { $$ = $1; }
6825 PredefinedValue { $$ = $1; }
6826 | ReferencedValue { $$ = $1; }
6829 PredefinedValue: // 470
6830 BitStringValue { $$ = $1; }
6831 | BooleanValue { $$ = $1; }
6832 | CharStringValue { $$ = $1; }
6833 | IntegerValue { $$ = $1; }
6834 | OctetStringValue { $$ = $1; }
6835 | HexStringValue { $$ = $1; }
6836 | VerdictValue { $$ = $1; }
6837 /* | EnumeratedValue -- covered by ReferencedValue */
6838 | FloatOrSpecialFloatValue
6840 $$ = new Value(Value::V_REAL, $1);
6841 $$->set_location(infile, @$);
6843 | AddressValue { $$ = $1; }
6844 | OmitValue { $$ = $1; }
6847 $$ = new Value(Value::V_NULL);
6848 $$->set_location(infile, @$);
6852 $$ = new Value(Value::V_MACRO, $1);
6853 $$->set_location(infile, @$);
6855 | ObjectIdentifierValue { $$ = $1; }
6858 $$=new Value(Value::V_ERROR);
6859 $$->set_location(infile, @$);
6863 BitStringValue: // 471
6866 $$ = new Value(Value::V_BSTR, $1);
6867 $$->set_location(infile, @$);
6871 BooleanValue: // 472
6874 $$ = new Value(Value::V_BOOL, true);
6875 $$->set_location(infile, @$);
6879 $$ = new Value(Value::V_BOOL, false);
6880 $$->set_location(infile, @$);
6884 /* TTCN-3 core language V4.2.1 */
6885 FloatOrSpecialFloatValue:
6900 IntegerValue: // 473
6903 $$ = new Value(Value::V_INT, $1);
6904 $$->set_location(infile, @$);
6908 OctetStringValue: // 474
6911 $$ = new Value(Value::V_OSTR, $1);
6912 $$->set_location(infile, @$);
6916 HexStringValue: // 475
6919 $$ = new Value(Value::V_HSTR, $1);
6920 $$->set_location(infile, @$);
6924 VerdictValue: // 476 VerdictTypeValue
6927 $$ = new Value(Value::V_VERDICT, Value::Verdict_NONE);
6928 $$->set_location(infile, @$);
6932 $$ = new Value(Value::V_VERDICT, Value::Verdict_PASS);
6933 $$->set_location(infile, @$);
6937 $$ = new Value(Value::V_VERDICT, Value::Verdict_INCONC);
6938 $$->set_location(infile, @$);
6942 $$ = new Value(Value::V_VERDICT, Value::Verdict_FAIL);
6943 $$->set_location(infile, @$);
6947 $$ = new Value(Value::V_VERDICT, Value::Verdict_ERROR);
6948 $$->set_location(infile, @$);
6952 CharStringValue: // 478
6955 if ($1->is_cstr()) $$ = new Value(Value::V_CSTR, $1);
6957 $$ = new Value(Value::V_USTR, new ustring(*$1));
6960 $$->set_location(infile, @$);
6964 $$ = new Value(Value::V_USTR, new ustring(*$1));
6966 $$->set_location(infile, @$);
6973 Location loc(infile, @1);
6974 $$ = parse_charstring_value($1, loc);
6980 CharKeyword '(' optError Group optError ',' optError Plane optError ','
6981 optError Row optError ',' optError Cell optError ')'
6982 { $$ = new ustring($4, $8, $12, $16); }
6983 | CharKeyword '(' error ')' { $$ = new ustring; }
6989 if (*$1 < 0 || *$1 > 127) {
6990 Location loc(infile, @1);
6991 loc.error("The first number of quadruple (group) must be within the "
6992 "range 0 .. 127 instead of %s", $1->t_str().c_str());
6993 $$ = *$1 < 0 ? 0 : 127;
7004 if (*$1 < 0 || *$1 > 255) {
7005 Location loc(infile, @1);
7006 loc.error("The second number of quadruple (plane) must be within the "
7007 "range 0 .. 255 instead of %s", $1->t_str().c_str());
7008 $$ = *$1 < 0 ? 0 : 255;
7019 if (*$1 < 0 || *$1 > 255) {
7020 Location loc(infile, @1);
7021 loc.error("The third number of quadruple (row) must be within the "
7022 "range 0 .. 255 instead of %s", $1->t_str().c_str());
7023 $$ = *$1 < 0 ? 0 : 255;
7034 if (*$1 < 0 || *$1 > 255) {
7035 Location loc(infile, @1);
7036 loc.error("The fourth number of quadruple (cell) must be within the "
7037 "range 0 .. 255 instead of %s", $1->t_str().c_str());
7038 $$ = *$1 < 0 ? 0 : 255;
7047 Cstring { $$ = $1; }
7050 $$ = mputstr($1, $2);
7055 AddressValue: // 510
7058 $$ = new Value(Value::V_TTCN3_NULL);
7059 $$->set_location(infile, @$);
7066 $$ = new Value(Value::V_OMIT);
7067 $$->set_location(infile, @$);
7071 ReferencedValue: // 489
7074 if ($1.is_ref) $$ = new Value(Value::V_REFD, $1.ref);
7075 else $$ = new Value(Value::V_UNDEF_LOWERID, $1.id);
7076 $$->set_location(infile, @$);
7079 Reference: // 490 ValueReference
7085 | IDentifier '.' PredefOrIdentifier optExtendedFieldReference
7088 $$.ref = new Ttcn::Reference($1);
7089 FieldOrArrayRef *fieldref = new FieldOrArrayRef($3);
7090 fieldref->set_location(infile, @3);
7091 $$.ref->add(fieldref);
7092 for (size_t i = 0; i < $4.nElements; i++) $$.ref->add($4.elements[i]);
7094 $$.ref->set_location(infile, @$);
7096 | IDentifier ArrayOrBitRef optExtendedFieldReference
7099 $$.ref = new Ttcn::Reference($1);
7101 for (size_t i = 0; i < $3.nElements; i++) $$.ref->add($3.elements[i]);
7103 $$.ref->set_location(infile, @$);
7105 | IDentifier '[' NotUsedSymbol ']'
7108 $$.ref = new Ttcn::Reference($1);
7109 Value* novalue = new Value(Value::V_NOTUSED);
7110 novalue->set_location(infile, @3);
7111 $$.ref->add(new FieldOrArrayRef(novalue));
7112 $$.ref->set_location(infile, @$);
7114 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
7115 optExtendedFieldReference
7118 $$.ref = new Ttcn::Reference($1, $5);
7120 for (size_t i = 0; i < $6.nElements; i++) $$.ref->add($6.elements[i]);
7122 $$.ref->set_location(infile, @$);
7126 /* A.1.6.5 Parameterization */
7129 /* empty */ { $$ = false; }
7130 | TitanSpecificLazyKeyword { $$ = true; }
7133 FormalValuePar: // 516
7134 optLazyEval Type IDentifier optParDefaultValue
7136 $$ = new FormalPar(Common::Assignment::A_PAR_VAL, $2, $3, $4, $1);
7137 $$->set_location(infile, @$);
7139 | InParKeyword optLazyEval Type IDentifier optParDefaultValue
7141 $$ = new FormalPar(Common::Assignment::A_PAR_VAL_IN, $3, $4, $5, $2);
7142 $$->set_location(infile, @$);
7144 | InOutParKeyword Type IDentifier optParDefaultValue
7146 $$ = new FormalPar(Common::Assignment::A_PAR_VAL_INOUT, $2, $3, $4);
7147 $$->set_location(infile, @$);
7149 | OutParKeyword Type IDentifier optParDefaultValue
7151 $$ = new FormalPar(Common::Assignment::A_PAR_VAL_OUT, $2, $3, $4);
7152 $$->set_location(infile, @$);
7157 FormalPortPar: // 518
7158 IDentifier IDentifier
7159 | InOutParKeyword IDentifier IDentifier
7163 FormalTimerPar: // 520
7164 TimerKeyword IDentifier optParDefaultValue
7166 $$ = new FormalPar(Common::Assignment::A_PAR_TIMER, $2, $3);
7167 $$->set_location(infile, @$);
7169 | InOutParKeyword TimerKeyword IDentifier optParDefaultValue
7171 $$ = new FormalPar(Common::Assignment::A_PAR_TIMER, $3, $4);
7172 $$->set_location(infile, @$);
7176 FormalTemplatePar: // 522
7177 TemplateOptRestricted optLazyEval Type IDentifier optParDefaultValue
7179 $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_IN, $1, $3, $4, $5, $2);
7180 $$->set_location(infile, @$);
7182 | InParKeyword TemplateOptRestricted optLazyEval Type IDentifier optParDefaultValue
7184 $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_IN, $2, $4, $5, $6, $3);
7185 $$->set_location(infile, @$);
7187 | InOutParKeyword TemplateOptRestricted Type IDentifier optParDefaultValue
7189 $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_INOUT, $2, $3, $4, $5);
7190 $$->set_location(infile, @$);
7192 | OutParKeyword TemplateOptRestricted Type IDentifier optParDefaultValue
7194 $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_OUT, $2, $3, $4, $5);
7195 $$->set_location(infile, @$);
7199 /* template with optional restriction */
7200 TemplateOptRestricted:
7201 TemplateKeyword optTemplateRestriction
7211 optTemplateRestriction:
7212 /* none */ { $$ = TR_NONE; }
7213 | TemplateRestriction { $$ = $1; }
7215 TemplateRestriction:
7216 '(' OmitKeyword ')' { $$ = TR_OMIT; }
7217 | '(' ValueKeyword ')' { $$ = TR_VALUE; }
7218 | '(' PresentKeyword ')' { $$ = TR_PRESENT; }
7222 /* empty */ { $$ = NULL; }
7223 | AssignmentChar TemplateInstance { $$ = $2; }
7224 | AssignmentChar NotUsedSymbol
7226 Template *t = new Template(Template::TEMPLATE_NOTUSED);
7227 t->set_location(infile, @$);
7228 $$ = new TemplateInstance(0, 0, t);
7229 $$->set_location(infile, @$);
7233 /* A.1.6.6 With statement */
7235 optWithStatement: // [526]
7236 /* empty */ { $$ = NULL; }
7237 | WithStatement { $$ = $1; }
7240 optWithStatementAndSemiColon:
7241 /* empty */ { $$ = NULL; }
7242 | WithStatement { $$ = $1; }
7243 | ';' { $$ = NULL; }
7244 | WithStatement ';' { $$ = $1; }
7247 WithStatement: // 526
7248 WithKeyword WithAttribList { $$ = $2; }
7251 WithAttribList: // 528
7252 '{' MultiWithAttrib optError '}' { $$ = $2; }
7253 | '{' error '}' { $$ = NULL; }
7256 MultiWithAttrib: // 529
7257 optError SingleWithAttrib optSemiColon
7259 $$ = new MultiWithAttrib;
7260 $$->set_location(infile, @$);
7261 $$->add_element($2);
7263 | MultiWithAttrib optError SingleWithAttrib optSemiColon
7266 $$->add_element($3);
7270 SingleWithAttrib: // 530
7271 AttribKeyword optOverrideKeyword optAttribQualifier AttribSpec
7273 $$ = new SingleWithAttrib($1,$2,$3,$4);
7274 $$->set_location(infile, @$);
7278 AttribKeyword: // 531
7279 EncodeKeyword { $$ = SingleWithAttrib::AT_ENCODE; }
7280 | VariantKeyword { $$ = SingleWithAttrib::AT_VARIANT; }
7281 | DisplayKeyword { $$ = SingleWithAttrib::AT_DISPLAY; }
7282 | ExtensionKeyword { $$ = SingleWithAttrib::AT_EXTENSION; }
7283 | OptionalKeyword { $$ = SingleWithAttrib::AT_OPTIONAL; }
7286 /* workaround to get rid of ErroneousKeyword which would clash with
7287 * existing TTCN-3 source code */
7288 if ($1->get_ttcnname()=="erroneous") $$ = SingleWithAttrib::AT_ERRONEOUS;
7290 Location loc(infile, @1);
7291 loc.error("Invalid attribute. Valid attributes are: "
7292 "`encode', `variant' , `display' , `extension', `optional' and `erroneous'");
7293 if ($1->get_ttcnname()=="titan")
7295 " ________ _____ ________ ____ __ _ \n"
7296 "(___ ___) (_ _) (___ ___) ( ) / \\ / ) \n"
7297 " ) ) | | ) ) / /\\ \\ / /\\ \\ / / \n"
7298 " ( ( | | ( ( ( (__) ) ) ) ) ) ) ) \n"
7299 " ) ) | | ) ) ) ( ( ( ( ( ( ( \n"
7300 " ( ( _| |__ ( ( / /\\ \\ / / \\ \\/ / \n"
7301 " /__\\ /_____( /__\\ /__( )__\\ (_/ \\__/ \n");
7302 $$ = SingleWithAttrib::AT_INVALID;
7308 optOverrideKeyword: // [536]
7309 /* empty */ { $$ = false; }
7310 | OverrideKeyword { $$ = true; }
7313 optAttribQualifier: // [537]
7314 /* empty */ { $$ = NULL; }
7315 | '(' DefOrFieldRefList optError ')' { $$ = $2; }
7316 | '(' error ')' { $$ = NULL; }
7319 DefOrFieldRefList: // 538
7320 optError DefOrFieldRef
7322 $$ = new Qualifiers();
7323 if ($2) $$->add_qualifier($2);
7325 | DefOrFieldRefList optError ',' optError DefOrFieldRef
7328 if ($5) $$->add_qualifier($5);
7330 | DefOrFieldRefList optError ',' error { $$ = $1; }
7333 ArrayOrBitRefOrDash:
7334 ArrayOrBitRef { $$ = $1; }
7335 | '[' NotUsedSymbol ']'
7337 Value* novalue = new Value(Value::V_NOTUSED);
7338 novalue->set_location(infile, @2);
7339 $$ = new FieldOrArrayRef(novalue);
7340 $$->set_location(infile, @$);
7343 DefOrFieldRef: // 539
7346 $$ = new Qualifier();
7347 $$->add(new FieldOrArrayRef($1));
7348 $$->set_location(infile, @1);
7350 | IDentifier '.' IDentifier optExtendedFieldReference
7352 $$ = new Qualifier();
7353 $$->add(new FieldOrArrayRef($1));
7354 $$->add(new FieldOrArrayRef($3));
7355 for(size_t i=0; i<$4.nElements; i++) {
7356 $$->add($4.elements[i]);
7359 $$->set_location(infile, @$);
7361 | IDentifier ArrayOrBitRefOrDash optExtendedFieldReference
7363 $$ = new Qualifier();
7364 $$->add(new FieldOrArrayRef($1));
7366 for(size_t i=0; i<$3.nElements; i++) {
7367 $$->add($3.elements[i]);
7370 $$->set_location(infile, @$);
7372 | ArrayOrBitRefOrDash optExtendedFieldReference
7374 $$ = new Qualifier();
7376 for(size_t i=0; i<$2.nElements; i++) {
7377 $$->add($2.elements[i]);
7380 $$->set_location(infile, @$);
7384 Location loc(infile, @$);
7385 loc.error("Reference to multiple definitions in attribute qualifiers is "
7386 "not currently supported");
7392 GroupKeyword AllKeyword
7393 | GroupKeyword AllKeyword ExceptKeyword '{' GroupRefList optError '}'
7394 | TypeDefKeyword AllKeyword
7395 | TypeDefKeyword AllKeyword ExceptKeyword '{' TypeRefList optError '}'
7396 | TemplateKeyword AllKeyword
7397 | TemplateKeyword AllKeyword ExceptKeyword '{' TemplateRefList optError '}'
7398 | ConstKeyword AllKeyword
7399 | ConstKeyword AllKeyword ExceptKeyword '{' ConstRefList optError '}'
7400 | AltstepKeyword AllKeyword
7401 | AltstepKeyword AllKeyword ExceptKeyword '{' AltstepRefList optError '}'
7402 | TestcaseKeyword AllKeyword
7403 | TestcaseKeyword AllKeyword ExceptKeyword '{' TestcaseRefList optError '}'
7404 | FunctionKeyword AllKeyword
7405 | FunctionKeyword AllKeyword ExceptKeyword '{' FunctionRefList optError '}'
7406 | SignatureKeyword AllKeyword
7407 | SignatureKeyword AllKeyword ExceptKeyword '{' SignatureRefList optError '}'
7408 | ModuleParKeyword AllKeyword
7409 | ModuleParKeyword AllKeyword ExceptKeyword '{' ModuleParRefList optError '}'
7415 $$ = new AttributeSpec(string($1));
7416 $$->set_location(infile, @$);
7421 /* A.1.6.7 Behaviour statements */
7423 BehaviourStatements: // 543
7426 if ($1.ref_pard) $$ = new Statement(Statement::S_TESTCASE_INSTANCE,
7427 $1.ref_pard, $1.value);
7428 else if($1.derefered_value) {
7429 $$ = new Statement(Statement::S_TESTCASE_INSTANCE_REFD,
7430 $1.derefered_value, $1.ap_list->steal_tis(), $1. value);
7433 else $$ = new Statement(Statement::S_ERROR);
7434 $$->set_location(infile, @$);
7438 $$ = new Statement(Statement::S_UNKNOWN_INSTANCE, $1);
7439 $$->set_location(infile, @$);
7443 $$ = new Statement(Statement::S_UNKNOWN_INVOKED, $1.value, $1.ap_list);
7444 $$->set_location(infile, @$);
7446 | ReturnStatement { $$ = $1; }
7447 | AltConstruct { $$ = $1; }
7448 | InterleavedConstruct { $$ = $1; }
7449 | LabelStatement { $$ = $1; }
7450 | GotoStatement { $$=$1; }
7451 | RepeatStatement { $$ = $1; }
7452 | BreakStatement { $$ = $1; }
7453 | ContinueStatement { $$ = $1; }
7454 | DeactivateStatement { $$ = $1; }
7455 /* | AltstepInstance -- covered by FunctionInstance */
7458 if ($1.ref_pard) $$ = new Statement(Statement::S_ACTIVATE, $1.ref_pard);
7459 else if($1.derefered_value) $$ = new Statement(Statement::S_ACTIVATE_REFD,
7460 $1.derefered_value, new ParsedActualParameters($1.ap_list));
7461 else $$ = new Statement(Statement::S_ERROR);
7462 $$->set_location(infile, @$);
7466 VerdictStatements: // 544
7467 SetLocalVerdict { $$ = $1; }
7471 GetLocalVerdict { $$ = $1; }
7474 SetLocalVerdict: // 546
7475 SetVerdictKeyword '(' Expression optError ',' LogItemList optError ')'
7477 $$=new Statement(Statement::S_SETVERDICT, $3, $6);
7478 $$->set_location(infile, @$);
7480 | SetVerdictKeyword '(' Expression optError ')'
7482 $$=new Statement(Statement::S_SETVERDICT, $3, (LogArguments*)0);
7483 $$->set_location(infile, @$);
7485 | SetVerdictKeyword '(' error ')'
7487 Value *v = new Value(Value::V_ERROR);
7488 v->set_location(infile, @3);
7489 $$ = new Statement(Statement::S_SETVERDICT, v);
7490 $$->set_location(infile, @$);
7494 GetLocalVerdict: // 548
7497 $$=new Value(Value::OPTYPE_GETVERDICT);
7498 $$->set_location(infile, @$);
7502 SUTStatements: // 549
7503 ActionKeyword '(' ')'
7505 $$=new Statement(Statement::S_ACTION, (LogArguments*)0);
7506 $$->set_location(infile, @$);
7508 | ActionKeyword '(' LogItemList optError ')'
7510 $$=new Statement(Statement::S_ACTION, $3);
7511 $$->set_location(infile, @$);
7513 | ActionKeyword '(' error ')'
7515 $$=new Statement(Statement::S_ACTION, new LogArguments());
7516 $$->set_location(infile, @$);
7520 StopExecutionStatement:
7523 $$=new Statement(Statement::S_STOP_EXEC);
7524 $$->set_location(infile, @$);
7528 StopTestcaseStatement:
7529 TestcaseKeyword DotStopKeyword
7531 $$ = new Statement(Statement::S_STOP_TESTCASE, (LogArguments*)0);
7532 $$->set_location(infile, @$);
7534 | TestcaseKeyword DotStopKeyword '(' LogItemList optError ')'
7536 $$ = new Statement(Statement::S_STOP_TESTCASE, $4);
7537 $$->set_location(infile, @$);
7541 ReturnStatement: // 552
7544 $$=new Statement(Statement::S_RETURN, (Template*)0);
7545 $$->set_location(infile, @$);
7547 | ReturnKeyword TemplateBody
7549 $$=new Statement(Statement::S_RETURN, $2);
7550 $$->set_location(infile, @$);
7554 AltConstruct: // 553
7555 AltKeyword '{' AltGuardList optError '}'
7557 $$=new Statement(Statement::S_ALT, $3);
7558 $$->set_location(infile, @$);
7560 | AltKeyword '{' error '}'
7562 $$=new Statement(Statement::S_ALT, new AltGuards());
7563 $$->set_location(infile, @$);
7567 AltGuardList: // 555
7573 | AltGuardList optError AltGuard
7581 GuardStatement { $$ = $1; }
7582 | ElseStatement { $$ = $1; }
7585 GuardStatement: // 556
7586 AltGuardChar AltstepInstance optSemiColon
7588 $$=new AltGuard($1, $2, 0);
7589 $$->set_location(infile, @$);
7591 | AltGuardChar ApplyOp optSemiColon
7593 $$=new AltGuard($1, $2.value, $2.ap_list->steal_tis(), 0);
7594 $$->set_location(infile, @$);
7597 | AltGuardChar AltstepInstance optSemiColon StatementBlock optSemiColon
7599 $$=new AltGuard($1, $2, $4);
7600 $$->set_location(infile, @$);
7602 | AltGuardChar ApplyOp optSemiColon StatementBlock optSemiColon
7604 $$= new AltGuard($1, $2.value, $2.ap_list->steal_tis(), $4);
7605 $$->set_location(infile, @$);
7608 | AltGuardChar GuardOp ';'
7610 $$=new AltGuard($1, $2, new StatementBlock());
7611 $$->set_location(infile, @$);
7613 | AltGuardChar GuardOp optSemiColon StatementBlock optSemiColon
7615 $$=new AltGuard($1, $2, $4);
7616 $$->set_location(infile, @$);
7620 ElseStatement: // 557
7621 '[' ElseKeyword ']' StatementBlock optSemiColon
7623 $$=new AltGuard($4);
7624 $$->set_location(infile, @$);
7628 AltGuardChar: // 558
7630 | '[' BooleanExpression ']' { $$ = $2; }
7634 TimeoutStatement { $$=$1; }
7635 | ReceiveStatement { $$=$1; }
7636 | TriggerStatement { $$=$1; }
7637 | GetCallStatement { $$=$1; }
7638 | CatchStatement { $$=$1; }
7639 | CheckStatement { $$=$1; }
7640 | GetReplyStatement { $$=$1; }
7641 | DoneStatement { $$=$1; }
7642 | KilledStatement { $$ = $1; }
7645 InterleavedConstruct: // 560
7646 InterleavedKeyword '{' InterleavedGuardList optError '}'
7648 $$ = new Statement(Statement::S_INTERLEAVE, $3);
7649 $$->set_location(infile, @$);
7651 | InterleavedKeyword '{' error '}'
7653 $$ = new Statement(Statement::S_INTERLEAVE, new AltGuards());
7654 $$->set_location(infile, @$);
7658 InterleavedGuardList: // 562
7659 optError InterleavedGuardElement
7661 $$ = new AltGuards();
7664 | InterleavedGuardList optError InterleavedGuardElement
7665 { $$ = $1; $$->add_ag($3); }
7668 InterleavedGuardElement: // 563
7669 '[' optError ']' GuardOp ';'
7671 $$ = new AltGuard(0, $4, new StatementBlock());
7672 $$->set_location(infile, @$);
7674 | '[' optError ']' GuardOp optSemiColon StatementBlock optSemiColon
7676 $$ = new AltGuard(0, $4, $6);
7677 $$->set_location(infile, @$);
7681 /* The following were folded into the above rule:
7683 InterleavedGuardElement: // 563
7684 InterleavedGuard InterleavedAction
7687 InterleavedGuard: // 564
7691 InterleavedAction: // 565
7696 LabelStatement: // 566
7697 LabelKeyword IDentifier
7699 $$=new Statement(Statement::S_LABEL, $2);
7700 $$->set_location(infile, @$);
7704 GotoStatement: // 569
7705 GotoKeyword IDentifier
7707 $$=new Statement(Statement::S_GOTO, $2);
7708 $$->set_location(infile, @$);
7710 | GotoKeyword AltKeyword
7712 Location loc(infile, @$);
7713 loc.warning("Obsolete statement `goto alt' was substituted with `repeat'");
7714 $$=new Statement(Statement::S_REPEAT);
7715 $$->set_location(infile, @$);
7719 RepeatStatement: // 571
7722 $$=new Statement(Statement::S_REPEAT);
7723 $$->set_location(infile, @$);
7728 ActivateKeyword '(' AltstepInstance optError ')'
7731 $$.derefered_value = 0;
7734 | ActivateKeyword '(' DereferOp '(' optFunctionActualParList ')' optError ')'
7736 $5->set_location(infile, @4, @6);
7738 $$.derefered_value = $3;
7739 $$.ap_list = $5->steal_tis(); /* XXX perhaps propagate the datatype instead ? */
7742 | ActivateKeyword '(' error ')'
7745 $$.derefered_value = 0;
7751 RefersKeyword '(' FunctionRef ')'
7753 Ttcn::Reference* t_ref = new Ttcn::Reference($3.modid, $3.id);
7754 t_ref->set_location(infile, @3);
7755 $$ = new Value(Value::V_REFER, t_ref);
7756 $$->set_location(infile, @$);
7760 DeactivateStatement: // 574
7763 $$=new Statement(Statement::S_DEACTIVATE, (Value*)0);
7764 $$->set_location(infile, @$);
7766 | DeactivateKeyword '(' Expression optError ')'
7768 $$=new Statement(Statement::S_DEACTIVATE, $3);
7769 $$->set_location(infile, @$);
7771 | DeactivateKeyword '(' error ')'
7773 Value *v = new Value(Value::V_ERROR);
7774 v->set_location(infile, @3);
7775 $$ = new Statement(Statement::S_DEACTIVATE, v);
7776 $$->set_location(infile, @$);
7780 BreakStatement: // 576
7783 $$=new Statement(Statement::S_BREAK);
7784 $$->set_location(infile, @$);
7788 ContinueStatement: // 577
7791 $$=new Statement(Statement::S_CONTINUE);
7792 $$->set_location(infile, @$);
7796 /* A.1.6.8 Basic statements */
7798 BasicStatements: // 578
7801 $$=new Statement(Statement::S_ASSIGNMENT, $1);
7802 $$->set_location(infile, @$);
7804 | LogStatement { $$ = $1; }
7805 | String2TtcnStatement { $$ = $1; }
7808 $$ = new Statement(Statement::S_BLOCK, $1);
7809 $$->set_location(infile, @$);
7811 | TitanSpecificTryKeyword StatementBlock
7813 $$ = new Statement(Statement::S_BLOCK, $2);
7814 $2->set_exception_handling(StatementBlock::EH_TRY);
7815 $$->set_location(infile, @$);
7817 | TitanSpecificCatchKeyword '(' IDentifier ')' StatementBlock
7819 $$ = new Statement(Statement::S_BLOCK, $5);
7820 $5->set_exception_handling(StatementBlock::EH_CATCH);
7821 /* add a newly constructed first statement which will contain the error message,
7822 same as: 'var charstring IDentifier;' */
7823 Type* str_type = new Type(Type::T_CSTR);
7824 str_type->set_location(infile, @3);
7825 Def_Var* str_def = new Def_Var($3, str_type, 0);
7826 str_def->set_location(infile, @3);
7827 Statement* str_stmt = new Statement(Statement::S_DEF, str_def);
7828 str_stmt->set_location(infile, @3);
7829 $5->add_stmt(str_stmt, true);
7830 $$->set_location(infile, @$);
7832 | LoopConstruct { $$ = $1; }
7833 | ConditionalConstruct { $$ = $1; }
7834 | SelectCaseConstruct { $$ = $1; }
7838 '(' optError Expression optError ')' { $$ = $3; }
7841 $$ = new Value(Value::V_ERROR);
7842 $$->set_location(infile, @$);
7844 | '+' Expression %prec UnarySign
7846 $$ = new Value(Value::OPTYPE_UNARYPLUS, $2);
7847 $$->set_location(infile, @$);
7849 | '-' Expression %prec UnarySign
7851 $$ = new Value(Value::OPTYPE_UNARYMINUS, $2);
7852 $$->set_location(infile, @$);
7854 | Expression '*' Expression
7856 $$ = new Value(Value::OPTYPE_MULTIPLY, $1, $3);
7857 $$->set_location(infile, @$);
7859 | Expression '/' Expression
7861 $$ = new Value(Value::OPTYPE_DIVIDE, $1, $3);
7862 $$->set_location(infile, @$);
7864 | Expression ModKeyword Expression
7866 $$ = new Value(Value::OPTYPE_MOD, $1, $3);
7867 $$->set_location(infile, @$);
7869 | Expression RemKeyword Expression
7871 $$ = new Value(Value::OPTYPE_REM, $1, $3);
7872 $$->set_location(infile, @$);
7874 | Expression '+' Expression
7876 $$ = new Value(Value::OPTYPE_ADD, $1, $3);
7877 $$->set_location(infile, @$);
7879 | Expression '-' Expression
7881 $$ = new Value(Value::OPTYPE_SUBTRACT, $1, $3);
7882 $$->set_location(infile, @$);
7884 | Expression '&' Expression
7886 $$ = new Value(Value::OPTYPE_CONCAT, $1, $3);
7887 $$->set_location(infile, @$);
7889 | Not4bKeyword Expression
7891 $$ = new Value(Value::OPTYPE_NOT4B, $2);
7892 $$->set_location(infile, @$);
7894 | Expression And4bKeyword Expression
7896 $$ = new Value(Value::OPTYPE_AND4B, $1, $3);
7897 $$->set_location(infile, @$);
7899 | Expression Xor4bKeyword Expression
7901 $$ = new Value(Value::OPTYPE_XOR4B, $1, $3);
7902 $$->set_location(infile, @$);
7904 | Expression Or4bKeyword Expression
7906 $$ = new Value(Value::OPTYPE_OR4B, $1, $3);
7907 $$->set_location(infile, @$);
7909 | Expression SL Expression
7911 $$ = new Value(Value::OPTYPE_SHL, $1, $3);
7912 $$->set_location(infile, @$);
7914 | Expression SR Expression
7916 $$ = new Value(Value::OPTYPE_SHR, $1, $3);
7917 $$->set_location(infile, @$);
7919 | Expression RL Expression
7921 $$ = new Value(Value::OPTYPE_ROTL, $1, $3);
7922 $$->set_location(infile, @$);
7924 | Expression _RR Expression
7926 $$ = new Value(Value::OPTYPE_ROTR, $1, $3);
7927 $$->set_location(infile, @$);
7929 | Expression '<' Expression
7931 $$ = new Value(Value::OPTYPE_LT, $1, $3);
7932 $$->set_location(infile, @$);
7934 | Expression '>' Expression
7936 $$ = new Value(Value::OPTYPE_GT, $1, $3);
7937 $$->set_location(infile, @$);
7939 | Expression LE Expression
7941 $$ = new Value(Value::OPTYPE_LE, $1, $3);
7942 $$->set_location(infile, @$);
7944 | Expression GE Expression
7946 $$ = new Value(Value::OPTYPE_GE, $1, $3);
7947 $$->set_location(infile, @$);
7949 | Expression EQ Expression
7951 $$ = new Value(Value::OPTYPE_EQ, $1, $3);
7952 $$->set_location(infile, @$);
7954 | Expression NE Expression
7956 $$ = new Value(Value::OPTYPE_NE, $1, $3);
7957 $$->set_location(infile, @$);
7959 | NotKeyword Expression
7961 $$ = new Value(Value::OPTYPE_NOT, $2);
7962 $$->set_location(infile, @$);
7964 | Expression AndKeyword Expression
7966 $$ = new Value(Value::OPTYPE_AND, $1, $3);
7967 $$->set_location(infile, @$);
7969 | Expression XorKeyword Expression
7971 $$ = new Value(Value::OPTYPE_XOR, $1, $3);
7972 $$->set_location(infile, @$);
7974 | Expression OrKeyword Expression
7976 $$ = new Value(Value::OPTYPE_OR, $1, $3);
7977 $$->set_location(infile, @$);
7979 | OpCall { $$ = $1; }
7980 | Value { $$ = $1; }
7981 | CompoundExpression { $$ = $1; }
7984 CompoundExpression: // 565
7985 FieldExpressionList { $$ = $1; }
7986 | ArrayExpressionList { $$ = $1; }
7987 | ArrayExpression { $$ = $1; }
7990 FieldExpressionList: // 581
7991 '{' seqFieldExpressionSpec optError '}'
7993 $$ = new Value(Value::V_SEQ, $2);
7994 $$->set_location(infile, @$);
7998 seqFieldExpressionSpec:
8001 $$ = new NamedValues();
8004 | error FieldExpressionSpec
8006 $$ = new NamedValues();
8009 | seqFieldExpressionSpec optError ',' optError FieldExpressionSpec
8014 | seqFieldExpressionSpec optError ',' error { $$ = $1; }
8017 FieldExpressionSpec: // 582
8018 FieldReference AssignmentChar NotUsedOrExpression
8020 $$ = new NamedValue($1, $3);
8021 $$->set_location(infile, @$);
8025 ArrayExpressionList:
8026 '{' seqArrayExpressionSpec optError '}'
8028 $$ = new Value(Value::V_SEQOF, $2);
8029 $$->set_location(infile, @$);
8033 seqArrayExpressionSpec:
8034 optError ArrayExpressionSpec
8036 // The only place for indexed-list notation.
8037 $$ = new Values(true);
8040 | seqArrayExpressionSpec optError ',' optError ArrayExpressionSpec
8045 | seqArrayExpressionSpec optError ',' error { $$ = $1; }
8048 ArrayExpressionSpec:
8049 ArrayOrBitRef AssignmentChar Expression
8051 $$ = new IndexedValue($1, $3);
8052 $$->set_location(infile, @$);
8056 ArrayExpression: // 583
8059 $$ = new Value(Value::V_SEQOF, new Values);
8060 $$->set_location(infile, @$);
8062 | '{' ArrayElementExpressionList optError '}'
8064 $$ = new Value(Value::V_SEQOF, $2);
8065 $$->set_location(infile, @$);
8069 $$ = new Value(Value::V_ERROR);
8070 $$->set_location(infile, @$);
8074 ArrayElementExpressionList: // 584
8080 | error NotUsedOrExpression
8085 | ArrayElementExpressionList optError ',' optError NotUsedOrExpression
8090 | ArrayElementExpressionList optError ',' error { $$ = $1; }
8093 NotUsedOrExpression: // 585
8094 Expression { $$ = $1; }
8097 $$ = new Value(Value::V_NOTUSED);
8098 $$->set_location(infile, @$);
8102 BooleanExpression: // 588
8103 Expression { $$ = $1; }
8106 $$ = new Value(Value::V_ERROR);
8107 $$->set_location(infile, @$);
8112 VariableRef AssignmentChar TemplateBody
8114 $$ = new Ttcn::Assignment($1, $3);
8115 $$->set_location(infile, @$);
8119 /* This can not be a single CompoundExpression (as opposed to Expression) */
8120 SingleExpression: // 595
8121 '(' SingleExpression ')' { $$ = $2; }
8122 | '(' error SingleExpression ')' { $$ = $3; }
8125 $$ = new Value(Value::V_ERROR);
8126 $$->set_location(infile, @$);
8128 | '+' Expression %prec UnarySign
8130 $$ = new Value(Value::OPTYPE_UNARYPLUS, $2);
8131 $$->set_location(infile, @$);
8133 | '-' Expression %prec UnarySign
8135 $$ = new Value(Value::OPTYPE_UNARYMINUS, $2);
8136 $$->set_location(infile, @$);
8138 | SingleExpression '*' Expression
8140 $$ = new Value(Value::OPTYPE_MULTIPLY, $1, $3);
8141 $$->set_location(infile, @$);
8143 | SingleExpression '/' Expression
8145 $$ = new Value(Value::OPTYPE_DIVIDE, $1, $3);
8146 $$->set_location(infile, @$);
8148 | SingleExpression ModKeyword Expression
8150 $$ = new Value(Value::OPTYPE_MOD, $1, $3);
8151 $$->set_location(infile, @$);
8153 | SingleExpression RemKeyword Expression
8155 $$ = new Value(Value::OPTYPE_REM, $1, $3);
8156 $$->set_location(infile, @$);
8158 | SingleExpression '+' Expression
8160 $$ = new Value(Value::OPTYPE_ADD, $1, $3);
8161 $$->set_location(infile, @$);
8163 | SingleExpression '-' Expression
8165 $$ = new Value(Value::OPTYPE_SUBTRACT, $1, $3);
8166 $$->set_location(infile, @$);
8168 | SingleExpression '&' Expression
8170 $$ = new Value(Value::OPTYPE_CONCAT, $1, $3);
8171 $$->set_location(infile, @$);
8173 | Not4bKeyword Expression
8175 $$ = new Value(Value::OPTYPE_NOT4B, $2);
8176 $$->set_location(infile, @$);
8178 | SingleExpression And4bKeyword Expression
8180 $$ = new Value(Value::OPTYPE_AND4B, $1, $3);
8181 $$->set_location(infile, @$);
8183 | SingleExpression Xor4bKeyword Expression
8185 $$ = new Value(Value::OPTYPE_XOR4B, $1, $3);
8186 $$->set_location(infile, @$);
8188 | SingleExpression Or4bKeyword Expression
8190 $$ = new Value(Value::OPTYPE_OR4B, $1, $3);
8191 $$->set_location(infile, @$);
8193 | SingleExpression SL Expression
8195 $$ = new Value(Value::OPTYPE_SHL, $1, $3);
8196 $$->set_location(infile, @$);
8198 | SingleExpression SR Expression
8200 $$ = new Value(Value::OPTYPE_SHR, $1, $3);
8201 $$->set_location(infile, @$);
8203 | SingleExpression RL Expression
8205 $$ = new Value(Value::OPTYPE_ROTL, $1, $3);
8206 $$->set_location(infile, @$);
8208 | SingleExpression _RR Expression
8210 $$ = new Value(Value::OPTYPE_ROTR, $1, $3);
8211 $$->set_location(infile, @$);
8213 | SingleExpression '<' Expression
8215 $$ = new Value(Value::OPTYPE_LT, $1, $3);
8216 $$->set_location(infile, @$);
8218 | SingleExpression '>' Expression
8220 $$ = new Value(Value::OPTYPE_GT, $1, $3);
8221 $$->set_location(infile, @$);
8223 | SingleExpression LE Expression
8225 $$ = new Value(Value::OPTYPE_LE, $1, $3);
8226 $$->set_location(infile, @$);
8228 | SingleExpression GE Expression
8230 $$ = new Value(Value::OPTYPE_GE, $1, $3);
8231 $$->set_location(infile, @$);
8233 | SingleExpression EQ Expression
8235 $$ = new Value(Value::OPTYPE_EQ, $1, $3);
8236 $$->set_location(infile, @$);
8238 | SingleExpression NE Expression
8240 $$ = new Value(Value::OPTYPE_NE, $1, $3);
8241 $$->set_location(infile, @$);
8243 | NotKeyword Expression
8245 $$ = new Value(Value::OPTYPE_NOT, $2);
8246 $$->set_location(infile, @$);
8248 | SingleExpression AndKeyword Expression
8250 $$ = new Value(Value::OPTYPE_AND, $1, $3);
8251 $$->set_location(infile, @$);
8253 | SingleExpression XorKeyword Expression
8255 $$ = new Value(Value::OPTYPE_XOR, $1, $3);
8256 $$->set_location(infile, @$);
8258 | SingleExpression OrKeyword Expression
8260 $$ = new Value(Value::OPTYPE_OR, $1, $3);
8261 $$->set_location(infile, @$);
8263 | OpCall { $$ = $1; }
8264 | Value { $$ = $1; }
8267 optExtendedFieldReference:
8268 // perhaps this should be called seqExtendedFieldReference,
8269 // but the convention appears to be that seq... can not be empty
8275 | optExtendedFieldReference FieldOrArrayReference
8277 $$.nElements = $1.nElements + 1;
8278 $$.elements = (FieldOrArrayRef**)
8279 Realloc($1.elements, ($$.nElements) * sizeof(*$$.elements));
8280 $$.elements[$1.nElements] = $2;
8284 FieldOrArrayReference:
8287 $$ = new FieldOrArrayRef($2);
8288 $$->set_location(infile, @$);
8290 | ArrayOrBitRefOrDash { $$ = $1; }
8294 PredefOrIdentifier { $$ = $1; }
8295 | IDentifier /* maybe PredefOrIdentifier here too */ TypeActualParList
8297 Location loc(infile, @$);
8298 loc.error("Reference to a parameterized field of type `anytype' is "
8299 "not currently supported");
8305 ConfigurationOps { $$ = $1; }
8306 | VerdictOps { $$ = $1; }
8307 | TimerOps { $$ = $1; }
8310 if ($1.ref_pard) $$ = new Value(Value::OPTYPE_EXECUTE, $1.ref_pard,
8312 else if($1.derefered_value)
8313 $$ = new Value(Value::OPTYPE_EXECUTE_REFD, $1.derefered_value, $1.ap_list,
8315 else $$ = new Value(Value::V_ERROR);
8316 $$->set_location(infile, @$);
8320 $$ = new Value(Value::V_REFD, $1);
8321 $$->set_location(infile, @$);
8325 $$ = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
8326 $$->set_location(infile, @$);
8328 | TemplateOps { $$ = $1; }
8329 | PredefinedOps { $$ = $1; }
8330 | ReferOp { $$ = $1; }
8333 if ($1.ref_pard) $$ = new Value(Value::OPTYPE_ACTIVATE, $1.ref_pard);
8334 else if($1.derefered_value) $$ = new Value(Value::OPTYPE_ACTIVATE_REFD,
8335 $1.derefered_value, new ParsedActualParameters($1.ap_list));
8336 else $$ = new Value(Value::V_ERROR);
8337 $$->set_location(infile, @$);
8342 PredefinedOpKeyword1 '(' optError Expression optError ')'
8344 $$ = new Value($1, $4);
8345 $$->set_location(infile, @$);
8347 | PredefinedOpKeyword1 '(' error ')'
8349 Value *v1 = new Value(Value::V_ERROR);
8350 v1->set_location(infile, @3);
8351 $$ = new Value($1, v1);
8352 $$->set_location(infile, @$);
8354 | PredefinedOpKeyword2 '(' optError Expression optError ',' optError
8355 Expression optError ')'
8357 $$ = new Value($1, $4, $8);
8358 $$->set_location(infile, @$);
8360 | PredefinedOpKeyword2 '(' error ')'
8362 Value *v1 = new Value(Value::V_ERROR);
8363 v1->set_location(infile, @3);
8364 Value *v2 = new Value(Value::V_ERROR);
8365 v2->set_location(infile, @3);
8366 $$ = new Value($1, v1, v2);
8367 $$->set_location(infile, @$);
8369 | PredefinedOpKeyword3 '(' optError Expression optError ',' optError
8370 Expression optError ')'
8372 $$ = new Value($1, $4, $8);
8373 $$->set_location(infile, @$);
8375 | PredefinedOpKeyword3 '(' optError Expression optError ')'
8377 $$ = new Value($1, $4, (Common::Value*)NULL);
8378 $$->set_location(infile, @$);
8380 | PredefinedOpKeyword3 '(' error ')'
8382 Value *v1 = new Value(Value::V_ERROR);
8383 v1->set_location(infile, @3);
8384 Value *v2 = new Value(Value::V_ERROR);
8385 v2->set_location(infile, @3);
8386 $$ = new Value($1, v1, v2);
8387 $$->set_location(infile, @$);
8389 | decompKeyword '(' optError Expression optError ',' optError
8390 Expression optError ',' optError Expression optError ')'
8392 $$ = new Value(Value::OPTYPE_DECOMP, $4, $8, $12);
8393 $$->set_location(infile, @$);
8395 | decompKeyword '(' error ')'
8397 Value *v1 = new Value(Value::V_ERROR);
8398 v1->set_location(infile, @3);
8399 Value *v2 = new Value(Value::V_ERROR);
8400 v2->set_location(infile, @3);
8401 Value *v3 = new Value(Value::V_ERROR);
8402 v3->set_location(infile, @3);
8403 $$ = new Value(Value::OPTYPE_DECOMP, v1, v2, v3);
8404 $$->set_location(infile, @$);
8406 | regexpKeyword '(' optError TemplateInstance optError ',' optError
8407 TemplateInstance optError ',' optError Expression optError ')'
8409 $$ = new Value(Value::OPTYPE_REGEXP, $4, $8, $12);
8410 $$->set_location(infile, @$);
8412 | regexpKeyword '(' error ')'
8414 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8415 t1->set_location(infile, @3);
8416 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8417 ti1->set_location(infile, @3);
8418 Template *t2 = new Template(Template::TEMPLATE_ERROR);
8419 t2->set_location(infile, @3);
8420 TemplateInstance *ti2 = new TemplateInstance(0, 0, t2);
8421 ti2->set_location(infile, @3);
8422 Value *v3 = new Value(Value::V_ERROR);
8423 v3->set_location(infile, @3);
8424 $$ = new Value(Value::OPTYPE_REGEXP, ti1, ti2, v3);
8425 $$->set_location(infile, @$);
8427 | encvalueKeyword '(' optError TemplateInstance optError ')'
8429 $$ = new Value(Value::OPTYPE_ENCODE, $4);
8430 $$->set_location(infile, @$);
8432 | encvalueKeyword '(' error ')'
8434 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8435 t1->set_location(infile, @3);
8436 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8437 ti1->set_location(infile, @3);
8438 $$ = new Value(Value::OPTYPE_ENCODE, ti1);
8439 $$->set_location(infile, @$);
8441 | substrKeyword '(' optError TemplateInstance optError ',' optError
8442 Expression optError ',' optError Expression optError ')'
8444 $$ = new Value(Value::OPTYPE_SUBSTR, $4, $8, $12);
8445 $$->set_location(infile, @$);
8447 | substrKeyword '(' error ')'
8449 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8450 t1->set_location(infile, @3);
8451 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8452 ti1->set_location(infile, @3);
8453 Value *v2 = new Value(Value::V_ERROR);
8454 v2->set_location(infile, @3);
8455 Value *v3 = new Value(Value::V_ERROR);
8456 v3->set_location(infile, @3);
8457 $$ = new Value(Value::OPTYPE_SUBSTR, ti1, v2, v3);
8458 $$->set_location(infile, @$);
8460 | replaceKeyword '(' optError TemplateInstance optError ',' optError
8461 Expression optError ',' optError Expression optError ',' optError
8462 TemplateInstance optError ')'
8464 $$ = new Value(Value::OPTYPE_REPLACE, $4, $8, $12, $16);
8465 $$->set_location(infile, @$);
8467 | replaceKeyword '(' error ')'
8469 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8470 t1->set_location(infile, @3);
8471 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8472 ti1->set_location(infile, @3);
8473 Value *v2 = new Value(Value::V_ERROR);
8474 v2->set_location(infile, @3);
8475 Value *v3 = new Value(Value::V_ERROR);
8476 v3->set_location(infile, @3);
8477 Template *t4 = new Template(Template::TEMPLATE_ERROR);
8478 t4->set_location(infile, @3);
8479 TemplateInstance *ti4 = new TemplateInstance(0, 0, t4);
8480 ti4->set_location(infile, @3);
8481 $$ = new Value(Value::OPTYPE_REPLACE, ti1, v2, v3, ti4);
8482 $$->set_location(infile, @$);
8484 | decvalueKeyword '(' optError DecValueArg optError ',' optError DecValueArg optError ')'
8486 $$ = new Value(Value::OPTYPE_DECODE, $4, $8);
8487 $$->set_location(infile, @$);
8489 | decvalueKeyword '(' error ')'
8491 /*Value *v1 = new Value(Value::V_ERROR);
8492 v1->set_location(infile, @3);
8493 TemplateInstance *t2 = new TemplateInstance(Type::T_ERROR);*/
8494 $$ = new Value(Value::V_ERROR);
8495 $$->set_location(infile, @$);
8497 | isvalueKeyword '(' optError TemplateInstance optError ')'
8499 $$ = new Value(Value::OPTYPE_ISVALUE, $4);
8500 $$->set_location(infile, @$);
8502 | isvalueKeyword '(' error ')'
8504 $$ = new Value(Value::V_ERROR);
8505 $$->set_location(infile, @$);
8507 | isboundKeyword '(' optError TemplateInstance optError ')'
8509 $$ = new Value(Value::OPTYPE_ISBOUND, $4);
8510 $$->set_location(infile, @$);
8512 | isboundKeyword '(' error ')'
8514 $$ = new Value(Value::V_ERROR);
8515 $$->set_location(infile, @$);
8517 | ischosenKeyword '(' optError IschosenArg optError ')'
8519 $$ = new Value(Value::OPTYPE_ISCHOSEN, $4.ref, $4.id);
8520 $$->set_location(infile, @$);
8522 | ischosenKeyword '(' error ')'
8524 $$ = new Value(Value::V_ERROR);
8525 $$->set_location(infile, @$);
8527 | ispresentKeyword '(' optError TemplateInstance optError ')'
8529 $$ = new Value(Value::OPTYPE_ISPRESENT, $4);
8530 $$->set_location(infile, @$);
8532 | ispresentKeyword '(' error ')'
8534 $$ = new Value(Value::V_ERROR);
8535 $$->set_location(infile, @$);
8537 | lengthofKeyword '(' optError TemplateInstance optError ')'
8539 $$ = new Value(Value::OPTYPE_LENGTHOF, $4);
8540 $$->set_location(infile, @$);
8542 | lengthofKeyword '(' error ')'
8544 $$ = new Value(Value::V_ERROR);
8545 $$->set_location(infile, @$);
8547 | rndKeyword '(' ')'
8549 $$ = new Value(Value::OPTYPE_RND);
8550 $$->set_location(infile, @$);
8552 | rndKeyword '(' optError Expression optError ')'
8554 $$ = new Value(Value::OPTYPE_RNDWITHVAL, $4);
8555 $$->set_location(infile, @$);
8557 | rndKeyword '(' error ')'
8559 Value *v = new Value(Value::V_ERROR);
8560 v->set_location(infile, @3);
8561 $$ = new Value(Value::OPTYPE_RNDWITHVAL, v);
8562 $$->set_location(infile, @$);
8564 | sizeofKeyword '(' optError TemplateInstance optError ')'
8566 $$ = new Value(Value::OPTYPE_SIZEOF, $4);
8567 $$->set_location(infile, @$);
8569 | sizeofKeyword '(' error ')'
8571 $$ = new Value(Value::V_ERROR);
8572 $$->set_location(infile, @$);
8574 | log2strKeyword '(' ')'
8576 $$ = new Value(Value::OPTYPE_LOG2STR, new LogArguments());
8577 $$->set_location(infile, @$);
8579 | log2strKeyword '(' LogItemList optError ')'
8581 $$ = new Value(Value::OPTYPE_LOG2STR, $3);
8582 $$->set_location(infile, @$);
8584 | log2strKeyword '(' error ')'
8586 $$ = new Value(Value::OPTYPE_LOG2STR, new LogArguments());
8587 $$->set_location(infile, @$);
8589 | testcasenameKeyword '(' ')'
8591 $$ = new Value(Value::OPTYPE_TESTCASENAME);
8592 $$->set_location(infile, @$);
8594 | ttcn2stringKeyword '(' optError TemplateInstance optError ')'
8596 $$ = new Value(Value::OPTYPE_TTCN2STRING, $4);
8597 $$->set_location(infile, @$);
8599 | ttcn2stringKeyword '(' error ')'
8601 $$ = new Value(Value::V_ERROR);
8602 $$->set_location(infile, @$);
8609 if ($1.is_ref) $$ = $1.ref;
8611 $$ = new Ttcn::Reference($1.id);
8612 $$->set_location(infile, @$);
8615 | FunctionInstance { $$ = $1; }
8619 IDentifier { $$ = $1; }
8620 | PredefinedType /* shall not be "anytype" */
8622 // Construct an identifier "on the fly" ($1 here is just a typetype_t)
8623 const char* builtin_typename = Type::get_typename_builtin($1);
8624 if (0 == builtin_typename) FATAL_ERROR("Unexpected type %d", $1);
8625 const string& at_field = anytype_field(string(builtin_typename));
8627 $$ = new Identifier(Identifier::ID_TTCN, at_field);
8630 IschosenArg: /* see also Reference... */
8631 IDentifier '.' PredefOrIdentifier
8633 $$.ref = new Ttcn::Reference($1);
8634 $$.ref->set_location(infile, @1);
8637 | IDentifier '.' PredefOrIdentifier optExtendedFieldReference '.' PredefOrIdentifier
8639 $$.ref = new Ttcn::Reference($1);
8640 FieldOrArrayRef *fieldref = new FieldOrArrayRef($3);
8641 fieldref->set_location(infile, @3);
8642 $$.ref->add(fieldref);
8643 for(size_t i=0; i<$4.nElements; i++) $$.ref->add($4.elements[i]);
8645 $$.ref->set_location(infile, @1, @4);
8648 | IDentifier ArrayOrBitRef optExtendedFieldReference '.' PredefOrIdentifier
8650 $$.ref = new Ttcn::Reference($1);
8652 for(size_t i=0; i<$3.nElements; i++) $$.ref->add($3.elements[i]);
8654 $$.ref->set_location(infile, @1, @3);
8657 | IDentifier '.' ObjectIdentifierValue '.' IDentifier optExtendedFieldReference
8658 '.' PredefOrIdentifier
8660 $$.ref = new Ttcn::Reference($1, $5);
8662 for(size_t i=0; i<$6.nElements; i++) $$.ref->add($6.elements[i]);
8664 $$.ref->set_location(infile, @1, @6);
8669 PredefinedOpKeyword1:
8670 bit2hexKeyword { $$ = Value::OPTYPE_BIT2HEX; }
8671 | bit2intKeyword { $$ = Value::OPTYPE_BIT2INT; }
8672 | bit2octKeyword { $$ = Value::OPTYPE_BIT2OCT; }
8673 | bit2strKeyword { $$ = Value::OPTYPE_BIT2STR; }
8674 | char2intKeyword { $$ = Value::OPTYPE_CHAR2INT; }
8675 | char2octKeyword { $$ = Value::OPTYPE_CHAR2OCT; }
8676 | float2intKeyword { $$ = Value::OPTYPE_FLOAT2INT; }
8677 | float2strKeyword { $$ = Value::OPTYPE_FLOAT2STR; }
8678 | hex2bitKeyword { $$ = Value::OPTYPE_HEX2BIT; }
8679 | hex2intKeyword { $$ = Value::OPTYPE_HEX2INT; }
8680 | hex2octKeyword { $$ = Value::OPTYPE_HEX2OCT; }
8681 | hex2strKeyword { $$ = Value::OPTYPE_HEX2STR; }
8682 | int2charKeyword { $$ = Value::OPTYPE_INT2CHAR; }
8683 | int2floatKeyword { $$ = Value::OPTYPE_INT2FLOAT; }
8684 | int2strKeyword { $$ = Value::OPTYPE_INT2STR; }
8685 | int2unicharKeyword { $$ = Value::OPTYPE_INT2UNICHAR; }
8686 | oct2bitKeyword { $$ = Value::OPTYPE_OCT2BIT; }
8687 | oct2charKeyword { $$ = Value::OPTYPE_OCT2CHAR; }
8688 | oct2hexKeyword { $$ = Value::OPTYPE_OCT2HEX; }
8689 | oct2intKeyword { $$ = Value::OPTYPE_OCT2INT; }
8690 | oct2strKeyword { $$ = Value::OPTYPE_OCT2STR; }
8691 | str2bitKeyword { $$ = Value::OPTYPE_STR2BIT; }
8692 | str2floatKeyword { $$ = Value::OPTYPE_STR2FLOAT; }
8693 | str2hexKeyword { $$ = Value::OPTYPE_STR2HEX; }
8694 | str2intKeyword { $$ = Value::OPTYPE_STR2INT; }
8695 | str2octKeyword { $$ = Value::OPTYPE_STR2OCT; }
8696 | unichar2intKeyword { $$ = Value::OPTYPE_UNICHAR2INT; }
8697 | unichar2charKeyword { $$ = Value::OPTYPE_UNICHAR2CHAR; }
8698 | enum2intKeyword { $$ = Value::OPTYPE_ENUM2INT; }
8699 | remove_bomKeyWord { $$ = Value::OPTYPE_REMOVE_BOM; }
8700 | get_stringencodingKeyWord { $$ = Value::OPTYPE_GET_STRINGENCODING; }
8701 | decode_base64KeyWord { $$ = Value::OPTYPE_DECODE_BASE64; }
8704 PredefinedOpKeyword2:
8705 int2bitKeyword { $$ = Value::OPTYPE_INT2BIT; }
8706 | int2hexKeyword { $$ = Value::OPTYPE_INT2HEX; }
8707 | int2octKeyword { $$ = Value::OPTYPE_INT2OCT; }
8710 PredefinedOpKeyword3:
8711 unichar2octKeyword { $$ = Value::OPTYPE_UNICHAR2OCT; }
8712 | oct2unicharKeyword { $$ = Value::OPTYPE_OCT2UNICHAR; }
8713 | encode_base64KeyWord { $$ = Value::OPTYPE_ENCODE_BASE64; }
8716 String2TtcnStatement:
8717 string2ttcnKeyword '(' optError Expression optError ',' optError Reference optError ')'
8719 Ttcn::Reference* out_ref;
8720 if ($8.is_ref) out_ref = $8.ref;
8722 out_ref = new Ttcn::Reference($8.id);
8723 out_ref->set_location(infile, @8);
8725 $$ = new Statement(Statement::S_STRING2TTCN, $4, out_ref);
8726 $$->set_location(infile, @$);
8730 LogStatement: // 619
8733 $$=new Statement(Statement::S_LOG, (LogArguments*)0);
8734 $$->set_location(infile, @$);
8736 | LogKeyword '(' LogItemList optError ')'
8738 $$=new Statement(Statement::S_LOG, $3);
8739 $$->set_location(infile, @$);
8741 | LogKeyword '(' error ')'
8743 $$=new Statement(Statement::S_LOG, new LogArguments());
8744 $$->set_location(infile, @$);
8751 $$ = new LogArguments();
8754 | LogItemList optError ',' optError LogItem
8759 | LogItemList optError ',' error { $$ = $1; }
8765 $$ = new LogArgument($1);
8766 $$->set_location(infile, @$);
8770 LoopConstruct: // 622
8771 ForStatement { $$ = $1; }
8772 | WhileStatement { $$ = $1; }
8773 | DoWhileStatement { $$ = $1; }
8776 ForStatement: // 623
8777 ForKeyword '(' Initial ';' Final ';' Step optError ')'
8780 $$ = new Statement(Statement::S_FOR, $3.defs, $3.ass, $5, $7, $10);
8781 $$->set_location(infile, @$);
8788 $$.defs = new Definitions;
8789 for (size_t i = 0; i < $1.nElements; i++) $$.defs->add_ass($1.elements[i]);
8800 $$.defs = new Definitions;
8806 BooleanExpression { $$ = $1; }
8810 Assignment { $$ = $1; }
8811 /** \todo for-ban nem lehet null a step
8812 | error { $$=NULL; }
8816 WhileStatement: // 628
8817 WhileKeyword '(' BooleanExpression ')' StatementBlock
8819 $$=new Statement(Statement::S_WHILE, $3, $5);
8820 $$->set_location(infile, @$);
8824 DoWhileStatement: // 630
8825 DoKeyword StatementBlock
8826 WhileKeyword '(' BooleanExpression ')'
8828 $$=new Statement(Statement::S_DOWHILE, $5, $2);
8829 $$->set_location(infile, @$);
8833 ConditionalConstruct: // 632
8834 IfKeyword '(' BooleanExpression ')'
8836 seqElseIfClause optElseClause
8838 IfClause *ic=new IfClause($3, $5);
8839 ic->set_location(infile, @1, @5);
8840 $6->add_front_ic(ic);
8841 $$=new Statement(Statement::S_IF, $6, $7,
8842 $7 ? new Location(infile, @7) : 0);
8843 $$->set_location(infile, @$);
8848 /* empty */ { $$=new IfClauses(); }
8849 | seqElseIfClause ElseIfClause
8856 ElseIfClause: // 634
8857 ElseKeyword IfKeyword '(' BooleanExpression ')' StatementBlock
8859 $$=new IfClause($4, $6);
8860 $$->set_location(infile, @$);
8864 optElseClause: // [636]
8865 /* empty */ { $$=0; }
8866 | ElseKeyword StatementBlock { $$=$2; }
8869 SelectCaseConstruct: // 637
8870 SelectKeyword '(' Expression optError ')' SelectCaseBody
8872 $$=new Statement(Statement::S_SELECT, $3, $6);
8873 $$->set_location(infile, @$);
8875 | SelectKeyword '(' error ')' SelectCaseBody
8877 Value *v = new Value(Value::V_ERROR);
8878 v->set_location(infile, @3);
8879 $$=new Statement(Statement::S_SELECT, v, $5);
8880 $$->set_location(infile, @$);
8884 SelectCaseBody: // 639
8885 '{' seqSelectCase optError '}' {$$=$2;}
8886 | '{' error '}' {$$=new SelectCases;}
8895 | seqSelectCase optError SelectCase
8903 CaseKeyword '(' seqTemplateInstance optError ')' StatementBlock optSemiColon
8905 $3->set_location(infile, @2, @5);
8906 $$=new SelectCase($3, $6);
8907 $$->set_location(infile, @$);
8909 | CaseKeyword '(' error ')' StatementBlock optSemiColon
8911 TemplateInstances *tis = new TemplateInstances;
8912 tis->set_location(infile, @2, @4);
8913 $$ = new SelectCase(tis, $5);
8914 $$->set_location(infile, @$);
8916 | CaseKeyword ElseKeyword StatementBlock optSemiColon
8918 $$=new SelectCase(0, $3);
8919 $$->set_location(infile, @$);
8923 seqTemplateInstance:
8924 optError TemplateInstance
8926 $$ = new TemplateInstances;
8929 | seqTemplateInstance optError ',' optError TemplateInstance
8934 | seqTemplateInstance optError ',' error { $$ = $1; }
8937 /* A.1.6.9 Miscellaneous productions */
8939 optSemiColon: // [645]
8944 /* A.1 ASN.1 support, from ES 201 873-7 V3.1.1 (2005-06) */
8946 optDefinitiveIdentifier:
8948 | DefinitiveIdentifier
8951 DefinitiveIdentifier:
8952 '.' ObjectIdentifierKeyword '{' DefinitiveObjIdComponentList optError '}'
8953 | '.' ObjectIdentifierKeyword '{' error '}'
8956 DefinitiveObjIdComponentList:
8957 optError DefinitiveObjIdComponent
8958 | DefinitiveObjIdComponentList optError DefinitiveObjIdComponent
8961 DefinitiveObjIdComponent:
8963 | DefinitiveNumberForm
8964 | DefinitiveNameAndNumberForm
8967 DefinitiveNumberForm:
8968 Number { delete $1; }
8971 DefinitiveNameAndNumberForm:
8972 IDentifier '(' Number optError ')' { delete $1; delete $3; }
8973 | IDentifier '(' error ')' { delete $1; }
8976 ObjectIdentifierValue:
8977 ObjectIdentifierKeyword '{' ObjIdComponentList optError '}'
8980 $$->set_location(infile, @$);
8982 | ObjectIdentifierKeyword '{' error '}'
8984 $$ = new Value(Value::V_ERROR);
8985 $$->set_location(infile, @$);
8990 optError ObjIdComponent
8992 $$ = new Value(Value::V_OID);
8993 $$->add_oid_comp($2);
8995 | ObjIdComponentList optError ObjIdComponent
8998 $$->add_oid_comp($3);
9003 /* NameForm -- covered by NumberForm (as ReferencedValue) */
9004 NumberForm { $$ = $1; }
9005 | NameAndNumberForm { $$ = $1; }
9011 Value *v = new Value(Value::V_INT, $1);
9012 v->set_location(infile, @1);
9013 $$ = new OID_comp(0, v);
9014 $$->set_location(infile, @$);
9019 /* it can be only a referenced value */
9020 Value *v = new Value(Value::V_REFD, $1.ref);
9021 v->set_location(infile, @1);
9022 $$ = new OID_comp(v);
9024 /* it can be either a name form or a referenced value */
9025 $$ = new OID_comp($1.id, 0);
9027 $$->set_location(infile, @$);
9032 IDentifier '(' Number optError ')'
9034 Value *v = new Value(Value::V_INT, $3);
9035 v->set_location(infile, @3);
9036 $$ = new OID_comp($1, v);
9037 $$->set_location(infile, @$);
9039 | IDentifier '(' ReferencedValue optError ')'
9041 $$ = new OID_comp($1, $3);
9042 $$->set_location(infile, @$);
9044 | IDentifier '(' error ')'
9046 Value *v = new Value(Value::V_ERROR);
9047 v->set_location(infile, @3);
9048 $$ = new OID_comp($1, v);
9049 $$->set_location(infile, @$);
9054 IDentifier { delete $1; }
9057 /* Rules for error recovery */
9066 | optErrorBlock ErrorBlock optError
9071 | '{' optError ErrorBlock optError '}'
9076 static void ttcn3_error(const char *str)
9078 Location loc(infile, ttcn3_lloc);
9080 // the most recently parsed token is known
9081 loc.error("at or before token `%s': %s", ttcn3_text, str);
9083 // the most recently parsed token is unknown
9084 loc.error("%s", str);
9088 int ttcn3_parse_file(const char* filename, boolean generate_code)
9090 anytype_access = false;
9091 ttcn3_in = fopen(filename, "r");
9092 if (ttcn3_in == NULL) {
9093 ERROR("Cannot open input file `%s': %s", filename, strerror(errno));
9099 is_erroneous_parsed = false;
9100 NOTIFY("Parsing TTCN-3 module `%s'...", filename);
9102 int retval = ttcn3_parse();
9104 free_ttcn3_lex(); // does fclose(ttcn3_in);
9106 if (act_ttcn3_module) {
9107 act_ttcn3_module->set_location(filename);
9108 set_md5_checksum(act_ttcn3_module);
9109 if (generate_code) act_ttcn3_module->set_gen_code();
9110 modules->add_mod(act_ttcn3_module);
9111 act_ttcn3_module = 0;
9119 Ttcn::ErroneousAttributeSpec* ttcn3_parse_erroneous_attr_spec_string(
9120 const char* p_str, const Common::Location& str_loc)
9122 is_erroneous_parsed = true;
9123 act_ttcn3_erroneous_attr_spec = NULL;
9124 string titan_err_str("$#&&&(#TITANERRONEOUS$#&&^#% ");
9125 int hack_str_len = (int)titan_err_str.size();
9126 string *parsed_string = parse_charstring_value(p_str, str_loc);
9127 titan_err_str += *parsed_string;
9128 delete parsed_string;
9129 init_erroneous_lex(str_loc.get_filename(), str_loc.get_first_line(), str_loc.get_first_column()-hack_str_len+1);
9130 yy_buffer_state *flex_buffer = ttcn3__scan_string(titan_err_str.c_str());
9131 if (flex_buffer == NULL) {
9132 ERROR("Flex buffer creation failed.");
9136 ttcn3_lex_destroy();
9137 free_dot_flag_stuff();
9139 return act_ttcn3_erroneous_attr_spec;
9143 static void yyprint(FILE *file, int type, const YYSTYPE& value)
9147 fprintf(file, "``%s''", value.id->get_name().c_str());
9150 fprintf(file, "%s", value.int_val->t_str().c_str());
9153 fprintf(file, "%f", value.float_val);
9158 case BitStringMatch:
9159 case HexStringMatch:
9160 case OctetStringMatch:
9161 fprintf(file, "``%s''", value.string_val->c_str());
9164 fprintf(file, "``%s''", value.str);