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