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