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