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