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