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