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