Sync with 5.3.0
[deliverable/titan.core.git] / compiler2 / ttcn3 / compiler.y
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 */
9
10 /* BNF compliance: v3.2.1 with extensions */
11
12 %{
13
14 /* C declarations */
15
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <errno.h>
20
21 #include "../../common/dbgnew.hh"
22 #include "../../common/memory.h"
23
24 #include "../datatypes.h"
25 #include "Attributes.hh"
26 #include "../main.hh"
27 #include "compiler.h"
28
29 #include "../Identifier.hh"
30 #include "Templatestuff.hh"
31 #include "AST_ttcn3.hh"
32 #include "../Type.hh"
33 #include "../CompType.hh"
34 #include "../CompField.hh"
35 #include "../EnumItem.hh"
36 #include "../SigParam.hh"
37
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"
48
49 using namespace Ttcn;
50 using namespace Common;
51
52 const char *infile = NULL;
53
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;
61
62 #ifndef NDEBUG
63
64 union YYSTYPE;
65 static void yyprint(FILE *file, int type, const YYSTYPE& value);
66 #define YYPRINT(f,t,v) yyprint(f,t,v)
67
68 #endif
69
70 extern Modules *modules;
71
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);
78
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();
84
85 extern string *parse_charstring_value(const char *str, const Location& loc);
86 extern PatternString* parse_pattern(const char *str, const Location& loc);
87
88 static const string anyname("anytype");
89
90 /* Various C macros */
91
92 #define YYERROR_VERBOSE
93
94
95 %}
96
97 /* Bison declarations */
98
99 /*********************************************************************
100 * The union-type
101 *********************************************************************/
102
103 %union {
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;
110
111 int_val_t *int_val; /* integer value */
112 Real float_val; /* float value */
113 Identifier *id;
114 string *string_val;
115 ustring *ustring_val;
116
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;
123
124 AltGuard *altguard;
125 AltGuards *altguards;
126 ArrayDimension *arraydimension;
127 AttributeSpec *attributespec;
128 CompField *compfield;
129 CompFieldMap *compfieldmap;
130 Def_Type *deftype;
131 Def_Timer *deftimer;
132 Definition *definition;
133 Definitions *defs;
134 EnumItem *enumitem;
135 EnumItems *enumitems;
136 FieldOrArrayRef *fieldorarrayref;
137 FormalPar *formalpar;
138 FormalParList *formalparlist;
139 Group *group;
140 FriendMod *friendMod;
141 IfClause *ifclause;
142 IfClauses *ifclauses;
143 ImpMod *impmod;
144 LengthRestriction *lenrestr;
145 LogArgument *logarg;
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;
155 OID_comp *oidcomp;
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;
169 Statement *stmt;
170 StatementBlock *statementblock;
171 SubTypeParse *subtypeparse;
172 Template *templ;
173 TemplateInstance *templinst;
174 TemplateInstances *templinsts;
175 Templates *templs;
176 Ttcn::Assignment *ass;
177 Ttcn::Ref_base *refbase;
178 Ttcn::Ref_pard *refpard;
179 Ttcn::Reference *reference;
180 ValueRange *valuerange;
181 Type *type;
182 Types *types;
183 Value *value;
184 Values *values;
185 VariableEntries *variableentries;
186 VariableEntry *variableentry;
187 vector<SubTypeParse> *subtypeparses;
188 CompTypeRefList *comprefs;
189 ComponentTypeBody *compbody;
190 template_restriction_t template_restriction;
191
192 struct {
193 bool is_raw;
194 ErroneousAttributeSpec::indicator_t indicator;
195 } erroneous_indicator;
196
197 struct arraydimension_list_t {
198 size_t nElements;
199 ArrayDimension **elements;
200 } arraydimension_list;
201
202 struct {
203 size_t nElements;
204 FieldOrArrayRef **elements;
205 } fieldorarrayref_list;
206
207 struct {
208 size_t nElements;
209 Ttcn::Definition **elements;
210 } def_list;
211
212 struct {
213 size_t nElements;
214 Ttcn::FriendMod **elements;
215 } friend_list;
216
217 struct {
218 size_t nElements;
219 Statement **elements;
220 } stmt_list;
221
222
223 struct {
224 Value *lower;
225 bool lower_exclusive;
226 Value *upper;
227 bool upper_exclusive;
228 } rangedef;
229
230 struct {
231 Type *type;
232 bool returns_template;
233 template_restriction_t template_restriction;
234 } returntype;
235
236 struct {
237 Type *type;
238 bool no_block_kw;
239 } returntypeornoblock;
240
241 struct {
242 Identifier *id;
243 CompFieldMap* cfm;
244 } structdefbody;
245
246 struct {
247 Type *type;
248 Identifier *id;
249 } structofdefbody;
250
251 struct {
252 Ttcn::Types *in_list, *out_list, *inout_list;
253 bool in_all, out_all, inout_all;
254 } portdefbody;
255
256 struct {
257 Ttcn::Reference *ref;
258 Identifier *id;
259 } ischosenarg;
260
261 struct {
262 bool is_ifpresent;
263 LengthRestriction *len_restr;
264 } extramatchingattrs;
265
266 struct {
267 Identifier *name;
268 Type *type;
269 FormalParList *fp_list;
270 } basetemplate;
271
272 struct {
273 Identifier *modid;
274 Identifier *id;
275 } templateref;
276
277 struct {
278 Ttcn::Ref_pard *ref_pard;
279 Value *derefered_value;
280 ParsedActualParameters *ap_list;
281 Value *value;
282 } testcaseinst;
283
284 struct {
285 Ttcn::Ref_pard *ref_pard;
286 Value *derefered_value;
287 TemplateInstances *ap_list;
288 } activateop;
289
290 struct {
291 TemplateInstance *templ_inst;
292 Value *val;
293 } portsendop;
294
295 struct {
296 Value *calltimerval; // if NULL: see nowait
297 bool nowait;
298 } calltimerval;
299
300 struct {
301 TemplateInstance *templ_inst;
302 Value *calltimerval; // if NULL: see nowait
303 bool nowait;
304 Value *val; // not used in callparams
305 } portcallop;
306
307 struct {
308 TemplateInstance *templ_inst;
309 Value *replyval;
310 Value *toclause;
311 } portreplyop;
312
313 struct {
314 Ttcn::Reference *signature;
315 TemplateInstance *templ_inst;
316 Value *toclause;
317 } portraiseop;
318
319 struct {
320 Ttcn::Reference *redirectval;
321 Ttcn::Reference *redirectsender;
322 } portredirect;
323
324 struct {
325 ParamRedirect *redirectparam;
326 Ttcn::Reference *redirectsender;
327 } portredirectwithparam;
328
329 struct {
330 Ttcn::Reference *redirectval;
331 ParamRedirect *redirectparam;
332 Ttcn::Reference *redirectsender;
333 } portredirectwithvalueandparam;
334
335 struct {
336 TemplateInstance *templ_inst;
337 TemplateInstance *valuematch;
338 } getreplypar;
339
340 struct {
341 TemplateInstance *templ_inst;
342 TemplateInstance *fromclause;
343 Ttcn::Reference *redirectval;
344 Ttcn::Reference *redirectsender;
345 } portreceiveop;
346
347 struct {
348 TemplateInstance *templ_inst;
349 TemplateInstance *fromclause;
350 ParamRedirect *redirectparam;
351 Ttcn::Reference *redirectsender;
352 } portgetcallop;
353
354 struct {
355 TemplateInstance *templ_inst;
356 TemplateInstance *valuematch;
357 TemplateInstance *fromclause;
358 Ttcn::Reference *redirectval;
359 ParamRedirect *redirectparam;
360 Ttcn::Reference *redirectsender;
361 } portgetreplyop;
362
363 struct {
364 Ttcn::Reference *signature;
365 TemplateInstance *templ_inst;
366 bool timeout;
367 } catchoppar;
368
369 struct {
370 Ttcn::Reference *signature;
371 TemplateInstance *templ_inst;
372 bool timeout;
373 TemplateInstance *fromclause;
374 Ttcn::Reference *redirectval;
375 Ttcn::Reference *redirectsender;
376 } portcatchop;
377
378 struct {
379 Statement::statementtype_t statementtype;
380 Ttcn::Reference *signature;
381 TemplateInstance *templ_inst;
382 TemplateInstance *valuematch;
383 bool timeout;
384 TemplateInstance *fromclause;
385 Ttcn::Reference *redirectval;
386 ParamRedirect *redirectparam;
387 Ttcn::Reference *redirectsender;
388 } portcheckop;
389
390 struct {
391 Value *compref;
392 Ttcn::Reference *portref;
393 } portref;
394
395 struct {
396 Value *compref1;
397 Ttcn::Reference *portref1;
398 Value *compref2;
399 Ttcn::Reference *portref2;
400 } connspec;
401
402 struct {
403 TemplateInstance *donematch;
404 Ttcn::Reference *redirect;
405 } donepar;
406
407 struct {
408 bool is_ref;
409 union {
410 Ttcn::Reference *ref;
411 Identifier *id;
412 };
413 } reforid;
414
415 struct {
416 Definitions *defs;
417 Ttcn::Assignment *ass;
418 } initial;
419
420 struct {
421 Ttcn::Reference *runsonref;
422 Ttcn::Reference *systemref;
423 } configspec;
424
425 struct {
426 Value *name;
427 Value *loc;
428 } createpar;
429
430 struct {
431 Value *value;
432 ParsedActualParameters *ap_list;
433 } applyop;
434
435
436 struct extconstidentifier_t {
437 Identifier *id;
438 YYLTYPE yyloc;
439 } extconstidentifier;
440
441 struct {
442 size_t nElements;
443 extconstidentifier_t *elements;
444 } identifier_list;
445
446 struct singlevarinst_t {
447 Identifier *id;
448 arraydimension_list_t arrays;
449 Value *initial_value;
450 YYLTYPE yyloc;
451 } singlevarinst;
452
453 struct singlevarinst_list_t {
454 size_t nElements;
455 struct singlevarinst_t *elements;
456 } singlevarinst_list;
457
458 struct singletempvarinst_t {
459 Identifier *id;
460 arraydimension_list_t arrays;
461 Template *initial_value;
462 YYLTYPE yyloc;
463 } singletempvarinst;
464
465 struct singletempvarinst_list_t {
466 size_t nElements;
467 singletempvarinst_t *elements;
468 } singletempvarinst_list;
469
470 struct singlemodulepar_t {
471 Identifier *id;
472 Value *defval;
473 YYLTYPE yyloc;
474 } singlemodulepar;
475
476 struct singletemplatemodulepar_t {
477 Identifier *id;
478 Template *deftempl;
479 YYLTYPE yyloc;
480 } singletemplatemodulepar;
481
482 struct singlemodulepar_list_t {
483 size_t nElements;
484 singlemodulepar_t *elements;
485 } singlemodulepar_list;
486
487 struct singletemplatemodulepar_list_t {
488 size_t nElements;
489 singletemplatemodulepar_t *elements;
490 } singletemplatemodulepar_list;
491
492 struct portelement_t {
493 Identifier *id;
494 ArrayDimensions *dims;
495 YYLTYPE yyloc;
496 } portelement;
497
498 struct portelement_list_t {
499 size_t nElements;
500 portelement_t *elements;
501 } portelement_list;
502
503 struct runs_on_compref_or_self_t {
504 bool self;
505 Ttcn::Reference *reference;
506 } runs_on_compref_or_self;
507
508 struct {
509 visibility_t visibility;
510 } visbilitytype;
511 }
512
513 /* Tokens of TTCN-3 */
514
515 /*********************************************************************
516 * Tokens with semantic value
517 *********************************************************************/
518
519 /* Terminals with semantic value */
520
521 %token <int_val> Number
522 %token <float_val> FloatValue
523 %token <id> IDentifier "Identifier"
524
525 %token <string_val> Bstring
526 Hstring
527 Ostring
528 BitStringMatch
529 HexStringMatch
530 OctetStringMatch
531 %token <str> Cstring
532 %token NullValue "ASN.1_NULL_value"
533 %token <macrotype> MacroValue
534
535 /*********************************************************************
536 * Tokens without semantic value
537 *********************************************************************/
538
539 /* Terminals without semantic value - keywords, operators, etc. */
540
541 %token TOK_errval "erroneous_value"
542
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
550 %token ActionKeyword
551 %token ActivateKeyword
552 %token AddressKeyword
553 %token AliveKeyword
554 %token AllKeyword
555 %token AltKeyword
556 %token AltstepKeyword
557 %token AndKeyword
558 %token And4bKeyword
559 %token AnyKeyword
560 %token AnyTypeKeyword
561 %token ApplyKeyword
562 %token BitStringKeyword
563 %token BooleanKeyword
564 %token BreakKeyword
565 %token CallOpKeyword
566 %token CaseKeyword
567 %token CatchOpKeyword
568 %token CharKeyword
569 %token CharStringKeyword
570 %token CheckOpKeyword
571 %token ClearOpKeyword
572 %token ComplementKeyword
573 %token ComponentKeyword
574 %token ConnectKeyword
575 %token ConstKeyword
576 %token ContinueKeyword
577 %token ControlKeyword
578 %token CreateKeyword
579 %token DeactivateKeyword
580 %token DefaultKeyword
581 %token DerefersKeyword
582 %token DisconnectKeyword
583 %token DisplayKeyword
584 %token DoKeyword
585 %token DoneKeyword
586 %token ElseKeyword
587 %token EncodeKeyword
588 %token EnumKeyword
589 %token ErrorKeyword
590 %token ExceptKeyword
591 %token ExceptionKeyword
592 %token ExecuteKeyword
593 %token ExtendsKeyword
594 %token ExtensionKeyword
595 %token ExtKeyword
596 %token FailKeyword
597 %token FalseKeyword
598 %token FloatKeyword
599 %token ForKeyword
600 %token FriendKeyword
601 %token FromKeyword
602 %token FunctionKeyword
603 %token GetCallOpKeyword
604 %token GetReplyOpKeyword
605 %token GetVerdictKeyword
606 %token GotoKeyword
607 %token GroupKeyword
608 %token HaltKeyword
609 %token HexStringKeyword
610 %token IfKeyword
611 %token IfPresentKeyword
612 %token ImportKeyword
613 %token InconcKeyword
614 %token InfinityKeyword
615 %token InOutParKeyword
616 %token InParKeyword
617 %token IntegerKeyword
618 %token InterleavedKeyword
619 %token KillKeyword
620 %token KilledKeyword
621 %token LabelKeyword
622 %token LanguageKeyword
623 %token LengthKeyword
624 %token LogKeyword
625 %token MapKeyword
626 %token MatchKeyword
627 %token MessageKeyword
628 %token MixedKeyword
629 %token ModKeyword
630 %token ModifiesKeyword
631 %token ModuleParKeyword
632 %token MTCKeyword
633 %token NaNKeyword
634 %token NoBlockKeyword
635 %token NoneKeyword
636 %token NotKeyword
637 %token Not4bKeyword
638 %token NowaitKeyword
639 %token NullKeyword
640 %token ObjectIdentifierKeyword
641 %token OctetStringKeyword
642 %token OfKeyword
643 %token OmitKeyword
644 %token OnKeyword
645 %token OptionalKeyword
646 %token OrKeyword
647 %token Or4bKeyword
648 %token OutParKeyword
649 %token OverrideKeyword
650 %token PassKeyword
651 %token ParamKeyword
652 %token PatternKeyword
653 %token PermutationKeyword
654 %token PresentKeyword
655 %token PortKeyword
656 %token PrivateKeyword
657 %token ProcedureKeyword
658 %token PublicKeyword
659 %token RaiseKeyword
660 %token ReadKeyword
661 %token ReceiveOpKeyword
662 %token RecordKeyword
663 %token RecursiveKeyword
664 %token RefersKeyword
665 %token RemKeyword
666 %token RepeatKeyword
667 %token ReplyKeyword
668 %token ReturnKeyword
669 %token RunningKeyword
670 %token RunsKeyword
671 %token SelectKeyword
672 %token SelfKeyword
673 %token SenderKeyword
674 %token SendOpKeyword
675 %token SetKeyword
676 %token SetVerdictKeyword
677 %token SignatureKeyword
678 %token StartKeyword
679 %token StopKeyword
680 %token SubsetKeyword
681 %token SupersetKeyword
682 %token SystemKeyword
683 %token TemplateKeyword
684 %token TestcaseKeyword
685 %token TimeoutKeyword
686 %token TimerKeyword
687 %token ToKeyword
688 %token TriggerOpKeyword
689 %token TrueKeyword
690 %token TTCN3ModuleKeyword
691 %token TypeDefKeyword
692 %token UnionKeyword
693 %token UniversalKeyword
694 %token UnmapKeyword
695 %token ValueKeyword
696 %token ValueofKeyword
697 %token VarKeyword
698 %token VariantKeyword
699 %token VerdictTypeKeyword
700 %token WhileKeyword
701 %token WithKeyword
702 %token XorKeyword
703 %token Xor4bKeyword
704
705 /* TITAN specific keywords */
706 %token TitanSpecificTryKeyword
707 %token TitanSpecificCatchKeyword
708 %token TitanSpecificLazyKeyword
709 %token TitanSpecificProfilerKeyword
710
711 /* Keywords combined with a leading dot */
712
713 /* If a '.' (dot) character is followed by one of the keywords below the
714 * lexical analyzer shall return one combined token instead of two distinct
715 * tokens. This eliminates the ambiguity that causes additional shift/reduce
716 * conflicts because the dot can be either the part of a field reference or a
717 * built-in operation denoted by a keyword. */
718
719 %token DotAliveKeyword
720 %token DotApplyKeyword
721 %token DotCallOpKeyword
722 %token DotCatchOpKeyword
723 %token DotCheckOpKeyword
724 %token DotClearOpKeyword
725 %token DotCreateKeyword
726 %token DotDoneKeyword
727 %token DotGetCallOpKeyword
728 %token DotGetReplyOpKeyword
729 %token DotHaltKeyword
730 %token DotKillKeyword
731 %token DotKilledKeyword
732 %token DotRaiseKeyword
733 %token DotReadKeyword
734 %token DotReceiveOpKeyword
735 %token DotReplyKeyword
736 %token DotRunningKeyword
737 %token DotSendOpKeyword
738 %token DotStartKeyword
739 %token DotStopKeyword
740 %token DotTimeoutKeyword
741 %token DotTriggerOpKeyword
742
743 /* Predefined function identifiers */
744
745 %token bit2hexKeyword
746 %token bit2intKeyword
747 %token bit2octKeyword
748 %token bit2strKeyword
749 %token char2intKeyword
750 %token char2octKeyword
751 %token decompKeyword
752 %token float2intKeyword
753 %token hex2bitKeyword
754 %token hex2intKeyword
755 %token hex2octKeyword
756 %token hex2strKeyword
757 %token int2bitKeyword
758 %token int2charKeyword
759 %token int2floatKeyword
760 %token int2hexKeyword
761 %token int2octKeyword
762 %token int2strKeyword
763 %token int2unicharKeyword
764 %token isvalueKeyword
765 %token isboundKeyword
766 %token ischosenKeyword
767 %token ispresentKeyword
768 %token lengthofKeyword
769 %token oct2bitKeyword
770 %token oct2charKeyword
771 %token oct2hexKeyword
772 %token oct2intKeyword
773 %token oct2strKeyword
774 %token oct2unicharKeyword
775 %token regexpKeyword
776 %token replaceKeyword
777 %token rndKeyword
778 %token testcasenameKeyword
779 %token sizeofKeyword
780 %token str2floatKeyword
781 %token str2intKeyword
782 %token str2octKeyword
783 %token substrKeyword
784 %token unichar2intKeyword
785 %token unichar2charKeyword
786 %token unichar2octKeyword
787
788 %token float2strKeyword
789 %token str2bitKeyword
790 %token str2hexKeyword
791
792 %token log2strKeyword
793 %token enum2intKeyword
794
795 %token encvalueKeyword
796 %token decvalueKeyword
797
798 %token ttcn2stringKeyword
799 %token string2ttcnKeyword
800 %token remove_bomKeyWord
801 %token get_stringencodingKeyWord
802 %token encode_base64KeyWord
803 %token decode_base64KeyWord
804
805 /* Multi-character operators */
806
807 %token AssignmentChar ":="
808 %token DotDot ".."
809 %token PortRedirectSymbol "->"
810 %token EQ "=="
811 %token NE "!="
812 %token GE ">="
813 %token LE "<="
814 %token SL "<<"
815 %token SR ">>"
816 %token RL "<@"
817 %token _RR "@>" /* Name clash with bn.h:292 */
818
819 /*********************************************************************
820 * Semantic types of nonterminals
821 *********************************************************************/
822
823 %type <bool_val> optAliveKeyword optOptionalKeyword optOverrideKeyword
824 optErrValueRaw optAllKeyword optLazyEval
825 %type <str> FreeText optLanguageSpec PatternChunk PatternChunkList
826 %type <uchar_val> Group Plane Row Cell
827 %type <id> FieldIdentifier FieldReference GlobalModuleId
828 IdentifierOrAddressKeyword StructFieldRef PredefOrIdentifier
829 %type <string_val> CstringList
830 %type <ustring_val> Quadruple
831
832 %type <typetype> PredefinedType
833 %type <portoperationmode> PortOperationMode
834 %type <operationtype> PredefinedOpKeyword1 PredefinedOpKeyword2 PredefinedOpKeyword3
835
836 %type <activateop> ActivateOp
837 %type <attribtype> AttribKeyword
838
839 %type <altguard> CallBodyStatement AltGuard ElseStatement GuardStatement
840 InterleavedGuardElement
841 %type <altguards> AltGuardList CallBodyStatementList InterleavedGuardList
842 optPortCallBody
843 %type <arraydimension> ArrayIndex
844 %type <attributespec> AttribSpec
845 %type <compbody> optComponentDefList ComponentElementDefList
846 %type <compfield> StructFieldDef UnionFieldDef
847 %type <compfieldmap> StructFieldDefList optStructFieldDefList UnionFieldDefList
848 %type <definition> AltstepDef ExtFunctionDef FunctionDef TemplateDef TestcaseDef
849 %type <deftype> TypeDefBody StructuredTypeDef SubTypeDef RecordDef UnionDef
850 SetDef RecordOfDef SetOfDef EnumDef PortDef PortDefBody ComponentDef
851 TypeDef SignatureDef FunctionTypeDef AltstepTypeDef TestcaseTypeDef
852 %type <deftimer> SingleTimerInstance
853 %type <enumitem> Enumeration
854 %type <enumitems> EnumerationList
855 %type <fieldorarrayref> ArrayOrBitRef ArrayOrBitRefOrDash FieldOrArrayReference
856 %type <formalpar> FormalValuePar FormalTemplatePar FormalTimerPar
857 TemplateFormalPar FunctionFormalPar TestcaseFormalPar
858 %type <formalparlist> optTemplateFormalParList TemplateFormalParList
859 optFunctionFormalParList FunctionFormalParList optTestcaseFormalParList
860 TestcaseFormalParList optAltstepFormalParList
861 %type <group> GroupDef GroupIdentifier
862 %type <friend_list> FriendModuleDef
863 %type <ifclause> ElseIfClause
864 %type <ifclauses> seqElseIfClause
865 %type <impmod> ImportFromSpec ModuleId ImportDef
866 %type <lenrestr> optStringLength LengthMatch StringLength
867 %type <logarg> LogItem
868 %type <logargs> LogItemList
869 %type <multiwithattrib> MultiWithAttrib WithAttribList WithStatement
870 optWithStatement optWithStatementAndSemiColon
871 %type <namedtempl> FieldSpec
872 %type <namedtempls> seqFieldSpec
873 %type <namedvalue> FieldExpressionSpec
874 %type <namedvalues> seqFieldExpressionSpec
875 %type <indexedtempl> ArraySpec
876 %type <indexedtempls> seqArraySpec
877 %type <indexedvalue> ArrayExpressionSpec
878 %type <oidcomp> NumberForm NameAndNumberForm ObjIdComponent
879 %type <parass> VariableAssignment
880 %type <parasss> AssignmentList
881 %type <parredir> ParamAssignmentList ParamSpec
882 %type <patstr> CharStringMatch
883 %type <qualifier> DefOrFieldRef FullGroupIdentifier
884 %type <qualifiers> DefOrFieldRefList optAttribQualifier
885 %type <selectcase> SelectCase
886 %type <selectcases> seqSelectCase SelectCaseBody
887 %type <signexc> ExceptionTypeList optExceptionSpec
888 %type <signparam> SignatureFormalPar
889 %type <signparamlist> SignatureFormalParList optSignatureFormalParList
890 %type <singlewithattrib> SingleWithAttrib
891 %type <stmt> AltConstruct BasicStatements BreakStatement BehaviourStatements
892 CallBodyOps CallStatement CatchStatement CheckStatement ClearStatement
893 CommunicationStatements ConditionalConstruct ConfigurationStatements
894 ConnectStatement ContinueStatement ControlStatement DeactivateStatement
895 DisconnectStatement DoWhileStatement DoneStatement ForStatement
896 FunctionStatement GetCallStatement GetReplyStatement GotoStatement GuardOp
897 HaltStatement InterleavedConstruct KillTCStatement KilledStatement
898 LabelStatement LogStatement LoopConstruct MapStatement RaiseStatement
899 ReceiveStatement RepeatStatement ReplyStatement ReturnStatement SUTStatements
900 SendStatement SetLocalVerdict StartStatement StartTCStatement
901 StartTimerStatement StopExecutionStatement StopStatement StopTCStatement
902 StopTimerStatement TimeoutStatement TimerStatements TriggerStatement
903 UnmapStatement VerdictStatements WhileStatement SelectCaseConstruct
904 StopTestcaseStatement String2TtcnStatement ProfilerStatement
905 %type <statementblock> StatementBlock optElseClause FunctionStatementOrDefList
906 ControlStatementOrDefList ModuleControlBody
907 %type <subtypeparse> ValueOrRange
908 %type <templ> MatchingSymbol SingleValueOrAttrib SimpleSpec TemplateBody
909 ArrayElementSpec ArrayValueOrAttrib FieldSpecList ArraySpecList
910 AllElementsFrom TemplateListElem
911 %type <templinst> AddressRef FromClause FunctionActualPar InLineTemplate
912 ReceiveParameter SendParameter TemplateActualPar TemplateInstance
913 /* TestcaseActualPar */ ValueMatchSpec optFromClause optParDefaultValue
914 optReceiveParameter
915 %type <parsedpar> FunctionActualParList TestcaseActualParList
916 optFunctionActualParList optTestcaseActualParList
917 NamedPart UnnamedPart
918 %type <templinsts> optTemplateActualParList
919 seqTemplateActualPar seqTemplateInstance
920 %type <templs> ValueOrAttribList seqValueOrAttrib ValueList Complement
921 ArrayElementSpecList SubsetMatch SupersetMatch PermutationMatch
922 %type <ass> Assignment Step
923 %type <refbase> DerivedRefWithParList TemplateRefWithParList DecValueArg
924 %type <refpard> FunctionInstance AltstepInstance
925 %type <reference> PortType optDerivedDef DerivedDef Signature VariableRef
926 TimerRef TimerRefOrAny Port PortOrAny PortOrAll ValueSpec
927 SenderSpec ComponentType optRunsOnSpec RunsOnSpec optSystemSpec
928 %type <valuerange> Range
929 %type <type> NestedEnumDef NestedRecordDef NestedRecordOfDef NestedSetDef
930 NestedSetOfDef NestedTypeDef NestedUnionDef PortDefAttribs ReferencedType
931 Type TypeOrNestedTypeDef NestedFunctionTypeDef NestedAltstepTypeDef
932 NestedTestcaseTypeDef
933 %type <types> TypeList AllOrTypeList
934 %type <value> AddressValue AliveOp AllPortsSpec AltGuardChar ArrayBounds
935 ArrayExpression ArrayExpressionList BitStringValue BooleanExpression
936 BooleanValue CharStringValue ComponentRef ComponentReferenceOrLiteral
937 ComponentOrDefaultReference CompoundExpression ConfigurationOps CreateOp
938 DereferOp Expression FieldExpressionList Final GetLocalVerdict HexStringValue
939 IntegerValue LowerBound MTCOp MatchOp NotUsedOrExpression ObjIdComponentList
940 ObjectIdentifierValue OctetStringValue OmitValue OpCall PredefinedOps
941 PredefinedValue ReadTimerOp ReferOp ReferencedValue RunningOp RunningTimerOp
942 SelfOp SingleExpression SingleLowerBound SystemOp TemplateOps TimerOps
943 TimerValue UpperBound Value ValueofOp VerdictOps VerdictValue optReplyValue
944 optTestcaseTimerValue optToClause ProfilerRunningOp
945 %type <values> ArrayElementExpressionList seqArrayExpressionSpec
946 %type <variableentries> VariableList
947 %type <variableentry> VariableEntry
948 %type <subtypeparses> seqValueOrRange AllowedValues optSubTypeSpec
949
950 %type <arraydimension_list> optArrayDef
951 %type <fieldorarrayref_list> optExtendedFieldReference
952 %type <def_list> AltstepLocalDef AltstepLocalDefList ComponentElementDef
953 ConstDef ExtConstDef FunctionLocalDef FunctionLocalInst ModuleDef ModulePar
954 ModuleParDef MultiTypedModuleParList PortInstance TimerInstance TimerList
955 VarInstance
956 %type <stmt_list> FunctionStatementOrDef ControlStatementOrDef
957
958 %type <rangedef> RangeDef
959 %type <returntype> optReturnType
960 %type <returntypeornoblock> optReturnTypeOrNoBlockKeyword
961 %type <structdefbody> StructDefBody UnionDefBody
962 %type <structofdefbody> StructOfDefBody
963 %type <portdefbody> PortDefList seqPortDefList PortDefLists
964 %type <ischosenarg> IschosenArg
965 %type <extramatchingattrs> optExtraMatchingAttributes
966 %type <basetemplate> BaseTemplate
967 %type <templateref> TemplateRef TestcaseRef FunctionRef
968 %type <testcaseinst> TestcaseInstance
969 %type <portsendop> PortSendOp
970 %type <calltimerval> CallTimerValue
971 %type <portcallop> PortCallOp CallParameters
972 %type <portreplyop> PortReplyOp
973 %type <portraiseop> PortRaiseOp
974 %type <portredirect> optPortRedirect
975 %type <portredirectwithparam> optPortRedirectWithParam
976 %type <portredirectwithvalueandparam> optPortRedirectWithValueAndParam
977 %type <getreplypar> optGetReplyParameter
978 %type <portreceiveop> PortReceiveOp PortTriggerOp
979 %type <portgetcallop> PortGetCallOp
980 %type <portgetreplyop> PortGetReplyOp
981 %type <catchoppar> optCatchOpParameter CatchOpParameter
982 %type <portcatchop> PortCatchOp
983 %type <portcheckop> optCheckParameter CheckParameter CheckPortOpsPresent
984 FromClausePresent RedirectPresent
985 %type <portref> PortRef AllConnectionsSpec
986 %type <connspec> SingleConnectionSpec SingleOrMultiConnectionSpec
987 %type <donepar> optDoneParameter
988 %type <reforid> Reference
989 %type <initial> Initial
990 %type <configspec> ConfigSpec
991 %type <createpar> optCreateParameter
992 %type <applyop> ApplyOp
993 %type <identifier_list> IdentifierList
994 %type <singlevarinst> SingleConstDef SingleVarInstance
995 %type <singlevarinst_list> ConstList VarList
996 %type <singletempvarinst> SingleTempVarInstance
997 %type <singletempvarinst_list> TempVarList
998 %type <singlemodulepar> SingleModulePar
999 %type <singletemplatemodulepar> SingleTemplateModulePar
1000 %type <singlemodulepar_list> ModuleParList
1001 %type <singletemplatemodulepar_list> TemplateModuleParList
1002 %type <portelement> PortElement
1003 %type <portelement_list> PortElementList
1004 %type <comprefs> optExtendsDef ComponentTypeList
1005 %type <runs_on_compref_or_self> optRunsOnComprefOrSelf
1006 %type <template_restriction> TemplateRestriction optTemplateRestriction
1007 TemplateOptRestricted
1008 %type <visbilitytype> optVisibility ComponentElementVisibility
1009 %type <float_val> FloatOrSpecialFloatValue
1010 %type <erroneous_indicator> ErroneousIndicator
1011 %type <imptype> ImportSpec ImportElement
1012
1013 /*********************************************************************
1014 * Destructors
1015 *********************************************************************/
1016
1017 %destructor {
1018 act_group = $$->get_parent_group();
1019 }
1020 GroupDef
1021 GroupIdentifier
1022
1023 %destructor {Free($$);}
1024 Cstring
1025 FreeText
1026 optLanguageSpec
1027 PatternChunk
1028 PatternChunkList
1029
1030 %destructor {
1031 delete $$.ref_pard;
1032 delete $$.derefered_value;
1033 delete $$.ap_list;
1034 }
1035 ActivateOp
1036
1037 %destructor {delete $$;}
1038 AddressRef
1039 AddressValue
1040 AliveOp
1041 AllOrTypeList
1042 AllPortsSpec
1043 AltConstruct
1044 AltGuard
1045 AltGuardChar
1046 AltGuardList
1047 AltstepDef
1048 AltstepInstance
1049 AltstepTypeDef
1050 ArrayBounds
1051 ArrayElementExpressionList
1052 ArrayElementSpec
1053 ArrayElementSpecList
1054 ArrayExpression
1055 ArrayIndex
1056 ArrayOrBitRef
1057 ArrayOrBitRefOrDash
1058 ArrayValueOrAttrib
1059 Assignment
1060 AssignmentList
1061 AttribSpec
1062 BasicStatements
1063 BehaviourStatements
1064 BitStringMatch
1065 BitStringValue
1066 BooleanExpression
1067 BooleanValue
1068 BreakStatement
1069 Bstring
1070 CallBodyOps
1071 CallBodyStatement
1072 CallBodyStatementList
1073 CallStatement
1074 CatchStatement
1075 CharStringMatch
1076 CharStringValue
1077 CheckStatement
1078 ClearStatement
1079 CommunicationStatements
1080 Complement
1081 ComponentDef
1082 ComponentElementDefList
1083 ComponentOrDefaultReference
1084 ComponentRef
1085 ComponentReferenceOrLiteral
1086 ComponentType
1087 ComponentTypeList
1088 CompoundExpression
1089 ConditionalConstruct
1090 ConfigurationOps
1091 ConfigurationStatements
1092 ConnectStatement
1093 ContinueStatement
1094 ControlStatement
1095 ControlStatementOrDefList
1096 CreateOp
1097 DeactivateStatement
1098 DefOrFieldRef
1099 DefOrFieldRefList
1100 DereferOp
1101 DerivedDef
1102 DerivedRefWithParList
1103 DisconnectStatement
1104 DoWhileStatement
1105 DoneStatement
1106 ElseIfClause
1107 ElseStatement
1108 EnumDef
1109 Enumeration
1110 EnumerationList
1111 ExceptionTypeList
1112 Expression
1113 FieldExpressionList
1114 FieldExpressionSpec
1115 FieldIdentifier
1116 FieldOrArrayReference
1117 FieldReference
1118 FieldSpec
1119 FieldSpecList
1120 Final
1121 ForStatement
1122 FormalTemplatePar
1123 FormalTimerPar
1124 FormalValuePar
1125 FromClause
1126 FullGroupIdentifier
1127 FunctionActualPar
1128 FunctionActualParList
1129 FunctionDef
1130 FunctionFormalPar
1131 FunctionFormalParList
1132 FunctionInstance
1133 FunctionStatement
1134 FunctionStatementOrDefList
1135 FunctionTypeDef
1136 GetCallStatement
1137 GetLocalVerdict
1138 GetReplyStatement
1139 GlobalModuleId
1140 GotoStatement
1141 GuardOp
1142 GuardStatement
1143 HaltStatement
1144 HexStringMatch
1145 HexStringValue
1146 Hstring
1147 IDentifier
1148 IdentifierOrAddressKeyword
1149 ImportFromSpec
1150 InLineTemplate
1151 IntegerValue
1152 InterleavedConstruct
1153 InterleavedGuardElement
1154 InterleavedGuardList
1155 KillTCStatement
1156 KilledStatement
1157 LabelStatement
1158 LengthMatch
1159 LogItem
1160 LogItemList
1161 LogStatement
1162 String2TtcnStatement
1163 LoopConstruct
1164 LowerBound
1165 MTCOp
1166 MapStatement
1167 MatchOp
1168 MatchingSymbol
1169 ModuleControlBody
1170 ModuleId
1171 MultiWithAttrib
1172 NamedPart
1173 NameAndNumberForm
1174 NestedAltstepTypeDef
1175 NestedEnumDef
1176 NestedFunctionTypeDef
1177 NestedRecordDef
1178 NestedRecordOfDef
1179 NestedSetDef
1180 NestedSetOfDef
1181 NestedTestcaseTypeDef
1182 NestedTypeDef
1183 NestedUnionDef
1184 NotUsedOrExpression
1185 Number
1186 NumberForm
1187 ObjIdComponent
1188 ObjIdComponentList
1189 ObjectIdentifierValue
1190 OctetStringMatch
1191 OctetStringValue
1192 OmitValue
1193 OpCall
1194 Ostring
1195 ParamAssignmentList
1196 ParamSpec
1197 PermutationMatch
1198 Port
1199 PortDef
1200 PortDefAttribs
1201 PortDefBody
1202 PortOrAll
1203 PortOrAny
1204 PortType
1205 PredefOrIdentifier
1206 PredefinedOps
1207 PredefinedValue
1208 ProfilerRunningOp
1209 ProfilerStatement
1210 RaiseStatement
1211 Range
1212 ReadTimerOp
1213 ReceiveParameter
1214 ReceiveStatement
1215 RecordDef
1216 RecordOfDef
1217 ReferOp
1218 ReferencedType
1219 ReferencedValue
1220 RepeatStatement
1221 ReplyStatement
1222 ReturnStatement
1223 RunningOp
1224 RunningTimerOp
1225 RunsOnSpec
1226 SUTStatements
1227 SelfOp
1228 SendParameter
1229 SendStatement
1230 SenderSpec
1231 SetDef
1232 SetLocalVerdict
1233 SetOfDef
1234 Signature
1235 SignatureDef
1236 SignatureFormalPar
1237 SignatureFormalParList
1238 SimpleSpec
1239 SingleExpression
1240 SingleLowerBound
1241 SingleTimerInstance
1242 SingleValueOrAttrib
1243 SingleWithAttrib
1244 DecValueArg
1245 StartStatement
1246 StartTCStatement
1247 StartTimerStatement
1248 StatementBlock
1249 Step
1250 StopExecutionStatement
1251 StopTestcaseStatement
1252 StopStatement
1253 StopTCStatement
1254 StopTimerStatement
1255 StringLength
1256 StructFieldDef
1257 StructFieldDefList
1258 StructFieldRef
1259 StructuredTypeDef
1260 SubTypeDef
1261 SubsetMatch
1262 SupersetMatch
1263 SystemOp
1264 TemplateActualPar
1265 TemplateBody
1266 TemplateDef
1267 TemplateFormalPar
1268 TemplateFormalParList
1269 TemplateInstance
1270 TemplateOps
1271 TemplateRefWithParList
1272 /* TestcaseActualPar */
1273 TestcaseActualParList
1274 TestcaseDef
1275 TestcaseFormalPar
1276 TestcaseFormalParList
1277 TestcaseTypeDef
1278 TimeoutStatement
1279 TimerOps
1280 TimerRef
1281 TimerRefOrAny
1282 TimerStatements
1283 TimerValue
1284 TriggerStatement
1285 Type
1286 TypeDef
1287 TypeDefBody
1288 TypeList
1289 TypeOrNestedTypeDef
1290 UnionDef
1291 UnionFieldDef
1292 UnionFieldDefList
1293 UnmapStatement
1294 UnnamedPart
1295 UpperBound
1296 Value
1297 ValueList
1298 ValueMatchSpec
1299 ValueOrAttribList
1300 ValueOrRange
1301 ValueSpec
1302 ValueofOp
1303 VariableAssignment
1304 VariableEntry
1305 VariableList
1306 VariableRef
1307 VerdictOps
1308 VerdictStatements
1309 VerdictValue
1310 WhileStatement
1311 WithAttribList
1312 WithStatement
1313 optAltstepFormalParList
1314 optAttribQualifier
1315 optComponentDefList
1316 optDerivedDef
1317 optElseClause
1318 optExceptionSpec
1319 optExtendsDef
1320 optFromClause
1321 optFunctionActualParList
1322 optFunctionFormalParList
1323 optParDefaultValue
1324 optPortCallBody
1325 optReceiveParameter
1326 optReplyValue
1327 optRunsOnSpec
1328 optSignatureFormalParList
1329 optStringLength
1330 optStructFieldDefList
1331 optSystemSpec
1332 optTemplateActualParList
1333 optTemplateFormalParList
1334 optTestcaseActualParList
1335 optTestcaseFormalParList
1336 optTestcaseTimerValue
1337 optToClause
1338 optWithStatement
1339 optWithStatementAndSemiColon
1340 seqElseIfClause
1341 seqFieldExpressionSpec
1342 seqFieldSpec
1343 seqTemplateActualPar
1344 seqTemplateInstance
1345 seqValueOrAttrib
1346 Quadruple
1347
1348 %destructor {
1349 for (size_t i = 0; i < $$->size(); i++) delete (*$$)[i];
1350 $$->clear();
1351 delete $$;
1352 }
1353 AllowedValues
1354 optSubTypeSpec
1355 seqValueOrRange
1356
1357 %destructor {
1358 for(size_t i=0; i<$$.nElements; i++) delete $$.elements[i];
1359 Free($$.elements);
1360 }
1361 AltstepLocalDef
1362 AltstepLocalDefList
1363 ComponentElementDef
1364 ConstDef
1365 ControlStatementOrDef
1366 ExtConstDef
1367 FunctionLocalDef
1368 FunctionLocalInst
1369 FunctionStatementOrDef
1370 ModuleDef
1371 ModulePar
1372 ModuleParDef
1373 MultiTypedModuleParList
1374 PortInstance
1375 TimerInstance
1376 TimerList
1377 VarInstance
1378 optArrayDef
1379 optExtendedFieldReference
1380 FriendModuleDef
1381
1382 %destructor {
1383 delete $$.lower;
1384 delete $$.upper;
1385 }
1386 RangeDef
1387
1388 %destructor {
1389 delete $$.type;
1390 }
1391 optReturnType
1392 optReturnTypeOrNoBlockKeyword
1393
1394 %destructor {
1395 delete $$.id;
1396 delete $$.cfm;
1397 }
1398 StructDefBody
1399 UnionDefBody
1400
1401 %destructor {
1402 delete $$.type;
1403 delete $$.id;
1404 }
1405 StructOfDefBody
1406
1407 %destructor {
1408 delete $$.in_list;
1409 delete $$.out_list;
1410 delete $$.inout_list;
1411 }
1412 PortDefList
1413 PortDefLists
1414 seqPortDefList
1415
1416 %destructor {
1417 delete $$.ref;
1418 delete $$.id;
1419 }
1420 IschosenArg
1421
1422 %destructor {
1423 delete $$.len_restr;
1424 }
1425 optExtraMatchingAttributes
1426
1427 %destructor {
1428 delete $$.name;
1429 delete $$.type;
1430 delete $$.fp_list;
1431 }
1432 BaseTemplate
1433
1434 %destructor {
1435 delete $$.modid;
1436 delete $$.id;
1437 }
1438 FunctionRef
1439 TemplateRef
1440 TestcaseRef
1441
1442 %destructor {
1443 delete $$.ref_pard;
1444 delete $$.derefered_value;
1445 delete $$.ap_list;
1446 delete $$.value;
1447 }
1448 TestcaseInstance
1449
1450 %destructor {
1451 delete $$.templ_inst;
1452 delete $$.val;
1453 }
1454 PortSendOp
1455
1456 %destructor {
1457 delete $$.calltimerval;
1458 }
1459 CallTimerValue
1460
1461 %destructor {
1462 delete $$.templ_inst;
1463 delete $$.calltimerval;
1464 delete $$.val;
1465 }
1466 PortCallOp CallParameters
1467
1468 %destructor {
1469 delete $$.templ_inst;
1470 delete $$.replyval;
1471 delete $$.toclause;
1472 }
1473 PortReplyOp
1474
1475 %destructor {
1476 delete $$.signature;
1477 delete $$.templ_inst;
1478 delete $$.toclause;
1479 }
1480 PortRaiseOp
1481
1482 %destructor {
1483 delete $$.redirectval;
1484 delete $$.redirectsender;
1485 }
1486 optPortRedirect
1487
1488 %destructor {
1489 delete $$.redirectparam;
1490 delete $$.redirectsender;
1491 }
1492 optPortRedirectWithParam
1493
1494 %destructor {
1495 delete $$.redirectval;
1496 delete $$.redirectparam;
1497 delete $$.redirectsender;
1498 }
1499 optPortRedirectWithValueAndParam
1500
1501 %destructor {
1502 delete $$.templ_inst;
1503 delete $$.valuematch;
1504 }
1505 optGetReplyParameter
1506
1507 %destructor {
1508 delete $$.templ_inst;
1509 delete $$.fromclause;
1510 delete $$.redirectval;
1511 delete $$.redirectsender;
1512 }
1513 PortReceiveOp
1514 PortTriggerOp
1515
1516 %destructor {
1517 delete $$.templ_inst;
1518 delete $$.fromclause;
1519 delete $$.redirectparam;
1520 delete $$.redirectsender;
1521 }
1522 PortGetCallOp
1523
1524 %destructor {
1525 delete $$.templ_inst;
1526 delete $$.valuematch;
1527 delete $$.fromclause;
1528 delete $$.redirectval;
1529 delete $$.redirectparam;
1530 delete $$.redirectsender;
1531 }
1532 PortGetReplyOp
1533
1534 %destructor {
1535 delete $$.signature;
1536 delete $$.templ_inst;
1537 }
1538 optCatchOpParameter
1539 CatchOpParameter
1540
1541 %destructor {
1542 delete $$.signature;
1543 delete $$.templ_inst;
1544 delete $$.fromclause;
1545 delete $$.redirectval;
1546 delete $$.redirectsender;
1547 }
1548 PortCatchOp
1549
1550 %destructor {
1551 delete $$.signature;
1552 delete $$.templ_inst;
1553 delete $$.valuematch;
1554 delete $$.fromclause;
1555 delete $$.redirectval;
1556 delete $$.redirectparam;
1557 delete $$.redirectsender;
1558 }
1559 optCheckParameter
1560 CheckParameter
1561 CheckPortOpsPresent
1562 FromClausePresent
1563 RedirectPresent
1564
1565 %destructor {
1566 delete $$.compref;
1567 delete $$.portref;
1568 }
1569 PortRef
1570 AllConnectionsSpec
1571
1572 %destructor {
1573 delete $$.compref1;
1574 delete $$.portref1;
1575 delete $$.compref2;
1576 delete $$.portref2;
1577 }
1578 SingleConnectionSpec
1579 SingleOrMultiConnectionSpec
1580
1581 %destructor {
1582 delete $$.donematch;
1583 delete $$.redirect;
1584 }
1585 optDoneParameter
1586
1587 %destructor {
1588 if ($$.is_ref) delete $$.ref;
1589 else delete $$.id;
1590 }
1591 Reference
1592
1593 %destructor {
1594 delete $$.defs;
1595 delete $$.ass;
1596 }
1597 Initial
1598
1599 %destructor {
1600 delete $$.runsonref;
1601 delete $$.systemref;
1602 }
1603 ConfigSpec
1604
1605 %destructor {
1606 delete $$.name;
1607 delete $$.loc;
1608 }
1609 optCreateParameter
1610
1611 %destructor {
1612 delete $$.value;
1613 delete $$.ap_list;
1614 }
1615 ApplyOp
1616
1617 %destructor {
1618 for (size_t i = 0; i < $$.nElements; i++) delete $$.elements[i].id;
1619 Free($$.elements);
1620 }
1621 IdentifierList
1622
1623 %destructor {
1624 delete $$.id;
1625 for (size_t i = 0; i < $$.arrays.nElements; i++)
1626 delete $$.arrays.elements[i];
1627 Free($$.arrays.elements);
1628 delete $$.initial_value;
1629 }
1630 SingleConstDef
1631 SingleVarInstance
1632 SingleTempVarInstance
1633
1634 %destructor {
1635 for (size_t i = 0; i < $$.nElements; i++) {
1636 delete $$.elements[i].id;
1637 for (size_t j = 0; i < $$.elements[i].arrays.nElements; j++)
1638 delete $$.elements[i].arrays.elements[j];
1639 Free($$.elements[i].arrays.elements);
1640 delete $$.elements[i].initial_value;
1641 }
1642 Free($$.elements);
1643 }
1644 ConstList
1645 TempVarList
1646 VarList
1647
1648 %destructor {
1649 delete $$.id;
1650 delete $$.defval;
1651 }
1652 SingleModulePar
1653
1654 %destructor {
1655 delete $$.id;
1656 delete $$.deftempl;
1657 }
1658 SingleTemplateModulePar
1659
1660 %destructor {
1661 for (size_t i = 0; i < $$.nElements; i++) {
1662 delete $$.elements[i].id;
1663 delete $$.elements[i].defval;
1664 }
1665 Free($$.elements);
1666 }
1667 ModuleParList
1668
1669 %destructor {
1670 for (size_t i = 0; i < $$.nElements; i++) {
1671 delete $$.elements[i].id;
1672 delete $$.elements[i].deftempl;
1673 }
1674 Free($$.elements);
1675 }
1676 TemplateModuleParList
1677
1678 %destructor {
1679 delete $$.id;
1680 delete $$.dims;
1681 }
1682 PortElement
1683
1684 %destructor {
1685 for (size_t i = 0; i < $$.nElements; i++) {
1686 delete $$.elements[i].id;
1687 delete $$.elements[i].dims;
1688 }
1689 Free($$.elements);
1690 }
1691 PortElementList
1692
1693 %destructor {
1694 delete $$.reference;
1695 }
1696 optRunsOnComprefOrSelf
1697
1698 /*********************************************************************
1699 * Operator precedences (lowest first)
1700 *********************************************************************/
1701
1702 %left OrKeyword
1703 %left XorKeyword
1704 %left AndKeyword
1705 %left NotKeyword
1706 %left EQ NE
1707 %nonassoc '<' '>' GE LE
1708 %left SL SR RL _RR
1709 %left Or4bKeyword
1710 %left Xor4bKeyword
1711 %left And4bKeyword
1712 %left Not4bKeyword
1713 %left '+' '-' '&'
1714 %left '*' '/' ModKeyword RemKeyword
1715 %left UnarySign
1716
1717 %expect 25
1718
1719 %start GrammarRoot
1720
1721 /*
1722 XXX Source of conflicts (25 S/R):
1723
1724 1.) 8 conflicts in one state
1725 The Expression after 'return' keyword is optional in ReturnStatement.
1726 For 8 tokens the parser cannot decide whether the token is a part of
1727 the return expression (shift) or it is the beginning of the next statement
1728 (reduce).
1729
1730 2.) 8 distinct states, each with one conflict caused by token '['
1731 The local definitions in altsteps can be followed immediately by the guard
1732 expression. When the parser sees the '[' token it cannot decide whether it
1733 belongs to the local definition as array dimension or array subreference
1734 (shift) or it is the beginning of the first guard expression (reduce).
1735 The situations are the following:
1736 - var t v := ref <here> [
1737 - var t v := ref[subref] <here> [
1738 - var t v := ref.integer <here> [
1739 - var t v := ref.subref <here> [
1740 - timer t <here> [
1741 - var t v <here> [
1742 - var t v := ref.objid{...}.subref <here> [
1743 - var template t v <here> [
1744
1745 3.) 1 conflict
1746 The sequence identifier.objid can be either the beginning of a module name
1747 qualified with a module object identifier (shift) or a reference to an objid
1748 value within an entity of type anytype (reduce).
1749
1750 4.) 1 conflict
1751 The '{' token after a call statement can be either the part of the response and
1752 exception handling part (shift) or the beginning of the next statement, which
1753 is a StatementBlock (reduce). Note that StatementBlock as a statement is a
1754 non-standard language extension.
1755
1756 5.) 5 conflicts in in three states, related to named parameters
1757
1758 6.) 1 Conflict due to pattern concatenation
1759
1760 7.) 1 conflict
1761 The TitanSpecificProfilerKeyword following the ReturnKeyword in a ReturnStatement
1762 can either be the returned boolean value if followed by the DotRunningKeyword (shift)
1763 or the next statement if followed by the DotStartKeyword or the DotStopKeyword (reduce).
1764
1765 Note that the parser implemented by bison always chooses to shift instead of
1766 reduce in case of conflicts. This is the desired behaviour in situations 1.),
1767 2.), 4.) and 7.) since the opposite alternative can be forced by the correct usage
1768 of semi-colons. Situation 3.) does not cause any problems as anytype is not
1769 supported at the moment.
1770 */
1771
1772 %%
1773
1774 /*********************************************************************
1775 * Grammar
1776 *********************************************************************/
1777
1778 /* The grammar of TTCN-3 */
1779 /* The numbers correspond to ES 201 873-1 V4.1.2 (2009-07) */
1780
1781 GrammarRoot:
1782 TTCN3Module
1783 {
1784 if (is_erroneous_parsed) {
1785 delete act_ttcn3_module;
1786 act_ttcn3_module = NULL;
1787 Location loc(infile, @1);
1788 loc.error("The erroneous attribute cannot be a TTCN-3 module.");
1789 }
1790 }
1791 | TitanErroneousHackKeyword ErroneousAttributeSpec
1792 {
1793 if (!is_erroneous_parsed) {
1794 delete act_ttcn3_erroneous_attr_spec;
1795 act_ttcn3_erroneous_attr_spec = NULL;
1796 Location loc(infile, @$);
1797 loc.error("File `%s' does not contain a TTCN-3 module.", infile);
1798 }
1799 }
1800 | error
1801 ;
1802
1803 ErroneousAttributeSpec:
1804 ErroneousIndicator AssignmentChar TemplateInstance optAllKeyword
1805 {
1806 act_ttcn3_erroneous_attr_spec = new ErroneousAttributeSpec($1.is_raw, $1.indicator, $3, $4);
1807 }
1808 ;
1809
1810 ErroneousIndicator:
1811 ValueKeyword optErrValueRaw
1812 {
1813 $$.indicator = ErroneousAttributeSpec::I_VALUE;
1814 $$.is_raw = $2;
1815 }
1816 | IDentifier optErrValueRaw
1817 {
1818 if ($1->get_ttcnname()=="before") $$.indicator = ErroneousAttributeSpec::I_BEFORE;
1819 else if ($1->get_ttcnname()=="after") $$.indicator = ErroneousAttributeSpec::I_AFTER;
1820 else {
1821 Location loc(infile, @1);
1822 loc.error("Invalid indicator. Valid indicators are: "
1823 "`before', `value' and `after'");
1824 $$.indicator = ErroneousAttributeSpec::I_INVALID;
1825 }
1826 delete $1;
1827 $$.is_raw = $2;
1828 }
1829 ;
1830
1831 optAllKeyword:
1832 /* empty */ { $$ = false; }
1833 | AllKeyword { $$ = true; }
1834 ;
1835
1836 optErrValueRaw:
1837 /* empty */ { $$ = false; }
1838 | '(' IDentifier ')'
1839 {
1840 if ($2->get_ttcnname()=="raw") $$ = true;
1841 else {
1842 Location loc(infile, @2);
1843 loc.error("Invalid keyword, only the optional `raw' keyword can be used here.");
1844 $$ = false;
1845 }
1846 delete $2;
1847 }
1848 ;
1849
1850
1851 /* A.1.6.0 TTCN Module */
1852
1853 TTCN3Module: // 1
1854 TTCN3ModuleId ModuleBody optWithStatementAndSemiColon optError
1855 {
1856 act_ttcn3_module->set_with_attr($3);
1857 if (anytype_access) {
1858 // If there was an attempted access to an anytype field, artificially
1859 // create a type definition as if the following appeared in TTCN-3:
1860 // type union anytype { /* empty, members added later */ }
1861 // NOTE: anything which looks like usage of an anytype field will bring
1862 // the local anytype to life, which trumps any imported anytype
1863 // (when resolving, the local anytype will be found first).
1864 // TODO: just to be safe, anytype should be removed from the exports.
1865 Type *t = new Type(Type::T_ANYTYPE);
1866 Identifier *anytype_id = new Identifier(Identifier::ID_TTCN, anyname);
1867 Def_Type *anytypedef = new Def_Type(anytype_id, t);
1868 anytypedef->set_parent_path(act_ttcn3_module->get_attrib_path());
1869 act_ttcn3_module->add_ass(anytypedef);
1870 // Def_Type is-a Definition is-a Assignment
1871 }
1872 }
1873 ;
1874
1875 TTCN3ModuleId: // 3
1876 optError TTCN3ModuleKeyword IDentifier optDefinitiveIdentifier
1877 optLanguageSpec optError
1878 {
1879 act_ttcn3_module = new Ttcn::Module($3);
1880 act_ttcn3_module->set_scope_name($3->get_dispname());
1881 act_ttcn3_module->set_language_spec($5);
1882 Free($5);
1883 }
1884 ;
1885
1886 ModuleId: // 4
1887 GlobalModuleId optLanguageSpec
1888 {
1889 $$ = new ImpMod($1);
1890 $$->set_language_spec($2);
1891 Free($2);
1892 }
1893 ;
1894
1895 GlobalModuleId: // 5
1896 IDentifier { $$ = $1; }
1897 | IDentifier '.' ObjectIdentifierValue
1898 { $$ = $1; delete $3; }
1899 ;
1900
1901 optLanguageSpec:
1902 /* empty */ { $$ = NULL; }
1903 | LanguageKeyword FreeText { $$ = $2; } // sort-of 7 LanguageSpec
1904 ;
1905
1906 ModuleBody:
1907 '{' optErrorBlock '}'
1908 | '{' ModuleDefinitionsList optErrorBlock '}'
1909 | '{' ModuleDefinitionsList ModuleControlPart optErrorBlock '}'
1910 | '{' ModuleControlPart optErrorBlock '}'
1911 ;
1912
1913 /* A.1.6.1 Module definitions part */
1914
1915 /* A.1.6.1.0 General */
1916
1917 ModuleDefinitionsList: // 10
1918 ModuleDefinition optSemiColon
1919 | error ModuleDefinition optSemiColon
1920 | ModuleDefinitionsList optErrorBlock ModuleDefinition optSemiColon
1921 ;
1922
1923 optVisibility: // 12
1924 // /* empty */ { $$.visibility = PUBLIC;}
1925 /* empty */ { $$.visibility = NOCHANGE;}
1926 | PublicKeyword { $$.visibility = PUBLIC;}
1927 | PrivateKeyword { $$.visibility = PRIVATE;}
1928 | FriendKeyword { $$.visibility = FRIEND;}
1929 ;
1930
1931 /* A definition _in_ the module, not a definition _of_ a module */
1932 ModuleDefinition: // 11
1933 optVisibility ModuleDef optWithStatement
1934 {
1935 for (size_t i = 0; i < $2.nElements; i++) {
1936 if ($3) {
1937 if (i == 0) $2.elements[i]->set_with_attr($3);
1938 else $2.elements[i]->set_with_attr($3->clone());
1939 }
1940 if ($1.visibility != NOCHANGE) {
1941 $2.elements[i]->set_visibility($1.visibility);
1942 }
1943 act_ttcn3_module->add_ass($2.elements[i]);
1944 if (act_group) {
1945 $2.elements[i]->set_parent_path(act_group->get_attrib_path());
1946 act_group->add_ass($2.elements[i]);
1947 } else {
1948 $2.elements[i]->set_parent_path(act_ttcn3_module->get_attrib_path());
1949 }
1950 }
1951 Free($2.elements);
1952 }
1953 | optVisibility ImportDef optWithStatement
1954 {
1955 $2->set_with_attr($3);
1956 if ($1.visibility != NOCHANGE) {
1957 $2->set_visibility($1.visibility);
1958 }
1959 if (act_group) {
1960 $2->set_parent_path(act_group->get_attrib_path());
1961 act_group->add_impmod($2);
1962 } else {
1963 $2->set_parent_path(act_ttcn3_module->get_attrib_path());
1964 }
1965 act_ttcn3_module->add_impmod($2);
1966 }
1967 | PublicKeyword GroupDef optWithStatement
1968 { // only public allowed for group, and it's redundant
1969 $2->set_with_attr($3);
1970 act_group = $2->get_parent_group();
1971 }
1972 | GroupDef optWithStatement
1973 { // same code as above
1974 $1->set_with_attr($2);
1975 act_group = $1->get_parent_group();
1976 }
1977 | PrivateKeyword FriendModuleDef optWithStatement
1978 { // only private allowed for "friend module", and it's redundant
1979 for (size_t i = 0; i < $2.nElements; i++) {
1980 if ($3) {
1981 if (i == 0) $2.elements[i]->set_with_attr($3);
1982 else $2.elements[i]->set_with_attr($3->clone());
1983 }
1984 act_ttcn3_module->add_friendmod($2.elements[i]);
1985 if (act_group) {
1986 $2.elements[i]->set_parent_path(act_group->get_attrib_path());
1987 act_group->add_friendmod($2.elements[i]);
1988 } else {
1989 $2.elements[i]->set_parent_path(act_ttcn3_module->get_attrib_path());
1990 }
1991 }
1992 Free($2.elements);
1993 }
1994 | FriendModuleDef optWithStatement
1995 { // same code as above
1996 for (size_t i = 0; i < $1.nElements; i++) {
1997 if ($2) {
1998 if (i == 0) $1.elements[i]->set_with_attr($2);
1999 else $1.elements[i]->set_with_attr($2->clone());
2000 }
2001 act_ttcn3_module->add_friendmod($1.elements[i]);
2002 if (act_group) {
2003 $1.elements[i]->set_parent_path(act_group->get_attrib_path());
2004 act_group->add_friendmod($1.elements[i]);
2005 } else {
2006 $1.elements[i]->set_parent_path(act_ttcn3_module->get_attrib_path());
2007 }
2008 }
2009 Free($1.elements);
2010 }
2011 ;
2012
2013 ModuleDef:
2014 ConstDef { $$ = $1; }
2015 | ModuleParDef { $$ = $1; }
2016 | TypeDef
2017 {
2018 $$.nElements = 1;
2019 $$.elements = (Ttcn::Definition**)
2020 Malloc(sizeof(*$$.elements));
2021 $$.elements[0] = $1;
2022 }
2023 | TemplateDef
2024 {
2025 $$.nElements = 1;
2026 $$.elements = (Ttcn::Definition**)
2027 Malloc(sizeof(*$$.elements));
2028 $$.elements[0] = $1;
2029 }
2030 | FunctionDef
2031 {
2032 $$.nElements = 1;
2033 $$.elements = (Ttcn::Definition**)
2034 Malloc(sizeof(*$$.elements));
2035 $$.elements[0] = $1;
2036 }
2037 | SignatureDef
2038 {
2039 $$.nElements = 1;
2040 $$.elements = (Ttcn::Definition**)
2041 Malloc(sizeof(*$$.elements));
2042 $$.elements[0] = $1;
2043 }
2044 | TestcaseDef
2045 {
2046 $$.nElements = 1;
2047 $$.elements = (Ttcn::Definition**)
2048 Malloc(sizeof(*$$.elements));
2049 $$.elements[0] = $1;
2050 }
2051 | AltstepDef
2052 {
2053 $$.nElements = 1;
2054 $$.elements = (Ttcn::Definition**)
2055 Malloc(sizeof(*$$.elements));
2056 $$.elements[0] = $1;
2057 }
2058 | ExtFunctionDef
2059 {
2060 $$.nElements = 1;
2061 $$.elements = (Ttcn::Definition**)
2062 Malloc(sizeof(*$$.elements));
2063 $$.elements[0] = $1;
2064 }
2065 | ExtConstDef { $$ = $1; }
2066 ;
2067
2068 /* A.1.6.1.1 Typedef definitions */
2069
2070 TypeDef: // 13
2071 TypeDefKeyword TypeDefBody
2072 {
2073 $$ = $2;
2074 $$->set_location(infile, @$);
2075 }
2076 ;
2077
2078 TypeDefBody: // 14
2079 StructuredTypeDef { $$ = $1; }
2080 | SubTypeDef { $$ = $1; }
2081 ;
2082
2083 StructuredTypeDef: // 16
2084 RecordDef { $$ = $1; }
2085 | UnionDef { $$ = $1; }
2086 | SetDef { $$ = $1; }
2087 | RecordOfDef { $$ = $1; }
2088 | SetOfDef { $$ = $1; }
2089 | EnumDef { $$ = $1; }
2090 | PortDef { $$ = $1; }
2091 | ComponentDef { $$ = $1; }
2092 | FunctionTypeDef { $$ = $1; }
2093 | AltstepTypeDef { $$ = $1; }
2094 | TestcaseTypeDef { $$ = $1; }
2095 ;
2096
2097 RecordDef: // 17
2098 RecordKeyword StructDefBody
2099 {
2100 Type *type = new Type(Type::T_SEQ_T, $2.cfm);
2101 type->set_location(infile, @$);
2102 $$ = new Def_Type($2.id, type);
2103 }
2104 ;
2105
2106 StructDefBody: // 19
2107 IDentifier optStructDefFormalParList
2108 '{' optStructFieldDefList '}'
2109 {
2110 $$.id = $1;
2111 $$.cfm = $4;
2112 }
2113 | AddressKeyword '{' optStructFieldDefList '}'
2114 {
2115 $$.id = new Identifier(Identifier::ID_TTCN, string("address"));
2116 $$.cfm = $3;
2117 }
2118 ;
2119
2120 optStructDefFormalParList:
2121 /* empty */ optError
2122 | '(' StructDefFormalParList optError ')'
2123 {
2124 Location loc(infile, @$);
2125 loc.error("Type parameterization is not currently supported");
2126 }
2127 | '(' error ')'
2128 {
2129 Location loc(infile, @$);
2130 loc.error("Type parameterization is not currently supported");
2131 }
2132 ;
2133
2134 StructDefFormalParList: // -> 202 784 "Advanced Parameterization", 9
2135 optError StructDefFormalPar
2136 | StructDefFormalParList optError ',' optError StructDefFormalPar
2137 | StructDefFormalParList optError ',' error
2138 ;
2139
2140 StructDefFormalPar: // -> 202 784 "Advanced Parameterization", 10
2141 FormalValuePar { delete $1; }
2142 ;
2143
2144 optStructFieldDefList:
2145 /* empty */ optError { $$ = new CompFieldMap; }
2146 | StructFieldDefList optError { $$ = $1; }
2147 ;
2148
2149 StructFieldDefList:
2150 optError StructFieldDef
2151 {
2152 $$ = new CompFieldMap;
2153 $$->add_comp($2);
2154 }
2155 | StructFieldDefList optError ',' optError StructFieldDef
2156 {
2157 $$ = $1;
2158 $$->add_comp($5);
2159 }
2160 | StructFieldDefList optError ',' error { $$ = $1; }
2161 ;
2162
2163 StructFieldDef: // 21
2164 TypeOrNestedTypeDef IDentifier optArrayDef optSubTypeSpec optOptionalKeyword
2165 {
2166 if ($4) {
2167 /* The subtype constraint belongs to the innermost embedded type of
2168 * possible nested 'record of' or 'set of' constructs. */
2169 Type *t = $1;
2170 while (t->is_seof()) t = t->get_ofType();
2171 t->set_parsed_restrictions($4);
2172 }
2173 Type *type = $1;
2174 /* creation of array type(s) if necessary (from right to left) */
2175 for (size_t i = $3.nElements; i > 0; i--) {
2176 type = new Type(Type::T_ARRAY, type, $3.elements[i - 1], true);
2177 type->set_location(*$1);
2178 }
2179 Free($3.elements);
2180 $$ = new CompField($2, type, $5);
2181 $$->set_location(infile, @$);
2182 }
2183 ;
2184
2185 optOptionalKeyword:
2186 /* empty */ { $$ = false; }
2187 | OptionalKeyword { $$ = true; }
2188 ;
2189
2190 TypeOrNestedTypeDef:
2191 Type { $$ = $1; }
2192 | NestedTypeDef { $$ = $1; }
2193 ;
2194
2195 NestedTypeDef: // 22
2196 NestedRecordDef { $$ = $1; }
2197 | NestedUnionDef { $$ = $1; }
2198 | NestedSetDef { $$ = $1; }
2199 | NestedRecordOfDef { $$ = $1; }
2200 | NestedSetOfDef { $$ = $1; }
2201 | NestedEnumDef { $$ = $1; }
2202 | NestedFunctionTypeDef { $$ = $1; }
2203 | NestedAltstepTypeDef { $$ = $1; }
2204 | NestedTestcaseTypeDef { $$ = $1; }
2205 ;
2206
2207 NestedRecordDef: // 23
2208 RecordKeyword '{' optStructFieldDefList '}'
2209 {
2210 $$ = new Type(Type::T_SEQ_T, $3);
2211 $$->set_location(infile, @$);
2212 }
2213 ;
2214
2215 NestedUnionDef: // 24
2216 UnionKeyword '{' UnionFieldDefList optError '}'
2217 {
2218 $$ = new Type(Type::T_CHOICE_T, $3);
2219 $$->set_location(infile, @$);
2220 }
2221 ;
2222
2223 NestedSetDef: // 25
2224 SetKeyword '{' optStructFieldDefList '}'
2225 {
2226 $$ = new Type(Type::T_SET_T, $3);
2227 $$->set_location(infile, @$);
2228 }
2229 ;
2230
2231 NestedRecordOfDef: // 26
2232 RecordKeyword optStringLength OfKeyword TypeOrNestedTypeDef
2233 {
2234 $$ = new Type(Type::T_SEQOF, $4);
2235 if ($2) {
2236 vector<SubTypeParse> *vstp = new vector<SubTypeParse>;
2237 SubTypeParse *stp = new SubTypeParse($2);
2238 vstp->add(stp);
2239 $$->set_parsed_restrictions(vstp);
2240 }
2241 $$->set_location(infile, @$);
2242 }
2243 ;
2244
2245 NestedSetOfDef: // 27
2246 SetKeyword optStringLength OfKeyword TypeOrNestedTypeDef
2247 {
2248 $$ = new Type(Type::T_SETOF, $4);
2249 if ($2) {
2250 vector<SubTypeParse> *vstp = new vector<SubTypeParse>;
2251 SubTypeParse *stp = new SubTypeParse($2);
2252 vstp->add(stp);
2253 $$->set_parsed_restrictions(vstp);
2254 }
2255 $$->set_location(infile, @$);
2256 }
2257 ;
2258
2259 NestedEnumDef: // 28
2260 EnumKeyword '{' EnumerationList optError '}'
2261 {
2262 $$ = new Type(Type::T_ENUM_T, $3);
2263 $$->set_location(infile, @$);
2264 }
2265 ;
2266
2267 NestedFunctionTypeDef:
2268 FunctionKeyword '(' optFunctionFormalParList ')'
2269 optRunsOnComprefOrSelf optReturnType
2270 {
2271 $3->set_location(infile, @2, @4);
2272 $$ = new Type(Type::T_FUNCTION, $3, $5.reference, $5.self, $6.type,
2273 $6.returns_template, $6.template_restriction);
2274 $$->set_location(infile, @$);
2275 }
2276 ;
2277
2278 NestedAltstepTypeDef:
2279 AltstepKeyword '(' optAltstepFormalParList ')'
2280 optRunsOnComprefOrSelf
2281 {
2282 $3->set_location(infile, @2, @4);
2283 $$ = new Type(Type::T_ALTSTEP, $3, $5.reference, $5.self);
2284 $$->set_location(infile, @$);
2285 }
2286 ;
2287
2288 NestedTestcaseTypeDef:
2289 TestcaseKeyword '(' optTestcaseFormalParList ')'
2290 ConfigSpec
2291 {
2292 $3->set_location(infile, @2, @4);
2293 $$ = new Type(Type::T_TESTCASE, $3, $5.runsonref,
2294 $5.systemref);
2295 $$->set_location(infile, @$);
2296 }
2297 ;
2298
2299 UnionDef: // 31
2300 UnionKeyword UnionDefBody
2301 {
2302 Type *type = new Type(Type::T_CHOICE_T, $2.cfm);
2303 type->set_location(infile, @$);
2304 $$ = new Def_Type($2.id, type);
2305 }
2306 ;
2307
2308 UnionDefBody: // 33
2309 IDentifier optStructDefFormalParList
2310 '{' UnionFieldDefList optError '}'
2311 {
2312 $$.id = $1;
2313 $$.cfm = $4;
2314 }
2315 | AddressKeyword '{' UnionFieldDefList optError '}'
2316 {
2317 $$.id = new Identifier(Identifier::ID_TTCN, string("address"));
2318 $$.cfm = $3;
2319 }
2320 ;
2321
2322 UnionFieldDefList:
2323 optError UnionFieldDef
2324 {
2325 $$ = new CompFieldMap;
2326 $$->add_comp($2);
2327 }
2328 | UnionFieldDefList optError ',' optError UnionFieldDef
2329 {
2330 $$ = $1;
2331 $$->add_comp($5);
2332 }
2333 | UnionFieldDefList optError ',' error { $$ = $1; }
2334 | error { $$ = new CompFieldMap; }
2335 ;
2336
2337 UnionFieldDef: // 34
2338 TypeOrNestedTypeDef IDentifier optArrayDef optSubTypeSpec
2339 {
2340 if ($4) {
2341 /* The subtype constraint belongs to the innermost embedded type of
2342 * possible nested 'record of' or 'set of' constructs. */
2343 Type *t = $1;
2344 while (t->is_seof()) t = t->get_ofType();
2345 t->set_parsed_restrictions($4);
2346 }
2347 Type *type = $1;
2348 /* creation of array type(s) if necessary (from right to left) */
2349 for (size_t i = $3.nElements; i > 0; i--) {
2350 type = new Type(Type::T_ARRAY, type, $3.elements[i - 1], true);
2351 type->set_location(*$1);
2352 }
2353 Free($3.elements);
2354 $$ = new CompField($2, type, false);
2355 $$->set_location(infile, @$);
2356 }
2357 ;
2358
2359 SetDef: // 35
2360 SetKeyword StructDefBody
2361 {
2362 Type *type = new Type(Type::T_SET_T, $2.cfm);
2363 type->set_location(infile, @$);
2364 $$ = new Def_Type($2.id, type);
2365 }
2366 ;
2367
2368 RecordOfDef: // 37
2369 RecordKeyword optStringLength OfKeyword StructOfDefBody
2370 {
2371 Type *type = new Type(Type::T_SEQOF, $4.type);
2372 if ($2) {
2373 vector<SubTypeParse> *vstp = new vector<SubTypeParse>;
2374 vstp->add(new SubTypeParse($2));
2375 type->set_parsed_restrictions(vstp);
2376 }
2377 type->set_location(infile, @$);
2378 $$ = new Def_Type($4.id, type);
2379 }
2380 ;
2381
2382 StructOfDefBody: // 39
2383 TypeOrNestedTypeDef IdentifierOrAddressKeyword optSubTypeSpec
2384 {
2385 if ($3) {
2386 /* The subtype constraint belongs to the innermost embedded type of
2387 * possible nested 'record of' or 'set of' constructs. */
2388 Type *t = $1;
2389 while (t->is_seof()) t = t->get_ofType();
2390 t->set_parsed_restrictions($3);
2391 }
2392 $$.type = $1;
2393 $$.id = $2;
2394 }
2395 ;
2396
2397 IdentifierOrAddressKeyword:
2398 IDentifier { $$ = $1; }
2399 | AddressKeyword
2400 {
2401 $$ = new Identifier(Identifier::ID_TTCN, string("address"));
2402 }
2403 ;
2404
2405 SetOfDef: // 40
2406 SetKeyword optStringLength OfKeyword StructOfDefBody
2407 {
2408 Type *type = new Type(Type::T_SETOF, $4.type);
2409 if ($2) {
2410 vector<SubTypeParse> *vstp = new vector<SubTypeParse>;
2411 vstp->add(new SubTypeParse($2));
2412 type->set_parsed_restrictions(vstp);
2413 }
2414 type->set_location(infile, @$);
2415 $$ = new Def_Type($4.id, type);
2416 }
2417 ;
2418
2419 EnumDef: // 41
2420 EnumKeyword IdentifierOrAddressKeyword
2421 '{' EnumerationList optError '}'
2422 {
2423 Type *type = new Type(Type::T_ENUM_T, $4);
2424 type->set_location(infile, @$);
2425 $$ = new Def_Type($2, type);
2426 }
2427 ;
2428
2429 EnumerationList: // 44
2430 optError Enumeration
2431 {
2432 $$ = new EnumItems;
2433 $$->add_ei($2);
2434 }
2435 | EnumerationList optError ',' optError Enumeration
2436 {
2437 $$ = $1;
2438 $$->add_ei($5);
2439 }
2440 | EnumerationList optError ',' error { $$ = $1; }
2441 | error { $$ = new EnumItems; }
2442 ;
2443
2444 Enumeration: // 45
2445 IDentifier
2446 {
2447 $$ = new EnumItem($1, NULL);
2448 $$->set_location(infile, @$);
2449 }
2450 | IDentifier '(' Number optError ')'
2451 {
2452 Value *value = new Value(Value::V_INT, $3);
2453 value->set_location(infile, @3);
2454 $$ = new EnumItem($1, value);
2455 $$->set_location(infile, @$);
2456 }
2457 | IDentifier '(' '-' Number optError ')'
2458 {
2459 *$4 = -*$4;
2460 Value *value = new Value(Value::V_INT, $4);
2461 value->set_location(infile, @3, @4);
2462 $$ = new EnumItem($1, value);
2463 $$->set_location(infile, @$);
2464 }
2465 | IDentifier '(' error ')'
2466 {
2467 Value *value = new Value(Value::V_ERROR);
2468 value->set_location(infile, @3);
2469 $$ = new EnumItem($1, value);
2470 $$->set_location(infile, @$);
2471 }
2472 ;
2473
2474 SubTypeDef: // 47
2475 Type IdentifierOrAddressKeyword optArrayDef optSubTypeSpec
2476 {
2477 /* the subtype constraint belongs to the innermost type */
2478 if ($4) $1->set_parsed_restrictions($4);
2479 Type *type = $1;
2480 /* creation of array type(s) if necessary (from right to left) */
2481 for (size_t i = $3.nElements; i > 0; i--) {
2482 type = new Type(Type::T_ARRAY, type, $3.elements[i - 1], true);
2483 type->set_location(*$1);
2484 }
2485 Free($3.elements);
2486 $$ = new Def_Type($2, type);
2487 }
2488 ;
2489
2490 optSubTypeSpec: // [49]
2491 /* empty */ { $$ = 0; }
2492 | AllowedValues { $$ = $1; }
2493 | AllowedValues StringLength
2494 {
2495 $$ = $1;
2496 $$->add(new SubTypeParse($2));
2497 }
2498 | StringLength
2499 {
2500 $$ = new vector<SubTypeParse>;
2501 $$->add(new SubTypeParse($1));
2502 }
2503 ;
2504
2505 AllowedValues: // 50
2506 '(' seqValueOrRange optError ')' { $$ = $2; }
2507 | '(' CharStringMatch optError ')'
2508 {
2509 $$ = new vector<SubTypeParse>;
2510 $$->add(new SubTypeParse($2));
2511 }
2512 | '(' error ')' { $$ = new vector<SubTypeParse>; }
2513 ;
2514
2515 seqValueOrRange:
2516 optError ValueOrRange
2517 {
2518 $$ = new vector<SubTypeParse>;
2519 $$->add($2);
2520 }
2521 | seqValueOrRange optError ',' optError ValueOrRange
2522 {
2523 $$ = $1;
2524 $$->add($5);
2525 }
2526 | seqValueOrRange optError ',' error { $$ = $1; }
2527 ;
2528
2529 ValueOrRange: // 51
2530 RangeDef { $$ = new SubTypeParse($1.lower, $1.lower_exclusive, $1.upper, $1.upper_exclusive); }
2531 | Expression { $$ = new SubTypeParse($1); }
2532 ;
2533
2534 RangeDef: // 52
2535 LowerBound DotDot UpperBound
2536 {
2537 $$.lower_exclusive = false;
2538 $$.lower = $1;
2539 $$.upper_exclusive = false;
2540 $$.upper = $3;
2541 }
2542 | '!' LowerBound DotDot UpperBound
2543 {
2544 $$.lower_exclusive = true;
2545 $$.lower = $2;
2546 $$.upper_exclusive = false;
2547 $$.upper = $4;
2548 }
2549 | LowerBound DotDot '!' UpperBound
2550 {
2551 $$.lower_exclusive = false;
2552 $$.lower = $1;
2553 $$.upper_exclusive = true;
2554 $$.upper = $4;
2555 }
2556 | '!' LowerBound DotDot '!' UpperBound
2557 {
2558 $$.lower_exclusive = true;
2559 $$.lower = $2;
2560 $$.upper_exclusive = true;
2561 $$.upper = $5;
2562 }
2563 ;
2564
2565 optStringLength:
2566 /* empty */ optError { $$ = 0; }
2567 | StringLength { $$ = $1; }
2568 ;
2569
2570 StringLength: // 53
2571 LengthKeyword '(' Expression optError ')'
2572 {
2573 $$ = new LengthRestriction($3);
2574 $$->set_location(infile, @$);
2575 }
2576 | LengthKeyword '(' Expression DotDot UpperBound optError ')'
2577 {
2578 $$ = new LengthRestriction($3, $5);
2579 $$->set_location(infile, @$);
2580 }
2581 | LengthKeyword '(' error ')'
2582 {
2583 Value *value = new Value(Value::V_ERROR);
2584 value->set_location(infile, @3);
2585 $$ = new LengthRestriction(value);
2586 $$->set_location(infile, @$);
2587 }
2588 ;
2589
2590 PortType: // 55
2591 IDentifier
2592 {
2593 $$ = new Ttcn::Reference($1);
2594 $$->set_location(infile, @$);
2595 }
2596 | IDentifier '.' IDentifier
2597 {
2598 $$ = new Ttcn::Reference($1, $3);
2599 $$->set_location(infile, @$);
2600 }
2601 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
2602 {
2603 $$ = new Ttcn::Reference($1, $5);
2604 $$->set_location(infile, @$);
2605 delete $3;
2606 }
2607 ;
2608
2609 PortDef: // 56
2610 PortKeyword PortDefBody { $$ = $2; }
2611 ;
2612
2613 PortDefBody: // 57
2614 IDentifier PortDefAttribs
2615 {
2616 $$ = new Def_Type($1, $2);
2617 }
2618 ;
2619
2620 PortDefAttribs: // 60
2621 PortOperationMode PortDefLists
2622 {
2623 PortTypeBody *body = new PortTypeBody($1,
2624 $2.in_list, $2.out_list, $2.inout_list,
2625 $2.in_all, $2.out_all, $2.inout_all);
2626 body->set_location(infile, @$);
2627 $$ = new Type(Type::T_PORT, body);
2628 $$->set_location(infile, @$);
2629 }
2630 ;
2631
2632 PortOperationMode:
2633 MessageKeyword { $$ = PortTypeBody::PO_MESSAGE; } // 61
2634 | ProcedureKeyword { $$ = PortTypeBody::PO_PROCEDURE; } // 68
2635 | MixedKeyword { $$ = PortTypeBody::PO_MIXED; } // 73
2636 | error { $$ = PortTypeBody::PO_MIXED; }
2637 ;
2638
2639 PortDefLists:
2640 '{' seqPortDefList '}' { $$ = $2; }
2641 | '{' error '}'
2642 {
2643 $$.in_list = 0;
2644 $$.out_list = 0;
2645 $$.inout_list = 0;
2646 $$.in_all = false;
2647 $$.out_all = false;
2648 $$.inout_all = false;
2649 }
2650 ;
2651
2652 seqPortDefList:
2653 optError PortDefList optSemiColon { $$ = $2; }
2654 | seqPortDefList PortDefList optSemiColon
2655 {
2656 $$ = $1;
2657 if ($2.in_list) {
2658 if ($$.in_list) {
2659 $$.in_list->steal_types($2.in_list);
2660 delete $2.in_list;
2661 } else $$.in_list = $2.in_list;
2662 }
2663 if ($2.out_list) {
2664 if ($$.out_list) {
2665 $$.out_list->steal_types($2.out_list);
2666 delete $2.out_list;
2667 } else $$.out_list = $2.out_list;
2668 }
2669 if ($2.inout_list) {
2670 if ($$.inout_list) {
2671 $$.inout_list->steal_types($2.inout_list);
2672 delete $2.inout_list;
2673 } else $$.inout_list = $2.inout_list;
2674 }
2675 if ($2.in_all) {
2676 if ($$.in_all) {
2677 Location loc(infile, @2);
2678 loc.warning("Duplicate directive `in all' in port type definition");
2679 } else $$.in_all = true;
2680 }
2681 if ($2.out_all) {
2682 if ($$.out_all) {
2683 Location loc(infile, @2);
2684 loc.warning("Duplicate directive `out all' in port type definition");
2685 } else $$.out_all = true;
2686 }
2687 if ($2.inout_all) {
2688 if ($$.inout_all) {
2689 Location loc(infile, @2);
2690 loc.warning("Duplicate directive `inout all' in port type definition");
2691 } else $$.inout_all = true;
2692 }
2693 }
2694 ;
2695
2696 PortDefList:
2697 InParKeyword AllOrTypeList
2698 {
2699 if ($2) {
2700 $$.in_list = $2;
2701 $$.in_list->set_location(infile, @$);
2702 $$.in_all = false;
2703 } else {
2704 $$.in_list = 0;
2705 $$.in_all = true;
2706 }
2707 $$.out_list = 0;
2708 $$.out_all = false;
2709 $$.inout_list = 0;
2710 $$.inout_all = false;
2711 }
2712 | OutParKeyword AllOrTypeList
2713 {
2714 $$.in_list = 0;
2715 $$.in_all = false;
2716 if ($2) {
2717 $$.out_list = $2;
2718 $$.out_list->set_location(infile, @$);
2719 $$.out_all = false;
2720 } else {
2721 $$.out_list = 0;
2722 $$.out_all = true;
2723 }
2724 $$.inout_list = 0;
2725 $$.inout_all = false;
2726 }
2727 | InOutParKeyword AllOrTypeList
2728 {
2729 $$.in_list = 0;
2730 $$.in_all = false;
2731 $$.out_list = 0;
2732 $$.out_all = false;
2733 if ($2) {
2734 $$.inout_list = $2;
2735 $$.inout_list->set_location(infile, @$);
2736 $$.inout_all = false;
2737 } else {
2738 $$.inout_list = 0;
2739 $$.inout_all = true;
2740 }
2741 }
2742 | InParKeyword error
2743 {
2744 $$.in_list = 0;
2745 $$.out_list = 0;
2746 $$.inout_list = 0;
2747 $$.in_all = false;
2748 $$.out_all = false;
2749 $$.inout_all = false;
2750 }
2751 | OutParKeyword error
2752 {
2753 $$.in_list = 0;
2754 $$.out_list = 0;
2755 $$.inout_list = 0;
2756 $$.in_all = false;
2757 $$.out_all = false;
2758 $$.inout_all = false;
2759 }
2760 | InOutParKeyword error
2761 {
2762 $$.in_list = 0;
2763 $$.out_list = 0;
2764 $$.inout_list = 0;
2765 $$.in_all = false;
2766 $$.out_all = false;
2767 $$.inout_all = false;
2768 }
2769 ;
2770
2771 AllOrTypeList: // 65
2772 AllKeyword { $$ = 0; }
2773 | TypeList { $$ = $1; }
2774 ;
2775
2776 TypeList: // 67
2777 optError Type
2778 {
2779 $$ = new Types;
2780 $$->add_type($2);
2781 }
2782 | TypeList optError ',' optError Type
2783 {
2784 $$ = $1;
2785 $$->add_type($5);
2786 }
2787 | TypeList optError ',' error { $$ = $1; }
2788 ;
2789
2790 ComponentDef: // 78
2791 ComponentKeyword IDentifier
2792 optExtendsDef
2793 '{' optComponentDefList '}'
2794 {
2795 $5->set_id($2);
2796 if ($3) $5->add_extends($3);
2797 $5->set_location(infile, @$);
2798 Type *type = new Type(Type::T_COMPONENT, $5);
2799 type->set_location(infile, @$);
2800 $$ = new Def_Type($2, type);
2801 }
2802 ;
2803
2804 optExtendsDef:
2805 /* empty */ optError { $$ = 0; }
2806 | ExtendsKeyword ComponentTypeList optError
2807 {
2808 $$ = $2;
2809 $$->set_location(infile, @1, @2);
2810 }
2811 | ExtendsKeyword error { $$ = 0; }
2812 ;
2813
2814 ComponentTypeList:
2815 optError ComponentType
2816 {
2817 $$ = new CompTypeRefList();
2818 $$->add_ref($2);
2819 }
2820 | ComponentTypeList optError ',' optError ComponentType
2821 {
2822 $$ = $1;
2823 $$->add_ref($5);
2824 }
2825 | ComponentTypeList optError ',' error { $$ = $1; }
2826 ;
2827
2828 ComponentType: // 81
2829 IDentifier
2830 {
2831 $$ = new Ttcn::Reference($1);
2832 $$->set_location(infile, @$);
2833 }
2834 | IDentifier '.' IDentifier
2835 {
2836 $$ = new Ttcn::Reference($1, $3);
2837 $$->set_location(infile, @$);
2838 }
2839 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
2840 {
2841 $$ = new Ttcn::Reference($1, $5);
2842 $$->set_location(infile, @$);
2843 delete $3;
2844 }
2845 ;
2846
2847 optComponentDefList:
2848 optError /* empty */ { $$ = new ComponentTypeBody(); }
2849 | ComponentElementDefList optError { $$ = $1; }
2850 ;
2851
2852 ComponentElementDefList:
2853 optError ComponentElementDef optSemiColon
2854 {
2855 $$ = new ComponentTypeBody();
2856 for (size_t i = 0; i < $2.nElements; i++)
2857 $$->add_ass($2.elements[i]);
2858 Free($2.elements);
2859 }
2860 | ComponentElementDefList optError ComponentElementDef optSemiColon
2861 {
2862 $$ = $1;
2863 for (size_t i = 0; i < $3.nElements; i++)
2864 $$->add_ass($3.elements[i]);
2865 Free($3.elements);
2866 }
2867 ;
2868
2869 ComponentElementVisibility:
2870 PublicKeyword { $$.visibility = PUBLIC;}
2871 | PrivateKeyword { $$.visibility = PRIVATE;}
2872 ;
2873
2874 ComponentElementDef: // 84
2875 PortInstance { $$ = $1; }
2876 | VarInstance { $$ = $1; }
2877 | TimerInstance { $$ = $1; }
2878 | ConstDef { $$ = $1; }
2879 | ComponentElementVisibility PortInstance
2880 {
2881 $$ = $2;
2882 for (size_t i = 0; i < $2.nElements; i++) {
2883 $2.elements[i]->set_visibility($1.visibility);
2884 }
2885 }
2886 | ComponentElementVisibility VarInstance
2887 {
2888 $$ = $2;
2889 for (size_t i = 0; i < $2.nElements; i++) {
2890 $2.elements[i]->set_visibility($1.visibility);
2891 }
2892 }
2893 | ComponentElementVisibility TimerInstance
2894 {
2895 $$ = $2;
2896 for (size_t i = 0; i < $2.nElements; i++) {
2897 $2.elements[i]->set_visibility($1.visibility);
2898 }
2899 }
2900 | ComponentElementVisibility ConstDef
2901 {
2902 $$ = $2;
2903 for (size_t i = 0; i < $2.nElements; i++) {
2904 $2.elements[i]->set_visibility($1.visibility);
2905 }
2906 }
2907 ;
2908
2909 PortInstance: // 85
2910 PortKeyword PortType PortElementList
2911 {
2912 $$.nElements = $3.nElements;
2913 $$.elements = (Ttcn::Definition**)
2914 Malloc($$.nElements*sizeof(*$$.elements));
2915 for (size_t i = 0; i < $3.nElements; i++) {
2916 Ttcn::Reference *ref = i > 0 ? $2->clone() : $2;
2917 $$.elements[i] = new Ttcn::Def_Port($3.elements[i].id, ref,
2918 $3.elements[i].dims);
2919 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
2920 }
2921 Free($3.elements);
2922 }
2923 ;
2924
2925 PortElementList:
2926 optError PortElement
2927 {
2928 $$.nElements = 1;
2929 $$.elements = (YYSTYPE::portelement_t*)Malloc(sizeof(*$$.elements));
2930 $$.elements[0] = $2;
2931 }
2932 | PortElementList ',' optError PortElement
2933 {
2934 $$.nElements = $1.nElements + 1;
2935 $$.elements = (YYSTYPE::portelement_t*)
2936 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
2937 $$.elements[$$.nElements - 1] = $4;
2938 }
2939 | PortElementList ',' error { $$ = $1; }
2940 ;
2941
2942 PortElement: // 86
2943 IDentifier optArrayDef
2944 {
2945 $$.id = $1;
2946 if ($2.nElements > 0) {
2947 $$.dims = new ArrayDimensions;
2948 for (size_t i = 0; i < $2.nElements; i++) $$.dims->add($2.elements[i]);
2949 Free($2.elements);
2950 } else $$.dims = 0;
2951 $$.yyloc = @$;
2952 }
2953 ;
2954
2955 /* A.1.6.1.2 Constant definitions */
2956
2957 ConstDef: // 88
2958 ConstKeyword Type ConstList
2959 {
2960 $$.nElements = $3.nElements;
2961 $$.elements = (Ttcn::Definition**)
2962 Malloc($$.nElements*sizeof(*$$.elements));
2963 for (size_t i = 0; i < $$.nElements; i++) {
2964 Type *type;
2965 if (i > 0) {
2966 type = new Type(Type::T_REFDSPEC, $2);
2967 type->set_location(*$2);
2968 } else type = $2;
2969 /* creation of array type(s) if necessary (from right to left) */
2970 for (size_t j = $3.elements[i].arrays.nElements; j > 0; j--) {
2971 type = new Type(Type::T_ARRAY, type,
2972 $3.elements[i].arrays.elements[j - 1], false);
2973 type->set_location(*$2);
2974 }
2975 Free($3.elements[i].arrays.elements);
2976
2977 /* Create the definition */
2978 $$.elements[i] = new Def_Const($3.elements[i].id,
2979 type, $3.elements[i].initial_value);
2980 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
2981 }
2982 Free($3.elements);
2983 }
2984 ;
2985
2986 ConstList: // 98
2987 optError SingleConstDef
2988 {
2989 $$.nElements = 1;
2990 $$.elements = (YYSTYPE::singlevarinst_t*)Malloc(sizeof(*$$.elements));
2991 $$.elements[0] = $2;
2992 }
2993 | ConstList ',' optError SingleConstDef
2994 {
2995 $$.nElements = $1.nElements + 1;
2996 $$.elements = (YYSTYPE::singlevarinst_t*)
2997 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
2998 $$.elements[$$.nElements - 1] = $4;
2999 }
3000 ;
3001
3002 SingleConstDef: // 90
3003 IDentifier optArrayDef AssignmentChar Expression
3004 {
3005 $$.id = $1;
3006 $$.arrays = $2;
3007 $$.initial_value = $4;
3008 $$.yyloc = @$;
3009 }
3010 ;
3011
3012 FunctionTypeDef:
3013 FunctionKeyword IDentifier '(' optFunctionFormalParList ')'
3014 optRunsOnComprefOrSelf optReturnType
3015 {
3016 $4->set_location(infile, @3, @5);
3017 Type *type = new Type(Type::T_FUNCTION, $4, $6.reference, $6.self, $7.type,
3018 $7.returns_template, $7.template_restriction);
3019 type->set_location(infile, @$);
3020 $$ = new Ttcn::Def_Type($2, type);
3021 $$->set_location(infile, @$);
3022 }
3023 ;
3024
3025 AltstepTypeDef:
3026 AltstepKeyword IDentifier '(' optAltstepFormalParList ')'
3027 optRunsOnComprefOrSelf
3028 {
3029 $4->set_location(infile, @3, @5);
3030 Type *type = new Type(Type::T_ALTSTEP, $4, $6.reference, $6.self);
3031 type->set_location(infile, @$);
3032 $$ = new Ttcn::Def_Type($2, type);
3033 $$->set_location(infile, @$);
3034 }
3035 ;
3036
3037 TestcaseTypeDef:
3038 TestcaseKeyword IDentifier '(' optTestcaseFormalParList ')'
3039 ConfigSpec
3040 {
3041 $4->set_location(infile, @3, @5);
3042 Type *type = new Type(Type::T_TESTCASE, $4, $6.runsonref,
3043 $6.systemref);
3044 type->set_location(infile, @$);
3045 $$ = new Ttcn::Def_Type($2, type);
3046 $$->set_location(infile, @$);
3047 }
3048 ;
3049
3050 /* A.1.6.1.3 Template definitions */
3051
3052 TemplateDef: // 93
3053 TemplateKeyword optTemplateRestriction BaseTemplate
3054 optDerivedDef AssignmentChar TemplateBody
3055 {
3056 $$ = new Def_Template($2, $3.name, $3.type, $3.fp_list, $4, $6);
3057 $$->set_location(infile, @$);
3058 }
3059 ;
3060
3061 BaseTemplate: // 94
3062 Type IDentifier optTemplateFormalParList
3063 {
3064 $$.name = $2;
3065 $$.type = $1;
3066 $$.fp_list = $3;
3067 }
3068 /* | Signature IDentifier optTemplateFormalParList -- covered by the previous
3069 rule */
3070 ;
3071
3072 optDerivedDef:
3073 /* empty */ { $$ = 0; }
3074 | DerivedDef { $$ = $1; }
3075 ;
3076
3077 DerivedDef: // 97
3078 ModifiesKeyword TemplateRef
3079 {
3080 $$ = new Ttcn::Reference($2.modid, $2.id);
3081 $$->set_location(infile, @$);
3082 }
3083 | ModifiesKeyword error { $$ = 0; }
3084 ;
3085
3086 optTemplateFormalParList:
3087 /* empty */ optError { $$ = 0; }
3088 | '(' TemplateFormalParList optError ')'
3089 {
3090 $$ = $2;
3091 $$->set_location(infile, @$);
3092 }
3093 | '(' error ')'
3094 {
3095 $$ = new FormalParList;
3096 $$->set_location(infile, @$);
3097 }
3098 ;
3099
3100 TemplateFormalParList: // 99 is a FormalParList*
3101 optError TemplateFormalPar
3102 {
3103 $$ = new FormalParList;
3104 $$->add_fp($2);
3105 }
3106 | TemplateFormalParList optError ',' optError TemplateFormalPar
3107 {
3108 $$ = $1;
3109 $$->add_fp($5);
3110 }
3111 | TemplateFormalParList optError ',' error { $$ = $1; }
3112 ;
3113
3114 TemplateFormalPar: // 100
3115 FormalValuePar { $$ = $1; }
3116 | FormalTemplatePar { $$ = $1; }
3117 ;
3118
3119 TemplateBody: // 101 is a Template*
3120 SimpleSpec optExtraMatchingAttributes
3121 {
3122 $$ = $1;
3123 $$->set_length_restriction($2.len_restr);
3124 $$->set_ifpresent($2.is_ifpresent);
3125 }
3126 | FieldSpecList optExtraMatchingAttributes
3127 {
3128 $$ = $1;
3129 $$->set_length_restriction($2.len_restr);
3130 $$->set_ifpresent($2.is_ifpresent);
3131 }
3132 | ArraySpecList optExtraMatchingAttributes
3133 {
3134 $$ = $1;
3135 $$->set_length_restriction($2.len_restr);
3136 $$->set_ifpresent($2.is_ifpresent);
3137 }
3138 | ArrayValueOrAttrib optExtraMatchingAttributes
3139 {
3140 $$ = $1;
3141 $$->set_length_restriction($2.len_restr);
3142 $$->set_ifpresent($2.is_ifpresent);
3143 }
3144 ;
3145
3146 SimpleSpec: // 102
3147 SingleValueOrAttrib { $$ = $1; }
3148 ;
3149
3150 FieldSpecList: // 103
3151 '{' '}'
3152 {
3153 $$ = new Template(Template::TEMPLATE_LIST, new Templates());
3154 $$->set_location(infile, @$);
3155
3156 }
3157 | '{' seqFieldSpec optError '}'
3158 {
3159 $$ = new Template($2); // NAMED_TEMLATE_LIST
3160 $$->set_location(infile, @$);
3161 }
3162 | '{' error '}'
3163 {
3164 $$ = new Template(Template::TEMPLATE_ERROR);
3165 $$->set_location(infile, @$);
3166 }
3167 ;
3168
3169 /* Sequence of FieldSpec. \note Cannot be empty */
3170 seqFieldSpec: // a NamedTemplates*
3171 FieldSpec
3172 {
3173 $$ = new NamedTemplates();
3174 $$->add_nt($1);
3175 }
3176 | error FieldSpec
3177 {
3178 $$ = new NamedTemplates();
3179 $$->add_nt($2);
3180 }
3181 | seqFieldSpec optError ',' optError FieldSpec
3182 {
3183 $$=$1;
3184 $$->add_nt($5);
3185 }
3186 | seqFieldSpec optError ',' error { $$ = $1; }
3187 ;
3188
3189 FieldSpec: // 104 a NamedTemplate*
3190 FieldReference AssignmentChar TemplateBody
3191 {
3192 $$ = new NamedTemplate($1, $3);
3193 $$->set_location(infile, @$);
3194 }
3195 | FieldReference AssignmentChar NotUsedSymbol
3196 {
3197 Template* temp = new Template(Template::TEMPLATE_NOTUSED);
3198 temp->set_location(infile, @3);
3199 $$ = new NamedTemplate($1, temp);
3200 $$->set_location(infile, @$);
3201 }
3202 ;
3203
3204 FieldReference: // 105
3205 StructFieldRef { $$ = $1; }
3206 /* | ArrayOrBitRef -- covered by ArraySpecList */
3207 /* | ParRef -- covered by StructFieldRef */
3208 ;
3209
3210 StructFieldRef: // 106 (and 107. ParRef)
3211 PredefOrIdentifier { $$ = $1; }
3212 /* | TypeReference
3213 Note: Non-parameterized type references are covered by (StructField)Identifier.
3214 Parameterized type references are covered by FunctionInstance */
3215 | FunctionInstance
3216 {
3217 Location loc(infile, @$);
3218 loc.error("Reference to a parameterized field of type `anytype' is "
3219 "not currently supported");
3220 delete $1;
3221 $$ = new Identifier(Identifier::ID_TTCN, string("<error>"));
3222 }
3223 ;
3224
3225 ArraySpecList:
3226 '{' seqArraySpec optError '}'
3227 {
3228 $$ = new Template($2);
3229 $$->set_location(infile, @$);
3230 }
3231 ;
3232
3233 seqArraySpec:
3234 ArraySpec
3235 {
3236 $$ = new IndexedTemplates();
3237 $$->add_it($1);
3238 }
3239 /* It was optError before. */
3240 | error ArraySpec
3241 {
3242 $$ = new IndexedTemplates();
3243 $$->add_it($2);
3244 }
3245 | seqArraySpec optError ',' optError ArraySpec
3246 {
3247 $$ = $1;
3248 $$->add_it($5);
3249 }
3250 | seqArraySpec optError ',' error { $$ = $1; }
3251 ;
3252
3253 ArraySpec:
3254 ArrayOrBitRef AssignmentChar TemplateBody
3255 {
3256 $$ = new IndexedTemplate($1, $3);
3257 $$->set_location(infile, @$);
3258 }
3259 ;
3260
3261 ArrayOrBitRef: // 109
3262 '[' Expression ']'
3263 {
3264 $$ = new FieldOrArrayRef($2);
3265 $$->set_location(infile, @$);
3266 }
3267 | '[' error ']'
3268 {
3269 $$ = new FieldOrArrayRef(new Value(Value::V_ERROR));
3270 $$->set_location(infile, @$);
3271 }
3272 ;
3273
3274 SingleValueOrAttrib: // 111
3275 MatchingSymbol { $$ = $1; }
3276 | SingleExpression
3277 {
3278 if ($1->get_valuetype() == Value::V_OMIT) {
3279 delete $1;
3280 $$ = new Template(Template::OMIT_VALUE);
3281 } else $$ = new Template($1); // SPECIFIC_VALUE; SingleExpr is a Template*
3282 $$->set_location(infile, @$);
3283 }
3284 /* | TemplateRefWithParList -- covered by SingleExpression */
3285 ;
3286
3287 ArrayValueOrAttrib: // 112
3288 '{' ArrayElementSpecList optError '}'
3289 {
3290 $$ = new Template(Template::TEMPLATE_LIST, $2);
3291 $$->set_location(infile, @$);
3292 }
3293 ;
3294
3295 ArrayElementSpecList: // 113
3296 ArrayElementSpec
3297 {
3298 $$ = new Templates;
3299 $$->add_t($1);
3300 }
3301 | error ArrayElementSpec
3302 {
3303 $$ = new Templates;
3304 $$->add_t($2);
3305 }
3306 | ArrayElementSpecList optError ',' optError ArrayElementSpec
3307 {
3308 $$=$1;
3309 $$->add_t($5);
3310 }
3311 | ArrayElementSpecList optError ',' error { $$ = $1; }
3312 ;
3313
3314 ArrayElementSpec: // 114 is a Template*
3315 NotUsedSymbol
3316 {
3317 $$ = new Template(Template::TEMPLATE_NOTUSED);
3318 $$->set_location(infile, @$);
3319 }
3320 | PermutationMatch
3321 {
3322 $$ = new Template(Template::PERMUTATION_MATCH, $1);
3323 $$->set_location(infile, @$);
3324 }
3325 | TemplateListElem { $$ = $1; }
3326 ;
3327
3328 NotUsedSymbol: // 115
3329 '-'
3330 ;
3331
3332 MatchingSymbol: // 116 is a Template*
3333 Complement
3334 {
3335 $$ = new Template(Template::COMPLEMENTED_LIST, $1);
3336 $$->set_location(infile, @$);
3337 }
3338 | AnyValue
3339 {
3340 $$ = new Template(Template::ANY_VALUE);
3341 $$->set_location(infile, @$);
3342 }
3343 | AnyOrOmit
3344 {
3345 $$ = new Template(Template::ANY_OR_OMIT);
3346 $$->set_location(infile, @$);
3347 }
3348 | ValueOrAttribList
3349 {
3350 $$ = new Template(Template::VALUE_LIST, $1);
3351 $$->set_location(infile, @$);
3352 }
3353 | Range
3354 {
3355 $$ = new Template($1);
3356 $$->set_location(infile, @$);
3357 }
3358 | BitStringMatch
3359 {
3360 $$ = new Template(Template::BSTR_PATTERN, $1);
3361 $$->set_location(infile, @$);
3362 }
3363 | HexStringMatch
3364 {
3365 $$ = new Template(Template::HSTR_PATTERN, $1);
3366 $$->set_location(infile, @$);
3367 }
3368 | OctetStringMatch
3369 {
3370 $$ = new Template(Template::OSTR_PATTERN, $1);
3371 $$->set_location(infile, @$);
3372 }
3373 | CharStringMatch
3374 {
3375 $$ = new Template($1);
3376 $$->set_location(infile, @$);
3377 }
3378 | SubsetMatch
3379 {
3380 $$ = new Template(Template::SUBSET_MATCH, $1);
3381 $$->set_location(infile, @$);
3382 }
3383 | SupersetMatch
3384 {
3385 $$ = new Template(Template::SUPERSET_MATCH, $1);
3386 $$->set_location(infile, @$);
3387 }
3388 | '(' AllElementsFrom ')'
3389 {
3390 $$ = new Template(Template::VALUE_LIST_ALL_FROM, $2);
3391 $$->set_location(infile, @$);
3392 }
3393 ;
3394
3395 optExtraMatchingAttributes: // [117]
3396 /* empty */
3397 {
3398 $$.is_ifpresent = false;
3399 $$.len_restr = NULL;
3400 }
3401 | LengthMatch
3402 {
3403 $$.len_restr = $1;
3404 $$.is_ifpresent = false;
3405 }
3406 | IfPresentMatch
3407 {
3408 $$.len_restr = NULL;
3409 $$.is_ifpresent = true;
3410 }
3411 | LengthMatch IfPresentMatch
3412 {
3413 $$.len_restr = $1;
3414 $$.is_ifpresent = true;
3415 }
3416 ;
3417
3418 CharStringMatch: // 124
3419 PatternKeyword PatternChunkList
3420 {
3421 Location loc(infile, @2);
3422 $$ = parse_pattern($2, loc);
3423 Free($2);
3424 }
3425 ;
3426
3427 PatternChunkList:
3428 PatternChunk
3429 {
3430 $$ = $1;
3431 }
3432 | PatternChunkList '&' PatternChunk
3433 {
3434 $$ = $1;
3435 $$ = mputstr($$, $3);
3436 Free($3);
3437 }
3438 ;
3439
3440 PatternChunk:
3441 Cstring
3442 {
3443 $$ = $1;
3444 }
3445 | ReferencedValue
3446 {
3447 switch ($1->get_valuetype()) {
3448 case Value::V_REFD: {
3449 /* Pretend to be a reference. Let pstring_la.l discover the
3450 references. */
3451 Common::Reference *ref = $1->get_reference();
3452 $$ = mprintf("{%s}", (ref->get_dispname()).c_str());
3453 break; }
3454 case Value::V_UNDEF_LOWERID: {
3455 const Common::Identifier *id = $1->get_val_id();
3456 $$ = mprintf("{%s}", (id->get_dispname()).c_str());
3457 break; }
3458 default:
3459 FATAL_ERROR("Internal error.");
3460 }
3461 /* Forget the Node. */
3462 delete $1;
3463 }
3464 | Quadruple
3465 {
3466 ustring::universal_char& uc = $1->operator[](0);
3467 $$ = mprintf("\\q{%d,%d,%d,%d}", uc.group, uc.plane, uc.row, uc.cell);
3468 delete $1;
3469 }
3470 ;
3471
3472 Complement: // 130 is a Templates*
3473 ComplementKeyword ValueList { $$ = $2; }
3474 ;
3475
3476 ValueList: // 132 is a Templates*
3477 '(' seqValueOrAttrib optError ')' { $$ = $2; }
3478 | '(' error ')' { $$ = new Templates; }
3479 ;
3480
3481 seqValueOrAttrib: // is a Templates*
3482 optError TemplateListElem
3483 {
3484 $$ = new Templates;
3485 $$->add_t($2);
3486 }
3487 | seqValueOrAttrib optError ',' optError TemplateListElem
3488 {
3489 $$ = $1;
3490 $$->add_t($5);
3491 }
3492 | seqValueOrAttrib optError ',' error { $$ = $1; }
3493 ;
3494
3495 SubsetMatch: // 133 is a Templates*
3496 SubsetKeyword ValueList { $$ = $2; }
3497 ;
3498
3499 SupersetMatch: // 135 is a Templates*
3500 SupersetKeyword ValueList { $$ = $2; }
3501 ;
3502
3503 PermutationMatch: // 137 is a Templates*
3504 PermutationKeyword ValueList { $$ = $2; }
3505 ;
3506
3507 AnyValue: // 140
3508 '?'
3509 ;
3510
3511 AnyOrOmit: // 141
3512 '*'
3513 ;
3514
3515 TemplateListElem: // is a Template*
3516 TemplateBody
3517 | AllElementsFrom
3518 ;
3519
3520 AllElementsFrom: // is a Template*
3521 AllKeyword FromKeyword TemplateBody
3522 { // $3 is a Template*
3523 $$ = new Template($3); // Constructs ALL_FROM
3524 $$->set_location(infile, @$);
3525 }
3526 ;
3527
3528 ValueOrAttribList: // 142 is a Templates*
3529 /* ValueOrAttribList always has two or more elements
3530 * (there's always a comma) and is reduced through
3531 * ValueOrAttribList -> MatchingSymbol -> SingleValueOrAttrib
3532 *
3533 * The one-element list is reduced through
3534 * '(' SingleExpression ')' -> SingleExpression -> SingleValueOrAttrib */
3535 '(' TemplateListElem optError ',' seqValueOrAttrib optError ')'
3536 {
3537 $$ = $5;
3538 $$->add_front_t($2);
3539 }
3540 | '(' error TemplateListElem optError ',' seqValueOrAttrib optError ')'
3541 {
3542 $$ = $6;
3543 $$->add_front_t($3);
3544 }
3545 ;
3546
3547 LengthMatch: // 143
3548 StringLength { $$ = $1; }
3549 ;
3550
3551 IfPresentMatch: // 144
3552 IfPresentKeyword
3553 ;
3554
3555 Range: // 147
3556 '(' SingleLowerBound DotDot UpperBound optError ')'
3557 { $$ = new ValueRange($2, $4); }
3558 ;
3559
3560 SingleLowerBound:
3561 SingleExpression
3562 {
3563 if ($1->is_parsed_infinity()==-1) {
3564 /* the conflicting rule alternative faked here: '-' InfinityKeyword */
3565 delete $1;
3566 $$ = 0;
3567 } else {
3568 $$ = $1;
3569 }
3570 }
3571 ;
3572
3573 LowerBound: // 148
3574 Expression
3575 {
3576 if ($1->is_parsed_infinity()==-1) {
3577 /* the conflicting rule alternative faked here: '-' InfinityKeyword */
3578 delete $1;
3579 $$ = 0;
3580 } else {
3581 $$ = $1;
3582 }
3583 }
3584 ;
3585
3586 UpperBound: // 149
3587 Expression
3588 {
3589 if ($1->is_parsed_infinity()==1) {
3590 /* the conflicting rule alternative faked here: InfinityKeyword */
3591 delete $1;
3592 $$ = 0;
3593 } else {
3594 $$ = $1;
3595 }
3596 }
3597 ;
3598
3599 TemplateInstance: // 151
3600 InLineTemplate { $$ = $1; }
3601 ;
3602
3603 TemplateRefWithParList: /* refbase */ // 153 ?
3604 TemplateRef optTemplateActualParList
3605 {
3606 if ($2) {
3607 $$ = new Ttcn::Ref_pard($1.modid, $1.id, new ParsedActualParameters($2));
3608 $$->set_location(infile, @$);
3609 } else {
3610 $$ = new Ttcn::Reference($1.modid, $1.id);
3611 $$->set_location(infile, @$);
3612 }
3613 }
3614 ;
3615
3616 TemplateRef: // 154
3617 IDentifier
3618 {
3619 $$.modid = 0;
3620 $$.id = $1;
3621 }
3622 | IDentifier '.' IDentifier
3623 {
3624 $$.modid = $1;
3625 $$.id = $3;
3626 }
3627 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
3628 {
3629 $$.modid = $1;
3630 $$.id = $5;
3631 delete $3;
3632 }
3633 ;
3634
3635 InLineTemplate: // 155
3636 TemplateBody
3637 {
3638 $$ = new TemplateInstance(0, 0, $1);
3639 $$->set_location(infile, @$);
3640 }
3641 | Type ':' TemplateBody
3642 {
3643 $$ = new TemplateInstance($1, 0, $3);
3644 $$->set_location(infile, @$);
3645 }
3646 /* | Signature ':' TemplateBody -- covered by the previous rule */
3647 | DerivedRefWithParList AssignmentChar TemplateBody
3648 {
3649 $$ = new TemplateInstance(0, $1, $3);
3650 $$->set_location(infile, @$);
3651 }
3652 | Type ':' DerivedRefWithParList AssignmentChar TemplateBody
3653 {
3654 $$ = new TemplateInstance($1, $3, $5);
3655 $$->set_location(infile, @$);
3656 }
3657 /* | Signature ':' DerivedRefWithParList AssignmentChar TemplateBody
3658 -- covered by the previous rule */
3659 ;
3660
3661 DerivedRefWithParList: // 156
3662 ModifiesKeyword TemplateRefWithParList { $$ = $2; }
3663 ;
3664
3665 optTemplateActualParList: // [157]
3666 /* empty */ optError { $$ = 0; }
3667 | '(' seqTemplateActualPar optError ')'
3668 {
3669 $$ = $2;
3670 $$->set_location(infile, @$);
3671 }
3672 | '(' error ')'
3673 {
3674 $$ = new TemplateInstances;
3675 $$->set_location(infile, @$);
3676 }
3677 ;
3678
3679 seqTemplateActualPar:
3680 optError TemplateActualPar
3681 {
3682 $$ = new TemplateInstances;
3683 $$->add_ti($2);
3684 }
3685 | seqTemplateActualPar optError ',' optError TemplateActualPar
3686 {
3687 $$ = $1;
3688 $$->add_ti($5);
3689 }
3690 | seqTemplateActualPar optError ',' error { $$ = $1; }
3691 ;
3692
3693 TemplateActualPar: // 158
3694 TemplateInstance { $$ = $1; }
3695 | NotUsedSymbol
3696 {
3697 Template *t = new Template(Template::TEMPLATE_NOTUSED);
3698 t->set_location(infile, @$);
3699 $$ = new TemplateInstance(0, 0, t);
3700 $$->set_location(infile, @$);
3701 }
3702 ;
3703
3704 TemplateOps: // 159
3705 MatchOp { $$ = $1; }
3706 | ValueofOp { $$ = $1; }
3707 ;
3708
3709 MatchOp: // 160
3710 MatchKeyword '(' optError Expression optError ',' optError TemplateInstance
3711 optError ')'
3712 {
3713 $$ = new Value(Value::OPTYPE_MATCH, $4, $8);
3714 $$->set_location(infile, @$);
3715 }
3716 | MatchKeyword '(' error ')'
3717 {
3718 Value *v = new Value(Value::V_ERROR);
3719 v->set_location(infile, @3);
3720 Template *t = new Template(Template::TEMPLATE_ERROR);
3721 t->set_location(infile, @3);
3722 TemplateInstance *ti = new TemplateInstance(0, 0, t);
3723 ti->set_location(infile, @3);
3724 $$ = new Value(Value::OPTYPE_MATCH, v, ti);
3725 $$->set_location(infile, @$);
3726 }
3727 ;
3728
3729 ValueofOp: // 162
3730 ValueofKeyword '(' optError TemplateInstance optError ')'
3731 {
3732 $$ = new Value(Value::OPTYPE_VALUEOF, $4);
3733 $$->set_location(infile, @$);
3734 }
3735 | ValueofKeyword '(' error ')'
3736 {
3737 Template *t = new Template(Template::TEMPLATE_ERROR);
3738 t->set_location(infile, @3);
3739 TemplateInstance *ti = new TemplateInstance(0, 0, t);
3740 ti->set_location(infile, @3);
3741 $$ = new Value(Value::OPTYPE_VALUEOF, ti);
3742 $$->set_location(infile, @$);
3743 }
3744 ;
3745
3746 /* A.1.6.1.4 Function definitions */
3747
3748 FunctionDef: // 164
3749 FunctionKeyword IDentifier '(' optFunctionFormalParList ')'
3750 optRunsOnSpec optReturnType optError StatementBlock
3751 {
3752 $4->set_location(infile, @3, @5);
3753 $$ = new Def_Function($2, $4, $6, $7.type, $7.returns_template,
3754 $7.template_restriction, $9);
3755 $$->set_location(infile, @$);
3756 }
3757 ;
3758
3759 optFunctionFormalParList: // [167]
3760 /* empty */ { $$ = new FormalParList; }
3761 | FunctionFormalParList { $$ = $1; }
3762 | error { $$ = new FormalParList; }
3763 ;
3764
3765 FunctionFormalParList: // 167
3766 optError FunctionFormalPar
3767 {
3768 $$ = new FormalParList;
3769 $$->add_fp($2);
3770 }
3771 | FunctionFormalParList optError ',' optError FunctionFormalPar
3772 {
3773 $$ = $1;
3774 $$->add_fp($5);
3775 }
3776 | FunctionFormalParList optError ',' error { $$ = $1; }
3777 ;
3778
3779 FunctionFormalPar: // 168
3780 FormalValuePar { $$ = $1; }
3781 | FormalTimerPar { $$ = $1; }
3782 | FormalTemplatePar { $$ = $1; }
3783 /*| FormalPortPar -- covered by FormalValuePar */
3784 ;
3785
3786 optReturnType: // [169]
3787 /* empty */
3788 {
3789 $$.type = 0;
3790 $$.returns_template = false;
3791 $$.template_restriction = TR_NONE;
3792 }
3793 | ReturnKeyword Type
3794 {
3795 $$.type = $2;
3796 $$.returns_template = false;
3797 $$.template_restriction = TR_NONE;
3798 }
3799 | ReturnKeyword TemplateOptRestricted Type
3800 {
3801 $$.type = $3;
3802 $$.returns_template = true;
3803 $$.template_restriction = $2;
3804 }
3805 | ReturnKeyword error
3806 {
3807 $$.type = 0;
3808 $$.returns_template = false;
3809 $$.template_restriction = TR_NONE;
3810 }
3811 ;
3812
3813 optRunsOnComprefOrSelf:
3814 optRunsOnSpec
3815 {
3816 $$.self = false;
3817 $$.reference = $1;
3818 }
3819 | RunsKeyword OnKeyword SelfKeyword
3820 {
3821 $$.self = true;
3822 $$.reference = 0;
3823 }
3824 ;
3825
3826 optRunsOnSpec:
3827 /* empty */ { $$ = 0; }
3828 | RunsOnSpec { $$ = $1; }
3829 | RunsKeyword error { $$ = 0; }
3830 ;
3831
3832 RunsOnSpec: // 171
3833 RunsKeyword OnKeyword ComponentType { $$ = $3; }
3834 ;
3835
3836 /* StatementBlock changed in 4.1.2 to explicitly prevent statements
3837 * followed by definitions. TITAN still allows them to be mixed. */
3838 StatementBlock: /* StatementBlock *statementblock */ // 175
3839 '{' optError '}'
3840 {
3841 $$ = new StatementBlock;
3842 $$->set_location(infile, @$);
3843 }
3844 | '{' FunctionStatementOrDefList optError '}'
3845 {
3846 $$ = $2;
3847 $$->set_location(infile, @$);
3848 }
3849 ;
3850
3851 FunctionStatementOrDefList: // (171 in 3.2.1)
3852 optError FunctionStatementOrDef optSemiColon
3853 {
3854 $$ = new StatementBlock;
3855 for(size_t i=0; i<$2.nElements; i++) $$->add_stmt($2.elements[i]);
3856 Free($2.elements);
3857 }
3858 | FunctionStatementOrDefList optError FunctionStatementOrDef optSemiColon
3859 {
3860 $$=$1;
3861 for(size_t i=0; i<$3.nElements; i++) $$->add_stmt($3.elements[i]);
3862 Free($3.elements);
3863 }
3864 ;
3865
3866 FunctionStatementOrDef: // (172 in 3.2.1)
3867 FunctionLocalDef // constant or template definition
3868 {
3869 $$.nElements=$1.nElements;
3870 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
3871 for(size_t i=0; i<$1.nElements; i++) {
3872 $$.elements[i]=new Statement(Statement::S_DEF, $1.elements[i]);
3873 $$.elements[i]->set_location(*$1.elements[i]);
3874 }
3875 Free($1.elements);
3876 }
3877 | FunctionLocalInst // variable or timer instance
3878 {
3879 $$.nElements=$1.nElements;
3880 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
3881 for(size_t i=0; i<$1.nElements; i++) {
3882 $$.elements[i]=new Statement(Statement::S_DEF, $1.elements[i]);
3883 $$.elements[i]->set_location(*$1.elements[i]);
3884 }
3885 Free($1.elements);
3886 }
3887 | FunctionStatement
3888 {
3889 $$.nElements=1;
3890 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
3891 $$.elements[0]=$1;
3892 }
3893 ;
3894
3895 FunctionLocalInst: // 178
3896 VarInstance { $$=$1; }
3897 | TimerInstance { $$=$1; }
3898 ;
3899
3900 FunctionLocalDef: // 179
3901 ConstDef { $$=$1; }
3902 | TemplateDef
3903 {
3904 $1->set_local();
3905 $$.nElements = 1;
3906 $$.elements = (Ttcn::Definition**)Malloc(sizeof(*$$.elements));
3907 $$.elements[0] = $1;
3908 }
3909 ;
3910
3911 FunctionStatement: // 180
3912 ConfigurationStatements {$$=$1;}
3913 | TimerStatements {$$=$1;}
3914 | CommunicationStatements {$$=$1;}
3915 | BasicStatements {$$=$1;}
3916 | BehaviourStatements {$$=$1;}
3917 | VerdictStatements {$$=$1;}
3918 | SUTStatements {$$=$1;}
3919 | StopExecutionStatement { $$ = $1; }
3920 | StopTestcaseStatement { $$ = $1; }
3921 | ProfilerStatement { $$ = $1; }
3922 ;
3923
3924 FunctionInstance: /* refpard */ // 181
3925 FunctionRef '(' optFunctionActualParList ')'
3926 /* templateref templinsts */
3927 {
3928 $3->set_location(infile, @2, @4);
3929 $$ = new Ttcn::Ref_pard($1.modid, $1.id, $3);
3930 $$->set_location(infile, @$);
3931 }
3932 ;
3933
3934 FunctionRef: // 182
3935 IDentifier
3936 {
3937 $$.modid = 0;
3938 $$.id = $1;
3939 }
3940 | IDentifier '.' IDentifier
3941 {
3942 $$.modid = $1;
3943 $$.id = $3;
3944 }
3945 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
3946 {
3947 $$.modid = $1;
3948 $$.id = $5;
3949 delete $3;
3950 }
3951 ;
3952
3953 optFunctionActualParList: /* parsedpar */ // [185]
3954 /* empty */ optError { $$ = new ParsedActualParameters; }
3955 | FunctionActualParList optError { $$ = $1; }
3956 ;
3957
3958 /* ***** this * can * not * be * empty ****************** */
3959 FunctionActualParList: /* parsedpar */ // 184
3960 UnnamedPart
3961 | NamedPart
3962 | UnnamedPart ',' NamedPart
3963 /* Splitting the NamedPart and UnnamedPart ensures that a named parameter
3964 * followed by an unnamed one causes a syntax error */
3965 {
3966 /* UnnamedPart becomes the value */
3967 $$ = $1;
3968 /* append the elements from NamedPart */
3969 const size_t n3 = $3->get_nof_nps();
3970 for (size_t i = 0; i < n3; ++i) {
3971 $$->add_np( $3->extract_np_byIndex(i) );
3972 }
3973 delete $3;
3974 }
3975 ;
3976
3977 UnnamedPart: /* parsedpar */
3978 /*optError*/ FunctionActualPar
3979 {
3980 $$ = new ParsedActualParameters;
3981 $$->add_ti($1);
3982 }
3983 | UnnamedPart /*optError*/ ',' /*optError*/ FunctionActualPar
3984 /* These optErrors mess up the parsing of actual parameters.
3985 * After only one FunctionActualPar, it is reduced to UnnamedPart
3986 * and the rest is expected to be the NamedPart */
3987 {
3988 $$ = $1;
3989 $$->add_ti($3);
3990 }
3991 | UnnamedPart optError ',' error { $$ = $1; }
3992 ;
3993
3994 NamedPart: /* parsedpar */
3995 seqFieldSpec /* namedtempls */
3996 {
3997 $$ = new ParsedActualParameters(0, new NamedParams);
3998 const size_t n1 = $1->get_nof_nts();
3999 for (size_t i = 0; i < n1; ++i) {
4000 NamedTemplate *pnt = $1->get_nt_byIndex(i);
4001 TemplateInstance *pti = new TemplateInstance(0,0,pnt->extract_template());
4002 NamedParam *pnp = new NamedParam(pnt->get_name().clone(), pti);
4003 pnp->set_location(*pnt);
4004 $$->add_np(pnp);
4005 }
4006 delete $1;
4007 $$->set_location(infile, @$);
4008 // This call to ParsedActualParameters::set_location copies the same
4009 // location info to the named and unnamed part. We cannot copy
4010 // the location info from the NamedTemplates to the named part,
4011 // because NamedTemplates is not a Location.
4012 }
4013 ;
4014
4015 FunctionActualPar: /* templinst */ // 185
4016 /* TimerRef */
4017 TemplateInstance { $$ = $1; }
4018 | NotUsedSymbol
4019 {
4020 Template *t = new Template(Template::TEMPLATE_NOTUSED);
4021 t->set_location(infile, @$);
4022 $$ = new TemplateInstance(0, 0, t);
4023 $$->set_location(infile, @$);
4024 }
4025 /* | Port
4026 | ComponentRef -- TemplateInstance covers all the others */
4027 ;
4028
4029 ApplyOp:
4030 Reference DotApplyKeyword '(' optFunctionActualParList ')'
4031 {
4032 if($1.is_ref) $$.value = new Value(Value::V_REFD, $1.ref);
4033 else {
4034 Ttcn::Reference *t_ref = new Ttcn::Reference($1.id);
4035 t_ref->set_location(infile, @1);
4036 $$.value = new Value(Value::V_REFD, t_ref);
4037 }
4038 $$.value->set_location(infile, @1);
4039 $$.ap_list = $4;
4040 $$.ap_list->set_location(infile, @3 , @5);
4041 }
4042 | FunctionInstance DotApplyKeyword '(' optFunctionActualParList ')'
4043 {
4044 $$.value = new Value(Value::V_REFD, $1);
4045 $$.value->set_location(infile, @1);
4046 $$.ap_list = $4;
4047 $$.ap_list->set_location(infile, @3 , @5);
4048 }
4049 | ApplyOp DotApplyKeyword '(' optFunctionActualParList ')'
4050 {
4051 $$.value = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
4052 $$.value->set_location(infile, @1);
4053 $$.ap_list = $4;
4054 $$.ap_list->set_location(infile, @3 , @5);
4055 }
4056 ;
4057
4058 DereferOp:
4059 DerefersKeyword '(' Expression ')' { $$ = $3; }
4060 ;
4061
4062 /* A.1.6.1.5 Signature definitions */
4063
4064 SignatureDef: // 187
4065 SignatureKeyword IDentifier
4066 '(' optSignatureFormalParList ')' optReturnTypeOrNoBlockKeyword
4067 optExceptionSpec
4068 {
4069 Type *type = new Type(Type::T_SIGNATURE, $4, $6.type, $6.no_block_kw, $7);
4070 type->set_location(infile, @3, @7);
4071 $$ = new Ttcn::Def_Type($2, type);
4072 $$->set_location(infile, @$);
4073 }
4074 ;
4075
4076 optSignatureFormalParList: // [190]
4077 /* empty */ { $$ = 0; }
4078 | SignatureFormalParList { $$ = $1; }
4079 | error { $$ = 0; }
4080 ;
4081
4082 SignatureFormalParList: // 190
4083 optError SignatureFormalPar
4084 {
4085 $$ = new SignatureParamList;
4086 $$->add_param($2);
4087 }
4088 | SignatureFormalParList optError ',' optError SignatureFormalPar
4089 {
4090 $$ = $1;
4091 $$->add_param($5);
4092 }
4093 | SignatureFormalParList optError ',' error { $$ = $1; }
4094 ;
4095
4096 SignatureFormalPar: // 191
4097 Type IDentifier
4098 {
4099 $$ = new SignatureParam(SignatureParam::PARAM_IN, $1, $2);
4100 $$->set_location(infile, @$);
4101 }
4102 | InParKeyword Type IDentifier
4103 {
4104 $$ = new SignatureParam(SignatureParam::PARAM_IN, $2, $3);
4105 $$->set_location(infile, @$);
4106 }
4107 | InOutParKeyword Type IDentifier
4108 {
4109 $$ = new SignatureParam(SignatureParam::PARAM_INOUT, $2, $3);
4110 $$->set_location(infile, @$);
4111 }
4112 | OutParKeyword Type IDentifier
4113 {
4114 $$ = new SignatureParam(SignatureParam::PARAM_OUT, $2, $3);
4115 $$->set_location(infile, @$);
4116 }
4117 ;
4118
4119 optReturnTypeOrNoBlockKeyword:
4120 /* empty */
4121 {
4122 $$.type = NULL;
4123 $$.no_block_kw = false;
4124 }
4125 | ReturnKeyword Type
4126 {
4127 $$.type = $2;
4128 $$.no_block_kw = false;
4129 }
4130 | NoBlockKeyword
4131 {
4132 $$.type = NULL;
4133 $$.no_block_kw = true;
4134 }
4135 ;
4136
4137 optExceptionSpec: // [192]
4138 /* empty */ { $$ = NULL; }
4139 | ExceptionKeyword '(' error ')' { $$ = NULL; }
4140 | ExceptionKeyword '(' ExceptionTypeList optError ')'
4141 {
4142 $$ = $3;
4143 $$->set_location(infile, @$);
4144 }
4145 ;
4146
4147 ExceptionTypeList: // 194
4148 optError Type
4149 {
4150 $$ = new SignatureExceptions;
4151 $$->add_type($2);
4152 }
4153 | ExceptionTypeList optError ',' optError Type
4154 {
4155 $$ = $1;
4156 $$->add_type($5);
4157 }
4158 | ExceptionTypeList optError ',' error { $$ = $1; }
4159 ;
4160
4161 Signature: // 196
4162 IDentifier
4163 {
4164 $$ = new Ttcn::Reference($1);
4165 $$->set_location(infile, @$);
4166 }
4167 | IDentifier '.' IDentifier
4168 {
4169 $$ = new Ttcn::Reference($1, $3);
4170 $$->set_location(infile, @$);
4171 }
4172 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
4173 {
4174 $$ = new Ttcn::Reference($1, $5);
4175 $$->set_location(infile, @$);
4176 delete $3;
4177 }
4178 ;
4179
4180 /* A.1.6.1.6 Testcase definitions */
4181
4182 TestcaseDef: // 197
4183 TestcaseKeyword IDentifier '(' optTestcaseFormalParList ')'
4184 ConfigSpec optError StatementBlock
4185 {
4186 $4->set_location(infile, @3, @5);
4187 $$ = new Def_Testcase($2, $4, $6.runsonref, $6.systemref, $8);
4188 $$->set_location(infile, @$);
4189 }
4190 ;
4191
4192 optTestcaseFormalParList: // [200]
4193 /* empty */ { $$ = new FormalParList; }
4194 | TestcaseFormalParList { $$ = $1; }
4195 | error { $$ = new FormalParList; }
4196 ;
4197
4198 TestcaseFormalParList: // 200
4199 optError TestcaseFormalPar
4200 {
4201 $$ = new FormalParList;
4202 $$->add_fp($2);
4203 }
4204 | TestcaseFormalParList optError ',' optError TestcaseFormalPar
4205 {
4206 $$ = $1;
4207 $$->add_fp($5);
4208 }
4209 | TestcaseFormalParList optError ',' error { $$ = $1; }
4210 ;
4211
4212 TestcaseFormalPar: // 201
4213 FormalValuePar { $$ = $1; }
4214 | FormalTemplatePar { $$ = $1; }
4215 ;
4216
4217 ConfigSpec: // 202
4218 RunsOnSpec optSystemSpec
4219 {
4220 $$.runsonref=$1;
4221 $$.systemref=$2;
4222 }
4223 ;
4224
4225 optSystemSpec: // [203]
4226 /* empty */ { $$ = 0; }
4227 | SystemKeyword ComponentType { $$ = $2; }
4228 | SystemKeyword error { $$ = 0; }
4229 ;
4230
4231 TestcaseInstance: // 205
4232 ExecuteKeyword '(' TestcaseRef '(' optTestcaseActualParList ')'
4233 optTestcaseTimerValue optError ')'
4234 {
4235 $5->set_location(infile, @4, @6);
4236 $$.ref_pard = new Ttcn::Ref_pard($3.modid, $3.id, $5);
4237 $$.ref_pard->set_location(infile, @3, @6);
4238 $$.derefered_value = 0;
4239 $$.ap_list = $5;
4240 $$.value = $7;
4241 }
4242 | ExecuteKeyword '(' DereferOp '(' optTestcaseActualParList ')'
4243 optTestcaseTimerValue optError ')'
4244 {
4245 $5->set_location(infile, @4, @6);
4246 $$.ref_pard = 0;
4247 $$.derefered_value = $3;
4248 $$.ap_list = $5;
4249 $$.value = $7;
4250 }
4251 | ExecuteKeyword '(' error ')'
4252 {
4253 $$.ref_pard = 0;
4254 $$.derefered_value = 0;
4255 $$.ap_list = 0;
4256 $$.value = 0;
4257 }
4258 ;
4259
4260 TestcaseRef: // 207
4261 IDentifier
4262 {
4263 $$.modid = NULL;
4264 $$.id = $1;
4265 }
4266 | IDentifier '.' IDentifier
4267 {
4268 $$.modid = $1;
4269 $$.id = $3;
4270 }
4271 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
4272 {
4273 $$.modid = $1;
4274 $$.id = $5;
4275 delete $3;
4276 }
4277 ;
4278
4279 optTestcaseTimerValue:
4280 /* empty */ { $$ = 0; }
4281 | ',' optError Expression { $$ = $3; }
4282 | ',' error
4283 {
4284 $$ = new Value(Value::V_ERROR);
4285 $$->set_location(infile, @$);
4286 }
4287 ;
4288
4289 optTestcaseActualParList: // [202]
4290 /* empty */ optError { $$ = new ParsedActualParameters; }
4291 | TestcaseActualParList optError { $$ = $1; }
4292 ;
4293
4294 TestcaseActualParList: // 208
4295 UnnamedPart
4296 | NamedPart
4297 | UnnamedPart ',' NamedPart
4298 /* Splitting the NamedPart and UnnamedPart ensures that a named parameter
4299 * followed by an unnamed one causes a syntax error */
4300 {
4301 /* UnnamedPart becomes the value */
4302 $$ = $1;
4303 /* append the elements from NamedPart */
4304 const size_t n3 = $3->get_nof_nps();
4305 for (size_t i = 0; i < n3; ++i) {
4306 $$->add_np( $3->extract_np_byIndex(i) );
4307 }
4308 delete $3;
4309 }
4310
4311 /*
4312 optError TestcaseActualPar
4313 {
4314 $$ = new TemplateInstances;
4315 $$->add_ti($2);
4316 }
4317 | TestcaseActualParList optError ',' optError TestcaseActualPar
4318 {
4319 $$ = $1;
4320 $$->add_ti($5);
4321 }
4322 | TestcaseActualParList optError ',' error { $$ = $1; }
4323 */
4324 ;
4325
4326 /*
4327 TestcaseActualPar:
4328 TemplateInstance { $$ = $1; }
4329 | NotUsedSymbol
4330 {
4331 Template *t = new Template(Template::TEMPLATE_NOTUSED);
4332 t->set_location(infile, @$);
4333 $$ = new TemplateInstance(0, 0, t);
4334 $$->set_location(infile, @$);
4335 }
4336 ;
4337 */
4338
4339 /* A.1.6.1.7 Altstep definitions */
4340
4341 AltstepDef: // 211
4342 AltstepKeyword IDentifier '(' optAltstepFormalParList ')' optRunsOnSpec
4343 optError '{' AltstepLocalDefList AltGuardList optError '}'
4344 {
4345 StatementBlock *sb = new StatementBlock;
4346 for (size_t i = 0; i < $9.nElements; i++) {
4347 Statement *stmt = new Statement(Statement::S_DEF, $9.elements[i]);
4348 stmt->set_location(*$9.elements[i]);
4349 sb->add_stmt(stmt);
4350 }
4351 Free($9.elements);
4352 $4->set_location(infile, @4);
4353 $$ = new Def_Altstep($2, $4, $6, sb, $10);
4354 $$->set_location(infile, @$);
4355 }
4356 ;
4357
4358 optAltstepFormalParList: // [214]
4359 /* empty */ { $$ = new FormalParList; }
4360 | FunctionFormalParList { $$ = $1; }
4361 | error { $$ = new FormalParList; }
4362 ;
4363
4364 AltstepLocalDefList: // 215
4365 /* empty */
4366 {
4367 $$.nElements = 0;
4368 $$.elements = 0;
4369 }
4370 | AltstepLocalDefList optError AltstepLocalDef optSemiColon
4371 {
4372 $$.nElements = $1.nElements + $3.nElements;
4373 $$.elements = (Ttcn::Definition**)
4374 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4375 memcpy($$.elements + $1.nElements, $3.elements,
4376 $3.nElements * sizeof(*$$.elements));
4377 Free($3.elements);
4378 }
4379 ;
4380
4381 AltstepLocalDef: // 216
4382 VarInstance { $$ = $1; }
4383 | TimerInstance { $$ = $1; }
4384 | ConstDef { $$ = $1; }
4385 | TemplateDef
4386 {
4387 $1->set_local();
4388 $$.nElements = 1;
4389 $$.elements = (Ttcn::Definition**)Malloc(sizeof(*$$.elements));
4390 $$.elements[0] = $1;
4391 }
4392 ;
4393
4394 AltstepInstance: /* refpard */ // 217
4395 FunctionRef '(' optFunctionActualParList ')'
4396 {
4397 $3->set_location(infile, @2, @4);
4398 $$ = new Ttcn::Ref_pard($1.modid, $1.id, $3);
4399 $$->set_location(infile, @$);
4400 }
4401 ;
4402
4403 /* Taken over by FunctionRef
4404 AltstepRef: // 211
4405 IDentifier
4406 | IDentifier '.' IDentifier
4407 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
4408 ;
4409 */
4410
4411 /* A.1.6.1.8 Import definitions */
4412
4413 ImportDef: // 219
4414 ImportKeyword ImportFromSpec AllWithExcepts
4415 {
4416 $2->set_imptype(ImpMod::I_ALL);
4417 $2->set_location(infile, @$);
4418
4419 $$ = $2;
4420 }
4421 | ImportKeyword ImportFromSpec '{' ImportSpec '}'
4422 {
4423 Location loc(infile, @$);
4424 if ( $4 == ImpMod::I_IMPORTSPEC) {
4425 loc.warning("Unsupported selective import statement was treated as "
4426 "`import all'");
4427 }
4428 $2->set_imptype($4);
4429 $2->set_location(infile, @$);
4430
4431 $$ = $2;
4432 }
4433 ;
4434
4435 AllWithExcepts: // 221
4436 AllKeyword
4437 | AllKeyword ExceptsDef
4438 {
4439 Location loc(infile, @$);
4440 loc.warning("Unsupported selective import statement was treated as "
4441 "`import all'");
4442 }
4443 ;
4444
4445 ExceptsDef: // 222
4446 ExceptKeyword '{' ExceptSpec '}'
4447 ;
4448
4449 ExceptSpec: // 224
4450 /* empty */ optError
4451 | ExceptSpec ExceptElement optSemiColon
4452 ;
4453
4454 ExceptElement: // 225
4455 ExceptGroupSpec
4456 | ExceptTypeDefSpec
4457 | ExceptTemplateSpec
4458 | ExceptConstSpec
4459 | ExceptTestcaseSpec
4460 | ExceptAltstepSpec
4461 | ExceptFunctionSpec
4462 | ExceptSignatureSpec
4463 | ExceptModuleParSpec
4464 ;
4465
4466 ExceptGroupSpec: // 226
4467 GroupKeyword ExceptGroupRefList
4468 | GroupKeyword AllKeyword
4469 ;
4470
4471 ExceptTypeDefSpec: // 227
4472 TypeDefKeyword TypeRefList
4473 | TypeDefKeyword AllKeyword
4474 ;
4475
4476 ExceptTemplateSpec: // 228
4477 TemplateKeyword TemplateRefList
4478 | TemplateKeyword AllKeyword
4479 ;
4480
4481 ExceptConstSpec: // 229
4482 ConstKeyword ConstRefList
4483 | ConstKeyword AllKeyword
4484 ;
4485
4486 ExceptTestcaseSpec: // 230
4487 TestcaseKeyword TestcaseRefList
4488 | TestcaseKeyword AllKeyword
4489 ;
4490
4491 ExceptAltstepSpec: // 231
4492 AltstepKeyword AltstepRefList
4493 | AltstepKeyword AllKeyword
4494 ;
4495
4496 ExceptFunctionSpec: // 232
4497 FunctionKeyword FunctionRefList
4498 | FunctionKeyword AllKeyword
4499 ;
4500
4501 ExceptSignatureSpec: // 233
4502 SignatureKeyword SignatureRefList
4503 | SignatureKeyword AllKeyword
4504 ;
4505
4506 ExceptModuleParSpec: // 234
4507 ModuleParKeyword ModuleParRefList
4508 | ModuleParKeyword AllKeyword
4509 ;
4510
4511 ImportSpec: // 235
4512 /* empty */ optError
4513 { $$ = ImpMod::I_ALL; }
4514 | ImportSpec ImportElement optSemiColon
4515 {
4516 switch ($$) {
4517 case ImpMod::I_ALL: // it was empty before
4518 $$ = $2;
4519 break;
4520
4521 case ImpMod::I_IMPORTSPEC:
4522 switch ($2) {
4523 case ImpMod::I_IMPORTSPEC:
4524 // selective import followed by another selective import: NOP
4525 break;
4526 case ImpMod::I_IMPORTIMPORT:
4527 $$ = $2; // import of import wins over selective import
4528 break;
4529 default: // including I_ALL
4530 FATAL_ERROR("Selective import cannot be followed by import all");
4531 }
4532 break;
4533
4534 case ImpMod::I_IMPORTIMPORT:
4535 switch ($2) {
4536 case ImpMod::I_IMPORTSPEC:
4537 // import of import followed by selective import: NOP (import of import wins)
4538 break;
4539 case ImpMod::I_IMPORTIMPORT:
4540 // import of import following another import of import: error
4541 Location(infile, @2).error("Import of imports can only be used once");
4542 break;
4543 default: // including I_ALL
4544 FATAL_ERROR("Import of imports cannot be followed by import all");
4545 }
4546 break;
4547
4548 default:
4549 FATAL_ERROR("Invalid import type");
4550 }
4551 }
4552 ;
4553
4554 ImportElement: // 236
4555 ImportGroupSpec
4556 { $$ = ImpMod::I_IMPORTSPEC; }
4557 | ImportTypeDefSpec
4558 { $$ = ImpMod::I_IMPORTSPEC; }
4559 | ImportTemplateSpec
4560 { $$ = ImpMod::I_IMPORTSPEC; }
4561 | ImportConstSpec
4562 { $$ = ImpMod::I_IMPORTSPEC; }
4563 | ImportTestcaseSpec
4564 { $$ = ImpMod::I_IMPORTSPEC; }
4565 | ImportAltstepSpec
4566 { $$ = ImpMod::I_IMPORTSPEC; }
4567 | ImportFunctionSpec
4568 { $$ = ImpMod::I_IMPORTSPEC; }
4569 | ImportSignatureSpec
4570 { $$ = ImpMod::I_IMPORTSPEC; }
4571 | ImportModuleParSpec
4572 { $$ = ImpMod::I_IMPORTSPEC; }
4573 | ImportImportSpec
4574 { $$ = ImpMod::I_IMPORTIMPORT; }
4575 ;
4576
4577 ImportImportSpec:
4578 ImportKeyword AllKeyword
4579
4580 ImportFromSpec: // 237
4581 FromKeyword ModuleId { $$ = $2; }
4582 | FromKeyword ModuleId RecursiveKeyword // already deprecated in v3.2.1
4583 {
4584 $$ = $2;
4585 $$->set_recursive();
4586 }
4587 ;
4588
4589 ImportGroupSpec: // 239
4590 GroupKeyword GroupRefListWithExcept
4591 | GroupKeyword AllGroupsWithExcept
4592 | GroupKeyword error
4593 ;
4594
4595 GroupRefList: // 240
4596 optError FullGroupIdentifier { delete $2; }
4597 | GroupRefList optError ',' optError FullGroupIdentifier { delete $5; }
4598 | GroupRefList optError ',' error
4599 ;
4600
4601 GroupRefListWithExcept: // 241
4602 optError FullGroupIdentifierWithExcept
4603 | GroupRefListWithExcept optError ',' optError FullGroupIdentifierWithExcept
4604 | GroupRefListWithExcept optError ',' error
4605 ;
4606
4607 AllGroupsWithExcept: // 242
4608 AllKeyword
4609 | AllKeyword error
4610 | AllKeyword ExceptKeyword GroupRefList
4611 | AllKeyword ExceptKeyword error
4612 ;
4613
4614 FullGroupIdentifier: // 243
4615 IDentifier
4616 {
4617 $$ = new Qualifier();
4618 $$->add(new FieldOrArrayRef($1));
4619 $$->set_location(infile, @$);
4620 }
4621 | FullGroupIdentifier '.' IDentifier
4622 {
4623 $$ = $1;
4624 $$->add(new FieldOrArrayRef($3));
4625 $$->set_location(infile, @$);
4626 }
4627 ;
4628
4629 FullGroupIdentifierWithExcept: // 244
4630 FullGroupIdentifier { delete $1; }
4631 | FullGroupIdentifier ExceptsDef { delete $1; }
4632 ;
4633
4634 ExceptGroupRefList: // 245
4635 optError ExceptFullGroupIdentifier
4636 | ExceptGroupRefList optError ',' optError ExceptFullGroupIdentifier
4637 | ExceptGroupRefList optError ',' error
4638 ;
4639
4640 ExceptFullGroupIdentifier: // 246
4641 FullGroupIdentifier { delete $1;}
4642 ;
4643
4644 ImportTypeDefSpec: // 247
4645 TypeDefKeyword TypeRefList
4646 | TypeDefKeyword AllTypesWithExcept
4647 | TypeDefKeyword error
4648 ;
4649
4650 TypeRefList: // 248
4651 optError IDentifier { delete $2; }
4652 | TypeRefList optError ',' optError IDentifier { delete $5; }
4653 | TypeRefList optError ',' error
4654 ;
4655
4656 AllTypesWithExcept: // 249
4657 AllKeyword
4658 | AllKeyword error
4659 | AllKeyword ExceptKeyword TypeRefList
4660 | AllKeyword ExceptKeyword error
4661 ;
4662
4663 /* 250. TypeDefIdentifier is replaced by IDentifier */
4664
4665 ImportTemplateSpec: // 251
4666 TemplateKeyword TemplateRefList
4667 | TemplateKeyword AllTemplsWithExcept
4668 | TemplateKeyword error
4669 ;
4670
4671 TemplateRefList: // 252
4672 optError IDentifier { delete $2; }
4673 | TemplateRefList optError ',' optError IDentifier { delete $5; }
4674 | TemplateRefList optError ',' error
4675 ;
4676
4677 AllTemplsWithExcept: // 253
4678 AllKeyword
4679 | AllKeyword error
4680 | AllKeyword ExceptKeyword TemplateRefList
4681 | AllKeyword ExceptKeyword error
4682 ;
4683
4684 ImportConstSpec: // 254
4685 ConstKeyword ConstRefList
4686 | ConstKeyword AllConstsWithExcept
4687 | ConstKeyword error
4688 ;
4689
4690 ConstRefList: // 255
4691 optError IDentifier { delete $2; }
4692 | ConstRefList optError ',' optError IDentifier { delete $5; }
4693 | ConstRefList optError ',' error
4694 ;
4695
4696 AllConstsWithExcept: // 256
4697 AllKeyword
4698 | AllKeyword error
4699 | AllKeyword ExceptKeyword ConstRefList
4700 | AllKeyword ExceptKeyword error
4701 ;
4702
4703 ImportAltstepSpec: // 257
4704 AltstepKeyword AltstepRefList
4705 | AltstepKeyword AllAltstepsWithExcept
4706 | AltstepKeyword error
4707 ;
4708
4709 AltstepRefList: // 258
4710 optError IDentifier { delete $2; }
4711 | AltstepRefList optError ',' optError IDentifier { delete $5; }
4712 | AltstepRefList optError ',' error
4713 ;
4714
4715 AllAltstepsWithExcept: // 259
4716 AllKeyword
4717 | AllKeyword error
4718 | AllKeyword ExceptKeyword AltstepRefList
4719 | AllKeyword ExceptKeyword error
4720 ;
4721
4722 ImportTestcaseSpec: // 260
4723 TestcaseKeyword TestcaseRefList
4724 | TestcaseKeyword AllTestcasesWithExcept
4725 | TestcaseKeyword error
4726 ;
4727
4728 TestcaseRefList: // 261
4729 optError IDentifier { delete $2; }
4730 | TestcaseRefList optError ',' optError IDentifier { delete $5; }
4731 | TestcaseRefList optError ',' error
4732 ;
4733
4734 AllTestcasesWithExcept: // 262
4735 AllKeyword
4736 | AllKeyword error
4737 | AllKeyword ExceptKeyword TestcaseRefList
4738 | AllKeyword ExceptKeyword error
4739 ;
4740
4741 ImportFunctionSpec: // 263
4742 FunctionKeyword FunctionRefList
4743 | FunctionKeyword AllFunctionsWithExcept
4744 | FunctionKeyword error
4745 ;
4746
4747 FunctionRefList: // 264
4748 optError IDentifier { delete $2; }
4749 | FunctionRefList optError ',' optError IDentifier { delete $5; }
4750 | FunctionRefList optError ',' error
4751 ;
4752
4753 AllFunctionsWithExcept: // 265
4754 AllKeyword
4755 | AllKeyword error
4756 | AllKeyword ExceptKeyword FunctionRefList
4757 | AllKeyword ExceptKeyword error
4758 ;
4759
4760 ImportSignatureSpec: // 266
4761 SignatureKeyword SignatureRefList
4762 | SignatureKeyword AllSignaturesWithExcept
4763 | SignatureKeyword error
4764 ;
4765
4766 SignatureRefList: // 267
4767 optError IDentifier { delete $2; }
4768 | SignatureRefList optError ',' optError IDentifier { delete $5; }
4769 | SignatureRefList optError ',' error
4770 ;
4771
4772 AllSignaturesWithExcept: // 268
4773 AllKeyword
4774 | AllKeyword error
4775 | AllKeyword ExceptKeyword SignatureRefList
4776 | AllKeyword ExceptKeyword error
4777 ;
4778
4779 ImportModuleParSpec: // 269
4780 ModuleParKeyword ModuleParRefList
4781 | ModuleParKeyword AllModuleParWithExcept
4782 | ModuleParKeyword error
4783 ;
4784
4785 ModuleParRefList: // 270
4786 optError IDentifier { delete $2; }
4787 | ModuleParRefList optError ',' optError IDentifier { delete $5; }
4788 | ModuleParRefList optError ',' error
4789 ;
4790
4791 AllModuleParWithExcept: // 271
4792 AllKeyword
4793 | AllKeyword error
4794 | AllKeyword ExceptKeyword ModuleParRefList
4795 | AllKeyword ExceptKeyword error
4796 ;
4797
4798 // 272 ImportImportSpec: ImportKeyword AllKeyword
4799
4800 /* A.1.6.1.9 Group definitions */
4801
4802 GroupDef: // 273
4803 GroupIdentifier '{' optErrorBlock '}'
4804 {
4805 $$ = $1;
4806 $$->set_location(infile, @$);
4807 }
4808 | GroupIdentifier '{' ModuleDefinitionsList optErrorBlock '}'
4809 {
4810 $$ = $1;
4811 $$->set_location(infile, @$);
4812 }
4813 ;
4814
4815 GroupIdentifier: // 274 (followed by) 275.
4816 GroupKeyword IDentifier
4817 {
4818 $$ = new Group($2);
4819 $$->set_parent_group(act_group);
4820 $$->set_location(infile, @$);
4821 if (act_group) {
4822 act_group->add_group($$);
4823 $$->set_parent_path(act_group->get_attrib_path());
4824 } else {
4825 act_ttcn3_module->add_group($$);
4826 $$->set_parent_path(act_ttcn3_module->get_attrib_path());
4827 }
4828 act_group = $$;
4829 }
4830 ;
4831
4832 /* A.1.6.1.10 External function definitions */
4833
4834 ExtFunctionDef: // 276
4835 ExtKeyword FunctionKeyword IDentifier
4836 '(' optFunctionFormalParList ')' optReturnType
4837 {
4838 $5->set_location(infile, @4, @6);
4839 $$ = new Def_ExtFunction($3, $5, $7.type, $7.returns_template,
4840 $7.template_restriction);
4841 $$->set_location(infile, @$);
4842 }
4843 ;
4844
4845 /* A.1.6.1.11 External constant definitions */
4846
4847 ExtConstDef: // 279
4848 ExtKeyword ConstKeyword Type IdentifierList
4849 {
4850 $$.nElements = $4.nElements;
4851 $$.elements = (Ttcn::Definition**)
4852 Malloc($$.nElements * sizeof(*$$.elements));
4853 for (size_t i = 0; i < $$.nElements; i++) {
4854 Type *type;
4855 if (i > 0) {
4856 type = new Type(Type::T_REFDSPEC, $3);
4857 type->set_location(*$3);
4858 } else type = $3;
4859 $$.elements[i] = new Ttcn::Def_ExtConst($4.elements[i].id, type);
4860 $$.elements[i]->set_location(infile, $4.elements[i].yyloc);
4861 }
4862 Free($4.elements);
4863 }
4864 ;
4865
4866 IdentifierList: // 280 ExtConstIdentifierList
4867 optError IDentifier
4868 {
4869 $$.nElements = 1;
4870 $$.elements = (YYSTYPE::extconstidentifier_t*)Malloc(sizeof(*$$.elements));
4871 $$.elements[0].id = $2;
4872 $$.elements[0].yyloc = @2;
4873 }
4874 | IdentifierList ',' optError IDentifier
4875 {
4876 $$.nElements = $1.nElements + 1;
4877 $$.elements = (YYSTYPE::extconstidentifier_t*)
4878 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4879 $$.elements[$1.nElements].id = $4;
4880 $$.elements[$1.nElements].yyloc = @4;
4881 }
4882 | IdentifierList ',' error { $$ = $1; }
4883 ;
4884
4885 /* A.1.6.1.12 Module parameter definitions */
4886
4887 ModuleParDef: // 282
4888 ModuleParKeyword ModulePar { $$ = $2; }
4889 | ModuleParKeyword '{' MultiTypedModuleParList optError '}' { $$ = $3; }
4890 | ModuleParKeyword '{' error '}' { $$.nElements = 0; $$.elements = NULL; }
4891 ;
4892
4893 MultiTypedModuleParList: // 284
4894 optError ModulePar optSemiColon { $$ = $2; }
4895 | MultiTypedModuleParList optError ModulePar optSemiColon
4896 {
4897 $$.nElements = $1.nElements + $3.nElements;
4898 $$.elements = (Ttcn::Definition**)
4899 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4900 memcpy($$.elements + $1.nElements, $3.elements,
4901 $3.nElements * sizeof(*$$.elements));
4902 Free($3.elements);
4903 }
4904 ;
4905
4906 ModulePar: // 285
4907 Type ModuleParList
4908 {
4909 $$.nElements = $2.nElements;
4910 $$.elements = (Ttcn::Definition**)
4911 Malloc($$.nElements * sizeof(*$$.elements));
4912 for(size_t i = 0; i < $2.nElements; i++) {
4913 Type *type;
4914 if (i > 0) {
4915 type = new Type(Type::T_REFDSPEC, $1);
4916 type->set_location(*$1);
4917 } else type = $1;
4918 $$.elements[i] = new Def_Modulepar($2.elements[i].id, type,
4919 $2.elements[i].defval);
4920 $$.elements[i]->set_location(infile, $2.elements[i].yyloc);
4921 }
4922 Free($2.elements);
4923 }
4924 | TemplateKeyword Type TemplateModuleParList
4925 {
4926 $$.nElements = $3.nElements;
4927 $$.elements = (Ttcn::Definition**)Malloc($$.nElements * sizeof(*$$.elements));
4928 for(size_t i = 0; i < $3.nElements; i++) {
4929 Type *type;
4930 if (i > 0) {
4931 type = new Type(Type::T_REFDSPEC, $2);
4932 type->set_location(*$2);
4933 } else type = $2;
4934 $$.elements[i] = new Def_Modulepar_Template($3.elements[i].id, type, $3.elements[i].deftempl);
4935 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
4936 }
4937 Free($3.elements);
4938 }
4939 ;
4940
4941 ModuleParList: // 287
4942 optError SingleModulePar
4943 {
4944 $$.nElements = 1;
4945 $$.elements = (YYSTYPE::singlemodulepar_t*)Malloc(sizeof(*$$.elements));
4946 $$.elements[0] = $2;
4947 }
4948 | ModuleParList ',' optError SingleModulePar
4949 {
4950 $$.nElements = $1.nElements + 1;
4951 $$.elements = (YYSTYPE::singlemodulepar_t*)
4952 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4953 $$.elements[$$.nElements - 1] = $4;
4954 }
4955 ;
4956
4957 TemplateModuleParList: // 287
4958 optError SingleTemplateModulePar
4959 {
4960 $$.nElements = 1;
4961 $$.elements = (YYSTYPE::singletemplatemodulepar_t*)Malloc(sizeof(*$$.elements));
4962 $$.elements[0] = $2;
4963 }
4964 | TemplateModuleParList ',' optError SingleTemplateModulePar
4965 {
4966 $$.nElements = $1.nElements + 1;
4967 $$.elements = (YYSTYPE::singletemplatemodulepar_t*)
4968 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
4969 $$.elements[$$.nElements - 1] = $4;
4970 }
4971 ;
4972
4973 SingleModulePar:
4974 IDentifier
4975 {
4976 $$.id = $1;
4977 $$.defval = NULL;
4978 $$.yyloc = @$;
4979 }
4980 | IDentifier AssignmentChar Expression
4981 {
4982 $$.id = $1;
4983 $$.defval = $3;
4984 $$.yyloc = @$;
4985 }
4986 ;
4987
4988 SingleTemplateModulePar:
4989 IDentifier
4990 {
4991 $$.id = $1;
4992 $$.deftempl = NULL;
4993 $$.yyloc = @$;
4994 }
4995 | IDentifier AssignmentChar TemplateBody
4996 {
4997 $$.id = $1;
4998 $$.deftempl = $3;
4999 $$.yyloc = @$;
5000 }
5001 ;
5002
5003 /* A.1.6.1.13 */
5004 FriendModuleDef: // 289
5005 FriendKeyword TTCN3ModuleKeyword IdentifierList optSemiColon
5006 {
5007 $$.nElements = $3.nElements;
5008 $$.elements = (Ttcn::FriendMod**)
5009 Malloc($$.nElements*sizeof(*$$.elements));
5010 for (size_t i = 0; i < $$.nElements; i++) {
5011 $$.elements[i] = new FriendMod($3.elements[i].id);
5012 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
5013 }
5014 Free($3.elements);
5015 }
5016 ;
5017
5018 /* A.1.6.2 Control part */
5019
5020 /* A.1.6.2.0 General */
5021
5022 ModuleControlPart: // 290
5023 optError ControlKeyword
5024 '{' ModuleControlBody '}'
5025 optWithStatementAndSemiColon
5026 {
5027 ControlPart* controlpart = new ControlPart($4);
5028 controlpart->set_location(infile, @2, @6);
5029 controlpart->set_with_attr($6);
5030 controlpart->set_parent_path(act_ttcn3_module->get_attrib_path());
5031 act_ttcn3_module->add_controlpart(controlpart);
5032 }
5033 ;
5034
5035 ModuleControlBody: // 292
5036 /* empty */ optError { $$=new StatementBlock(); }
5037 | ControlStatementOrDefList { $$ = $1; }
5038 ;
5039
5040 ControlStatementOrDefList: // 293
5041 optError ControlStatementOrDef optSemiColon
5042 {
5043 $$=new StatementBlock();
5044 for(size_t i=0; i<$2.nElements; i++) $$->add_stmt($2.elements[i]);
5045 Free($2.elements);
5046 }
5047 | ControlStatementOrDefList optError ControlStatementOrDef optSemiColon
5048 {
5049 $$=$1;
5050 for(size_t i=0; i<$3.nElements; i++) $$->add_stmt($3.elements[i]);
5051 Free($3.elements);
5052 }
5053 ;
5054
5055 ControlStatementOrDef: // 294
5056 FunctionLocalDef
5057 {
5058 $$.nElements=$1.nElements;
5059 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
5060 for(size_t i=0; i<$1.nElements; i++) {
5061 $$.elements[i]=new Statement(Statement::S_DEF, $1.elements[i]);
5062 $$.elements[i]->set_location(*$1.elements[i]);
5063 }
5064 Free($1.elements);
5065 }
5066 | FunctionLocalInst
5067 {
5068 $$.nElements=$1.nElements;
5069 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
5070 for(size_t i=0; i<$1.nElements; i++) {
5071 $$.elements[i]=new Statement(Statement::S_DEF, $1.elements[i]);
5072 $$.elements[i]->set_location(*$1.elements[i]);
5073 }
5074 Free($1.elements);
5075 }
5076 | ControlStatement
5077 {
5078 $$.nElements=1;
5079 $$.elements=(Statement**)Malloc($$.nElements*sizeof(*$$.elements));
5080 $$.elements[0]=$1;
5081 }
5082 ;
5083
5084 ControlStatement: /* Statement *stmt */ // 295
5085 TimerStatements { $$ = $1; }
5086 | BasicStatements { $$ = $1; }
5087 | BehaviourStatements { $$ = $1; }
5088 | SUTStatements { $$ = $1; }
5089 | StopExecutionStatement { $$ = $1; }
5090 | ProfilerStatement { $$ = $1; }
5091 ;
5092
5093 /* A.1.6.2.1 Variable instantiation */
5094
5095 VarInstance: // 296
5096 VarKeyword Type VarList
5097 {
5098 $$.nElements = $3.nElements;
5099 $$.elements = (Ttcn::Definition**)
5100 Malloc($$.nElements*sizeof(*$$.elements));
5101 for (size_t i = 0; i < $$.nElements; i++) {
5102 Type *type;
5103 if (i > 0) {
5104 type = new Type(Type::T_REFDSPEC, $2);
5105 type->set_location(*$2);
5106 } else type = $2;
5107 /* creation of array type(s) if necessary (from right to left) */
5108 for (size_t j = $3.elements[i].arrays.nElements; j > 0; j--) {
5109 type = new Type(Type::T_ARRAY, type,
5110 $3.elements[i].arrays.elements[j - 1], false);
5111 type->set_location(*$2);
5112 }
5113 Free($3.elements[i].arrays.elements);
5114
5115 /* Create the definition */
5116 $$.elements[i] = new Def_Var($3.elements[i].id,
5117 type, $3.elements[i].initial_value);
5118 $$.elements[i]->set_location(infile, $3.elements[i].yyloc);
5119 }
5120 Free($3.elements);
5121 }
5122 | VarKeyword TemplateOptRestricted Type TempVarList
5123 {
5124 $$.nElements = $4.nElements;
5125 $$.elements = (Ttcn::Definition**)
5126 Malloc($$.nElements * sizeof(*$$.elements));
5127 for (size_t i = 0; i < $$.nElements; i++) {
5128 Type *type;
5129 if (i > 0) {
5130 type = new Type(Type::T_REFDSPEC, $3);
5131 type->set_location(*$3);
5132 } else type = $3;
5133 /* creation of array type(s) if necessary (from right to left) */
5134 for (size_t j = $4.elements[i].arrays.nElements; j > 0; j--) {
5135 type = new Type(Type::T_ARRAY, type,
5136 $4.elements[i].arrays.elements[j - 1], false);
5137 type->set_location(*$3);
5138 }
5139 Free($4.elements[i].arrays.elements);
5140
5141 /* Create the definition */
5142 $$.elements[i] = new Def_Var_Template($4.elements[i].id, type,
5143 $4.elements[i].initial_value, $2);
5144 $$.elements[i]->set_location(infile, $4.elements[i].yyloc);
5145 }
5146
5147 Free($4.elements);
5148 }
5149 ;
5150
5151 VarList: // 297
5152 optError SingleVarInstance
5153 {
5154 $$.nElements = 1;
5155 $$.elements = (YYSTYPE::singlevarinst_t*)Malloc(sizeof(*$$.elements));
5156 $$.elements[0] = $2;
5157 }
5158 | VarList ',' optError SingleVarInstance
5159 {
5160 $$.nElements = $1.nElements + 1;
5161 $$.elements = (YYSTYPE::singlevarinst_t*)
5162 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
5163 $$.elements[$$.nElements - 1] = $4;
5164 }
5165 ;
5166
5167 SingleVarInstance: // 298
5168 IDentifier optArrayDef
5169 {
5170 $$.id = $1;
5171 $$.arrays = $2;
5172 $$.initial_value = 0;
5173 $$.yyloc = @$;
5174 }
5175 | IDentifier optArrayDef AssignmentChar Expression
5176 {
5177 $$.id = $1;
5178 $$.arrays = $2;
5179 $$.initial_value = $4;
5180 $$.yyloc = @$;
5181 }
5182 ;
5183
5184 TempVarList: // 302
5185 optError SingleTempVarInstance
5186 {
5187 $$.nElements = 1;
5188 $$.elements = (YYSTYPE::singletempvarinst_t*)Malloc(sizeof(*$$.elements));
5189 $$.elements[0] = $2;
5190 }
5191 | TempVarList ',' optError SingleTempVarInstance
5192 {
5193 $$.nElements = $1.nElements + 1;
5194 $$.elements = (YYSTYPE::singletempvarinst_t*)
5195 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
5196 $$.elements[$$.nElements - 1] = $4;
5197 }
5198 ;
5199
5200 SingleTempVarInstance: // 303
5201 IDentifier optArrayDef
5202 {
5203 $$.id = $1;
5204 $$.arrays = $2;
5205 $$.initial_value = NULL;
5206 $$.yyloc = @$;
5207 }
5208 | IDentifier optArrayDef AssignmentChar TemplateBody
5209 {
5210 $$.id = $1;
5211 $$.arrays = $2;
5212 $$.initial_value = $4;
5213 $$.yyloc = @$;
5214 }
5215 ;
5216
5217 VariableRef: // 305
5218 Reference
5219 {
5220 if ($1.is_ref) $$ = $1.ref;
5221 else {
5222 $$ = new Ttcn::Reference($1.id);
5223 $$->set_location(infile, @$);
5224 }
5225 }
5226 ;
5227
5228 /* A.1.6.2.2 Timer instantiation */
5229
5230 TimerInstance: // 306
5231 TimerKeyword TimerList { $$ = $2; }
5232 ;
5233
5234 TimerList: // 307
5235 optError SingleTimerInstance
5236 {
5237 $$.nElements = 1;
5238 $$.elements = (Ttcn::Definition**)Malloc(sizeof(*$$.elements));
5239 $$.elements[0] = $2;
5240 }
5241 | TimerList ',' optError SingleTimerInstance
5242 {
5243 $$.nElements = $1.nElements + 1;
5244 $$.elements = (Ttcn::Definition**)
5245 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
5246 $$.elements[$$.nElements - 1] = $4;
5247 }
5248 ;
5249
5250 SingleTimerInstance: // 308
5251 IDentifier optArrayDef
5252 {
5253 ArrayDimensions *dims;
5254 if ($2.nElements > 0) {
5255 dims = new ArrayDimensions;
5256 for (size_t i = 0; i < $2.nElements; i++) dims->add($2.elements[i]);
5257 Free($2.elements);
5258 } else dims = 0;
5259 $$ = new Ttcn::Def_Timer($1, dims, 0);
5260 $$->set_location(infile, @$);
5261 }
5262 | IDentifier optArrayDef AssignmentChar TimerValue
5263 {
5264 ArrayDimensions *dims;
5265 if ($2.nElements > 0) {
5266 dims = new ArrayDimensions;
5267 for (size_t i = 0; i < $2.nElements; i++) dims->add($2.elements[i]);
5268 Free($2.elements);
5269 } else dims = 0;
5270 $$ = new Ttcn::Def_Timer($1, dims, $4);
5271 $$->set_location(infile, @$);
5272 }
5273 ;
5274
5275 TimerValue: // 311
5276 Expression { $$ = $1; }
5277 ;
5278
5279 TimerRef: // 312
5280 VariableRef { $$ = $1; }
5281 ;
5282
5283 /* A.1.6.2.3 Component operations */
5284
5285 ConfigurationStatements: // 313
5286 ConnectStatement { $$ = $1; }
5287 | MapStatement { $$ = $1; }
5288 | DisconnectStatement { $$ = $1; }
5289 | UnmapStatement { $$ = $1; }
5290 | DoneStatement { $$ = $1; }
5291 | KilledStatement { $$ = $1; }
5292 | StartTCStatement { $$ = $1; }
5293 | StopTCStatement { $$ = $1; }
5294 | KillTCStatement { $$ = $1; }
5295 ;
5296
5297 ConfigurationOps: // 314
5298 CreateOp {$$=$1;}
5299 | SelfOp {$$=$1;}
5300 | SystemOp {$$=$1;}
5301 | MTCOp {$$=$1;}
5302 | RunningOp {$$=$1;}
5303 | AliveOp { $$ = $1; }
5304 ;
5305
5306 CreateOp: // 315
5307 VariableRef DotCreateKeyword optCreateParameter optAliveKeyword
5308 {
5309 $$ = new Value(Value::OPTYPE_COMP_CREATE, $1, $3.name, $3.loc, $4);
5310 $$->set_location(infile, @$);
5311 }
5312 ;
5313
5314 optCreateParameter:
5315 /* empty */
5316 {
5317 $$.name=0;
5318 $$.loc=0;
5319 }
5320 | '(' optError Expression optError ')'
5321 {
5322 $$.name = $3;
5323 $$.loc = 0;
5324 }
5325 | '(' optError Expression optError ',' optError Expression optError ')'
5326 {
5327 $$.name = $3;
5328 $$.loc = $7;
5329 }
5330 | '(' optError NotUsedSymbol optError ',' optError Expression optError ')'
5331 {
5332 $$.name = 0;
5333 $$.loc = $7;
5334 }
5335 | '(' error ')'
5336 {
5337 $$.name = 0;
5338 $$.loc = 0;
5339 }
5340 ;
5341
5342 optAliveKeyword: // [328]
5343 /* empty */ { $$ = false; }
5344 | AliveKeyword { $$ = true; }
5345 ;
5346
5347 SystemOp: // 316
5348 SystemKeyword
5349 {
5350 $$=new Value(Value::OPTYPE_COMP_SYSTEM);
5351 $$->set_location(infile, @$);
5352 }
5353 ;
5354
5355 SelfOp: // 317
5356 SelfKeyword
5357 {
5358 $$=new Value(Value::OPTYPE_COMP_SELF);
5359 $$->set_location(infile, @$);
5360 }
5361 ;
5362
5363 MTCOp: // 318
5364 MTCKeyword
5365 {
5366 $$=new Value(Value::OPTYPE_COMP_MTC);
5367 $$->set_location(infile, @$);
5368 }
5369 ;
5370
5371 DoneStatement: // 319
5372 ComponentOrDefaultReference DotDoneKeyword optDoneParameter
5373 {
5374 $$ = new Statement(Statement::S_DONE, $1, $3.donematch, $3.redirect);
5375 $$->set_location(infile, @$);
5376 }
5377 | AnyKeyword ComponentKeyword DotDoneKeyword
5378 {
5379 $$ = new Statement(Statement::S_DONE, Statement::C_ANY);
5380 $$->set_location(infile, @$);
5381 }
5382 | AllKeyword ComponentKeyword DotDoneKeyword
5383 {
5384 $$ = new Statement(Statement::S_DONE, Statement::C_ALL);
5385 $$->set_location(infile, @$);
5386 }
5387 ;
5388
5389 optDoneParameter:
5390 optReceiveParameter
5391 {
5392 $$.donematch = $1;
5393 $$.redirect = 0;
5394 }
5395 | optReceiveParameter PortRedirectSymbol ValueSpec
5396 {
5397 $$.donematch = $1;
5398 $$.redirect = $3;
5399 }
5400 ;
5401
5402 KilledStatement: // 320
5403 ComponentOrDefaultReference DotKilledKeyword
5404 {
5405 $$ = new Statement(Statement::S_KILLED, $1);
5406 $$->set_location(infile, @$);
5407 }
5408 | AnyKeyword ComponentKeyword DotKilledKeyword
5409 {
5410 $$ = new Statement(Statement::S_KILLED, Statement::C_ANY);
5411 $$->set_location(infile, @$);
5412 }
5413 | AllKeyword ComponentKeyword DotKilledKeyword
5414 {
5415 $$ = new Statement(Statement::S_KILLED, Statement::C_ALL);
5416 $$->set_location(infile, @$);
5417 }
5418 ;
5419
5420 /*
5421 ComponentId: // 321
5422 ComponentOrDefaultReference
5423 | AnyKeyword ComponentKeyword
5424 | AllKeyword ComponentKeyword
5425 ;
5426 */
5427
5428 RunningOp: // 324
5429 /* VariableRef DotRunningKeyword -- covered by RunningTimerOp */
5430 FunctionInstance DotRunningKeyword
5431 {
5432 Value *t_val = new Value(Value::V_REFD, $1);
5433 t_val->set_location(infile, @1);
5434 $$ = new Value(Value::OPTYPE_COMP_RUNNING, t_val);
5435 $$->set_location(infile, @$);
5436 }
5437 | ApplyOp DotRunningKeyword
5438 {
5439 Value *t_val = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5440 t_val->set_location(infile, @1);
5441 $$ = new Value(Value::OPTYPE_COMP_RUNNING, t_val);
5442 $$->set_location(infile, @$);
5443 }
5444 | AnyKeyword ComponentKeyword DotRunningKeyword
5445 {
5446 $$ = new Value(Value::OPTYPE_COMP_RUNNING_ANY);
5447 $$->set_location(infile, @$);
5448 }
5449 | AllKeyword ComponentKeyword DotRunningKeyword
5450 {
5451 $$ = new Value(Value::OPTYPE_COMP_RUNNING_ALL);
5452 $$->set_location(infile, @$);
5453 }
5454 ;
5455
5456 AliveOp: // 326
5457 ComponentOrDefaultReference DotAliveKeyword
5458 {
5459 $$ = new Value(Value::OPTYPE_COMP_ALIVE, $1);
5460 $$->set_location(infile, @$);
5461 }
5462 | AnyKeyword ComponentKeyword DotAliveKeyword
5463 {
5464 $$ = new Value(Value::OPTYPE_COMP_ALIVE_ANY);
5465 $$->set_location(infile, @$);
5466 }
5467 | AllKeyword ComponentKeyword DotAliveKeyword
5468 {
5469 $$ = new Value(Value::OPTYPE_COMP_ALIVE_ALL);
5470 $$->set_location(infile, @$);
5471 }
5472 ;
5473
5474 ConnectStatement: // 329
5475 ConnectKeyword SingleConnectionSpec
5476 {
5477 $$=new Statement(Statement::S_CONNECT,
5478 $2.compref1, $2.portref1, $2.compref2, $2.portref2);
5479 $$->set_location(infile, @$);
5480 }
5481 ;
5482
5483 SingleConnectionSpec: // 331
5484 '(' PortRef optError ',' optError PortRef optError ')'
5485 {
5486 $$.compref1 = $2.compref;
5487 $$.portref1 = $2.portref;
5488 $$.compref2 = $6.compref;
5489 $$.portref2 = $6.portref;
5490 }
5491 ;
5492
5493 PortRef: // 332
5494 ComponentRef ':' Port
5495 {
5496 $$.compref = $1;
5497 $$.portref = $3;
5498 }
5499 ;
5500
5501 ComponentRef: // 333
5502 ComponentOrDefaultReference { $$ = $1; }
5503 | SystemOp { $$ = $1; }
5504 | SelfOp { $$ = $1; }
5505 | MTCOp { $$ = $1; }
5506 ;
5507
5508 DisconnectStatement: // 335
5509 DisconnectKeyword
5510 {
5511 Location loc(infile, @$);
5512 loc.error("Disconnect operation on multiple connections is "
5513 "not currently supported");
5514 $$ = new Statement(Statement::S_ERROR);
5515 $$->set_location(infile, @$);
5516 }
5517 | DisconnectKeyword SingleOrMultiConnectionSpec
5518 {
5519 if ($2.compref1 && $2.portref1 && $2.compref1 && $2.compref2) {
5520 $$ = new Statement(Statement::S_DISCONNECT,
5521 $2.compref1, $2.portref1, $2.compref2, $2.portref2);
5522 } else {
5523 Location loc(infile, @$);
5524 loc.error("Disconnect operation on multiple connections is "
5525 "not currently supported");
5526 delete $2.compref1;
5527 delete $2.portref1;
5528 delete $2.compref2;
5529 delete $2.portref2;
5530 $$ = new Statement(Statement::S_ERROR);
5531 }
5532 $$->set_location(infile, @$);
5533 }
5534 ;
5535
5536 SingleOrMultiConnectionSpec: // 336
5537 SingleConnectionSpec { $$ = $1; }
5538 | AllConnectionsSpec
5539 {
5540 $$.compref1 = $1.compref;
5541 $$.portref1 = $1.portref;
5542 $$.compref2 = 0;
5543 $$.portref2 = 0;
5544 }
5545 | AllPortsSpec
5546 {
5547 $$.compref1 = $1;
5548 $$.portref1 = 0;
5549 $$.compref2 = 0;
5550 $$.portref2 = 0;
5551 }
5552 | AllCompsAllPortsSpec
5553 {
5554 $$.compref1 = 0;
5555 $$.portref1 = 0;
5556 $$.compref2 = 0;
5557 $$.portref2 = 0;
5558 }
5559 ;
5560
5561 AllConnectionsSpec: // 337
5562 '(' PortRef optError ')' { $$ = $2; }
5563 ;
5564
5565 AllPortsSpec: // 338
5566 '(' ComponentRef ':' AllKeyword PortKeyword optError ')' { $$ = $2; }
5567 ;
5568
5569 AllCompsAllPortsSpec: // 339
5570 '(' AllKeyword ComponentKeyword ':' AllKeyword PortKeyword optError ')'
5571 ;
5572
5573 MapStatement: // 341
5574 MapKeyword SingleConnectionSpec
5575 {
5576 $$=new Statement(Statement::S_MAP,
5577 $2.compref1, $2.portref1,
5578 $2.compref2, $2.portref2);
5579 $$->set_location(infile, @$);
5580 }
5581 ;
5582
5583 UnmapStatement: // 343
5584 UnmapKeyword
5585 {
5586 $$ = new Statement(Statement::S_ERROR);
5587 $$->set_location(infile, @$);
5588 Location loc(infile, @$);
5589 loc.error("Unmap operation on multiple mappings is "
5590 "not currently supported");
5591 }
5592 | UnmapKeyword SingleOrMultiConnectionSpec
5593 {
5594 if ($2.compref1 && $2.portref1 && $2.compref1 && $2.compref2) {
5595 $$ = new Statement(Statement::S_UNMAP,
5596 $2.compref1, $2.portref1, $2.compref2, $2.portref2);
5597 } else {
5598 Location loc(infile, @$);
5599 loc.error("Unmap operation on multiple mappings is "
5600 "not currently supported");
5601 delete $2.compref1;
5602 delete $2.portref1;
5603 delete $2.compref2;
5604 delete $2.portref2;
5605 $$ = new Statement(Statement::S_ERROR);
5606 }
5607 $$->set_location(infile, @$);
5608 }
5609 ;
5610
5611 StartTCStatement: // 345
5612 /* VariableRef DotStartKeyword '(' FunctionInstance ')'
5613 -- covered by StartTimerStatement */
5614 VariableRef DotStartKeyword '(' DereferOp '(' optFunctionActualParList ')'
5615 optError ')'
5616 {
5617 Value *t_val = new Value(Value::V_REFD, $1);
5618 t_val->set_location(infile, @1);
5619 $6->set_location(infile, @5, @7);
5620 //ParsedActualParameters *pap = new ParsedActualParameters($6);
5621 $$ = new Statement(Statement::S_START_COMP_REFD, t_val, $4, $6);
5622 $$->set_location(infile, @$);
5623 }
5624 | FunctionInstance DotStartKeyword '(' FunctionInstance optError ')'
5625 {
5626 Value *t_val = new Value(Value::V_REFD, $1);
5627 t_val->set_location(infile, @1);
5628 $$ = new Statement(Statement::S_START_COMP, t_val, $4);
5629 $$->set_location(infile, @$);
5630 }
5631 | FunctionInstance DotStartKeyword '(' DereferOp '('
5632 optFunctionActualParList ')' optError ')'
5633 {
5634 Value *t_val = new Value(Value::V_REFD, $1);
5635 t_val->set_location(infile, @1);
5636 $6->set_location(infile, @5 , @7);
5637 $$ = new Statement(Statement::S_START_COMP_REFD, t_val, $4, $6);
5638 $$->set_location(infile, @$);
5639 }
5640 | FunctionInstance DotStartKeyword '(' error ')'
5641 {
5642 delete $1;
5643 $$ = new Statement(Statement::S_ERROR);
5644 $$->set_location(infile, @$);
5645 }
5646 | ApplyOp DotStartKeyword '(' FunctionInstance ')'
5647 {
5648 Value *t_val = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5649 t_val->set_location(infile, @1);
5650 $$ = new Statement(Statement::S_START_COMP, t_val, $4);
5651 $$->set_location(infile, @$);
5652 }
5653 | ApplyOp DotStartKeyword '(' DereferOp '(' optFunctionActualParList ')'
5654 optError ')'
5655 {
5656 Value *t_val = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5657 t_val->set_location(infile, @1);
5658 $6->set_location(infile, @5 , @7);
5659 $$ = new Statement(Statement::S_START_COMP_REFD, t_val, $4, $6);
5660 $$->set_location(infile, @$);
5661 }
5662 | ApplyOp DotStartKeyword '(' error ')'
5663 {
5664 delete $1.value;
5665 delete $1.ap_list;
5666 $$ = new Statement(Statement::S_ERROR);
5667 $$->set_location(infile, @$);
5668 }
5669 ;
5670
5671 StopTCStatement: // 337
5672 /* VariableRef DotStopKeyword -- covered by StopTimerStatement */
5673 FunctionInstance DotStopKeyword
5674 {
5675 Value *t_val = new Value(Value::V_REFD, $1);
5676 t_val->set_location(infile, @1);
5677 $$ = new Statement(Statement::S_STOP_COMP, t_val);
5678 $$->set_location(infile, @$);
5679 }
5680 | ApplyOp DotStopKeyword
5681 {
5682 Value *t_val = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5683 t_val->set_location(infile, @1);
5684 $$ = new Statement(Statement::S_STOP_COMP, t_val);
5685 $$->set_location(infile, @$);
5686 }
5687 | MTCOp DotStopKeyword
5688 {
5689 $$ = new Statement(Statement::S_STOP_COMP, $1);
5690 $$->set_location(infile, @$);
5691 }
5692 | SelfOp DotStopKeyword
5693 {
5694 $$ = new Statement(Statement::S_STOP_COMP, $1);
5695 $$->set_location(infile, @$);
5696 }
5697 | AllKeyword ComponentKeyword DotStopKeyword
5698 {
5699 $$ = new Statement(Statement::S_STOP_COMP, (Value*)0);
5700 $$->set_location(infile, @$);
5701 }
5702 ;
5703
5704 ComponentReferenceOrLiteral: // 348
5705 ComponentOrDefaultReference { $$ = $1; }
5706 | MTCOp { $$ = $1; }
5707 | SelfOp { $$ = $1; }
5708 ;
5709
5710 KillTCStatement: // 349
5711 KillKeyword
5712 {
5713 Value *self = new Value(Value::OPTYPE_COMP_SELF);
5714 self->set_location(infile, @1);
5715 $$ = new Statement(Statement::S_KILL, self);
5716 $$->set_location(infile, @$);
5717 }
5718 | ComponentReferenceOrLiteral DotKillKeyword
5719 {
5720 $$ = new Statement(Statement::S_KILL, $1);
5721 $$->set_location(infile, @$);
5722 }
5723 | AllKeyword ComponentKeyword DotKillKeyword
5724 {
5725 $$ = new Statement(Statement::S_KILL, (Value*)0);
5726 $$->set_location(infile, @$);
5727 }
5728 ;
5729
5730 ComponentOrDefaultReference: // 350
5731 VariableRef
5732 {
5733 $$ = new Value(Value::V_REFD, $1);
5734 $$->set_location(infile, @$);
5735 }
5736 | FunctionInstance
5737 {
5738 $$ = new Value(Value::V_REFD, $1);
5739 $$->set_location(infile, @$);
5740 }
5741 | ApplyOp
5742 {
5743 $$ = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
5744 $$->set_location(infile, @$);
5745 }
5746 ;
5747
5748 /* A.1.6.2.4 Port operations */
5749
5750 Port: // 325
5751 VariableRef { $$ = $1; }
5752 ;
5753
5754 CommunicationStatements: // 353
5755 SendStatement {$$ = $1;}
5756 | CallStatement {$$ = $1;}
5757 | ReplyStatement {$$ = $1;}
5758 | RaiseStatement {$$ = $1;}
5759 | ReceiveStatement {$$ = $1;}
5760 | TriggerStatement {$$ = $1;}
5761 | GetCallStatement {$$ = $1;}
5762 | GetReplyStatement {$$ = $1;}
5763 | CatchStatement {$$ = $1;}
5764 | CheckStatement {$$ = $1;}
5765 | ClearStatement {$$ = $1;}
5766 | StartStatement {$$ = $1;}
5767 | StopStatement {$$ = $1;}
5768 | HaltStatement { $$ = $1; }
5769 ;
5770
5771 SendStatement: // 354
5772 Port DotSendOpKeyword PortSendOp
5773 {
5774 $$ = new Statement(Statement::S_SEND, $1, $3.templ_inst, $3.val);
5775 $$->set_location(infile, @$);
5776 }
5777 ;
5778
5779 PortSendOp: // 355
5780 '(' SendParameter optError ')' optToClause
5781 {
5782 $$.templ_inst = $2;
5783 $$.val = $5;
5784 }
5785 | '(' error ')' optToClause
5786 {
5787 Template *t = new Template(Template::TEMPLATE_ERROR);
5788 t->set_location(infile, @2);
5789 $$.templ_inst = new TemplateInstance(0, 0, t);
5790 $$.templ_inst->set_location(infile, @2);
5791 $$.val = $4;
5792 }
5793 ;
5794
5795 SendParameter: // 357
5796 TemplateInstance { $$=$1; }
5797 ;
5798
5799 optToClause: // [3583]
5800 /* empty */ { $$ = 0; }
5801 | ToKeyword AddressRef
5802 {
5803 Template *templ = $2->get_Template();
5804 if (!$2->get_Type() && !$2->get_DerivedRef() && templ->is_Value()) {
5805 $$ = templ->get_Value();
5806 } else {
5807 Location loc(infile, @$);
5808 loc.error("Multicast communication is not currently supported");
5809 $$ = 0;
5810 }
5811 delete $2;
5812 }
5813 /* | ToKeyword AddressRefList -- covered by the previous rule
5814 (as ValueOrAttribList) */
5815 | ToKeyword AllKeyword ComponentKeyword
5816 {
5817 Location loc(infile, @$);
5818 loc.error("Broadcast communication is not currently supported");
5819 $$ = 0;
5820 }
5821 | ToKeyword error { $$ = 0; }
5822 ;
5823
5824 /*
5825 AddressRefList: // 359
5826 '(' seqAddressRef ')'
5827 ;
5828
5829 seqAddressRef:
5830 AddressRef
5831 | seqAddressRef ',' AddressRef
5832 ;
5833 */
5834
5835 AddressRef: // 361
5836 TemplateInstance { $$ = $1; }
5837 ;
5838
5839 CallStatement: // 362
5840 Port DotCallOpKeyword PortCallOp optPortCallBody
5841 {
5842 $$ = new Statement(Statement::S_CALL, $1, $3.templ_inst,
5843 $3.calltimerval, $3.nowait, $3.val, $4);
5844 $$->set_location(infile, @$);
5845 }
5846 ;
5847
5848 PortCallOp: // 363
5849 '(' CallParameters optError ')' optToClause
5850 {
5851 $$.templ_inst = $2.templ_inst;
5852 $$.calltimerval = $2.calltimerval;
5853 $$.nowait = $2.nowait;
5854 $$.val = $5;
5855 }
5856 | '(' error ')' optToClause
5857 {
5858 Template *t = new Template(Template::TEMPLATE_ERROR);
5859 t->set_location(infile, @2);
5860 $$.templ_inst = new TemplateInstance(0, 0, t);
5861 $$.templ_inst->set_location(infile, @2);
5862 $$.calltimerval = 0;
5863 $$.nowait = false;
5864 $$.val = $4;
5865 }
5866 ;
5867
5868 CallParameters: // 365
5869 TemplateInstance
5870 {
5871 $$.templ_inst=$1;
5872 $$.calltimerval=0;
5873 $$.nowait=false;
5874 }
5875 | TemplateInstance ',' optError CallTimerValue
5876 {
5877 $$.templ_inst=$1;
5878 $$.calltimerval=$4.calltimerval;
5879 $$.nowait=$4.nowait;
5880 }
5881 ;
5882
5883 CallTimerValue: // 366
5884 TimerValue
5885 {
5886 $$.calltimerval=$1;
5887 $$.nowait=false;
5888 }
5889 | NowaitKeyword
5890 {
5891 $$.calltimerval=0;
5892 $$.nowait=true;
5893 }
5894 ;
5895
5896 optPortCallBody: // [368]
5897 /* empty */ { $$=0; }
5898 | '{' CallBodyStatementList optError '}' { $$=$2; }
5899 | '{' error '}' { $$ = new AltGuards; }
5900 ;
5901
5902 CallBodyStatementList: // 369
5903 optError CallBodyStatement
5904 {
5905 $$=new AltGuards();
5906 $$->add_ag($2);
5907 }
5908 | CallBodyStatementList optError CallBodyStatement
5909 {
5910 $$=$1;
5911 $$->add_ag($3);
5912 }
5913 ;
5914
5915 CallBodyStatement: // 370 and 371. rolled into one.
5916 AltGuardChar CallBodyOps ';' // This alternative is a TITAN extension
5917 {
5918 $$=new AltGuard($1, $2, new StatementBlock());
5919 $$->set_location(infile, @$);
5920 }
5921 | AltGuardChar CallBodyOps optSemiColon StatementBlock optSemiColon
5922 {
5923 $$=new AltGuard($1, $2, $4);
5924 $$->set_location(infile, @$);
5925 }
5926 ;
5927
5928 CallBodyOps: // 372
5929 GetReplyStatement {$$=$1;}
5930 | CatchStatement {$$=$1;}
5931 ;
5932
5933 ReplyStatement: // 373
5934 Port DotReplyKeyword PortReplyOp
5935 {
5936 $$ = new Statement(Statement::S_REPLY, $1, $3.templ_inst,
5937 $3.replyval, $3.toclause);
5938 $$->set_location(infile, @$);
5939 }
5940 ;
5941
5942 PortReplyOp: // 374
5943 '(' TemplateInstance optReplyValue optError ')' optToClause
5944 {
5945 $$.templ_inst = $2;
5946 $$.replyval = $3;
5947 $$.toclause = $6;
5948 }
5949 | '(' error ')' optToClause
5950 {
5951 Template *t = new Template(Template::TEMPLATE_ERROR);
5952 t->set_location(infile, @2);
5953 $$.templ_inst = new TemplateInstance(0, 0, t);
5954 $$.templ_inst->set_location(infile, @2);
5955 $$.replyval = 0;
5956 $$.toclause = $4;
5957 }
5958 ;
5959
5960 optReplyValue: // [376]
5961 /* empty */ { $$=0; }
5962 | ValueKeyword Expression { $$=$2; }
5963 | ValueKeyword error { $$ = 0; }
5964 ;
5965
5966 RaiseStatement: // 377
5967 Port DotRaiseKeyword PortRaiseOp
5968 {
5969 if ($3.signature) $$ = new Statement(Statement::S_RAISE, $1,
5970 $3.signature, $3.templ_inst, $3.toclause);
5971 else {
5972 $$ = new Statement(Statement::S_ERROR);
5973 delete $1;
5974 delete $3.signature;
5975 delete $3.templ_inst;
5976 delete $3.toclause;
5977 }
5978 $$->set_location(infile, @$);
5979 }
5980 ;
5981
5982 PortRaiseOp: // 378
5983 '(' Signature optError ',' optError TemplateInstance optError ')' optToClause
5984 {
5985 $$.signature = $2;
5986 $$.templ_inst = $6;
5987 $$.toclause = $9;
5988 }
5989 | '(' error ')' optToClause
5990 {
5991 $$.signature = 0;
5992 $$.templ_inst = 0;
5993 $$.toclause = 0;
5994 delete $4;
5995 }
5996 ;
5997
5998 ReceiveStatement: // 380
5999 PortOrAny DotReceiveOpKeyword PortReceiveOp
6000 {
6001 $$ = new Statement(Statement::S_RECEIVE, $1, $3.templ_inst,
6002 $3.fromclause, $3.redirectval, $3.redirectsender);
6003 $$->set_location(infile, @$);
6004 }
6005 ;
6006
6007 PortOrAny: // 381
6008 Port { $$ = $1; }
6009 | AnyKeyword PortKeyword { $$ = 0; }
6010 ;
6011
6012 PortReceiveOp: // 382
6013 optReceiveParameter optFromClause optPortRedirect
6014 {
6015 $$.templ_inst = $1;
6016 $$.fromclause = $2;
6017 $$.redirectval = $3.redirectval;
6018 $$.redirectsender = $3.redirectsender;
6019 }
6020 ;
6021
6022 optReceiveParameter: // [384]
6023 /* empty */ { $$ = 0; }
6024 | '(' ReceiveParameter optError ')' { $$ = $2; }
6025 | '(' error ')'
6026 {
6027 Template *t = new Template(Template::TEMPLATE_ERROR);
6028 t->set_location(infile, @2);
6029 $$ = new TemplateInstance(0, 0, t);
6030 $$->set_location(infile, @$);
6031 }
6032 ;
6033
6034 ReceiveParameter: // 384
6035 TemplateInstance { $$ = $1; }
6036 ;
6037
6038 optFromClause: // [385]
6039 /* empty */ { $$=0; }
6040 | FromClause { $$=$1; }
6041 ;
6042
6043 FromClause: // 385
6044 FromKeyword AddressRef { $$=$2; }
6045 | FromKeyword error { $$ = 0; }
6046 ;
6047
6048 optPortRedirect: // [387]
6049 /* empty */
6050 {
6051 $$.redirectval=0;
6052 $$.redirectsender=0;
6053 }
6054 | PortRedirectSymbol ValueSpec
6055 {
6056 $$.redirectval=$2;
6057 $$.redirectsender=0;
6058 }
6059 | PortRedirectSymbol SenderSpec
6060 {
6061 $$.redirectval=0;
6062 $$.redirectsender=$2;
6063 }
6064 | PortRedirectSymbol ValueSpec SenderSpec
6065 {
6066 $$.redirectval=$2;
6067 $$.redirectsender=$3;
6068 }
6069 | PortRedirectSymbol error
6070 {
6071 $$.redirectval=0;
6072 $$.redirectsender=0;
6073 }
6074 ;
6075
6076 ValueSpec: // 389
6077 ValueKeyword VariableRef { $$ = $2; }
6078 | ValueKeyword error { $$ = 0; }
6079 ;
6080
6081 SenderSpec: // 391
6082 SenderKeyword VariableRef { $$ = $2; }
6083 | SenderKeyword error { $$ = 0; }
6084 ;
6085
6086 TriggerStatement: // 393
6087 PortOrAny DotTriggerOpKeyword PortTriggerOp
6088 {
6089 $$ = new Statement(Statement::S_TRIGGER, $1, $3.templ_inst,
6090 $3.fromclause, $3.redirectval, $3.redirectsender);
6091 $$->set_location(infile, @$);
6092 }
6093 ;
6094
6095 PortTriggerOp: // 394
6096 optReceiveParameter optFromClause optPortRedirect
6097 {
6098 $$.templ_inst = $1;
6099 $$.fromclause = $2;
6100 $$.redirectval = $3.redirectval;
6101 $$.redirectsender = $3.redirectsender;
6102 }
6103 ;
6104
6105 GetCallStatement: // 396
6106 PortOrAny DotGetCallOpKeyword PortGetCallOp
6107 {
6108 $$ = new Statement(Statement::S_GETCALL, $1, $3.templ_inst,
6109 $3.fromclause, $3.redirectparam, $3.redirectsender);
6110 $$->set_location(infile, @$);
6111 }
6112 ;
6113
6114 PortGetCallOp: // 397
6115 optReceiveParameter optFromClause optPortRedirectWithParam
6116 {
6117 $$.templ_inst = $1;
6118 $$.fromclause = $2;
6119 $$.redirectparam = $3.redirectparam;
6120 $$.redirectsender = $3.redirectsender;
6121 }
6122 ;
6123
6124 optPortRedirectWithParam: // [399]
6125 /* empty */
6126 {
6127 $$.redirectparam=0;
6128 $$.redirectsender=0;
6129 }
6130 | PortRedirectSymbol ParamSpec
6131 {
6132 $$.redirectparam=$2;
6133 $$.redirectsender=0;
6134 }
6135 | PortRedirectSymbol ParamSpec SenderSpec
6136 {
6137 $$.redirectparam=$2;
6138 $$.redirectsender=$3;
6139 }
6140 | PortRedirectSymbol SenderSpec
6141 {
6142 $$.redirectparam=0;
6143 $$.redirectsender=$2;
6144 }
6145 | PortRedirectSymbol error
6146 {
6147 $$.redirectparam=0;
6148 $$.redirectsender=0;
6149 }
6150 ;
6151
6152 ParamSpec: // 401
6153 ParamKeyword ParamAssignmentList { $$ = $2; }
6154 | ParamKeyword error { $$ = 0; }
6155 ;
6156
6157 ParamAssignmentList: // 403
6158 '(' AssignmentList optError ')'
6159 {
6160 $$=new ParamRedirect($2);
6161 $$->set_location(infile, @$);
6162 }
6163 | '(' VariableList optError ')'
6164 {
6165 $$=new ParamRedirect($2);
6166 $$->set_location(infile, @$);
6167 }
6168 | '(' error ')'
6169 {
6170 $$=new ParamRedirect(new ParamAssignments());
6171 $$->set_location(infile, @$);
6172 }
6173 ;
6174
6175 AssignmentList: // 404
6176 VariableAssignment
6177 {
6178 $$ = new ParamAssignments();
6179 $$->add_parass($1);
6180 }
6181 | error VariableAssignment
6182 {
6183 $$ = new ParamAssignments();
6184 $$->add_parass($2);
6185 }
6186 | AssignmentList optError ',' optError VariableAssignment
6187 {
6188 $$ = $1;
6189 $$->add_parass($5);
6190 }
6191 | AssignmentList optError ',' error { $$ = $1; }
6192 ;
6193
6194 VariableAssignment: // 405
6195 VariableRef AssignmentChar IDentifier
6196 {
6197 $$ = new ParamAssignment($3, $1);
6198 $$->set_location(infile, @$);
6199 }
6200 ;
6201
6202 VariableList: // 407
6203 VariableEntry
6204 {
6205 $$ = new VariableEntries();
6206 $$->add_ve($1);
6207 }
6208 | error VariableEntry
6209 {
6210 $$ = new VariableEntries();
6211 $$->add_ve($2);
6212 }
6213 | VariableList optError ',' optError VariableEntry
6214 {
6215 $$ = $1;
6216 $$->add_ve($5);
6217 }
6218 | VariableList optError ',' error { $$ = $1; }
6219 ;
6220
6221 VariableEntry: // 408
6222 VariableRef
6223 {
6224 $$ = new VariableEntry($1);
6225 $$->set_location(infile, @$);
6226 }
6227 | NotUsedSymbol
6228 {
6229 $$ = new VariableEntry;
6230 $$->set_location(infile, @$);
6231 }
6232 ;
6233
6234 GetReplyStatement: // 409
6235 PortOrAny DotGetReplyOpKeyword PortGetReplyOp
6236 {
6237 $$ = new Statement(Statement::S_GETREPLY, $1, $3.templ_inst,
6238 $3.valuematch, $3.fromclause, $3.redirectval,
6239 $3.redirectparam, $3.redirectsender);
6240 $$->set_location(infile, @$);
6241 }
6242 ;
6243
6244 PortGetReplyOp: // 410
6245 optGetReplyParameter optFromClause optPortRedirectWithValueAndParam
6246 {
6247 $$.templ_inst = $1.templ_inst;
6248 $$.valuematch = $1.valuematch;
6249 $$.fromclause = $2;
6250 $$.redirectval = $3.redirectval;
6251 $$.redirectparam = $3.redirectparam;
6252 $$.redirectsender = $3.redirectsender;
6253 }
6254 ;
6255
6256 optPortRedirectWithValueAndParam: // [411]
6257 /* empty */
6258 {
6259 $$.redirectval=0;
6260 $$.redirectparam=0;
6261 $$.redirectsender=0;
6262 }
6263 | PortRedirectSymbol ValueSpec
6264 {
6265 $$.redirectval=$2;
6266 $$.redirectparam=0;
6267 $$.redirectsender=0;
6268 }
6269 | PortRedirectSymbol ValueSpec ParamSpec
6270 {
6271 $$.redirectval=$2;
6272 $$.redirectparam=$3;
6273 $$.redirectsender=0;
6274 }
6275 | PortRedirectSymbol ValueSpec SenderSpec
6276 {
6277 $$.redirectval=$2;
6278 $$.redirectparam=0;
6279 $$.redirectsender=$3;
6280 }
6281 | PortRedirectSymbol ValueSpec ParamSpec SenderSpec
6282 {
6283 $$.redirectval=$2;
6284 $$.redirectparam=$3;
6285 $$.redirectsender=$4;
6286 }
6287 | PortRedirectSymbol ParamSpec
6288 {
6289 $$.redirectval=0;
6290 $$.redirectparam=$2;
6291 $$.redirectsender=0;
6292 }
6293 | PortRedirectSymbol SenderSpec
6294 {
6295 $$.redirectval=0;
6296 $$.redirectparam=0;
6297 $$.redirectsender=$2;
6298 }
6299 | PortRedirectSymbol ParamSpec SenderSpec
6300 {
6301 $$.redirectval=0;
6302 $$.redirectparam=$2;
6303 $$.redirectsender=$3;
6304 }
6305 | PortRedirectSymbol error
6306 {
6307 $$.redirectval=0;
6308 $$.redirectparam=0;
6309 $$.redirectsender=0;
6310 }
6311 ;
6312
6313 optGetReplyParameter:
6314 /* empty */
6315 {
6316 $$.templ_inst=0;
6317 $$.valuematch=0;
6318 }
6319 | '(' ReceiveParameter optError ')'
6320 {
6321 $$.templ_inst=$2;
6322 $$.valuematch=0;
6323 }
6324 | '(' ReceiveParameter ValueMatchSpec optError ')'
6325 {
6326 $$.templ_inst=$2;
6327 $$.valuematch=$3;
6328 }
6329 | '(' error ')'
6330 {
6331 Template *t = new Template(Template::TEMPLATE_ERROR);
6332 t->set_location(infile, @2);
6333 $$.templ_inst = new TemplateInstance(0, 0, t);
6334 $$.templ_inst->set_location(infile, @2);
6335 $$.valuematch = 0;
6336 }
6337 ;
6338
6339 ValueMatchSpec: // 414
6340 ValueKeyword TemplateInstance { $$=$2; }
6341 | ValueKeyword error { $$ = 0; }
6342 ;
6343
6344 CheckStatement: // 415
6345 PortOrAny DotCheckOpKeyword optCheckParameter
6346 {
6347 switch ($3.statementtype) {
6348 case Statement::S_CHECK:
6349 $$ = new Statement(Statement::S_CHECK, $1, $3.templ_inst,
6350 $3.redirectsender);
6351 break;
6352 case Statement::S_CHECK_RECEIVE:
6353 $$ = new Statement(Statement::S_CHECK_RECEIVE, $1, $3.templ_inst,
6354 $3.fromclause, $3.redirectval, $3.redirectsender);
6355 break;
6356 case Statement::S_CHECK_GETCALL:
6357 $$ = new Statement(Statement::S_CHECK_GETCALL, $1, $3.templ_inst,
6358 $3.fromclause, $3.redirectparam, $3.redirectsender);
6359 break;
6360 case Statement::S_CHECK_GETREPLY:
6361 $$ = new Statement(Statement::S_CHECK_GETREPLY, $1, $3.templ_inst,
6362 $3.valuematch, $3.fromclause, $3.redirectval,
6363 $3.redirectparam, $3.redirectsender);
6364 break;
6365 case Statement::S_CHECK_CATCH:
6366 $$ = new Statement(Statement::S_CHECK_CATCH, $1, $3.signature,
6367 $3.templ_inst, $3.timeout, $3.fromclause,
6368 $3.redirectval, $3.redirectsender);
6369 break;
6370 default:
6371 FATAL_ERROR("Internal error.");
6372 } // switch
6373 $$->set_location(infile, @$);
6374 }
6375 ;
6376
6377 optCheckParameter: // [418]
6378 /* empty */
6379 {
6380 $$.statementtype = Statement::S_CHECK;
6381 $$.signature = 0;
6382 $$.templ_inst = 0;
6383 $$.valuematch = 0;
6384 $$.timeout = false;
6385 $$.fromclause = 0;
6386 $$.redirectval = 0;
6387 $$.redirectparam = 0;
6388 $$.redirectsender = 0;
6389 }
6390 | '(' CheckParameter optError ')' { $$ = $2; }
6391 | '(' error ')'
6392 {
6393 $$.statementtype = Statement::S_CHECK;
6394 $$.signature = 0;
6395 $$.templ_inst = 0;
6396 $$.valuematch = 0;
6397 $$.timeout = false;
6398 $$.fromclause = 0;
6399 $$.redirectval = 0;
6400 $$.redirectparam = 0;
6401 $$.redirectsender = 0;
6402 }
6403 ;
6404
6405 CheckParameter: // 418
6406 CheckPortOpsPresent { $$ = $1; }
6407 | FromClausePresent { $$ = $1; }
6408 | RedirectPresent { $$ = $1; }
6409 ;
6410
6411 FromClausePresent: // 419
6412 FromClause
6413 {
6414 $$.statementtype = Statement::S_CHECK;
6415 $$.signature = 0;
6416 $$.templ_inst = $1;
6417 $$.valuematch = 0;
6418 $$.timeout = false;
6419 $$.fromclause = 0;
6420 $$.redirectval = 0;
6421 $$.redirectparam = 0;
6422 $$.redirectsender = 0;
6423 }
6424 | FromClause PortRedirectSymbol SenderSpec
6425 {
6426 $$.statementtype = Statement::S_CHECK;
6427 $$.signature = 0;
6428 $$.templ_inst = $1;
6429 $$.valuematch = 0;
6430 $$.timeout = false;
6431 $$.fromclause = 0;
6432 $$.redirectval = 0;
6433 $$.redirectparam = 0;
6434 $$.redirectsender = $3;
6435 }
6436 ;
6437
6438 RedirectPresent: // 420
6439 PortRedirectSymbol SenderSpec
6440 {
6441 $$.statementtype = Statement::S_CHECK;
6442 $$.signature = 0;
6443 $$.templ_inst = 0;
6444 $$.valuematch = 0;
6445 $$.timeout = false;
6446 $$.fromclause = 0;
6447 $$.redirectval = 0;
6448 $$.redirectparam = 0;
6449 $$.redirectsender = $2;
6450 }
6451 ;
6452
6453 CheckPortOpsPresent: // 421
6454 ReceiveOpKeyword PortReceiveOp
6455 {
6456 $$.statementtype = Statement::S_CHECK_RECEIVE;
6457 $$.signature = 0;
6458 $$.templ_inst = $2.templ_inst;
6459 $$.valuematch = 0;
6460 $$.timeout = false;
6461 $$.fromclause = $2.fromclause;
6462 $$.redirectval = $2.redirectval;
6463 $$.redirectparam = 0;
6464 $$.redirectsender = $2.redirectsender;
6465 }
6466 | GetCallOpKeyword PortGetCallOp
6467 {
6468 $$.statementtype = Statement::S_CHECK_GETCALL;
6469 $$.signature = 0;
6470 $$.templ_inst = $2.templ_inst;
6471 $$.valuematch = 0;
6472 $$.timeout = false;
6473 $$.fromclause = $2.fromclause;
6474 $$.redirectval = 0;
6475 $$.redirectparam = $2.redirectparam;
6476 $$.redirectsender = $2.redirectsender;
6477 }
6478 | GetReplyOpKeyword PortGetReplyOp
6479 {
6480 $$.statementtype = Statement::S_CHECK_GETREPLY;
6481 $$.signature = 0;
6482 $$.templ_inst = $2.templ_inst;
6483 $$.valuematch = $2.valuematch;
6484 $$.timeout = false;
6485 $$.fromclause = $2.fromclause;
6486 $$.redirectval = $2.redirectval;
6487 $$.redirectparam = $2.redirectparam;
6488 $$.redirectsender = $2.redirectsender;
6489 }
6490 | CatchOpKeyword PortCatchOp
6491 {
6492 $$.statementtype = Statement::S_CHECK_CATCH;
6493 $$.signature = $2.signature;
6494 $$.templ_inst = $2.templ_inst;
6495 $$.valuematch = 0;
6496 $$.timeout = $2.timeout;
6497 $$.fromclause = $2.fromclause;
6498 $$.redirectval = $2.redirectval;
6499 $$.redirectparam = 0;
6500 $$.redirectsender = $2.redirectsender;
6501 }
6502 ;
6503
6504 CatchStatement: // 422
6505 PortOrAny DotCatchOpKeyword PortCatchOp
6506 {
6507 $$ = new Statement(Statement::S_CATCH, $1, $3.signature, $3.templ_inst,
6508 $3.timeout, $3.fromclause, $3.redirectval,
6509 $3.redirectsender);
6510 $$->set_location(infile, @$);
6511 }
6512 ;
6513
6514 PortCatchOp: // 423
6515 optCatchOpParameter optFromClause optPortRedirect
6516 {
6517 $$.signature = $1.signature;
6518 $$.templ_inst = $1.templ_inst;
6519 $$.timeout = $1.timeout;
6520 $$.fromclause = $2;
6521 $$.redirectval = $3.redirectval;
6522 $$.redirectsender = $3.redirectsender;
6523 }
6524 ;
6525
6526 optCatchOpParameter: // [425]
6527 /* empty */
6528 {
6529 $$.signature = 0;
6530 $$.templ_inst = 0;
6531 $$.timeout = false;
6532 }
6533 | '(' CatchOpParameter optError ')' { $$ = $2; }
6534 | '(' error ')'
6535 {
6536 $$.signature = 0;
6537 $$.templ_inst = 0;
6538 $$.timeout = false;
6539 }
6540 ;
6541
6542 CatchOpParameter: // 425
6543 Signature optError ',' optError TemplateInstance
6544 {
6545 $$.signature = $1;
6546 $$.templ_inst = $5;
6547 $$.timeout = false;
6548 }
6549 | TimeoutKeyword
6550 {
6551 $$.signature = 0;
6552 $$.templ_inst = 0;
6553 $$.timeout = true;
6554 }
6555 ;
6556
6557 ClearStatement: // 426
6558 PortOrAll DotClearOpKeyword
6559 {
6560 $$ = new Statement(Statement::S_CLEAR, $1);
6561 $$->set_location(infile, @$);
6562 }
6563 ;
6564
6565 PortOrAll: // 427
6566 Port { $$ = $1; }
6567 | AllKeyword PortKeyword { $$ = 0; }
6568 ;
6569
6570 StartStatement: // 430
6571 /* Port DotPortStartKeyword -- covered by StartTimerStatement */
6572 AllKeyword PortKeyword DotStartKeyword
6573 {
6574 $$=new Statement(Statement::S_START_PORT, (Ttcn::Reference*)0);
6575 $$->set_location(infile, @$);
6576 }
6577 ;
6578
6579 StopStatement: // 432
6580 /* Port DotPortStopKeyword -- covered by StopTimerStatement */
6581 AllKeyword PortKeyword DotStopKeyword
6582 {
6583 $$=new Statement(Statement::S_STOP_PORT, (Ttcn::Reference*)0);
6584 $$->set_location(infile, @$);
6585 }
6586 ;
6587
6588 HaltStatement: // 435
6589 PortOrAll DotHaltKeyword
6590 {
6591 $$ = new Statement(Statement::S_HALT, $1);
6592 $$->set_location(infile, @$);
6593 }
6594 ;
6595
6596 /* A.1.6.2.5 Timer operations */
6597
6598 TimerStatements: // 439
6599 StartTimerStatement { $$ = $1; }
6600 | StopTimerStatement { $$ = $1; }
6601 | TimeoutStatement { $$ = $1; }
6602 ;
6603
6604 TimerOps: // 440
6605 ReadTimerOp { $$ = $1; }
6606 | RunningTimerOp { $$ = $1; }
6607 ;
6608
6609 StartTimerStatement: // 441
6610 VariableRef DotStartKeyword
6611 {
6612 $$ = new Statement(Statement::S_START_UNDEF, $1, (Value*)0);
6613 $$->set_location(infile, @$);
6614 }
6615 | VariableRef DotStartKeyword '(' Expression optError ')'
6616 {
6617 $$ = new Statement(Statement::S_START_UNDEF, $1, $4);
6618 $$->set_location(infile, @$);
6619 }
6620 | VariableRef DotStartKeyword '(' error ')'
6621 {
6622 Value *v = new Value(Value::V_ERROR);
6623 v->set_location(infile, @4);
6624 $$ = new Statement(Statement::S_START_UNDEF, $1, v);
6625 $$->set_location(infile, @$);
6626 }
6627 ;
6628
6629 StopTimerStatement: // 442
6630 TimerRef DotStopKeyword
6631 {
6632 $$ = new Statement(Statement::S_STOP_UNDEF, $1, (Value*)0);
6633 $$->set_location(infile, @$);
6634 }
6635 | AllKeyword TimerKeyword DotStopKeyword
6636 {
6637 $$ = new Statement(Statement::S_STOP_TIMER, (Ttcn::Reference*)0);
6638 $$->set_location(infile, @$);
6639 }
6640 ;
6641
6642 /* no separate rule, folded into StopTimerStatement
6643 TimerRefOrAll: // 443
6644 TimerRef
6645 | AllKeyword TimerKeyword
6646 ;
6647 */
6648
6649 ReadTimerOp: // 444
6650 TimerRef DotReadKeyword
6651 {
6652 $$ = new Value(Value::OPTYPE_TMR_READ, $1);
6653 $$->set_location(infile, @$);
6654 }
6655 ;
6656
6657 RunningTimerOp: // 446
6658 TimerRef DotRunningKeyword
6659 {
6660 $$ = new Value(Value::OPTYPE_UNDEF_RUNNING, $1);
6661 $$->set_location(infile, @$);
6662 }
6663 | AnyKeyword TimerKeyword DotRunningKeyword
6664 {
6665 $$ = new Value(Value::OPTYPE_TMR_RUNNING_ANY);
6666 $$->set_location(infile, @$);
6667 }
6668 ;
6669
6670 TimeoutStatement: // 447
6671 TimerRefOrAny DotTimeoutKeyword
6672 {
6673 $$ = new Statement(Statement::S_TIMEOUT, $1);
6674 $$->set_location(infile, @$);
6675 }
6676 ;
6677
6678 TimerRefOrAny: // 448
6679 TimerRef { $$ = $1; }
6680 | AnyKeyword TimerKeyword { $$ = 0; }
6681 ;
6682
6683 /* A.1.6.3 Type */
6684
6685 Type: // 450
6686 PredefinedType
6687 {
6688 $$ = new Type($1);
6689 $$->set_location(infile, @$);
6690 }
6691 | AnyTypeKeyword /* a predefined type with special treatment */
6692 {
6693 anytype_access = true;
6694 Identifier *id = new Identifier(Identifier::ID_TTCN, string("anytype"));
6695 Ttcn::Reference *ref = new Ttcn::Reference(id);
6696 ref->set_location(infile, @1);
6697 $$ = new Type(Type::T_REFD, ref);
6698 }
6699 | ReferencedType { $$ = $1; }
6700
6701 ;
6702
6703 PredefinedType: // 451, but see below
6704 BitStringKeyword { $$ = Type::T_BSTR; }
6705 | BooleanKeyword { $$ = Type::T_BOOL; }
6706 | CharStringKeyword { $$ = Type::T_CSTR; }
6707 | UniversalCharString { $$ = Type::T_USTR; }
6708 | CharKeyword // not in the standard anymore
6709 {
6710 Location loc(infile, @$);
6711 loc.warning("Obsolete type `char' was substituted with `charstring'");
6712 $$ = Type::T_CSTR;
6713 }
6714 | UniversalChar // not in the standard anymore
6715 {
6716 Location loc(infile, @$);
6717 loc.warning("Obsolete type `universal char' was substituted with "
6718 "`universal charstring'");
6719 $$ = Type::T_USTR;
6720 }
6721 | IntegerKeyword { $$ = Type::T_INT; }
6722 | OctetStringKeyword { $$ = Type::T_OSTR; }
6723 | HexStringKeyword { $$ = Type::T_HSTR; }
6724 | VerdictTypeKeyword { $$ = Type::T_VERDICT; }
6725 | FloatKeyword { $$ = Type::T_REAL; }
6726 | AddressKeyword { $$ = Type::T_ADDRESS; }
6727 | DefaultKeyword { $$ = Type::T_DEFAULT; }
6728 | ObjectIdentifierKeyword { $$ = Type::T_OID; }
6729 /*
6730 * AnyTypeKeyword is not part of PredefinedType (this differs from the BNF
6731 * in the TTCN-3 standard).
6732 * PredefinedType is used in two contexts:
6733 * - as a RHS for Type, above (where AnyTypeKeyword needs special treatment,
6734 * and it's easier to appear as an alternative to PredefinedType)
6735 * - as field name for the anytype (where anytype is not permitted)
6736 */
6737 ;
6738
6739 UniversalCharString: // 463
6740 UniversalKeyword CharStringKeyword
6741 ;
6742
6743 UniversalChar:
6744 UniversalKeyword CharKeyword
6745 ;
6746
6747 ReferencedType: // 465
6748 Reference
6749 {
6750 if ($1.is_ref) $$ = new Type(Type::T_REFD, $1.ref);
6751 else {
6752 Ttcn::Reference *ref = new Ttcn::Reference($1.id);
6753 ref->set_location(infile, @1);
6754 $$ = new Type(Type::T_REFD, ref);
6755 }
6756 $$->set_location(infile, @$);
6757 }
6758 | FunctionInstance optExtendedFieldReference
6759 /* covers all parameterized type references */
6760 {
6761 Location loc(infile, @1);
6762 loc.error("Reference to parameterized type is not currently supported");
6763 delete $1;
6764 for (size_t i = 0; i < $2.nElements; i++) delete $2.elements[i];
6765 Free($2.elements);
6766 $$ = new Type(Type::T_ERROR);
6767 $$->set_location(infile, @$);
6768 }
6769 ;
6770
6771 /*
6772 TypeReference: // 466
6773 IDentifier
6774 | IDentifier TypeActualParList
6775 ;
6776 */
6777
6778 TypeActualParList: // -> 202 784 "Advanced Parameterization"
6779 '(' seqTypeActualPar optError ')'
6780 | '(' error ')'
6781 ;
6782
6783 seqTypeActualPar: // -> 202 784 "Advanced Parameterization"
6784 optError TypeActualPar
6785 | seqTypeActualPar optError ',' optError TypeActualPar
6786 | seqTypeActualPar optError ',' error
6787 ;
6788
6789 TypeActualPar: // -> 202 784 "Advanced Parameterization"
6790 Expression { delete $1; }
6791 ;
6792
6793 optArrayDef: // [467]
6794 /* empty */
6795 {
6796 $$.nElements = 0;
6797 $$.elements = 0;
6798 }
6799 | optArrayDef ArrayIndex
6800 {
6801 $$.nElements = $1.nElements + 1;
6802 $$.elements = (ArrayDimension**)
6803 Realloc($1.elements, $$.nElements * sizeof(*$$.elements));
6804 $$.elements[$1.nElements] = $2;
6805 }
6806 ;
6807
6808 ArrayIndex:
6809 '[' ArrayBounds ']'
6810 {
6811 $$ = new ArrayDimension($2);
6812 $$->set_location(infile, @$);
6813 }
6814 | '[' ArrayBounds DotDot ArrayBounds ']'
6815 {
6816 $$ = new ArrayDimension($2, $4);
6817 $$->set_location(infile, @$);
6818 }
6819 | '[' error ']'
6820 {
6821 Value *v = new Value(Value::V_ERROR);
6822 v->set_location(infile, @2);
6823 $$ = new ArrayDimension(v);
6824 $$->set_location(infile, @$);
6825 }
6826 ;
6827
6828 ArrayBounds: // 468
6829 Expression { $$ = $1; }
6830 ;
6831
6832 /* A.1.6.4 Value */
6833
6834 Value: // 469
6835 PredefinedValue { $$ = $1; }
6836 | ReferencedValue { $$ = $1; }
6837 ;
6838
6839 PredefinedValue: // 470
6840 BitStringValue { $$ = $1; }
6841 | BooleanValue { $$ = $1; }
6842 | CharStringValue { $$ = $1; }
6843 | IntegerValue { $$ = $1; }
6844 | OctetStringValue { $$ = $1; }
6845 | HexStringValue { $$ = $1; }
6846 | VerdictValue { $$ = $1; }
6847 /* | EnumeratedValue -- covered by ReferencedValue */
6848 | FloatOrSpecialFloatValue
6849 {
6850 $$ = new Value(Value::V_REAL, $1);
6851 $$->set_location(infile, @$);
6852 }
6853 | AddressValue { $$ = $1; }
6854 | OmitValue { $$ = $1; }
6855 | NullValue
6856 {
6857 $$ = new Value(Value::V_NULL);
6858 $$->set_location(infile, @$);
6859 }
6860 | MacroValue
6861 {
6862 $$ = new Value(Value::V_MACRO, $1);
6863 $$->set_location(infile, @$);
6864 }
6865 | ObjectIdentifierValue { $$ = $1; }
6866 | TOK_errval
6867 {
6868 $$=new Value(Value::V_ERROR);
6869 $$->set_location(infile, @$);
6870 }
6871 ;
6872
6873 BitStringValue: // 471
6874 Bstring
6875 {
6876 $$ = new Value(Value::V_BSTR, $1);
6877 $$->set_location(infile, @$);
6878 }
6879 ;
6880
6881 BooleanValue: // 472
6882 TrueKeyword
6883 {
6884 $$ = new Value(Value::V_BOOL, true);
6885 $$->set_location(infile, @$);
6886 }
6887 | FalseKeyword
6888 {
6889 $$ = new Value(Value::V_BOOL, false);
6890 $$->set_location(infile, @$);
6891 }
6892 ;
6893
6894 /* TTCN-3 core language V4.2.1 */
6895 FloatOrSpecialFloatValue:
6896 FloatValue
6897 {
6898 $$ = $1;
6899 }
6900 | InfinityKeyword
6901 {
6902 $$ = REAL_INFINITY;
6903 }
6904 | NaNKeyword
6905 {
6906 $$ = REAL_NAN;
6907 }
6908 ;
6909
6910 IntegerValue: // 473
6911 Number
6912 {
6913 $$ = new Value(Value::V_INT, $1);
6914 $$->set_location(infile, @$);
6915 }
6916 ;
6917
6918 OctetStringValue: // 474
6919 Ostring
6920 {
6921 $$ = new Value(Value::V_OSTR, $1);
6922 $$->set_location(infile, @$);
6923 }
6924 ;
6925
6926 HexStringValue: // 475
6927 Hstring
6928 {
6929 $$ = new Value(Value::V_HSTR, $1);
6930 $$->set_location(infile, @$);
6931 }
6932 ;
6933
6934 VerdictValue: // 476 VerdictTypeValue
6935 NoneKeyword
6936 {
6937 $$ = new Value(Value::V_VERDICT, Value::Verdict_NONE);
6938 $$->set_location(infile, @$);
6939 }
6940 | PassKeyword
6941 {
6942 $$ = new Value(Value::V_VERDICT, Value::Verdict_PASS);
6943 $$->set_location(infile, @$);
6944 }
6945 | InconcKeyword
6946 {
6947 $$ = new Value(Value::V_VERDICT, Value::Verdict_INCONC);
6948 $$->set_location(infile, @$);
6949 }
6950 | FailKeyword
6951 {
6952 $$ = new Value(Value::V_VERDICT, Value::Verdict_FAIL);
6953 $$->set_location(infile, @$);
6954 }
6955 | ErrorKeyword
6956 {
6957 $$ = new Value(Value::V_VERDICT, Value::Verdict_ERROR);
6958 $$->set_location(infile, @$);
6959 }
6960 ;
6961
6962 CharStringValue: // 478
6963 CstringList
6964 {
6965 if ($1->is_cstr()) $$ = new Value(Value::V_CSTR, $1);
6966 else {
6967 $$ = new Value(Value::V_USTR, new ustring(*$1));
6968 delete $1;
6969 }
6970 $$->set_location(infile, @$);
6971 }
6972 | Quadruple
6973 {
6974 $$ = new Value(Value::V_USTR, new ustring(*$1));
6975 delete $1;
6976 $$->set_location(infile, @$);
6977 }
6978 ;
6979
6980 CstringList:
6981 Cstring
6982 {
6983 Location loc(infile, @1);
6984 $$ = parse_charstring_value($1, loc);
6985 Free($1);
6986 }
6987 ;
6988
6989 Quadruple: // 479
6990 CharKeyword '(' optError Group optError ',' optError Plane optError ','
6991 optError Row optError ',' optError Cell optError ')'
6992 { $$ = new ustring($4, $8, $12, $16); }
6993 | CharKeyword '(' error ')' { $$ = new ustring; }
6994 ;
6995
6996 Group: // 481
6997 Number
6998 {
6999 if (*$1 < 0 || *$1 > 127) {
7000 Location loc(infile, @1);
7001 loc.error("The first number of quadruple (group) must be within the "
7002 "range 0 .. 127 instead of %s", $1->t_str().c_str());
7003 $$ = *$1 < 0 ? 0 : 127;
7004 } else {
7005 $$ = $1->get_val();
7006 }
7007 delete $1;
7008 }
7009 ;
7010
7011 Plane: // 482
7012 Number
7013 {
7014 if (*$1 < 0 || *$1 > 255) {
7015 Location loc(infile, @1);
7016 loc.error("The second number of quadruple (plane) must be within the "
7017 "range 0 .. 255 instead of %s", $1->t_str().c_str());
7018 $$ = *$1 < 0 ? 0 : 255;
7019 } else {
7020 $$ = $1->get_val();
7021 }
7022 delete $1;
7023 }
7024 ;
7025
7026 Row: // 483
7027 Number
7028 {
7029 if (*$1 < 0 || *$1 > 255) {
7030 Location loc(infile, @1);
7031 loc.error("The third number of quadruple (row) must be within the "
7032 "range 0 .. 255 instead of %s", $1->t_str().c_str());
7033 $$ = *$1 < 0 ? 0 : 255;
7034 } else {
7035 $$ = $1->get_val();
7036 }
7037 delete $1;
7038 }
7039 ;
7040
7041 Cell: // 484
7042 Number
7043 {
7044 if (*$1 < 0 || *$1 > 255) {
7045 Location loc(infile, @1);
7046 loc.error("The fourth number of quadruple (cell) must be within the "
7047 "range 0 .. 255 instead of %s", $1->t_str().c_str());
7048 $$ = *$1 < 0 ? 0 : 255;
7049 } else {
7050 $$ = $1->get_val();
7051 }
7052 delete $1;
7053 }
7054 ;
7055
7056 FreeText: // 509
7057 Cstring { $$ = $1; }
7058 | FreeText Cstring
7059 {
7060 $$ = mputstr($1, $2);
7061 Free($2);
7062 }
7063 ;
7064
7065 AddressValue: // 510
7066 NullKeyword
7067 {
7068 $$ = new Value(Value::V_TTCN3_NULL);
7069 $$->set_location(infile, @$);
7070 }
7071 ;
7072
7073 OmitValue: // 511
7074 OmitKeyword
7075 {
7076 $$ = new Value(Value::V_OMIT);
7077 $$->set_location(infile, @$);
7078 }
7079 ;
7080
7081 ReferencedValue: // 489
7082 Reference
7083 {
7084 if ($1.is_ref) $$ = new Value(Value::V_REFD, $1.ref);
7085 else $$ = new Value(Value::V_UNDEF_LOWERID, $1.id);
7086 $$->set_location(infile, @$);
7087 }
7088
7089 Reference: // 490 ValueReference
7090 IDentifier
7091 {
7092 $$.is_ref = false;
7093 $$.id = $1;
7094 }
7095 | IDentifier '.' PredefOrIdentifier optExtendedFieldReference
7096 {
7097 $$.is_ref = true;
7098 $$.ref = new Ttcn::Reference($1);
7099 FieldOrArrayRef *fieldref = new FieldOrArrayRef($3);
7100 fieldref->set_location(infile, @3);
7101 $$.ref->add(fieldref);
7102 for (size_t i = 0; i < $4.nElements; i++) $$.ref->add($4.elements[i]);
7103 Free($4.elements);
7104 $$.ref->set_location(infile, @$);
7105 }
7106 | IDentifier ArrayOrBitRef optExtendedFieldReference
7107 {
7108 $$.is_ref = true;
7109 $$.ref = new Ttcn::Reference($1);
7110 $$.ref->add($2);
7111 for (size_t i = 0; i < $3.nElements; i++) $$.ref->add($3.elements[i]);
7112 Free($3.elements);
7113 $$.ref->set_location(infile, @$);
7114 }
7115 | IDentifier '[' NotUsedSymbol ']'
7116 {
7117 $$.is_ref = true;
7118 $$.ref = new Ttcn::Reference($1);
7119 Value* novalue = new Value(Value::V_NOTUSED);
7120 novalue->set_location(infile, @3);
7121 $$.ref->add(new FieldOrArrayRef(novalue));
7122 $$.ref->set_location(infile, @$);
7123 }
7124 | IDentifier '.' ObjectIdentifierValue '.' IDentifier
7125 optExtendedFieldReference
7126 {
7127 $$.is_ref = true;
7128 $$.ref = new Ttcn::Reference($1, $5);
7129 delete $3;
7130 for (size_t i = 0; i < $6.nElements; i++) $$.ref->add($6.elements[i]);
7131 Free($6.elements);
7132 $$.ref->set_location(infile, @$);
7133 }
7134 ;
7135
7136 /* A.1.6.5 Parameterization */
7137
7138 optLazyEval:
7139 /* empty */ { $$ = false; }
7140 | TitanSpecificLazyKeyword { $$ = true; }
7141 ;
7142
7143 FormalValuePar: // 516
7144 optLazyEval Type IDentifier optParDefaultValue
7145 {
7146 $$ = new FormalPar(Common::Assignment::A_PAR_VAL, $2, $3, $4, $1);
7147 $$->set_location(infile, @$);
7148 }
7149 | InParKeyword optLazyEval Type IDentifier optParDefaultValue
7150 {
7151 $$ = new FormalPar(Common::Assignment::A_PAR_VAL_IN, $3, $4, $5, $2);
7152 $$->set_location(infile, @$);
7153 }
7154 | InOutParKeyword Type IDentifier optParDefaultValue
7155 {
7156 $$ = new FormalPar(Common::Assignment::A_PAR_VAL_INOUT, $2, $3, $4);
7157 $$->set_location(infile, @$);
7158 }
7159 | OutParKeyword Type IDentifier optParDefaultValue
7160 {
7161 $$ = new FormalPar(Common::Assignment::A_PAR_VAL_OUT, $2, $3, $4);
7162 $$->set_location(infile, @$);
7163 }
7164 ;
7165
7166 /*
7167 FormalPortPar: // 518
7168 IDentifier IDentifier
7169 | InOutParKeyword IDentifier IDentifier
7170 ;
7171 */
7172
7173 FormalTimerPar: // 520
7174 TimerKeyword IDentifier optParDefaultValue
7175 {
7176 $$ = new FormalPar(Common::Assignment::A_PAR_TIMER, $2, $3);
7177 $$->set_location(infile, @$);
7178 }
7179 | InOutParKeyword TimerKeyword IDentifier optParDefaultValue
7180 {
7181 $$ = new FormalPar(Common::Assignment::A_PAR_TIMER, $3, $4);
7182 $$->set_location(infile, @$);
7183 }
7184 ;
7185
7186 FormalTemplatePar: // 522
7187 TemplateOptRestricted optLazyEval Type IDentifier optParDefaultValue
7188 {
7189 $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_IN, $1, $3, $4, $5, $2);
7190 $$->set_location(infile, @$);
7191 }
7192 | InParKeyword TemplateOptRestricted optLazyEval Type IDentifier optParDefaultValue
7193 {
7194 $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_IN, $2, $4, $5, $6, $3);
7195 $$->set_location(infile, @$);
7196 }
7197 | InOutParKeyword TemplateOptRestricted Type IDentifier optParDefaultValue
7198 {
7199 $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_INOUT, $2, $3, $4, $5);
7200 $$->set_location(infile, @$);
7201 }
7202 | OutParKeyword TemplateOptRestricted Type IDentifier optParDefaultValue
7203 {
7204 $$ = new FormalPar(Common::Assignment::A_PAR_TEMPL_OUT, $2, $3, $4, $5);
7205 $$->set_location(infile, @$);
7206 }
7207 ;
7208
7209 /* template with optional restriction */
7210 TemplateOptRestricted:
7211 TemplateKeyword optTemplateRestriction
7212 {
7213 $$ = $2;
7214 }
7215 | OmitKeyword
7216 {
7217 $$ = TR_OMIT;
7218 }
7219 ;
7220
7221 optTemplateRestriction:
7222 /* none */ { $$ = TR_NONE; }
7223 | TemplateRestriction { $$ = $1; }
7224
7225 TemplateRestriction:
7226 '(' OmitKeyword ')' { $$ = TR_OMIT; }
7227 | '(' ValueKeyword ')' { $$ = TR_VALUE; }
7228 | '(' PresentKeyword ')' { $$ = TR_PRESENT; }
7229 ;
7230
7231 optParDefaultValue:
7232 /* empty */ { $$ = NULL; }
7233 | AssignmentChar TemplateInstance { $$ = $2; }
7234 | AssignmentChar NotUsedSymbol
7235 {
7236 Template *t = new Template(Template::TEMPLATE_NOTUSED);
7237 t->set_location(infile, @$);
7238 $$ = new TemplateInstance(0, 0, t);
7239 $$->set_location(infile, @$);
7240 }
7241 ;
7242
7243 /* A.1.6.6 With statement */
7244
7245 optWithStatement: // [526]
7246 /* empty */ { $$ = NULL; }
7247 | WithStatement { $$ = $1; }
7248 ;
7249
7250 optWithStatementAndSemiColon:
7251 /* empty */ { $$ = NULL; }
7252 | WithStatement { $$ = $1; }
7253 | ';' { $$ = NULL; }
7254 | WithStatement ';' { $$ = $1; }
7255 ;
7256
7257 WithStatement: // 526
7258 WithKeyword WithAttribList { $$ = $2; }
7259 ;
7260
7261 WithAttribList: // 528
7262 '{' MultiWithAttrib optError '}' { $$ = $2; }
7263 | '{' error '}' { $$ = NULL; }
7264 ;
7265
7266 MultiWithAttrib: // 529
7267 optError SingleWithAttrib optSemiColon
7268 {
7269 $$ = new MultiWithAttrib;
7270 $$->set_location(infile, @$);
7271 $$->add_element($2);
7272 }
7273 | MultiWithAttrib optError SingleWithAttrib optSemiColon
7274 {
7275 $$ = $1;
7276 $$->add_element($3);
7277 }
7278 ;
7279
7280 SingleWithAttrib: // 530
7281 AttribKeyword optOverrideKeyword optAttribQualifier AttribSpec
7282 {
7283 $$ = new SingleWithAttrib($1,$2,$3,$4);
7284 $$->set_location(infile, @$);
7285 }
7286 ;
7287
7288 AttribKeyword: // 531
7289 EncodeKeyword { $$ = SingleWithAttrib::AT_ENCODE; }
7290 | VariantKeyword { $$ = SingleWithAttrib::AT_VARIANT; }
7291 | DisplayKeyword { $$ = SingleWithAttrib::AT_DISPLAY; }
7292 | ExtensionKeyword { $$ = SingleWithAttrib::AT_EXTENSION; }
7293 | OptionalKeyword { $$ = SingleWithAttrib::AT_OPTIONAL; }
7294 | IDentifier
7295 {
7296 /* workaround to get rid of ErroneousKeyword which would clash with
7297 * existing TTCN-3 source code */
7298 if ($1->get_ttcnname()=="erroneous") $$ = SingleWithAttrib::AT_ERRONEOUS;
7299 else {
7300 Location loc(infile, @1);
7301 loc.error("Invalid attribute. Valid attributes are: "
7302 "`encode', `variant' , `display' , `extension', `optional' and `erroneous'");
7303 if ($1->get_ttcnname()=="titan")
7304 loc.note("\n"
7305 " ________ _____ ________ ____ __ _ \n"
7306 "(___ ___) (_ _) (___ ___) ( ) / \\ / ) \n"
7307 " ) ) | | ) ) / /\\ \\ / /\\ \\ / / \n"
7308 " ( ( | | ( ( ( (__) ) ) ) ) ) ) ) \n"
7309 " ) ) | | ) ) ) ( ( ( ( ( ( ( \n"
7310 " ( ( _| |__ ( ( / /\\ \\ / / \\ \\/ / \n"
7311 " /__\\ /_____( /__\\ /__( )__\\ (_/ \\__/ \n");
7312 $$ = SingleWithAttrib::AT_INVALID;
7313 }
7314 delete $1;
7315 }
7316 ;
7317
7318 optOverrideKeyword: // [536]
7319 /* empty */ { $$ = false; }
7320 | OverrideKeyword { $$ = true; }
7321 ;
7322
7323 optAttribQualifier: // [537]
7324 /* empty */ { $$ = NULL; }
7325 | '(' DefOrFieldRefList optError ')' { $$ = $2; }
7326 | '(' error ')' { $$ = NULL; }
7327 ;
7328
7329 DefOrFieldRefList: // 538
7330 optError DefOrFieldRef
7331 {
7332 $$ = new Qualifiers();
7333 if ($2) $$->add_qualifier($2);
7334 }
7335 | DefOrFieldRefList optError ',' optError DefOrFieldRef
7336 {
7337 $$ = $1;
7338 if ($5) $$->add_qualifier($5);
7339 }
7340 | DefOrFieldRefList optError ',' error { $$ = $1; }
7341 ;
7342
7343 ArrayOrBitRefOrDash:
7344 ArrayOrBitRef { $$ = $1; }
7345 | '[' NotUsedSymbol ']'
7346 {
7347 Value* novalue = new Value(Value::V_NOTUSED);
7348 novalue->set_location(infile, @2);
7349 $$ = new FieldOrArrayRef(novalue);
7350 $$->set_location(infile, @$);
7351 }
7352
7353 DefOrFieldRef: // 539
7354 IDentifier
7355 {
7356 $$ = new Qualifier();
7357 $$->add(new FieldOrArrayRef($1));
7358 $$->set_location(infile, @1);
7359 }
7360 | IDentifier '.' IDentifier optExtendedFieldReference
7361 {
7362 $$ = new Qualifier();
7363 $$->add(new FieldOrArrayRef($1));
7364 $$->add(new FieldOrArrayRef($3));
7365 for(size_t i=0; i<$4.nElements; i++) {
7366 $$->add($4.elements[i]);
7367 }
7368 Free($4.elements);
7369 $$->set_location(infile, @$);
7370 }
7371 | IDentifier ArrayOrBitRefOrDash optExtendedFieldReference
7372 {
7373 $$ = new Qualifier();
7374 $$->add(new FieldOrArrayRef($1));
7375 $$->add($2);
7376 for(size_t i=0; i<$3.nElements; i++) {
7377 $$->add($3.elements[i]);
7378 }
7379 Free($3.elements);
7380 $$->set_location(infile, @$);
7381 }
7382 | ArrayOrBitRefOrDash optExtendedFieldReference
7383 {
7384 $$ = new Qualifier();
7385 $$->add($1);
7386 for(size_t i=0; i<$2.nElements; i++) {
7387 $$->add($2.elements[i]);
7388 }
7389 Free($2.elements);
7390 $$->set_location(infile, @$);
7391 }
7392 | AllRef
7393 {
7394 Location loc(infile, @$);
7395 loc.error("Reference to multiple definitions in attribute qualifiers is "
7396 "not currently supported");
7397 $$ = 0;
7398 }
7399 ;
7400
7401 AllRef: // 541
7402 GroupKeyword AllKeyword
7403 | GroupKeyword AllKeyword ExceptKeyword '{' GroupRefList optError '}'
7404 | TypeDefKeyword AllKeyword
7405 | TypeDefKeyword AllKeyword ExceptKeyword '{' TypeRefList optError '}'
7406 | TemplateKeyword AllKeyword
7407 | TemplateKeyword AllKeyword ExceptKeyword '{' TemplateRefList optError '}'
7408 | ConstKeyword AllKeyword
7409 | ConstKeyword AllKeyword ExceptKeyword '{' ConstRefList optError '}'
7410 | AltstepKeyword AllKeyword
7411 | AltstepKeyword AllKeyword ExceptKeyword '{' AltstepRefList optError '}'
7412 | TestcaseKeyword AllKeyword
7413 | TestcaseKeyword AllKeyword ExceptKeyword '{' TestcaseRefList optError '}'
7414 | FunctionKeyword AllKeyword
7415 | FunctionKeyword AllKeyword ExceptKeyword '{' FunctionRefList optError '}'
7416 | SignatureKeyword AllKeyword
7417 | SignatureKeyword AllKeyword ExceptKeyword '{' SignatureRefList optError '}'
7418 | ModuleParKeyword AllKeyword
7419 | ModuleParKeyword AllKeyword ExceptKeyword '{' ModuleParRefList optError '}'
7420 ;
7421
7422 AttribSpec: // 542
7423 FreeText
7424 {
7425 $$ = new AttributeSpec(string($1));
7426 $$->set_location(infile, @$);
7427 Free($1);
7428 }
7429 ;
7430
7431 /* A.1.6.7 Behaviour statements */
7432
7433 BehaviourStatements: // 543
7434 TestcaseInstance
7435 {
7436 if ($1.ref_pard) $$ = new Statement(Statement::S_TESTCASE_INSTANCE,
7437 $1.ref_pard, $1.value);
7438 else if($1.derefered_value) {
7439 $$ = new Statement(Statement::S_TESTCASE_INSTANCE_REFD,
7440 $1.derefered_value, $1.ap_list->steal_tis(), $1. value);
7441 delete $1.ap_list;
7442 }
7443 else $$ = new Statement(Statement::S_ERROR);
7444 $$->set_location(infile, @$);
7445 }
7446 | FunctionInstance
7447 {
7448 $$ = new Statement(Statement::S_UNKNOWN_INSTANCE, $1);
7449 $$->set_location(infile, @$);
7450 }
7451 | ApplyOp
7452 {
7453 $$ = new Statement(Statement::S_UNKNOWN_INVOKED, $1.value, $1.ap_list);
7454 $$->set_location(infile, @$);
7455 }
7456 | ReturnStatement { $$ = $1; }
7457 | AltConstruct { $$ = $1; }
7458 | InterleavedConstruct { $$ = $1; }
7459 | LabelStatement { $$ = $1; }
7460 | GotoStatement { $$=$1; }
7461 | RepeatStatement { $$ = $1; }
7462 | BreakStatement { $$ = $1; }
7463 | ContinueStatement { $$ = $1; }
7464 | DeactivateStatement { $$ = $1; }
7465 /* | AltstepInstance -- covered by FunctionInstance */
7466 | ActivateOp
7467 {
7468 if ($1.ref_pard) $$ = new Statement(Statement::S_ACTIVATE, $1.ref_pard);
7469 else if($1.derefered_value) $$ = new Statement(Statement::S_ACTIVATE_REFD,
7470 $1.derefered_value, new ParsedActualParameters($1.ap_list));
7471 else $$ = new Statement(Statement::S_ERROR);
7472 $$->set_location(infile, @$);
7473 }
7474 ;
7475
7476 VerdictStatements: // 544
7477 SetLocalVerdict { $$ = $1; }
7478 ;
7479
7480 VerdictOps: // 545
7481 GetLocalVerdict { $$ = $1; }
7482 ;
7483
7484 SetLocalVerdict: // 546
7485 SetVerdictKeyword '(' Expression optError ',' LogItemList optError ')'
7486 {
7487 $$=new Statement(Statement::S_SETVERDICT, $3, $6);
7488 $$->set_location(infile, @$);
7489 }
7490 | SetVerdictKeyword '(' Expression optError ')'
7491 {
7492 $$=new Statement(Statement::S_SETVERDICT, $3, (LogArguments*)0);
7493 $$->set_location(infile, @$);
7494 }
7495 | SetVerdictKeyword '(' error ')'
7496 {
7497 Value *v = new Value(Value::V_ERROR);
7498 v->set_location(infile, @3);
7499 $$ = new Statement(Statement::S_SETVERDICT, v);
7500 $$->set_location(infile, @$);
7501 }
7502 ;
7503
7504 GetLocalVerdict: // 548
7505 GetVerdictKeyword
7506 {
7507 $$=new Value(Value::OPTYPE_GETVERDICT);
7508 $$->set_location(infile, @$);
7509 }
7510 ;
7511
7512 SUTStatements: // 549
7513 ActionKeyword '(' ')'
7514 {
7515 $$=new Statement(Statement::S_ACTION, (LogArguments*)0);
7516 $$->set_location(infile, @$);
7517 }
7518 | ActionKeyword '(' LogItemList optError ')'
7519 {
7520 $$=new Statement(Statement::S_ACTION, $3);
7521 $$->set_location(infile, @$);
7522 }
7523 | ActionKeyword '(' error ')'
7524 {
7525 $$=new Statement(Statement::S_ACTION, new LogArguments());
7526 $$->set_location(infile, @$);
7527 }
7528 ;
7529
7530 StopExecutionStatement:
7531 StopKeyword
7532 {
7533 $$=new Statement(Statement::S_STOP_EXEC);
7534 $$->set_location(infile, @$);
7535 }
7536 ;
7537
7538 StopTestcaseStatement:
7539 TestcaseKeyword DotStopKeyword
7540 {
7541 $$ = new Statement(Statement::S_STOP_TESTCASE, (LogArguments*)0);
7542 $$->set_location(infile, @$);
7543 }
7544 | TestcaseKeyword DotStopKeyword '(' LogItemList optError ')'
7545 {
7546 $$ = new Statement(Statement::S_STOP_TESTCASE, $4);
7547 $$->set_location(infile, @$);
7548 }
7549 ;
7550
7551 /* these deliberately don't have their locations set */
7552 ProfilerStatement:
7553 TitanSpecificProfilerKeyword DotStartKeyword
7554 {
7555 $$ = new Statement(Statement::S_START_PROFILER);
7556 }
7557 | TitanSpecificProfilerKeyword DotStopKeyword
7558 {
7559 $$ = new Statement(Statement::S_STOP_PROFILER);
7560 }
7561 ;
7562
7563 ProfilerRunningOp:
7564 TitanSpecificProfilerKeyword DotRunningKeyword
7565 {
7566 $$ = new Value(Value::OPTYPE_PROF_RUNNING);
7567 $$->set_location(infile, @$);
7568 }
7569 ;
7570
7571 ReturnStatement: // 552
7572 ReturnKeyword
7573 {
7574 $$=new Statement(Statement::S_RETURN, (Template*)0);
7575 $$->set_location(infile, @$);
7576 }
7577 | ReturnKeyword TemplateBody
7578 {
7579 $$=new Statement(Statement::S_RETURN, $2);
7580 $$->set_location(infile, @$);
7581 }
7582 ;
7583
7584 AltConstruct: // 553
7585 AltKeyword '{' AltGuardList optError '}'
7586 {
7587 $$=new Statement(Statement::S_ALT, $3);
7588 $$->set_location(infile, @$);
7589 }
7590 | AltKeyword '{' error '}'
7591 {
7592 $$=new Statement(Statement::S_ALT, new AltGuards());
7593 $$->set_location(infile, @$);
7594 }
7595 ;
7596
7597 AltGuardList: // 555
7598 optError AltGuard
7599 {
7600 $$ = new AltGuards;
7601 $$->add_ag($2);
7602 }
7603 | AltGuardList optError AltGuard
7604 {
7605 $$ = $1;
7606 $$->add_ag($3);
7607 }
7608 ;
7609
7610 AltGuard:
7611 GuardStatement { $$ = $1; }
7612 | ElseStatement { $$ = $1; }
7613 ;
7614
7615 GuardStatement: // 556
7616 AltGuardChar AltstepInstance optSemiColon
7617 {
7618 $$=new AltGuard($1, $2, 0);
7619 $$->set_location(infile, @$);
7620 }
7621 | AltGuardChar ApplyOp optSemiColon
7622 {
7623 $$=new AltGuard($1, $2.value, $2.ap_list->steal_tis(), 0);
7624 $$->set_location(infile, @$);
7625 delete $2.ap_list;
7626 }
7627 | AltGuardChar AltstepInstance optSemiColon StatementBlock optSemiColon
7628 {
7629 $$=new AltGuard($1, $2, $4);
7630 $$->set_location(infile, @$);
7631 }
7632 | AltGuardChar ApplyOp optSemiColon StatementBlock optSemiColon
7633 {
7634 $$= new AltGuard($1, $2.value, $2.ap_list->steal_tis(), $4);
7635 $$->set_location(infile, @$);
7636 delete $2.ap_list;
7637 }
7638 | AltGuardChar GuardOp ';'
7639 {
7640 $$=new AltGuard($1, $2, new StatementBlock());
7641 $$->set_location(infile, @$);
7642 }
7643 | AltGuardChar GuardOp optSemiColon StatementBlock optSemiColon
7644 {
7645 $$=new AltGuard($1, $2, $4);
7646 $$->set_location(infile, @$);
7647 }
7648 ;
7649
7650 ElseStatement: // 557
7651 '[' ElseKeyword ']' StatementBlock optSemiColon
7652 {
7653 $$=new AltGuard($4);
7654 $$->set_location(infile, @$);
7655 }
7656 ;
7657
7658 AltGuardChar: // 558
7659 '[' ']' { $$=0; }
7660 | '[' BooleanExpression ']' { $$ = $2; }
7661 ;
7662
7663 GuardOp: // 559
7664 TimeoutStatement { $$=$1; }
7665 | ReceiveStatement { $$=$1; }
7666 | TriggerStatement { $$=$1; }
7667 | GetCallStatement { $$=$1; }
7668 | CatchStatement { $$=$1; }
7669 | CheckStatement { $$=$1; }
7670 | GetReplyStatement { $$=$1; }
7671 | DoneStatement { $$=$1; }
7672 | KilledStatement { $$ = $1; }
7673 ;
7674
7675 InterleavedConstruct: // 560
7676 InterleavedKeyword '{' InterleavedGuardList optError '}'
7677 {
7678 $$ = new Statement(Statement::S_INTERLEAVE, $3);
7679 $$->set_location(infile, @$);
7680 }
7681 | InterleavedKeyword '{' error '}'
7682 {
7683 $$ = new Statement(Statement::S_INTERLEAVE, new AltGuards());
7684 $$->set_location(infile, @$);
7685 }
7686 ;
7687
7688 InterleavedGuardList: // 562
7689 optError InterleavedGuardElement
7690 {
7691 $$ = new AltGuards();
7692 $$->add_ag($2);
7693 }
7694 | InterleavedGuardList optError InterleavedGuardElement
7695 { $$ = $1; $$->add_ag($3); }
7696 ;
7697
7698 InterleavedGuardElement: // 563
7699 '[' optError ']' GuardOp ';'
7700 {
7701 $$ = new AltGuard(0, $4, new StatementBlock());
7702 $$->set_location(infile, @$);
7703 }
7704 | '[' optError ']' GuardOp optSemiColon StatementBlock optSemiColon
7705 {
7706 $$ = new AltGuard(0, $4, $6);
7707 $$->set_location(infile, @$);
7708 }
7709 ;
7710
7711 /* The following were folded into the above rule:
7712
7713 InterleavedGuardElement: // 563
7714 InterleavedGuard InterleavedAction
7715 ;
7716
7717 InterleavedGuard: // 564
7718 '[' ']' GuardOp
7719 ;
7720
7721 InterleavedAction: // 565
7722 StatementBlock
7723 ;
7724 */
7725
7726 LabelStatement: // 566
7727 LabelKeyword IDentifier
7728 {
7729 $$=new Statement(Statement::S_LABEL, $2);
7730 $$->set_location(infile, @$);
7731 }
7732 ;
7733
7734 GotoStatement: // 569
7735 GotoKeyword IDentifier
7736 {
7737 $$=new Statement(Statement::S_GOTO, $2);
7738 $$->set_location(infile, @$);
7739 }
7740 | GotoKeyword AltKeyword
7741 {
7742 Location loc(infile, @$);
7743 loc.warning("Obsolete statement `goto alt' was substituted with `repeat'");
7744 $$=new Statement(Statement::S_REPEAT);
7745 $$->set_location(infile, @$);
7746 }
7747 ;
7748
7749 RepeatStatement: // 571
7750 RepeatKeyword
7751 {
7752 $$=new Statement(Statement::S_REPEAT);
7753 $$->set_location(infile, @$);
7754 }
7755 ;
7756
7757 ActivateOp: // 572
7758 ActivateKeyword '(' AltstepInstance optError ')'
7759 {
7760 $$.ref_pard = $3;
7761 $$.derefered_value = 0;
7762 $$.ap_list = 0;
7763 }
7764 | ActivateKeyword '(' DereferOp '(' optFunctionActualParList ')' optError ')'
7765 {
7766 $5->set_location(infile, @4, @6);
7767 $$.ref_pard = 0;
7768 $$.derefered_value = $3;
7769 $$.ap_list = $5->steal_tis(); /* XXX perhaps propagate the datatype instead ? */
7770 delete $5;
7771 }
7772 | ActivateKeyword '(' error ')'
7773 {
7774 $$.ref_pard = 0;
7775 $$.derefered_value = 0;
7776 $$.ap_list = 0;
7777 }
7778 ;
7779
7780 ReferOp:
7781 RefersKeyword '(' FunctionRef ')'
7782 {
7783 Ttcn::Reference* t_ref = new Ttcn::Reference($3.modid, $3.id);
7784 t_ref->set_location(infile, @3);
7785 $$ = new Value(Value::V_REFER, t_ref);
7786 $$->set_location(infile, @$);
7787 }
7788 ;
7789
7790 DeactivateStatement: // 574
7791 DeactivateKeyword
7792 {
7793 $$=new Statement(Statement::S_DEACTIVATE, (Value*)0);
7794 $$->set_location(infile, @$);
7795 }
7796 | DeactivateKeyword '(' Expression optError ')'
7797 {
7798 $$=new Statement(Statement::S_DEACTIVATE, $3);
7799 $$->set_location(infile, @$);
7800 }
7801 | DeactivateKeyword '(' error ')'
7802 {
7803 Value *v = new Value(Value::V_ERROR);
7804 v->set_location(infile, @3);
7805 $$ = new Statement(Statement::S_DEACTIVATE, v);
7806 $$->set_location(infile, @$);
7807 }
7808 ;
7809
7810 BreakStatement: // 576
7811 BreakKeyword
7812 {
7813 $$=new Statement(Statement::S_BREAK);
7814 $$->set_location(infile, @$);
7815 }
7816 ;
7817
7818 ContinueStatement: // 577
7819 ContinueKeyword
7820 {
7821 $$=new Statement(Statement::S_CONTINUE);
7822 $$->set_location(infile, @$);
7823 }
7824 ;
7825
7826 /* A.1.6.8 Basic statements */
7827
7828 BasicStatements: // 578
7829 Assignment
7830 {
7831 $$=new Statement(Statement::S_ASSIGNMENT, $1);
7832 $$->set_location(infile, @$);
7833 }
7834 | LogStatement { $$ = $1; }
7835 | String2TtcnStatement { $$ = $1; }
7836 | StatementBlock
7837 {
7838 $$ = new Statement(Statement::S_BLOCK, $1);
7839 $$->set_location(infile, @$);
7840 }
7841 | TitanSpecificTryKeyword StatementBlock
7842 {
7843 $$ = new Statement(Statement::S_BLOCK, $2);
7844 $2->set_exception_handling(StatementBlock::EH_TRY);
7845 $$->set_location(infile, @$);
7846 }
7847 | TitanSpecificCatchKeyword '(' IDentifier ')' StatementBlock
7848 {
7849 $$ = new Statement(Statement::S_BLOCK, $5);
7850 $5->set_exception_handling(StatementBlock::EH_CATCH);
7851 /* add a newly constructed first statement which will contain the error message,
7852 same as: 'var charstring IDentifier;' */
7853 Type* str_type = new Type(Type::T_CSTR);
7854 str_type->set_location(infile, @3);
7855 Def_Var* str_def = new Def_Var($3, str_type, 0);
7856 str_def->set_location(infile, @3);
7857 Statement* str_stmt = new Statement(Statement::S_DEF, str_def);
7858 str_stmt->set_location(infile, @3);
7859 $5->add_stmt(str_stmt, true);
7860 $$->set_location(infile, @$);
7861 }
7862 | LoopConstruct { $$ = $1; }
7863 | ConditionalConstruct { $$ = $1; }
7864 | SelectCaseConstruct { $$ = $1; }
7865 ;
7866
7867 Expression: // 579
7868 '(' optError Expression optError ')' { $$ = $3; }
7869 | '(' error ')'
7870 {
7871 $$ = new Value(Value::V_ERROR);
7872 $$->set_location(infile, @$);
7873 }
7874 | '+' Expression %prec UnarySign
7875 {
7876 $$ = new Value(Value::OPTYPE_UNARYPLUS, $2);
7877 $$->set_location(infile, @$);
7878 }
7879 | '-' Expression %prec UnarySign
7880 {
7881 $$ = new Value(Value::OPTYPE_UNARYMINUS, $2);
7882 $$->set_location(infile, @$);
7883 }
7884 | Expression '*' Expression
7885 {
7886 $$ = new Value(Value::OPTYPE_MULTIPLY, $1, $3);
7887 $$->set_location(infile, @$);
7888 }
7889 | Expression '/' Expression
7890 {
7891 $$ = new Value(Value::OPTYPE_DIVIDE, $1, $3);
7892 $$->set_location(infile, @$);
7893 }
7894 | Expression ModKeyword Expression
7895 {
7896 $$ = new Value(Value::OPTYPE_MOD, $1, $3);
7897 $$->set_location(infile, @$);
7898 }
7899 | Expression RemKeyword Expression
7900 {
7901 $$ = new Value(Value::OPTYPE_REM, $1, $3);
7902 $$->set_location(infile, @$);
7903 }
7904 | Expression '+' Expression
7905 {
7906 $$ = new Value(Value::OPTYPE_ADD, $1, $3);
7907 $$->set_location(infile, @$);
7908 }
7909 | Expression '-' Expression
7910 {
7911 $$ = new Value(Value::OPTYPE_SUBTRACT, $1, $3);
7912 $$->set_location(infile, @$);
7913 }
7914 | Expression '&' Expression
7915 {
7916 $$ = new Value(Value::OPTYPE_CONCAT, $1, $3);
7917 $$->set_location(infile, @$);
7918 }
7919 | Not4bKeyword Expression
7920 {
7921 $$ = new Value(Value::OPTYPE_NOT4B, $2);
7922 $$->set_location(infile, @$);
7923 }
7924 | Expression And4bKeyword Expression
7925 {
7926 $$ = new Value(Value::OPTYPE_AND4B, $1, $3);
7927 $$->set_location(infile, @$);
7928 }
7929 | Expression Xor4bKeyword Expression
7930 {
7931 $$ = new Value(Value::OPTYPE_XOR4B, $1, $3);
7932 $$->set_location(infile, @$);
7933 }
7934 | Expression Or4bKeyword Expression
7935 {
7936 $$ = new Value(Value::OPTYPE_OR4B, $1, $3);
7937 $$->set_location(infile, @$);
7938 }
7939 | Expression SL Expression
7940 {
7941 $$ = new Value(Value::OPTYPE_SHL, $1, $3);
7942 $$->set_location(infile, @$);
7943 }
7944 | Expression SR Expression
7945 {
7946 $$ = new Value(Value::OPTYPE_SHR, $1, $3);
7947 $$->set_location(infile, @$);
7948 }
7949 | Expression RL Expression
7950 {
7951 $$ = new Value(Value::OPTYPE_ROTL, $1, $3);
7952 $$->set_location(infile, @$);
7953 }
7954 | Expression _RR Expression
7955 {
7956 $$ = new Value(Value::OPTYPE_ROTR, $1, $3);
7957 $$->set_location(infile, @$);
7958 }
7959 | Expression '<' Expression
7960 {
7961 $$ = new Value(Value::OPTYPE_LT, $1, $3);
7962 $$->set_location(infile, @$);
7963 }
7964 | Expression '>' Expression
7965 {
7966 $$ = new Value(Value::OPTYPE_GT, $1, $3);
7967 $$->set_location(infile, @$);
7968 }
7969 | Expression LE Expression
7970 {
7971 $$ = new Value(Value::OPTYPE_LE, $1, $3);
7972 $$->set_location(infile, @$);
7973 }
7974 | Expression GE Expression
7975 {
7976 $$ = new Value(Value::OPTYPE_GE, $1, $3);
7977 $$->set_location(infile, @$);
7978 }
7979 | Expression EQ Expression
7980 {
7981 $$ = new Value(Value::OPTYPE_EQ, $1, $3);
7982 $$->set_location(infile, @$);
7983 }
7984 | Expression NE Expression
7985 {
7986 $$ = new Value(Value::OPTYPE_NE, $1, $3);
7987 $$->set_location(infile, @$);
7988 }
7989 | NotKeyword Expression
7990 {
7991 $$ = new Value(Value::OPTYPE_NOT, $2);
7992 $$->set_location(infile, @$);
7993 }
7994 | Expression AndKeyword Expression
7995 {
7996 $$ = new Value(Value::OPTYPE_AND, $1, $3);
7997 $$->set_location(infile, @$);
7998 }
7999 | Expression XorKeyword Expression
8000 {
8001 $$ = new Value(Value::OPTYPE_XOR, $1, $3);
8002 $$->set_location(infile, @$);
8003 }
8004 | Expression OrKeyword Expression
8005 {
8006 $$ = new Value(Value::OPTYPE_OR, $1, $3);
8007 $$->set_location(infile, @$);
8008 }
8009 | OpCall { $$ = $1; }
8010 | Value { $$ = $1; }
8011 | CompoundExpression { $$ = $1; }
8012 ;
8013
8014 CompoundExpression: // 565
8015 FieldExpressionList { $$ = $1; }
8016 | ArrayExpressionList { $$ = $1; }
8017 | ArrayExpression { $$ = $1; }
8018 ;
8019
8020 FieldExpressionList: // 581
8021 '{' seqFieldExpressionSpec optError '}'
8022 {
8023 $$ = new Value(Value::V_SEQ, $2);
8024 $$->set_location(infile, @$);
8025 }
8026 ;
8027
8028 seqFieldExpressionSpec:
8029 FieldExpressionSpec
8030 {
8031 $$ = new NamedValues();
8032 $$->add_nv($1);
8033 }
8034 | error FieldExpressionSpec
8035 {
8036 $$ = new NamedValues();
8037 $$->add_nv($2);
8038 }
8039 | seqFieldExpressionSpec optError ',' optError FieldExpressionSpec
8040 {
8041 $$ = $1;
8042 $$->add_nv($5);
8043 }
8044 | seqFieldExpressionSpec optError ',' error { $$ = $1; }
8045 ;
8046
8047 FieldExpressionSpec: // 582
8048 FieldReference AssignmentChar NotUsedOrExpression
8049 {
8050 $$ = new NamedValue($1, $3);
8051 $$->set_location(infile, @$);
8052 }
8053 ;
8054
8055 ArrayExpressionList:
8056 '{' seqArrayExpressionSpec optError '}'
8057 {
8058 $$ = new Value(Value::V_SEQOF, $2);
8059 $$->set_location(infile, @$);
8060 }
8061 ;
8062
8063 seqArrayExpressionSpec:
8064 optError ArrayExpressionSpec
8065 {
8066 // The only place for indexed-list notation.
8067 $$ = new Values(true);
8068 $$->add_iv($2);
8069 }
8070 | seqArrayExpressionSpec optError ',' optError ArrayExpressionSpec
8071 {
8072 $$ = $1;
8073 $$->add_iv($5);
8074 }
8075 | seqArrayExpressionSpec optError ',' error { $$ = $1; }
8076 ;
8077
8078 ArrayExpressionSpec:
8079 ArrayOrBitRef AssignmentChar Expression
8080 {
8081 $$ = new IndexedValue($1, $3);
8082 $$->set_location(infile, @$);
8083 }
8084 ;
8085
8086 ArrayExpression: // 583
8087 '{' '}'
8088 {
8089 $$ = new Value(Value::V_SEQOF, new Values);
8090 $$->set_location(infile, @$);
8091 }
8092 | '{' ArrayElementExpressionList optError '}'
8093 {
8094 $$ = new Value(Value::V_SEQOF, $2);
8095 $$->set_location(infile, @$);
8096 }
8097 | '{' error '}'
8098 {
8099 $$ = new Value(Value::V_ERROR);
8100 $$->set_location(infile, @$);
8101 }
8102 ;
8103
8104 ArrayElementExpressionList: // 584
8105 NotUsedOrExpression
8106 {
8107 $$ = new Values;
8108 $$->add_v($1);
8109 }
8110 | error NotUsedOrExpression
8111 {
8112 $$ = new Values;
8113 $$->add_v($2);
8114 }
8115 | ArrayElementExpressionList optError ',' optError NotUsedOrExpression
8116 {
8117 $$ = $1;
8118 $$->add_v($5);
8119 }
8120 | ArrayElementExpressionList optError ',' error { $$ = $1; }
8121 ;
8122
8123 NotUsedOrExpression: // 585
8124 Expression { $$ = $1; }
8125 | NotUsedSymbol
8126 {
8127 $$ = new Value(Value::V_NOTUSED);
8128 $$->set_location(infile, @$);
8129 }
8130 ;
8131
8132 BooleanExpression: // 588
8133 Expression { $$ = $1; }
8134 | error
8135 {
8136 $$ = new Value(Value::V_ERROR);
8137 $$->set_location(infile, @$);
8138 }
8139 ;
8140
8141 Assignment: // 594
8142 VariableRef AssignmentChar TemplateBody
8143 {
8144 $$ = new Ttcn::Assignment($1, $3);
8145 $$->set_location(infile, @$);
8146 }
8147 ;
8148
8149 /* This can not be a single CompoundExpression (as opposed to Expression) */
8150 SingleExpression: // 595
8151 '(' SingleExpression ')' { $$ = $2; }
8152 | '(' error SingleExpression ')' { $$ = $3; }
8153 | '(' error ')'
8154 {
8155 $$ = new Value(Value::V_ERROR);
8156 $$->set_location(infile, @$);
8157 }
8158 | '+' Expression %prec UnarySign
8159 {
8160 $$ = new Value(Value::OPTYPE_UNARYPLUS, $2);
8161 $$->set_location(infile, @$);
8162 }
8163 | '-' Expression %prec UnarySign
8164 {
8165 $$ = new Value(Value::OPTYPE_UNARYMINUS, $2);
8166 $$->set_location(infile, @$);
8167 }
8168 | SingleExpression '*' Expression
8169 {
8170 $$ = new Value(Value::OPTYPE_MULTIPLY, $1, $3);
8171 $$->set_location(infile, @$);
8172 }
8173 | SingleExpression '/' Expression
8174 {
8175 $$ = new Value(Value::OPTYPE_DIVIDE, $1, $3);
8176 $$->set_location(infile, @$);
8177 }
8178 | SingleExpression ModKeyword Expression
8179 {
8180 $$ = new Value(Value::OPTYPE_MOD, $1, $3);
8181 $$->set_location(infile, @$);
8182 }
8183 | SingleExpression RemKeyword Expression
8184 {
8185 $$ = new Value(Value::OPTYPE_REM, $1, $3);
8186 $$->set_location(infile, @$);
8187 }
8188 | SingleExpression '+' Expression
8189 {
8190 $$ = new Value(Value::OPTYPE_ADD, $1, $3);
8191 $$->set_location(infile, @$);
8192 }
8193 | SingleExpression '-' Expression
8194 {
8195 $$ = new Value(Value::OPTYPE_SUBTRACT, $1, $3);
8196 $$->set_location(infile, @$);
8197 }
8198 | SingleExpression '&' Expression
8199 {
8200 $$ = new Value(Value::OPTYPE_CONCAT, $1, $3);
8201 $$->set_location(infile, @$);
8202 }
8203 | Not4bKeyword Expression
8204 {
8205 $$ = new Value(Value::OPTYPE_NOT4B, $2);
8206 $$->set_location(infile, @$);
8207 }
8208 | SingleExpression And4bKeyword Expression
8209 {
8210 $$ = new Value(Value::OPTYPE_AND4B, $1, $3);
8211 $$->set_location(infile, @$);
8212 }
8213 | SingleExpression Xor4bKeyword Expression
8214 {
8215 $$ = new Value(Value::OPTYPE_XOR4B, $1, $3);
8216 $$->set_location(infile, @$);
8217 }
8218 | SingleExpression Or4bKeyword Expression
8219 {
8220 $$ = new Value(Value::OPTYPE_OR4B, $1, $3);
8221 $$->set_location(infile, @$);
8222 }
8223 | SingleExpression SL Expression
8224 {
8225 $$ = new Value(Value::OPTYPE_SHL, $1, $3);
8226 $$->set_location(infile, @$);
8227 }
8228 | SingleExpression SR Expression
8229 {
8230 $$ = new Value(Value::OPTYPE_SHR, $1, $3);
8231 $$->set_location(infile, @$);
8232 }
8233 | SingleExpression RL Expression
8234 {
8235 $$ = new Value(Value::OPTYPE_ROTL, $1, $3);
8236 $$->set_location(infile, @$);
8237 }
8238 | SingleExpression _RR Expression
8239 {
8240 $$ = new Value(Value::OPTYPE_ROTR, $1, $3);
8241 $$->set_location(infile, @$);
8242 }
8243 | SingleExpression '<' Expression
8244 {
8245 $$ = new Value(Value::OPTYPE_LT, $1, $3);
8246 $$->set_location(infile, @$);
8247 }
8248 | SingleExpression '>' Expression
8249 {
8250 $$ = new Value(Value::OPTYPE_GT, $1, $3);
8251 $$->set_location(infile, @$);
8252 }
8253 | SingleExpression LE Expression
8254 {
8255 $$ = new Value(Value::OPTYPE_LE, $1, $3);
8256 $$->set_location(infile, @$);
8257 }
8258 | SingleExpression GE Expression
8259 {
8260 $$ = new Value(Value::OPTYPE_GE, $1, $3);
8261 $$->set_location(infile, @$);
8262 }
8263 | SingleExpression EQ Expression
8264 {
8265 $$ = new Value(Value::OPTYPE_EQ, $1, $3);
8266 $$->set_location(infile, @$);
8267 }
8268 | SingleExpression NE Expression
8269 {
8270 $$ = new Value(Value::OPTYPE_NE, $1, $3);
8271 $$->set_location(infile, @$);
8272 }
8273 | NotKeyword Expression
8274 {
8275 $$ = new Value(Value::OPTYPE_NOT, $2);
8276 $$->set_location(infile, @$);
8277 }
8278 | SingleExpression AndKeyword Expression
8279 {
8280 $$ = new Value(Value::OPTYPE_AND, $1, $3);
8281 $$->set_location(infile, @$);
8282 }
8283 | SingleExpression XorKeyword Expression
8284 {
8285 $$ = new Value(Value::OPTYPE_XOR, $1, $3);
8286 $$->set_location(infile, @$);
8287 }
8288 | SingleExpression OrKeyword Expression
8289 {
8290 $$ = new Value(Value::OPTYPE_OR, $1, $3);
8291 $$->set_location(infile, @$);
8292 }
8293 | OpCall { $$ = $1; }
8294 | Value { $$ = $1; }
8295 ;
8296
8297 optExtendedFieldReference:
8298 // perhaps this should be called seqExtendedFieldReference,
8299 // but the convention appears to be that seq... can not be empty
8300 /* empty */
8301 {
8302 $$.nElements = 0;
8303 $$.elements = 0;
8304 }
8305 | optExtendedFieldReference FieldOrArrayReference
8306 {
8307 $$.nElements = $1.nElements + 1;
8308 $$.elements = (FieldOrArrayRef**)
8309 Realloc($1.elements, ($$.nElements) * sizeof(*$$.elements));
8310 $$.elements[$1.nElements] = $2;
8311 }
8312 ;
8313
8314 FieldOrArrayReference:
8315 '.' FieldIdentifier
8316 {
8317 $$ = new FieldOrArrayRef($2);
8318 $$->set_location(infile, @$);
8319 }
8320 | ArrayOrBitRefOrDash { $$ = $1; }
8321 ;
8322
8323 FieldIdentifier:
8324 PredefOrIdentifier { $$ = $1; }
8325 | IDentifier /* maybe PredefOrIdentifier here too */ TypeActualParList
8326 {
8327 Location loc(infile, @$);
8328 loc.error("Reference to a parameterized field of type `anytype' is "
8329 "not currently supported");
8330 $$ = $1;
8331 }
8332 ;
8333
8334 OpCall: // 611
8335 ConfigurationOps { $$ = $1; }
8336 | VerdictOps { $$ = $1; }
8337 | TimerOps { $$ = $1; }
8338 | TestcaseInstance
8339 {
8340 if ($1.ref_pard) $$ = new Value(Value::OPTYPE_EXECUTE, $1.ref_pard,
8341 $1.value);
8342 else if($1.derefered_value)
8343 $$ = new Value(Value::OPTYPE_EXECUTE_REFD, $1.derefered_value, $1.ap_list,
8344 $1.value);
8345 else $$ = new Value(Value::V_ERROR);
8346 $$->set_location(infile, @$);
8347 }
8348 | FunctionInstance
8349 {
8350 $$ = new Value(Value::V_REFD, $1);
8351 $$->set_location(infile, @$);
8352 }
8353 | ApplyOp
8354 {
8355 $$ = new Value(Value::V_INVOKE, $1.value, $1.ap_list);
8356 $$->set_location(infile, @$);
8357 }
8358 | TemplateOps { $$ = $1; }
8359 | PredefinedOps { $$ = $1; }
8360 | ReferOp { $$ = $1; }
8361 | ActivateOp
8362 {
8363 if ($1.ref_pard) $$ = new Value(Value::OPTYPE_ACTIVATE, $1.ref_pard);
8364 else if($1.derefered_value) $$ = new Value(Value::OPTYPE_ACTIVATE_REFD,
8365 $1.derefered_value, new ParsedActualParameters($1.ap_list));
8366 else $$ = new Value(Value::V_ERROR);
8367 $$->set_location(infile, @$);
8368 }
8369 | ProfilerRunningOp { $$ = $1; }
8370 ;
8371
8372 PredefinedOps:
8373 PredefinedOpKeyword1 '(' optError Expression optError ')'
8374 {
8375 $$ = new Value($1, $4);
8376 $$->set_location(infile, @$);
8377 }
8378 | PredefinedOpKeyword1 '(' error ')'
8379 {
8380 Value *v1 = new Value(Value::V_ERROR);
8381 v1->set_location(infile, @3);
8382 $$ = new Value($1, v1);
8383 $$->set_location(infile, @$);
8384 }
8385 | PredefinedOpKeyword2 '(' optError Expression optError ',' optError
8386 Expression optError ')'
8387 {
8388 $$ = new Value($1, $4, $8);
8389 $$->set_location(infile, @$);
8390 }
8391 | PredefinedOpKeyword2 '(' error ')'
8392 {
8393 Value *v1 = new Value(Value::V_ERROR);
8394 v1->set_location(infile, @3);
8395 Value *v2 = new Value(Value::V_ERROR);
8396 v2->set_location(infile, @3);
8397 $$ = new Value($1, v1, v2);
8398 $$->set_location(infile, @$);
8399 }
8400 | PredefinedOpKeyword3 '(' optError Expression optError ',' optError
8401 Expression optError ')'
8402 {
8403 $$ = new Value($1, $4, $8);
8404 $$->set_location(infile, @$);
8405 }
8406 | PredefinedOpKeyword3 '(' optError Expression optError ')'
8407 {
8408 $$ = new Value($1, $4, (Common::Value*)NULL);
8409 $$->set_location(infile, @$);
8410 }
8411 | PredefinedOpKeyword3 '(' error ')'
8412 {
8413 Value *v1 = new Value(Value::V_ERROR);
8414 v1->set_location(infile, @3);
8415 Value *v2 = new Value(Value::V_ERROR);
8416 v2->set_location(infile, @3);
8417 $$ = new Value($1, v1, v2);
8418 $$->set_location(infile, @$);
8419 }
8420 | decompKeyword '(' optError Expression optError ',' optError
8421 Expression optError ',' optError Expression optError ')'
8422 {
8423 $$ = new Value(Value::OPTYPE_DECOMP, $4, $8, $12);
8424 $$->set_location(infile, @$);
8425 }
8426 | decompKeyword '(' error ')'
8427 {
8428 Value *v1 = new Value(Value::V_ERROR);
8429 v1->set_location(infile, @3);
8430 Value *v2 = new Value(Value::V_ERROR);
8431 v2->set_location(infile, @3);
8432 Value *v3 = new Value(Value::V_ERROR);
8433 v3->set_location(infile, @3);
8434 $$ = new Value(Value::OPTYPE_DECOMP, v1, v2, v3);
8435 $$->set_location(infile, @$);
8436 }
8437 | regexpKeyword '(' optError TemplateInstance optError ',' optError
8438 TemplateInstance optError ',' optError Expression optError ')'
8439 {
8440 $$ = new Value(Value::OPTYPE_REGEXP, $4, $8, $12);
8441 $$->set_location(infile, @$);
8442 }
8443 | regexpKeyword '(' error ')'
8444 {
8445 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8446 t1->set_location(infile, @3);
8447 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8448 ti1->set_location(infile, @3);
8449 Template *t2 = new Template(Template::TEMPLATE_ERROR);
8450 t2->set_location(infile, @3);
8451 TemplateInstance *ti2 = new TemplateInstance(0, 0, t2);
8452 ti2->set_location(infile, @3);
8453 Value *v3 = new Value(Value::V_ERROR);
8454 v3->set_location(infile, @3);
8455 $$ = new Value(Value::OPTYPE_REGEXP, ti1, ti2, v3);
8456 $$->set_location(infile, @$);
8457 }
8458 | encvalueKeyword '(' optError TemplateInstance optError ')'
8459 {
8460 $$ = new Value(Value::OPTYPE_ENCODE, $4);
8461 $$->set_location(infile, @$);
8462 }
8463 | encvalueKeyword '(' error ')'
8464 {
8465 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8466 t1->set_location(infile, @3);
8467 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8468 ti1->set_location(infile, @3);
8469 $$ = new Value(Value::OPTYPE_ENCODE, ti1);
8470 $$->set_location(infile, @$);
8471 }
8472 | substrKeyword '(' optError TemplateInstance optError ',' optError
8473 Expression optError ',' optError Expression optError ')'
8474 {
8475 $$ = new Value(Value::OPTYPE_SUBSTR, $4, $8, $12);
8476 $$->set_location(infile, @$);
8477 }
8478 | substrKeyword '(' error ')'
8479 {
8480 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8481 t1->set_location(infile, @3);
8482 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8483 ti1->set_location(infile, @3);
8484 Value *v2 = new Value(Value::V_ERROR);
8485 v2->set_location(infile, @3);
8486 Value *v3 = new Value(Value::V_ERROR);
8487 v3->set_location(infile, @3);
8488 $$ = new Value(Value::OPTYPE_SUBSTR, ti1, v2, v3);
8489 $$->set_location(infile, @$);
8490 }
8491 | replaceKeyword '(' optError TemplateInstance optError ',' optError
8492 Expression optError ',' optError Expression optError ',' optError
8493 TemplateInstance optError ')'
8494 {
8495 $$ = new Value(Value::OPTYPE_REPLACE, $4, $8, $12, $16);
8496 $$->set_location(infile, @$);
8497 }
8498 | replaceKeyword '(' error ')'
8499 {
8500 Template *t1 = new Template(Template::TEMPLATE_ERROR);
8501 t1->set_location(infile, @3);
8502 TemplateInstance *ti1 = new TemplateInstance(0, 0, t1);
8503 ti1->set_location(infile, @3);
8504 Value *v2 = new Value(Value::V_ERROR);
8505 v2->set_location(infile, @3);
8506 Value *v3 = new Value(Value::V_ERROR);
8507 v3->set_location(infile, @3);
8508 Template *t4 = new Template(Template::TEMPLATE_ERROR);
8509 t4->set_location(infile, @3);
8510 TemplateInstance *ti4 = new TemplateInstance(0, 0, t4);
8511 ti4->set_location(infile, @3);
8512 $$ = new Value(Value::OPTYPE_REPLACE, ti1, v2, v3, ti4);
8513 $$->set_location(infile, @$);
8514 }
8515 | decvalueKeyword '(' optError DecValueArg optError ',' optError DecValueArg optError ')'
8516 {
8517 $$ = new Value(Value::OPTYPE_DECODE, $4, $8);
8518 $$->set_location(infile, @$);
8519 }
8520 | decvalueKeyword '(' error ')'
8521 {
8522 /*Value *v1 = new Value(Value::V_ERROR);
8523 v1->set_location(infile, @3);
8524 TemplateInstance *t2 = new TemplateInstance(Type::T_ERROR);*/
8525 $$ = new Value(Value::V_ERROR);
8526 $$->set_location(infile, @$);
8527 }
8528 | isvalueKeyword '(' optError TemplateInstance optError ')'
8529 {
8530 $$ = new Value(Value::OPTYPE_ISVALUE, $4);
8531 $$->set_location(infile, @$);
8532 }
8533 | isvalueKeyword '(' error ')'
8534 {
8535 $$ = new Value(Value::V_ERROR);
8536 $$->set_location(infile, @$);
8537 }
8538 | isboundKeyword '(' optError TemplateInstance optError ')'
8539 {
8540 $$ = new Value(Value::OPTYPE_ISBOUND, $4);
8541 $$->set_location(infile, @$);
8542 }
8543 | isboundKeyword '(' error ')'
8544 {
8545 $$ = new Value(Value::V_ERROR);
8546 $$->set_location(infile, @$);
8547 }
8548 | ischosenKeyword '(' optError IschosenArg optError ')'
8549 {
8550 $$ = new Value(Value::OPTYPE_ISCHOSEN, $4.ref, $4.id);
8551 $$->set_location(infile, @$);
8552 }
8553 | ischosenKeyword '(' error ')'
8554 {
8555 $$ = new Value(Value::V_ERROR);
8556 $$->set_location(infile, @$);
8557 }
8558 | ispresentKeyword '(' optError TemplateInstance optError ')'
8559 {
8560 $$ = new Value(Value::OPTYPE_ISPRESENT, $4);
8561 $$->set_location(infile, @$);
8562 }
8563 | ispresentKeyword '(' error ')'
8564 {
8565 $$ = new Value(Value::V_ERROR);
8566 $$->set_location(infile, @$);
8567 }
8568 | lengthofKeyword '(' optError TemplateInstance optError ')'
8569 {
8570 $$ = new Value(Value::OPTYPE_LENGTHOF, $4);
8571 $$->set_location(infile, @$);
8572 }
8573 | lengthofKeyword '(' error ')'
8574 {
8575 $$ = new Value(Value::V_ERROR);
8576 $$->set_location(infile, @$);
8577 }
8578 | rndKeyword '(' ')'
8579 {
8580 $$ = new Value(Value::OPTYPE_RND);
8581 $$->set_location(infile, @$);
8582 }
8583 | rndKeyword '(' optError Expression optError ')'
8584 {
8585 $$ = new Value(Value::OPTYPE_RNDWITHVAL, $4);
8586 $$->set_location(infile, @$);
8587 }
8588 | rndKeyword '(' error ')'
8589 {
8590 Value *v = new Value(Value::V_ERROR);
8591 v->set_location(infile, @3);
8592 $$ = new Value(Value::OPTYPE_RNDWITHVAL, v);
8593 $$->set_location(infile, @$);
8594 }
8595 | sizeofKeyword '(' optError TemplateInstance optError ')'
8596 {
8597 $$ = new Value(Value::OPTYPE_SIZEOF, $4);
8598 $$->set_location(infile, @$);
8599 }
8600 | sizeofKeyword '(' error ')'
8601 {
8602 $$ = new Value(Value::V_ERROR);
8603 $$->set_location(infile, @$);
8604 }
8605 | log2strKeyword '(' ')'
8606 {
8607 $$ = new Value(Value::OPTYPE_LOG2STR, new LogArguments());
8608 $$->set_location(infile, @$);
8609 }
8610 | log2strKeyword '(' LogItemList optError ')'
8611 {
8612 $$ = new Value(Value::OPTYPE_LOG2STR, $3);
8613 $$->set_location(infile, @$);
8614 }
8615 | log2strKeyword '(' error ')'
8616 {
8617 $$ = new Value(Value::OPTYPE_LOG2STR, new LogArguments());
8618 $$->set_location(infile, @$);
8619 }
8620 | testcasenameKeyword '(' ')'
8621 {
8622 $$ = new Value(Value::OPTYPE_TESTCASENAME);
8623 $$->set_location(infile, @$);
8624 }
8625 | ttcn2stringKeyword '(' optError TemplateInstance optError ')'
8626 {
8627 $$ = new Value(Value::OPTYPE_TTCN2STRING, $4);
8628 $$->set_location(infile, @$);
8629 }
8630 | ttcn2stringKeyword '(' error ')'
8631 {
8632 $$ = new Value(Value::V_ERROR);
8633 $$->set_location(infile, @$);
8634 }
8635 ;
8636
8637 DecValueArg:
8638 Reference
8639 {
8640 if ($1.is_ref) $$ = $1.ref;
8641 else {
8642 $$ = new Ttcn::Reference($1.id);
8643 $$->set_location(infile, @$);
8644 }
8645 }
8646 | FunctionInstance { $$ = $1; }
8647 ;
8648
8649 PredefOrIdentifier:
8650 IDentifier { $$ = $1; }
8651 | PredefinedType /* shall not be "anytype" */
8652 {
8653 // Construct an identifier "on the fly" ($1 here is just a typetype_t)
8654 const char* builtin_typename = Type::get_typename_builtin($1);
8655 if (0 == builtin_typename) FATAL_ERROR("Unexpected type %d", $1);
8656 const string& at_field = anytype_field(string(builtin_typename));
8657
8658 $$ = new Identifier(Identifier::ID_TTCN, at_field);
8659 }
8660
8661 IschosenArg: /* see also Reference... */
8662 IDentifier '.' PredefOrIdentifier
8663 {
8664 $$.ref = new Ttcn::Reference($1);
8665 $$.ref->set_location(infile, @1);
8666 $$.id = $3;
8667 }
8668 | IDentifier '.' PredefOrIdentifier optExtendedFieldReference '.' PredefOrIdentifier
8669 {
8670 $$.ref = new Ttcn::Reference($1);
8671 FieldOrArrayRef *fieldref = new FieldOrArrayRef($3);
8672 fieldref->set_location(infile, @3);
8673 $$.ref->add(fieldref);
8674 for(size_t i=0; i<$4.nElements; i++) $$.ref->add($4.elements[i]);
8675 Free($4.elements);
8676 $$.ref->set_location(infile, @1, @4);
8677 $$.id = $6;
8678 }
8679 | IDentifier ArrayOrBitRef optExtendedFieldReference '.' PredefOrIdentifier
8680 {
8681 $$.ref = new Ttcn::Reference($1);
8682 $$.ref->add($2);
8683 for(size_t i=0; i<$3.nElements; i++) $$.ref->add($3.elements[i]);
8684 Free($3.elements);
8685 $$.ref->set_location(infile, @1, @3);
8686 $$.id = $5;
8687 }
8688 | IDentifier '.' ObjectIdentifierValue '.' IDentifier optExtendedFieldReference
8689 '.' PredefOrIdentifier
8690 {
8691 $$.ref = new Ttcn::Reference($1, $5);
8692 delete $3;
8693 for(size_t i=0; i<$6.nElements; i++) $$.ref->add($6.elements[i]);
8694 Free($6.elements);
8695 $$.ref->set_location(infile, @1, @6);
8696 $$.id = $8;
8697 }
8698 ;
8699
8700 PredefinedOpKeyword1:
8701 bit2hexKeyword { $$ = Value::OPTYPE_BIT2HEX; }
8702 | bit2intKeyword { $$ = Value::OPTYPE_BIT2INT; }
8703 | bit2octKeyword { $$ = Value::OPTYPE_BIT2OCT; }
8704 | bit2strKeyword { $$ = Value::OPTYPE_BIT2STR; }
8705 | char2intKeyword { $$ = Value::OPTYPE_CHAR2INT; }
8706 | char2octKeyword { $$ = Value::OPTYPE_CHAR2OCT; }
8707 | float2intKeyword { $$ = Value::OPTYPE_FLOAT2INT; }
8708 | float2strKeyword { $$ = Value::OPTYPE_FLOAT2STR; }
8709 | hex2bitKeyword { $$ = Value::OPTYPE_HEX2BIT; }
8710 | hex2intKeyword { $$ = Value::OPTYPE_HEX2INT; }
8711 | hex2octKeyword { $$ = Value::OPTYPE_HEX2OCT; }
8712 | hex2strKeyword { $$ = Value::OPTYPE_HEX2STR; }
8713 | int2charKeyword { $$ = Value::OPTYPE_INT2CHAR; }
8714 | int2floatKeyword { $$ = Value::OPTYPE_INT2FLOAT; }
8715 | int2strKeyword { $$ = Value::OPTYPE_INT2STR; }
8716 | int2unicharKeyword { $$ = Value::OPTYPE_INT2UNICHAR; }
8717 | oct2bitKeyword { $$ = Value::OPTYPE_OCT2BIT; }
8718 | oct2charKeyword { $$ = Value::OPTYPE_OCT2CHAR; }
8719 | oct2hexKeyword { $$ = Value::OPTYPE_OCT2HEX; }
8720 | oct2intKeyword { $$ = Value::OPTYPE_OCT2INT; }
8721 | oct2strKeyword { $$ = Value::OPTYPE_OCT2STR; }
8722 | str2bitKeyword { $$ = Value::OPTYPE_STR2BIT; }
8723 | str2floatKeyword { $$ = Value::OPTYPE_STR2FLOAT; }
8724 | str2hexKeyword { $$ = Value::OPTYPE_STR2HEX; }
8725 | str2intKeyword { $$ = Value::OPTYPE_STR2INT; }
8726 | str2octKeyword { $$ = Value::OPTYPE_STR2OCT; }
8727 | unichar2intKeyword { $$ = Value::OPTYPE_UNICHAR2INT; }
8728 | unichar2charKeyword { $$ = Value::OPTYPE_UNICHAR2CHAR; }
8729 | enum2intKeyword { $$ = Value::OPTYPE_ENUM2INT; }
8730 | remove_bomKeyWord { $$ = Value::OPTYPE_REMOVE_BOM; }
8731 | get_stringencodingKeyWord { $$ = Value::OPTYPE_GET_STRINGENCODING; }
8732 | decode_base64KeyWord { $$ = Value::OPTYPE_DECODE_BASE64; }
8733 ;
8734
8735 PredefinedOpKeyword2:
8736 int2bitKeyword { $$ = Value::OPTYPE_INT2BIT; }
8737 | int2hexKeyword { $$ = Value::OPTYPE_INT2HEX; }
8738 | int2octKeyword { $$ = Value::OPTYPE_INT2OCT; }
8739 ;
8740
8741 PredefinedOpKeyword3:
8742 unichar2octKeyword { $$ = Value::OPTYPE_UNICHAR2OCT; }
8743 | oct2unicharKeyword { $$ = Value::OPTYPE_OCT2UNICHAR; }
8744 | encode_base64KeyWord { $$ = Value::OPTYPE_ENCODE_BASE64; }
8745 ;
8746
8747 String2TtcnStatement:
8748 string2ttcnKeyword '(' optError Expression optError ',' optError Reference optError ')'
8749 {
8750 Ttcn::Reference* out_ref;
8751 if ($8.is_ref) out_ref = $8.ref;
8752 else {
8753 out_ref = new Ttcn::Reference($8.id);
8754 out_ref->set_location(infile, @8);
8755 }
8756 $$ = new Statement(Statement::S_STRING2TTCN, $4, out_ref);
8757 $$->set_location(infile, @$);
8758 }
8759 ;
8760
8761 LogStatement: // 619
8762 LogKeyword '(' ')'
8763 {
8764 $$=new Statement(Statement::S_LOG, (LogArguments*)0);
8765 $$->set_location(infile, @$);
8766 }
8767 | LogKeyword '(' LogItemList optError ')'
8768 {
8769 $$=new Statement(Statement::S_LOG, $3);
8770 $$->set_location(infile, @$);
8771 }
8772 | LogKeyword '(' error ')'
8773 {
8774 $$=new Statement(Statement::S_LOG, new LogArguments());
8775 $$->set_location(infile, @$);
8776 }
8777 ;
8778
8779 LogItemList:
8780 optError LogItem
8781 {
8782 $$ = new LogArguments();
8783 $$->add_logarg($2);
8784 }
8785 | LogItemList optError ',' optError LogItem
8786 {
8787 $$ = $1;
8788 $$->add_logarg($5);
8789 }
8790 | LogItemList optError ',' error { $$ = $1; }
8791 ;
8792
8793 LogItem: // 621
8794 TemplateInstance
8795 {
8796 $$ = new LogArgument($1);
8797 $$->set_location(infile, @$);
8798 }
8799 ;
8800
8801 LoopConstruct: // 622
8802 ForStatement { $$ = $1; }
8803 | WhileStatement { $$ = $1; }
8804 | DoWhileStatement { $$ = $1; }
8805 ;
8806
8807 ForStatement: // 623
8808 ForKeyword '(' Initial ';' Final ';' Step optError ')'
8809 StatementBlock
8810 {
8811 $$ = new Statement(Statement::S_FOR, $3.defs, $3.ass, $5, $7, $10);
8812 $$->set_location(infile, @$);
8813 }
8814 ;
8815
8816 Initial: // 625
8817 VarInstance
8818 {
8819 $$.defs = new Definitions;
8820 for (size_t i = 0; i < $1.nElements; i++) $$.defs->add_ass($1.elements[i]);
8821 Free($1.elements);
8822 $$.ass = 0;
8823 }
8824 | Assignment
8825 {
8826 $$.defs = 0;
8827 $$.ass = $1;
8828 }
8829 | error
8830 {
8831 $$.defs = new Definitions;
8832 $$.ass = 0;
8833 }
8834 ;
8835
8836 Final: // 626
8837 BooleanExpression { $$ = $1; }
8838 ;
8839
8840 Step: // 627
8841 Assignment { $$ = $1; }
8842 /** \todo for-ban nem lehet null a step
8843 | error { $$=NULL; }
8844 */
8845 ;
8846
8847 WhileStatement: // 628
8848 WhileKeyword '(' BooleanExpression ')' StatementBlock
8849 {
8850 $$=new Statement(Statement::S_WHILE, $3, $5);
8851 $$->set_location(infile, @$);
8852 }
8853 ;
8854
8855 DoWhileStatement: // 630
8856 DoKeyword StatementBlock
8857 WhileKeyword '(' BooleanExpression ')'
8858 {
8859 $$=new Statement(Statement::S_DOWHILE, $5, $2);
8860 $$->set_location(infile, @$);
8861 }
8862 ;
8863
8864 ConditionalConstruct: // 632
8865 IfKeyword '(' BooleanExpression ')'
8866 StatementBlock
8867 seqElseIfClause optElseClause
8868 {
8869 IfClause *ic=new IfClause($3, $5);
8870 ic->set_location(infile, @1, @5);
8871 $6->add_front_ic(ic);
8872 $$=new Statement(Statement::S_IF, $6, $7,
8873 $7 ? new Location(infile, @7) : 0);
8874 $$->set_location(infile, @$);
8875 }
8876 ;
8877
8878 seqElseIfClause:
8879 /* empty */ { $$=new IfClauses(); }
8880 | seqElseIfClause ElseIfClause
8881 {
8882 $$=$1;
8883 $$->add_ic($2);
8884 }
8885 ;
8886
8887 ElseIfClause: // 634
8888 ElseKeyword IfKeyword '(' BooleanExpression ')' StatementBlock
8889 {
8890 $$=new IfClause($4, $6);
8891 $$->set_location(infile, @$);
8892 }
8893 ;
8894
8895 optElseClause: // [636]
8896 /* empty */ { $$=0; }
8897 | ElseKeyword StatementBlock { $$=$2; }
8898 ;
8899
8900 SelectCaseConstruct: // 637
8901 SelectKeyword '(' Expression optError ')' SelectCaseBody
8902 {
8903 $$=new Statement(Statement::S_SELECT, $3, $6);
8904 $$->set_location(infile, @$);
8905 }
8906 | SelectKeyword '(' error ')' SelectCaseBody
8907 {
8908 Value *v = new Value(Value::V_ERROR);
8909 v->set_location(infile, @3);
8910 $$=new Statement(Statement::S_SELECT, v, $5);
8911 $$->set_location(infile, @$);
8912 }
8913 ;
8914
8915 SelectCaseBody: // 639
8916 '{' seqSelectCase optError '}' {$$=$2;}
8917 | '{' error '}' {$$=new SelectCases;}
8918 ;
8919
8920 seqSelectCase:
8921 optError SelectCase
8922 {
8923 $$=new SelectCases;
8924 $$->add_sc($2);
8925 }
8926 | seqSelectCase optError SelectCase
8927 {
8928 $$=$1;
8929 $$->add_sc($3);
8930 }
8931 ;
8932
8933 SelectCase: // 640
8934 CaseKeyword '(' seqTemplateInstance optError ')' StatementBlock optSemiColon
8935 {
8936 $3->set_location(infile, @2, @5);
8937 $$=new SelectCase($3, $6);
8938 $$->set_location(infile, @$);
8939 }
8940 | CaseKeyword '(' error ')' StatementBlock optSemiColon
8941 {
8942 TemplateInstances *tis = new TemplateInstances;
8943 tis->set_location(infile, @2, @4);
8944 $$ = new SelectCase(tis, $5);
8945 $$->set_location(infile, @$);
8946 }
8947 | CaseKeyword ElseKeyword StatementBlock optSemiColon
8948 {
8949 $$=new SelectCase(0, $3);
8950 $$->set_location(infile, @$);
8951 }
8952 ;
8953
8954 seqTemplateInstance:
8955 optError TemplateInstance
8956 {
8957 $$ = new TemplateInstances;
8958 $$->add_ti($2);
8959 }
8960 | seqTemplateInstance optError ',' optError TemplateInstance
8961 {
8962 $$ = $1;
8963 $$->add_ti($5);
8964 }
8965 | seqTemplateInstance optError ',' error { $$ = $1; }
8966 ;
8967
8968 /* A.1.6.9 Miscellaneous productions */
8969
8970 optSemiColon: // [645]
8971 /* empty */
8972 | ';'
8973 ;
8974
8975 /* A.1 ASN.1 support, from ES 201 873-7 V3.1.1 (2005-06) */
8976
8977 optDefinitiveIdentifier:
8978 /* empty */
8979 | DefinitiveIdentifier
8980 ;
8981
8982 DefinitiveIdentifier:
8983 '.' ObjectIdentifierKeyword '{' DefinitiveObjIdComponentList optError '}'
8984 | '.' ObjectIdentifierKeyword '{' error '}'
8985 ;
8986
8987 DefinitiveObjIdComponentList:
8988 optError DefinitiveObjIdComponent
8989 | DefinitiveObjIdComponentList optError DefinitiveObjIdComponent
8990 ;
8991
8992 DefinitiveObjIdComponent:
8993 NameForm
8994 | DefinitiveNumberForm
8995 | DefinitiveNameAndNumberForm
8996 ;
8997
8998 DefinitiveNumberForm:
8999 Number { delete $1; }
9000 ;
9001
9002 DefinitiveNameAndNumberForm:
9003 IDentifier '(' Number optError ')' { delete $1; delete $3; }
9004 | IDentifier '(' error ')' { delete $1; }
9005 ;
9006
9007 ObjectIdentifierValue:
9008 ObjectIdentifierKeyword '{' ObjIdComponentList optError '}'
9009 {
9010 $$ = $3;
9011 $$->set_location(infile, @$);
9012 }
9013 | ObjectIdentifierKeyword '{' error '}'
9014 {
9015 $$ = new Value(Value::V_ERROR);
9016 $$->set_location(infile, @$);
9017 }
9018 ;
9019
9020 ObjIdComponentList:
9021 optError ObjIdComponent
9022 {
9023 $$ = new Value(Value::V_OID);
9024 $$->add_oid_comp($2);
9025 }
9026 | ObjIdComponentList optError ObjIdComponent
9027 {
9028 $$ = $1;
9029 $$->add_oid_comp($3);
9030 }
9031 ;
9032
9033 ObjIdComponent:
9034 /* NameForm -- covered by NumberForm (as ReferencedValue) */
9035 NumberForm { $$ = $1; }
9036 | NameAndNumberForm { $$ = $1; }
9037 ;
9038
9039 NumberForm:
9040 Number
9041 {
9042 Value *v = new Value(Value::V_INT, $1);
9043 v->set_location(infile, @1);
9044 $$ = new OID_comp(0, v);
9045 $$->set_location(infile, @$);
9046 }
9047 | Reference
9048 {
9049 if ($1.is_ref) {
9050 /* it can be only a referenced value */
9051 Value *v = new Value(Value::V_REFD, $1.ref);
9052 v->set_location(infile, @1);
9053 $$ = new OID_comp(v);
9054 } else {
9055 /* it can be either a name form or a referenced value */
9056 $$ = new OID_comp($1.id, 0);
9057 }
9058 $$->set_location(infile, @$);
9059 }
9060 ;
9061
9062 NameAndNumberForm:
9063 IDentifier '(' Number optError ')'
9064 {
9065 Value *v = new Value(Value::V_INT, $3);
9066 v->set_location(infile, @3);
9067 $$ = new OID_comp($1, v);
9068 $$->set_location(infile, @$);
9069 }
9070 | IDentifier '(' ReferencedValue optError ')'
9071 {
9072 $$ = new OID_comp($1, $3);
9073 $$->set_location(infile, @$);
9074 }
9075 | IDentifier '(' error ')'
9076 {
9077 Value *v = new Value(Value::V_ERROR);
9078 v->set_location(infile, @3);
9079 $$ = new OID_comp($1, v);
9080 $$->set_location(infile, @$);
9081 }
9082 ;
9083
9084 NameForm:
9085 IDentifier { delete $1; }
9086 ;
9087
9088 /* Rules for error recovery */
9089
9090 optError:
9091 /* empty */
9092 | error
9093 ;
9094
9095 optErrorBlock:
9096 optError
9097 | optErrorBlock ErrorBlock optError
9098 ;
9099
9100 ErrorBlock:
9101 '{' error '}'
9102 | '{' optError ErrorBlock optError '}'
9103 ;
9104
9105 %%
9106
9107 static void ttcn3_error(const char *str)
9108 {
9109 Location loc(infile, ttcn3_lloc);
9110 if (*ttcn3_text) {
9111 // the most recently parsed token is known
9112 loc.error("at or before token `%s': %s", ttcn3_text, str);
9113 } else {
9114 // the most recently parsed token is unknown
9115 loc.error("%s", str);
9116 }
9117 }
9118
9119 int ttcn3_parse_file(const char* filename, boolean generate_code)
9120 {
9121 anytype_access = false;
9122 ttcn3_in = fopen(filename, "r");
9123 if (ttcn3_in == NULL) {
9124 ERROR("Cannot open input file `%s': %s", filename, strerror(errno));
9125 return -1;
9126 }
9127 infile = filename;
9128 init_ttcn3_lex();
9129
9130 is_erroneous_parsed = false;
9131 NOTIFY("Parsing TTCN-3 module `%s'...", filename);
9132
9133 int retval = ttcn3_parse();
9134
9135 free_ttcn3_lex(); // does fclose(ttcn3_in);
9136
9137 if (act_ttcn3_module) {
9138 act_ttcn3_module->set_location(filename);
9139 set_md5_checksum(act_ttcn3_module);
9140 if (generate_code) act_ttcn3_module->set_gen_code();
9141 modules->add_mod(act_ttcn3_module);
9142 act_ttcn3_module = 0;
9143 }
9144
9145 act_group = 0;
9146
9147 return retval;
9148 }
9149
9150 Ttcn::ErroneousAttributeSpec* ttcn3_parse_erroneous_attr_spec_string(
9151 const char* p_str, const Common::Location& str_loc)
9152 {
9153 is_erroneous_parsed = true;
9154 act_ttcn3_erroneous_attr_spec = NULL;
9155 string titan_err_str("$#&&&(#TITANERRONEOUS$#&&^#% ");
9156 int hack_str_len = (int)titan_err_str.size();
9157 string *parsed_string = parse_charstring_value(p_str, str_loc);
9158 titan_err_str += *parsed_string;
9159 delete parsed_string;
9160 init_erroneous_lex(str_loc.get_filename(), str_loc.get_first_line(), str_loc.get_first_column()-hack_str_len+1);
9161 yy_buffer_state *flex_buffer = ttcn3__scan_string(titan_err_str.c_str());
9162 if (flex_buffer == NULL) {
9163 ERROR("Flex buffer creation failed.");
9164 return NULL;
9165 }
9166 yyparse();
9167 ttcn3_lex_destroy();
9168 free_dot_flag_stuff();
9169
9170 return act_ttcn3_erroneous_attr_spec;
9171 }
9172
9173 #ifndef NDEBUG
9174 static void yyprint(FILE *file, int type, const YYSTYPE& value)
9175 {
9176 switch (type) {
9177 case IDentifier:
9178 fprintf(file, "``%s''", value.id->get_name().c_str());
9179 break;
9180 case Number:
9181 fprintf(file, "%s", value.int_val->t_str().c_str());
9182 break;
9183 case FloatValue:
9184 fprintf(file, "%f", value.float_val);
9185 break;
9186 case Bstring:
9187 case Hstring:
9188 case Ostring:
9189 case BitStringMatch:
9190 case HexStringMatch:
9191 case OctetStringMatch:
9192 fprintf(file, "``%s''", value.string_val->c_str());
9193 break;
9194 case Cstring:
9195 fprintf(file, "``%s''", value.str);
9196 break;
9197 default:
9198 break;
9199 }
9200 }
9201 #endif
This page took 0.228201 seconds and 6 git commands to generate.