1 /* A Bison parser, made by GNU Bison 3.0.4. */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
29
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
32
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
35
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
42
43 /* Identify Bison output. */
44 #define YYBISON 1
45
46 /* Bison version. */
47 #define YYBISON_VERSION "3.0.4"
48
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51
52 /* Pure parsers. */
53 #define YYPURE 0
54
55 /* Push parsers. */
56 #define YYPUSH 0
57
58 /* Pull parsers. */
59 #define YYPULL 1
60
61
62
63
64 /* Copy the first part of user declarations. */
65 #line 1 "gram.y" /* yacc.c:339 */
66
67 /* This file is part of Mailfromd.
68 Copyright (C) 2005-2021 Sergey Poznyakoff
69
70 This program is free software; you can redistribute it and/or modify
71 it under the terms of the GNU General Public License as published by
72 the Free Software Foundation; either version 3, or (at your option)
73 any later version.
74
75 This program is distributed in the hope that it will be useful,
76 but WITHOUT ANY WARRANTY; without even the implied warranty of
77 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
78 GNU General Public License for more details.
79
80 You should have received a copy of the GNU General Public License
81 along with this program. If not, see <http://www.gnu.org/licenses/>. */
82
83 #ifdef HAVE_CONFIG_H
84 # include <config.h>
85 #endif
86
87 #include <fnmatch.h>
88 #include <netdb.h>
89 #include <limits.h>
90 #include "mailfromd.h"
91 #include <mailutils/yyloc.h>
92 #include "prog.h"
93 #include "optab.h"
94
95 static void free_node(NODE *node);
96 static void set_poll_arg(struct poll_data *poll, int kw, NODE *expr);
97 static int codegen(prog_counter_t *pc, NODE *node, struct exmask *exmask,
98 int finalize, size_t nautos);
99 static void mark(NODE *node);
100 static void dataseg_layout(void);
101 static void regex_layout(void);
102 static int optimize_tree(NODE *node);
103 static void compile_tree(NODE *node);
104 static NODE *reverse(NODE *in);
105 static size_t nodelistlength(NODE *list);
106 static NODE *function_call(struct function *function, size_t count,
107 NODE *subtree);
108 static NODE *declare_function(struct function *func,
109 struct mu_locus_range const *loc,
110 size_t nautos);
111 static data_type_t node_type(NODE *node);
112 static NODE *cast_arg_list(NODE *args, size_t parmc, data_type_t *parmtype,
113 int disable_prom);
114 void add_xref(struct variable *var, struct mu_locus_range const *locus);
115 static struct variable *vardecl(const char *name, data_type_t type,
116 storage_class_t sc,
117 struct mu_locus_range const *loc);
118 static struct variable *externdecl(const char *name, struct value *value,
119 struct mu_locus_range const *loc);
120 static int initialize_variable(struct variable *var, struct value *val,
121 struct mu_locus_range const *locus);
122 static void apply_deferred_init(void);
123 static NODE *create_asgn_node(struct variable *var, NODE *expr,
124 struct mu_locus_range const *loc);
125
126 NODE *defined_parm(struct variable *var, struct mu_locus_range const *locus);
127
128 static void register_auto(struct variable *var);
129 static void unregister_auto(struct variable *var);
130 static size_t forget_autos(size_t nparam, size_t prev, size_t hidden_arg);
131 static void optimize(NODE *node);
132
133 static NODE *root_node[smtp_state_count];
134 prog_counter_t entry_point[smtp_state_count];
135
136 #define PS_BEGIN 0
137 #define PS_END 1
138
139 int regex_flags; /* Should default to REG_NOSUB ? */
140 unsigned error_count; /* Number of detected errors */
141 size_t variable_count = 0; /* Number of variables in the data segment. */
142 size_t precious_count = 0;
143
144 static enum smtp_state state_tag; /* State tag of the currently processed
145 PROG */
146
147 static struct function *func; /* The currently compiled function */
148 static prog_counter_t jump_pc; /* Pointer to the chain of jmp instructions */
149
150 /* Outermost context decides how to code exits from catches.
151 Innermost context is used to access parameters. */
152 enum lexical_context outer_context, inner_context;
153
154 size_t catch_nesting; /* Nesting level for catch statements */
155
156 static struct stmtlist genstmt; /* List of generated statements */
157
158 /* State handlers and their positional parameters */
159 struct state_parms {
160 int cnt; /* Number or positional parameters */
161 data_type_t types[4]; /* Their data types */
162 } state_parms[] = {
163 { 0, }, /* smtp_state_none */
164 { 0, }, /* smtp_state_begin */
165 { 4, { dtype_string, dtype_number, dtype_number, dtype_string } },
166 /* smtp_state_connect */
167 { 1, { dtype_string } }, /* smtp_state_helo */
168 { 2, { dtype_string, dtype_string } }, /* smtp_state_envfrom */
169 { 2, { dtype_string, dtype_string } }, /* smtp_state_envrcpt */
170 { 0, }, /* smtp_state_data */
171 { 2, { dtype_string, dtype_string } }, /* smtp_state_header */
172 { 0, }, /* smtp_state_eoh */
173 { 2, { dtype_pointer, dtype_number } }, /* smtp_state_body */
174 { 0, }, /* smtp_state_eom */
175 { 0, } /* smtp_state_end */
176 };
177
178 struct parmtype {
179 struct parmtype *next;
180 data_type_t type;
181 };
182
183 static int
parmcount_none()184 parmcount_none()
185 {
186 return 0;
187 }
188
189 static data_type_t
parmtype_none(int n)190 parmtype_none(int n)
191 {
192 return dtype_unspecified;
193 }
194
195 static int
parmcount_handler()196 parmcount_handler()
197 {
198 return state_parms[state_tag].cnt;
199 }
200
201 static data_type_t
parmtype_handler(int n)202 parmtype_handler(int n)
203 {
204 return state_parms[state_tag].types[n-1];
205 }
206
207 static int
parmcount_catch()208 parmcount_catch()
209 {
210 return 2;
211 }
212
213 static data_type_t
parmtype_catch(int n)214 parmtype_catch(int n)
215 {
216 switch (n) {
217 case 1:
218 return dtype_number;
219 case 2:
220 return dtype_string;
221 }
222 abort();
223 }
224
225 static int
parmcount_function()226 parmcount_function()
227 {
228 return func->parmcount;
229 }
230
231 static data_type_t
parmtype_function(int n)232 parmtype_function(int n)
233 {
234 if (func->varargs && n > func->parmcount)
235 return dtype_string;
236 return func->parmtype[n-1];
237 }
238
239 struct parminfo {
240 int (*parmcount)(void);
241 data_type_t (*parmtype)(int n);
242 } parminfo[] = {
243 { parmcount_none, parmtype_none },
244 { parmcount_handler, parmtype_handler },
245 { parmcount_catch, parmtype_catch },
246 { parmcount_function, parmtype_function },
247 };
248
249 #define PARMCOUNT() parminfo[inner_context].parmcount()
250 #define PARMTYPE(n) parminfo[inner_context].parmtype(n)
251 #define FUNC_HIDDEN_ARGS(f) (((f)->optcount || (f)->varargs) ? 1 : 0)
252
253
254 data_type_t
string_to_type(const char * s)255 string_to_type(const char *s)
256 {
257 if (strcmp(s, "n") == 0)
258 return dtype_number;
259 else if (strcmp(s, "s") == 0)
260 return dtype_string;
261 else
262 return dtype_unspecified;
263 }
264
265 const char *
type_to_string(data_type_t t)266 type_to_string(data_type_t t)
267 {
268 switch (t) {
269 case dtype_number:
270 return "number";
271 case dtype_string:
272 return "string";
273 case dtype_unspecified:
274 return "unspecified";
275 case dtype_pointer:
276 return "pointer";
277 default:
278 abort();
279 }
280 }
281
282 static int
check_func_usage(struct function * fp,struct mu_locus_range const * locus)283 check_func_usage(struct function *fp, struct mu_locus_range const *locus)
284 {
285 switch (outer_context) {
286 case context_handler:
287 if (fp->statemask && !(STATMASK(state_tag) & fp->statemask)) {
288 parse_error_locus(locus,
289 _("function `%s' cannot be used in "
290 "prog `%s'"),
291 fp->sym.name,
292 state_to_string(state_tag));
293 return 1;
294 }
295 break;
296
297 case context_function:
298 func->statemask |= fp->statemask;
299 break;
300
301 default:
302 break;
303 }
304 return 0;
305 }
306
307 static int
check_builtin_usage(const struct builtin * bp,struct mu_locus_range const * locus)308 check_builtin_usage(const struct builtin *bp,
309 struct mu_locus_range const *locus)
310 {
311 switch (outer_context) {
312 case context_handler:
313 if (bp->statemask && !(STATMASK(state_tag) & bp->statemask)) {
314 parse_error_locus(locus,
315 _("built-in function `%s' cannot be used in "
316 "prog `%s'"),
317 bp->name,
318 state_to_string(state_tag));
319 return 1;
320 }
321 break;
322
323 case context_function:
324 func->statemask |= bp->statemask;
325 break;
326
327 default:
328 break;
329 }
330
331 if (bp->flags & MFD_BUILTIN_CAPTURE)
332 capture_on();
333 return 0;
334 }
335
336 static void jump_fixup(prog_counter_t pos, prog_counter_t endpos);
337
338 #define LITERAL_TEXT(lit) ((lit) ? (lit)->text : NULL)
339 #define LITERAL_OFF(lit) ((lit) ? (lit)->off : 0)
340
341 static int
_create_alias(void * item,void * data)342 _create_alias(void *item, void *data)
343 {
344 struct literal *lit = item;
345 struct function *fun = data;
346 /* FIXME: Ideally we should pass a locus of `lit' instead of
347 fun->locus. However, its only purpose is for use in redefinition
348 diagnostic messages and these are never produced, because the
349 grammar catches these errors earlier. This might change in
350 the future. 2008-09-14 */
351 install_alias(lit->text, fun, &fun->sym.locus);
352 return 0;
353 }
354
355 #line 356 "gram.c" /* yacc.c:339 */
356
357 # ifndef YY_NULLPTR
358 # if defined __cplusplus && 201103L <= __cplusplus
359 # define YY_NULLPTR nullptr
360 # else
361 # define YY_NULLPTR 0
362 # endif
363 # endif
364
365 /* Enabling verbose error messages. */
366 #ifdef YYERROR_VERBOSE
367 # undef YYERROR_VERBOSE
368 # define YYERROR_VERBOSE 1
369 #else
370 # define YYERROR_VERBOSE 1
371 #endif
372
373 /* In a future release of Bison, this section will be replaced
374 by #include "y.tab.h". */
375 #ifndef YY_YY_GRAM_H_INCLUDED
376 # define YY_YY_GRAM_H_INCLUDED
377 /* Debug traces. */
378 #ifndef YYDEBUG
379 # define YYDEBUG 1
380 #endif
381 #if YYDEBUG
382 extern int yydebug;
383 #endif
384
385 /* Token type. */
386 #ifndef YYTOKENTYPE
387 # define YYTOKENTYPE
388 enum yytokentype
389 {
390 T_ACCEPT = 258,
391 T_REJECT = 259,
392 T_TEMPFAIL = 260,
393 T_CONTINUE = 261,
394 T_DISCARD = 262,
395 T_ADD = 263,
396 T_REPLACE = 264,
397 T_DELETE = 265,
398 T_PROG = 266,
399 T_BEGIN = 267,
400 T_END = 268,
401 T_IF = 269,
402 T_FI = 270,
403 T_ELSE = 271,
404 T_ELIF = 272,
405 T_ON = 273,
406 T_HOST = 274,
407 T_FROM = 275,
408 T_AS = 276,
409 T_DO = 277,
410 T_DONE = 278,
411 T_POLL = 279,
412 T_MATCHES = 280,
413 T_FNMATCHES = 281,
414 T_MXMATCHES = 282,
415 T_MXFNMATCHES = 283,
416 T_WHEN = 284,
417 T_PASS = 285,
418 T_SET = 286,
419 T_CATCH = 287,
420 T_TRY = 288,
421 T_THROW = 289,
422 T_ECHO = 290,
423 T_RETURNS = 291,
424 T_RETURN = 292,
425 T_FUNC = 293,
426 T_SWITCH = 294,
427 T_CASE = 295,
428 T_DEFAULT = 296,
429 T_CONST = 297,
430 T_FOR = 298,
431 T_LOOP = 299,
432 T_WHILE = 300,
433 T_BREAK = 301,
434 T_NEXT = 302,
435 T_ARGCOUNT = 303,
436 T_ALIAS = 304,
437 T_DOTS = 305,
438 T_ARGX = 306,
439 T_VAPTR = 307,
440 T_PRECIOUS = 308,
441 T_OR = 309,
442 T_AND = 310,
443 T_EQ = 311,
444 T_NE = 312,
445 T_LT = 313,
446 T_LE = 314,
447 T_GT = 315,
448 T_GE = 316,
449 T_NOT = 317,
450 T_LOGAND = 318,
451 T_LOGOR = 319,
452 T_LOGXOR = 320,
453 T_LOGNOT = 321,
454 T_REQUIRE = 322,
455 T_IMPORT = 323,
456 T_STATIC = 324,
457 T_PUBLIC = 325,
458 T_MODULE = 326,
459 T_BYE = 327,
460 T_DCLEX = 328,
461 T_SHL = 329,
462 T_SHR = 330,
463 T_SED = 331,
464 T_COMPOSE = 332,
465 T_MODBEG = 333,
466 T_MODEND = 334,
467 T_STRING = 335,
468 T_SYMBOL = 336,
469 T_IDENTIFIER = 337,
470 T_ARG = 338,
471 T_NUMBER = 339,
472 T_BACKREF = 340,
473 T_BUILTIN = 341,
474 T_FUNCTION = 342,
475 T_TYPE = 343,
476 T_TYPECAST = 344,
477 T_VARIABLE = 345,
478 T_BOGUS = 346,
479 T_UMINUS = 347
480 };
481 #endif
482 /* Tokens. */
483 #define T_ACCEPT 258
484 #define T_REJECT 259
485 #define T_TEMPFAIL 260
486 #define T_CONTINUE 261
487 #define T_DISCARD 262
488 #define T_ADD 263
489 #define T_REPLACE 264
490 #define T_DELETE 265
491 #define T_PROG 266
492 #define T_BEGIN 267
493 #define T_END 268
494 #define T_IF 269
495 #define T_FI 270
496 #define T_ELSE 271
497 #define T_ELIF 272
498 #define T_ON 273
499 #define T_HOST 274
500 #define T_FROM 275
501 #define T_AS 276
502 #define T_DO 277
503 #define T_DONE 278
504 #define T_POLL 279
505 #define T_MATCHES 280
506 #define T_FNMATCHES 281
507 #define T_MXMATCHES 282
508 #define T_MXFNMATCHES 283
509 #define T_WHEN 284
510 #define T_PASS 285
511 #define T_SET 286
512 #define T_CATCH 287
513 #define T_TRY 288
514 #define T_THROW 289
515 #define T_ECHO 290
516 #define T_RETURNS 291
517 #define T_RETURN 292
518 #define T_FUNC 293
519 #define T_SWITCH 294
520 #define T_CASE 295
521 #define T_DEFAULT 296
522 #define T_CONST 297
523 #define T_FOR 298
524 #define T_LOOP 299
525 #define T_WHILE 300
526 #define T_BREAK 301
527 #define T_NEXT 302
528 #define T_ARGCOUNT 303
529 #define T_ALIAS 304
530 #define T_DOTS 305
531 #define T_ARGX 306
532 #define T_VAPTR 307
533 #define T_PRECIOUS 308
534 #define T_OR 309
535 #define T_AND 310
536 #define T_EQ 311
537 #define T_NE 312
538 #define T_LT 313
539 #define T_LE 314
540 #define T_GT 315
541 #define T_GE 316
542 #define T_NOT 317
543 #define T_LOGAND 318
544 #define T_LOGOR 319
545 #define T_LOGXOR 320
546 #define T_LOGNOT 321
547 #define T_REQUIRE 322
548 #define T_IMPORT 323
549 #define T_STATIC 324
550 #define T_PUBLIC 325
551 #define T_MODULE 326
552 #define T_BYE 327
553 #define T_DCLEX 328
554 #define T_SHL 329
555 #define T_SHR 330
556 #define T_SED 331
557 #define T_COMPOSE 332
558 #define T_MODBEG 333
559 #define T_MODEND 334
560 #define T_STRING 335
561 #define T_SYMBOL 336
562 #define T_IDENTIFIER 337
563 #define T_ARG 338
564 #define T_NUMBER 339
565 #define T_BACKREF 340
566 #define T_BUILTIN 341
567 #define T_FUNCTION 342
568 #define T_TYPE 343
569 #define T_TYPECAST 344
570 #define T_VARIABLE 345
571 #define T_BOGUS 346
572 #define T_UMINUS 347
573
574 /* Value type. */
575 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
576
577 union YYSTYPE
578 {
579 #line 295 "gram.y" /* yacc.c:355 */
580
581 struct literal *literal;
582 struct stmtlist stmtlist;
583 NODE *node;
584 struct return_node ret;
585 struct poll_data poll;
586 struct pollarg {
587 int kw;
588 NODE *expr;
589 } pollarg;
590 struct arglist {
591 NODE *head;
592 NODE *tail;
593 size_t count;
594 } arglist;
595 long number;
596 const struct builtin *builtin;
597 struct variable *var;
598 enum smtp_state state;
599 struct {
600 int qualifier;
601 } matchtype;
602 data_type_t type;
603 struct parmtype *parm;
604 struct parmlist {
605 struct parmtype *head, *tail;
606 size_t count;
607 size_t optcount;
608 int varargs;
609 } parmlist;
610 enum lexical_context tie_in;
611 struct function *function;
612 struct {
613 struct valist *head, *tail;
614 } valist_list;
615 struct {
616 int all;
617 struct valist *valist;
618 } catchlist;
619 struct valist *valist;
620 struct value value;
621 struct {
622 struct case_stmt *head, *tail;
623 } case_list ;
624 struct case_stmt *case_stmt;
625 struct loop_node loop;
626 struct {
627 int code;
628 } progspecial;
629 struct enumlist {
630 struct constant *cv;
631 struct enumlist *prev;
632 } enumlist;
633 mu_list_t list;
634 struct import_rule_list import_rule_list;
635 char *string;
636
637 #line 638 "gram.c" /* yacc.c:355 */
638 };
639
640 typedef union YYSTYPE YYSTYPE;
641 # define YYSTYPE_IS_TRIVIAL 1
642 # define YYSTYPE_IS_DECLARED 1
643 #endif
644
645 /* Location type. */
646 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
647 typedef struct YYLTYPE YYLTYPE;
648 struct YYLTYPE
649 {
650 int first_line;
651 int first_column;
652 int last_line;
653 int last_column;
654 };
655 # define YYLTYPE_IS_DECLARED 1
656 # define YYLTYPE_IS_TRIVIAL 1
657 #endif
658
659
660 extern YYSTYPE yylval;
661 extern YYLTYPE yylloc;
662 int yyparse (void);
663
664 #endif /* !YY_YY_GRAM_H_INCLUDED */
665
666 /* Copy the second part of user declarations. */
667
668 #line 669 "gram.c" /* yacc.c:358 */
669
670 #ifdef short
671 # undef short
672 #endif
673
674 #ifdef YYTYPE_UINT8
675 typedef YYTYPE_UINT8 yytype_uint8;
676 #else
677 typedef unsigned char yytype_uint8;
678 #endif
679
680 #ifdef YYTYPE_INT8
681 typedef YYTYPE_INT8 yytype_int8;
682 #else
683 typedef signed char yytype_int8;
684 #endif
685
686 #ifdef YYTYPE_UINT16
687 typedef YYTYPE_UINT16 yytype_uint16;
688 #else
689 typedef unsigned short int yytype_uint16;
690 #endif
691
692 #ifdef YYTYPE_INT16
693 typedef YYTYPE_INT16 yytype_int16;
694 #else
695 typedef short int yytype_int16;
696 #endif
697
698 #ifndef YYSIZE_T
699 # ifdef __SIZE_TYPE__
700 # define YYSIZE_T __SIZE_TYPE__
701 # elif defined size_t
702 # define YYSIZE_T size_t
703 # elif ! defined YYSIZE_T
704 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
705 # define YYSIZE_T size_t
706 # else
707 # define YYSIZE_T unsigned int
708 # endif
709 #endif
710
711 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
712
713 #ifndef YY_
714 # if defined YYENABLE_NLS && YYENABLE_NLS
715 # if ENABLE_NLS
716 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
717 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
718 # endif
719 # endif
720 # ifndef YY_
721 # define YY_(Msgid) Msgid
722 # endif
723 #endif
724
725 #ifndef YY_ATTRIBUTE
726 # if (defined __GNUC__ \
727 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
728 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
729 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
730 # else
731 # define YY_ATTRIBUTE(Spec) /* empty */
732 # endif
733 #endif
734
735 #ifndef YY_ATTRIBUTE_PURE
736 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
737 #endif
738
739 #ifndef YY_ATTRIBUTE_UNUSED
740 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
741 #endif
742
743 #if !defined _Noreturn \
744 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
745 # if defined _MSC_VER && 1200 <= _MSC_VER
746 # define _Noreturn __declspec (noreturn)
747 # else
748 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
749 # endif
750 #endif
751
752 /* Suppress unused-variable warnings by "using" E. */
753 #if ! defined lint || defined __GNUC__
754 # define YYUSE(E) ((void) (E))
755 #else
756 # define YYUSE(E) /* empty */
757 #endif
758
759 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
760 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
761 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
762 _Pragma ("GCC diagnostic push") \
763 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
764 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
765 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
766 _Pragma ("GCC diagnostic pop")
767 #else
768 # define YY_INITIAL_VALUE(Value) Value
769 #endif
770 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
771 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
772 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
773 #endif
774 #ifndef YY_INITIAL_VALUE
775 # define YY_INITIAL_VALUE(Value) /* Nothing. */
776 #endif
777
778
779 #if ! defined yyoverflow || YYERROR_VERBOSE
780
781 /* The parser invokes alloca or malloc; define the necessary symbols. */
782
783 # ifdef YYSTACK_USE_ALLOCA
784 # if YYSTACK_USE_ALLOCA
785 # ifdef __GNUC__
786 # define YYSTACK_ALLOC __builtin_alloca
787 # elif defined __BUILTIN_VA_ARG_INCR
788 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
789 # elif defined _AIX
790 # define YYSTACK_ALLOC __alloca
791 # elif defined _MSC_VER
792 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
793 # define alloca _alloca
794 # else
795 # define YYSTACK_ALLOC alloca
796 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
797 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
798 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
799 # ifndef EXIT_SUCCESS
800 # define EXIT_SUCCESS 0
801 # endif
802 # endif
803 # endif
804 # endif
805 # endif
806
807 # ifdef YYSTACK_ALLOC
808 /* Pacify GCC's 'empty if-body' warning. */
809 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
810 # ifndef YYSTACK_ALLOC_MAXIMUM
811 /* The OS might guarantee only one guard page at the bottom of the stack,
812 and a page size can be as small as 4096 bytes. So we cannot safely
813 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
814 to allow for a few compiler-allocated temporary stack slots. */
815 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
816 # endif
817 # else
818 # define YYSTACK_ALLOC YYMALLOC
819 # define YYSTACK_FREE YYFREE
820 # ifndef YYSTACK_ALLOC_MAXIMUM
821 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
822 # endif
823 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
824 && ! ((defined YYMALLOC || defined malloc) \
825 && (defined YYFREE || defined free)))
826 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
827 # ifndef EXIT_SUCCESS
828 # define EXIT_SUCCESS 0
829 # endif
830 # endif
831 # ifndef YYMALLOC
832 # define YYMALLOC malloc
833 # if ! defined malloc && ! defined EXIT_SUCCESS
834 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
835 # endif
836 # endif
837 # ifndef YYFREE
838 # define YYFREE free
839 # if ! defined free && ! defined EXIT_SUCCESS
840 void free (void *); /* INFRINGES ON USER NAME SPACE */
841 # endif
842 # endif
843 # endif
844 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
845
846
847 #if (! defined yyoverflow \
848 && (! defined __cplusplus \
849 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
850 && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
851
852 /* A type that is properly aligned for any stack member. */
853 union yyalloc
854 {
855 yytype_int16 yyss_alloc;
856 YYSTYPE yyvs_alloc;
857 YYLTYPE yyls_alloc;
858 };
859
860 /* The size of the maximum gap between one aligned stack and the next. */
861 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
862
863 /* The size of an array large to enough to hold all stacks, each with
864 N elements. */
865 # define YYSTACK_BYTES(N) \
866 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
867 + 2 * YYSTACK_GAP_MAXIMUM)
868
869 # define YYCOPY_NEEDED 1
870
871 /* Relocate STACK from its old location to the new one. The
872 local variables YYSIZE and YYSTACKSIZE give the old and new number of
873 elements in the stack, and YYPTR gives the new location of the
874 stack. Advance YYPTR to a properly aligned location for the next
875 stack. */
876 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
877 do \
878 { \
879 YYSIZE_T yynewbytes; \
880 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
881 Stack = &yyptr->Stack_alloc; \
882 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
883 yyptr += yynewbytes / sizeof (*yyptr); \
884 } \
885 while (0)
886
887 #endif
888
889 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
890 /* Copy COUNT objects from SRC to DST. The source and destination do
891 not overlap. */
892 # ifndef YYCOPY
893 # if defined __GNUC__ && 1 < __GNUC__
894 # define YYCOPY(Dst, Src, Count) \
895 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
896 # else
897 # define YYCOPY(Dst, Src, Count) \
898 do \
899 { \
900 YYSIZE_T yyi; \
901 for (yyi = 0; yyi < (Count); yyi++) \
902 (Dst)[yyi] = (Src)[yyi]; \
903 } \
904 while (0)
905 # endif
906 # endif
907 #endif /* !YYCOPY_NEEDED */
908
909 /* YYFINAL -- State number of the termination state. */
910 #define YYFINAL 33
911 /* YYLAST -- Last index in YYTABLE. */
912 #define YYLAST 1606
913
914 /* YYNTOKENS -- Number of terminals. */
915 #define YYNTOKENS 105
916 /* YYNNTS -- Number of nonterminals. */
917 #define YYNNTS 93
918 /* YYNRULES -- Number of rules. */
919 #define YYNRULES 233
920 /* YYNSTATES -- Number of states. */
921 #define YYNSTATES 398
922
923 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
924 by yylex, with out-of-bounds checking. */
925 #define YYUNDEFTOK 2
926 #define YYMAXUTOK 347
927
928 #define YYTRANSLATE(YYX) \
929 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
930
931 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
932 as returned by yylex, without out-of-bounds checking. */
933 static const yytype_uint8 yytranslate[] =
934 {
935 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
936 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
937 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
938 2, 2, 2, 2, 2, 2, 2, 97, 2, 2,
939 100, 101, 95, 93, 99, 94, 92, 96, 2, 2,
940 2, 2, 2, 2, 2, 2, 2, 2, 103, 102,
941 2, 2, 2, 2, 104, 2, 2, 2, 2, 2,
942 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
943 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
944 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
945 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
946 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
947 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
948 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
949 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
950 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
951 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
952 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
953 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
954 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
955 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
956 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
957 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
958 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
959 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
960 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
961 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
962 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
963 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
964 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
965 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
966 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
967 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
968 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
969 85, 86, 87, 88, 89, 90, 91, 98
970 };
971
972 #if YYDEBUG
973 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
974 static const yytype_uint16 yyrline[] =
975 {
976 0, 484, 484, 510, 511, 517, 521, 522, 533, 546,
977 550, 558, 561, 564, 575, 593, 597, 603, 604, 610,
978 615, 623, 624, 627, 638, 664, 682, 686, 690, 696,
979 702, 710, 711, 717, 731, 768, 796, 799, 808, 812,
980 816, 823, 828, 841, 855, 895, 919, 927, 945, 955,
981 961, 992, 996, 999, 1000, 1005, 1020, 1025, 1028, 1035,
982 1044, 1045, 1052, 1061, 1072, 1075, 1078, 1083, 1090, 1097,
983 1100, 1106, 1118, 1124, 1137, 1138, 1139, 1140, 1141, 1142,
984 1143, 1144, 1152, 1153, 1154, 1157, 1181, 1187, 1199, 1212,
985 1220, 1224, 1232, 1240, 1246, 1254, 1260, 1268, 1274, 1282,
986 1283, 1292, 1299, 1306, 1316, 1319, 1322, 1329, 1337, 1345,
987 1354, 1367, 1390, 1391, 1392, 1395, 1405, 1408, 1415, 1421,
988 1466, 1470, 1477, 1486, 1497, 1503, 1514, 1519, 1526, 1539,
989 1543, 1549, 1553, 1562, 1573, 1580, 1583, 1587, 1590, 1593,
990 1613, 1643, 1648, 1653, 1661, 1664, 1670, 1684, 1709, 1715,
991 1722, 1729, 1736, 1743, 1750, 1757, 1771, 1779, 1786, 1793,
992 1797, 1800, 1803, 1804, 1811, 1817, 1824, 1831, 1838, 1845,
993 1852, 1859, 1866, 1873, 1882, 1887, 1891, 1895, 1896, 1902,
994 1906, 1914, 1918, 1923, 1927, 1928, 1932, 1938, 1943, 1946,
995 1947, 1955, 1960, 1963, 1967, 1971, 1998, 1999, 2005, 2039,
996 2054, 2094, 2102, 2112, 2118, 2127, 2131, 2137, 2145, 2153,
997 2161, 2160, 2191, 2195, 2202, 2218, 2230, 2249, 2277, 2336,
998 2344, 2350, 2356, 2365, 2374, 2380, 2385, 2392, 2397, 2402,
999 2407, 2415, 2419, 2427
1000 };
1001 #endif
1002
1003 #if YYDEBUG || YYERROR_VERBOSE || 1
1004 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1005 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1006 static const char *const yytname[] =
1007 {
1008 "$end", "error", "$undefined", "\"accept\"", "\"reject\"",
1009 "\"tempfail\"", "\"continue\"", "\"discard\"", "\"add\"", "\"replace\"",
1010 "\"delete\"", "\"prog\"", "\"begin\"", "\"end\"", "\"if\"", "\"fi\"",
1011 "\"else\"", "\"elif\"", "\"on\"", "\"host\"", "\"from\"", "\"as\"",
1012 "\"do\"", "\"done\"", "\"poll\"", "\"matches\"", "\"fnmatches\"",
1013 "\"mx matches\"", "\"mx fnmatches\"", "\"when\"", "\"pass\"", "\"set\"",
1014 "\"catch\"", "\"try\"", "\"throw\"", "\"echo\"", "\"returns\"",
1015 "\"return\"", "\"func\"", "\"switch\"", "\"case\"", "\"default\"",
1016 "\"const\"", "\"for\"", "\"loop\"", "\"while\"", "\"break\"", "\"next\"",
1017 "\"$#\"", "\"alias\"", "\"...\"", "\"$(n)\"", "\"vaptr\"",
1018 "\"precious\"", "\"or\"", "\"and\"", "\"==\"", "\"!=\"", "\"<\"",
1019 "\"<=\"", "\">\"", "\">=\"", "\"!\"", "\"&\"", "\"|\"", "\"^\"", "\"~\"",
1020 "\"require\"", "\"import\"", "\"static\"", "\"public\"", "\"module\"",
1021 "\"bye\"", "\"dclex\"", "\"<<\"", "\">>\"", "\"sed\"",
1022 "\"composed string\"", "T_MODBEG", "T_MODEND", "\"string\"",
1023 "\"MTA macro\"", "\"identifier\"", "\"$n\"", "\"number\"",
1024 "\"back reference\"", "\"builtin function\"", "\"function\"",
1025 "\"data type\"", "\"typecast\"", "\"variable\"", "T_BOGUS", "'.'", "'+'",
1026 "'-'", "'*'", "'/'", "'%'", "T_UMINUS", "','", "'('", "')'", "';'",
1027 "':'", "'@'", "$accept", "input", "program", "decllist", "modcntl",
1028 "opt_moddecl", "moddecl", "require", "bye", "imports", "literal", "decl",
1029 "progspecial", "varname", "vardecl", "qualifiers", "qualifier",
1030 "constdecl", "qualconst", "constdefn", "enumlist", "exdecl", "fundecl",
1031 "parmdecl", "params", "opt_parmlist", "parmlist", "fparmlist", "parm",
1032 "aliasdecl", "aliases", "alias", "retdecl", "state_ident", "stmtlist",
1033 "stmt", "asgn", "autodcl", "action", "sendmail_action",
1034 "maybe_xcode_expr", "header_action", "maybe_triplet", "triplet", "code",
1035 "xcode", "condition", "if_cond", "else_cond", "case_cond",
1036 "cond_branches", "cond_branch", "valist", "value", "string", "matches",
1037 "fnmatches", "loopstmt", "loop_ident", "opt_ident", "opt_loop_parms",
1038 "loop_parm_list", "loop_parm", "opt_while", "jumpstmt", "expr",
1039 "maybe_expr", "simp_expr", "atom_expr", "atom", "strcat", "strval",
1040 "argref", "paren_argref", "funcall", "arglist", "variable", "catch",
1041 "try_block", "simple_catch", "@1", "catchlist", "throw", "return",
1042 "bool_expr", "on_cond", "on", "do", "pollstmt", "pollarglist", "pollarg",
1043 "branches", "branch", YY_NULLPTR
1044 };
1045 #endif
1046
1047 # ifdef YYPRINT
1048 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
1049 (internal) symbol number NUM (which must be that of a token). */
1050 static const yytype_uint16 yytoknum[] =
1051 {
1052 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1053 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1054 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1055 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1056 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1057 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1058 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1059 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1060 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1061 345, 346, 46, 43, 45, 42, 47, 37, 347, 44,
1062 40, 41, 59, 58, 64
1063 };
1064 # endif
1065
1066 #define YYPACT_NINF -287
1067
1068 #define yypact_value_is_default(Yystate) \
1069 (!!((Yystate) == (-287)))
1070
1071 #define YYTABLE_NINF -234
1072
1073 #define yytable_value_is_error(Yytable_value) \
1074 (!!((Yytable_value) == (-234)))
1075
1076 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1077 STATE-NUM. */
1078 static const yytype_int16 yypact[] =
1079 {
1080 640, -61, -287, -287, 33, 70, 33, 33, -55, 48,
1081 -287, 581, -287, 316, -1, -287, 58, -287, 103, -287,
1082 0, -287, -287, 62, -287, -287, 30, -287, -287, 1411,
1083 -287, 89, -287, -287, -287, -287, 50, 79, 1250, 70,
1084 -287, -287, -287, -287, 70, -287, 70, 1411, -287, 1250,
1085 33, -287, 71, 110, 1411, 1477, 95, -287, -287, -287,
1086 -287, -287, -287, 104, 123, 129, -287, -287, 1477, 1477,
1087 1411, 72, 712, 1000, -287, -287, 87, -287, -287, -287,
1088 -287, -287, 116, -287, -287, 316, -287, 153, -54, -51,
1089 -287, -287, 67, 67, 67, 1411, -287, -287, 70, 45,
1090 226, 67, 1411, 1411, 1411, 70, 70, 70, 70, 183,
1091 -287, 837, -287, -287, -287, -287, -287, -287, -287, -287,
1092 -287, -287, -287, -287, -287, 222, -287, -287, -287, -287,
1093 -8, 170, 250, 1411, 1411, -287, 3, 712, 896, -28,
1094 -287, 1411, 63, -287, -287, 831, -287, 1411, 1323, 1367,
1095 1411, -287, -287, 205, -287, -287, -287, -287, -287, 1411,
1096 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1477,
1097 1477, 1477, 1477, 1477, 1477, 1477, 1477, 1477, 1477, 1477,
1098 -287, -287, 76, -287, -287, -287, 1455, 1411, -287, 1411,
1099 -287, -287, -287, -287, 1411, 1411, -287, 712, 1250, 1411,
1100 -287, 219, -287, 253, 1250, 1411, 712, 712, 417, -287,
1101 478, -287, -287, -287, 1411, -287, -287, -287, 1279, 254,
1102 254, -33, 1250, 712, -287, 1411, -287, -287, -287, 33,
1103 359, 177, 712, 108, -287, 127, -287, 139, 476, -287,
1104 772, 831, 890, 890, 279, 279, 279, 279, 890, 890,
1105 445, 1176, 1509, 315, 315, 237, 31, 31, -287, -287,
1106 -287, 201, 190, 1411, 712, 712, 184, 185, 712, 712,
1107 541, 712, 67, -287, 955, 712, 143, 1250, 1411, 360,
1108 265, 193, -287, 712, 1411, 1411, 1411, 1411, 1292, 81,
1109 -287, -287, 260, 260, -287, 70, 194, -287, 195, 144,
1110 -287, -287, 1014, -287, -287, -287, 1411, -287, -287, -287,
1111 -287, -287, 220, 712, 1455, 1455, 1250, 1411, 290, -287,
1112 1250, -287, 67, 204, 16, -287, 419, 712, 1250, 718,
1113 712, 712, 712, 712, 81, -287, 67, 15, -287, 159,
1114 -287, 259, 221, -21, -287, 712, 223, 215, -287, -287,
1115 224, 1073, 1250, -287, 1132, -12, 1250, -287, -287, 1191,
1116 -287, -11, -287, -287, -287, 70, 282, 259, -287, 236,
1117 -287, -287, -287, 241, 1411, 1411, 541, -287, 1250, 600,
1118 275, 1250, -287, 257, -287, -287, -287, 248, 249, -287,
1119 659, 1411, -287, 778, -287, -287, -287, 712
1120 };
1121
1122 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
1123 Performed when YYTABLE does not specify something else to do. Zero
1124 means the default is an error. */
1125 static const yytype_uint8 yydefact[] =
1126 {
1127 36, 0, 29, 30, 0, 0, 0, 0, 0, 0,
1128 2, 36, 6, 36, 9, 5, 0, 26, 0, 27,
1129 0, 28, 71, 0, 21, 22, 0, 31, 32, 0,
1130 15, 0, 49, 1, 8, 7, 36, 11, 36, 0,
1131 43, 38, 39, 40, 0, 37, 0, 0, 41, 36,
1132 0, 185, 0, 0, 0, 0, 0, 192, 191, 181,
1133 194, 182, 183, 0, 0, 0, 205, 206, 0, 0,
1134 0, 0, 35, 159, 162, 177, 188, 189, 184, 174,
1135 193, 13, 0, 18, 4, 36, 12, 104, 104, 104,
1136 97, 98, 0, 0, 0, 0, 220, 90, 0, 0,
1137 0, 0, 0, 215, 0, 135, 135, 135, 0, 0,
1138 82, 36, 72, 76, 77, 75, 88, 89, 74, 112,
1139 113, 83, 84, 81, 78, 0, 207, 79, 80, 114,
1140 0, 0, 0, 33, 45, 46, 0, 44, 36, 0,
1141 19, 0, 0, 196, 187, 148, 180, 0, 0, 0,
1142 0, 179, 178, 0, 186, 129, 131, 130, 132, 0,
1143 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1144 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1145 190, 14, 36, 110, 92, 105, 106, 160, 93, 160,
1146 95, 126, 127, 128, 0, 0, 103, 217, 36, 0,
1147 212, 213, 124, 0, 36, 0, 91, 216, 0, 136,
1148 36, 134, 146, 147, 86, 24, 73, 208, 0, 0,
1149 0, 51, 36, 34, 42, 47, 48, 23, 16, 0,
1150 0, 0, 203, 0, 199, 0, 202, 0, 0, 175,
1151 157, 158, 149, 150, 151, 152, 153, 154, 155, 156,
1152 169, 170, 171, 172, 173, 164, 163, 165, 166, 167,
1153 168, 0, 182, 107, 109, 161, 0, 0, 101, 102,
1154 36, 85, 0, 210, 36, 214, 0, 36, 0, 36,
1155 0, 138, 139, 87, 0, 0, 0, 0, 222, 224,
1156 225, 221, 0, 0, 54, 63, 0, 52, 0, 57,
1157 53, 58, 36, 20, 195, 197, 0, 200, 198, 201,
1158 176, 10, 0, 108, 160, 160, 36, 0, 0, 125,
1159 36, 209, 0, 0, 0, 120, 36, 143, 36, 36,
1160 228, 230, 229, 227, 223, 226, 0, 0, 231, 0,
1161 62, 64, 0, 0, 25, 204, 0, 0, 100, 99,
1162 0, 36, 36, 115, 36, 0, 36, 119, 121, 36,
1163 140, 0, 219, 232, 218, 0, 69, 65, 66, 60,
1164 55, 61, 59, 0, 160, 160, 36, 211, 36, 36,
1165 144, 36, 68, 0, 50, 67, 111, 0, 0, 117,
1166 36, 0, 133, 36, 70, 94, 96, 145
1167 };
1168
1169 /* YYPGOTO[NTERM-NUM]. */
1170 static const yytype_int16 yypgoto[] =
1171 {
1172 -287, -287, -287, -2, -4, -287, 305, -287, 171, -287,
1173 -5, 4, -287, 8, -287, 23, 321, 24, -287, -37,
1174 -287, -287, -287, -287, -287, -287, 12, 14, 17, -287,
1175 -287, -10, -287, -287, -30, -80, -287, -287, -287, -287,
1176 44, -287, 91, -287, -287, 175, -287, -287, 1, -287,
1177 -287, 47, -250, -95, 109, -287, -287, -287, -287, 162,
1178 -287, -287, 43, -287, -287, -29, -177, 42, -287, -287,
1179 -287, 299, -48, -287, -35, 102, -287, -287, -287, 251,
1180 -287, -287, -287, -287, 64, -287, -287, 160, -287, 100,
1181 -269, 86, -286
1182 };
1183
1184 /* YYDEFGOTO[NTERM-NUM]. */
1185 static const yytype_int16 yydefgoto[] =
1186 {
1187 -1, 9, 10, 11, 12, 85, 13, 14, 84, 139,
1188 26, 15, 16, 209, 17, 109, 45, 110, 20, 48,
1189 136, 21, 132, 296, 297, 298, 299, 300, 301, 366,
1190 367, 368, 384, 23, 279, 112, 113, 114, 115, 116,
1191 347, 117, 184, 185, 186, 348, 118, 119, 318, 120,
1192 324, 325, 201, 193, 194, 167, 168, 121, 210, 211,
1193 280, 281, 282, 392, 122, 265, 349, 73, 74, 75,
1194 76, 77, 78, 144, 79, 233, 80, 124, 125, 126,
1195 320, 203, 127, 128, 198, 129, 130, 292, 220, 289,
1196 290, 337, 338
1197 };
1198
1199 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
1200 positive, shift that token. If negative, reduce the rule whose
1201 number is the opposite. If YYTABLE_NINF, syntax error. */
1202 static const yytype_int16 yytable[] =
1203 {
1204 72, 30, 31, 123, 202, 143, 205, 34, 111, 135,
1205 266, 36, 267, 29, 123, 35, 218, 294, 137, 138,
1206 335, 22, 46, 18, 19, 145, 224, 32, 47, 371,
1207 183, 216, 34, 183, 18, 19, 18, 19, 362, 357,
1208 35, 153, 272, 272, 336, 140, 187, 131, 33, 189,
1209 -17, 363, 133, 363, 134, 295, 322, 323, 216, 18,
1210 19, 1, 2, 3, 228, 335, 197, 295, 56, -56,
1211 4, 229, 355, 206, 207, 208, 123, 37, 63, 64,
1212 38, 5, 27, 182, 49, 27, 361, 1, 2, 3,
1213 28, 378, 381, 28, 231, 219, 4, 146, 50, 226,
1214 284, 285, 286, 123, 223, 137, 199, 5, 18, 19,
1215 151, 152, 230, 24, 52, 25, 214, 6, 232, 232,
1216 232, 238, 83, 8, 287, 191, 177, 178, 179, 192,
1217 240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
1218 200, 39, 41, 6, 225, 40, 60, 191, 83, 8,
1219 7, 192, 27, 66, 67, -17, 41, 264, 42, 43,
1220 28, 52, 154, 123, 57, 268, 269, 58, 270, 123,
1221 271, 141, 42, 43, 274, 123, 275, 319, 34, 188,
1222 190, 81, 364, 322, 323, 283, 35, 123, 336, 288,
1223 216, 44, 302, 60, 216, 147, 137, 387, 388, 216,
1224 66, 67, 195, 196, 148, 18, 19, 306, 181, 307,
1225 142, 250, 251, 252, 253, 254, 255, 256, 257, 258,
1226 259, 260, 216, 149, 303, 40, 306, 202, 308, 150,
1227 155, 156, 157, 158, 313, 123, 41, 183, 306, 123,
1228 309, 202, 123, 343, 123, -60, 216, 326, 204, 327,
1229 235, 237, 42, 43, 99, 330, 331, 332, 333, 159,
1230 160, 161, 162, 163, 164, 165, 166, 123, 212, 213,
1231 221, 216, 222, 272, 216, 273, 291, 345, 305, 216,
1232 311, 123, 312, 314, 315, 123, 351, 328, 197, 336,
1233 354, 123, 329, 123, 123, 341, 216, 342, 359, 216,
1234 169, 170, 171, 340, 346, 353, 239, 356, 365, 295,
1235 216, 172, 173, 216, 374, 373, 123, 123, 383, 123,
1236 391, 123, 376, 375, 123, 386, 379, 1, 2, 3,
1237 175, 176, 177, 178, 179, 343, 4, -234, -234, -234,
1238 -234, 123, 86, 123, 123, 394, 123, 5, 390, 395,
1239 396, 393, 82, 261, 369, 123, 370, 385, 123, 350,
1240 372, 263, 397, 87, 88, 89, 90, 91, 92, 93,
1241 94, 358, 360, 382, 95, 180, 217, 389, 96, 339,
1242 293, 352, -141, 6, 155, 156, 157, 158, 334, 8,
1243 97, 98, 99, 100, 101, 102, 0, 103, 0, 104,
1244 0, 0, 0, 0, 105, 0, 106, 107, 175, 176,
1245 177, 178, 179, 159, 160, 161, 162, 163, 164, 165,
1246 166, 0, 87, 88, 89, 90, 91, 92, 93, 94,
1247 0, 0, 0, 95, 0, 0, 56, 96, 0, 276,
1248 0, -142, 155, 156, 157, 158, 63, 64, 108, 97,
1249 98, 99, 100, 101, 102, 0, 103, 0, 104, -141,
1250 304, 0, 0, 105, 0, 106, 107, 0, 0, 0,
1251 0, 159, 160, 161, 162, 163, 164, 165, 166, 0,
1252 0, 87, 88, 89, 90, 91, 92, 93, 94, 0,
1253 0, 0, 95, 0, 0, 56, 96, 0, 0, 0,
1254 -137, 155, 156, 157, 158, 63, 64, 108, 97, 98,
1255 99, 100, 101, 102, 0, 103, 0, 104, -142, 172,
1256 173, 277, 105, 278, 106, 107, 0, 0, 0, 0,
1257 159, 160, 161, 162, 163, 164, 165, 166, 175, 176,
1258 177, 178, 179, 0, 87, 88, 89, 90, 91, 92,
1259 93, 94, 0, 0, 56, 95, -116, 316, 317, 96,
1260 0, 0, 0, 0, 63, 64, 108, 0, 0, 0,
1261 0, 97, 98, 99, 100, 101, 102, 310, 103, 0,
1262 104, -3, 0, 0, 0, 105, 0, 106, 107, 0,
1263 0, 0, 1, 2, 3, 0, 0, 0, 0, 0,
1264 0, 4, 0, 87, 88, 89, 90, 91, 92, 93,
1265 94, 0, 5, 0, 95, 0, 0, 56, 96, 0,
1266 0, 0, 0, -123, 0, 0, 0, 63, 64, 108,
1267 97, 98, 99, 100, 101, 102, 0, 103, 0, 104,
1268 -123, -123, 0, 0, 105, 0, 106, 107, 6, 0,
1269 0, 1, 2, 3, 8, 0, 0, 0, 0, 0,
1270 4, 0, 87, 88, 89, 90, 91, 92, 93, 94,
1271 0, 5, 0, 95, 0, 0, 56, 96, 0, 0,
1272 0, 0, -122, 0, 0, 0, 63, 64, 108, 97,
1273 98, 99, 100, 101, 102, 0, 103, 0, 104, -122,
1274 -122, 0, 0, 105, 0, 106, 107, 6, 0, 0,
1275 0, 7, 0, 8, 0, 0, 0, 0, 0, 0,
1276 0, 87, 88, 89, 90, 91, 92, 93, 94, 0,
1277 0, 0, 95, 0, 0, 56, 96, 155, 156, 157,
1278 158, 0, 0, 0, 0, 63, 64, 108, 97, 98,
1279 99, 100, 101, 102, 0, 103, 0, 104, 0, 0,
1280 0, 277, 105, 278, 106, 107, 159, 160, 161, 162,
1281 163, 164, 165, 166, 0, 0, 0, 0, 0, 0,
1282 0, 87, 88, 89, 90, 91, 92, 93, 94, 0,
1283 0, 0, 95, 0, 56, 0, 96, 155, 156, 157,
1284 158, -233, 0, 0, 63, 64, 108, -233, 97, 98,
1285 99, 100, 101, 102, 0, 103, 0, 104, 0, 0,
1286 0, 0, 105, 0, 106, 107, 0, 160, 161, 162,
1287 163, 164, 165, 166, 0, 0, 0, 0, 0, 0,
1288 87, 88, 89, 90, 91, 92, 93, 94, 0, 0,
1289 0, 95, 0, 0, 56, 96, 155, 156, 157, 158,
1290 215, 0, 0, 0, 63, 64, 108, 97, 98, 99,
1291 100, 101, 102, 0, 103, 0, 104, 0, 0, 0,
1292 0, 105, 0, 106, 107, 0, 0, 161, 162, 163,
1293 164, 165, 166, 0, 0, 0, 0, 0, 0, 87,
1294 88, 89, 90, 91, 92, 93, 94, 0, 0, 0,
1295 95, 0, 0, 56, 96, -234, -234, -234, -234, 227,
1296 0, 0, 0, 63, 64, 108, 97, 98, 99, 100,
1297 101, 102, 0, 103, 0, 104, 0, 0, 0, 0,
1298 105, 0, 106, 107, 0, 0, -234, -234, 163, 164,
1299 165, 166, 0, 0, 0, 0, 0, 0, 87, 88,
1300 89, 90, 91, 92, 93, 94, 0, 0, 0, 95,
1301 0, 0, 56, 96, 0, 0, 0, 0, 321, 0,
1302 0, 0, 63, 64, 108, 97, 98, 99, 100, 101,
1303 102, 0, 103, 0, 104, 0, 0, 0, 0, 105,
1304 0, 106, 107, 0, 0, 0, 0, 0, 0, 0,
1305 0, 0, 0, 0, 0, 0, 0, 87, 88, 89,
1306 90, 91, 92, 93, 94, 0, 0, 0, 95, 0,
1307 0, 56, 96, 0, 0, 0, 0, 344, 0, 0,
1308 0, 63, 64, 108, 97, 98, 99, 100, 101, 102,
1309 0, 103, 0, 104, 0, 0, 0, 0, 105, 0,
1310 106, 107, 0, 169, 170, 171, 0, 0, 0, 0,
1311 0, 0, 0, 0, 172, 173, 87, 88, 89, 90,
1312 91, 92, 93, 94, 0, 0, 0, 95, -118, 0,
1313 56, 96, 174, 175, 176, 177, 178, 179, 0, 0,
1314 63, 64, 108, 97, 98, 99, 100, 101, 102, 0,
1315 103, 0, 104, 0, 0, 0, 0, 105, 0, 106,
1316 107, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1317 0, 0, 0, 0, 0, 87, 88, 89, 90, 91,
1318 92, 93, 94, 0, 0, 0, 95, 0, 0, 56,
1319 96, 0, 0, 0, 0, 377, 0, 0, 0, 63,
1320 64, 108, 97, 98, 99, 100, 101, 102, 0, 103,
1321 0, 104, 0, 0, 0, 0, 105, 0, 106, 107,
1322 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1323 0, 0, 0, 0, 87, 88, 89, 90, 91, 92,
1324 93, 94, 0, 0, 0, 95, 0, 0, 56, 96,
1325 0, 0, 0, 0, 380, 0, 0, 0, 63, 64,
1326 108, 97, 98, 99, 100, 101, 102, 0, 103, 0,
1327 104, 0, 0, 0, 0, 105, 0, 106, 107, 169,
1328 0, 171, 0, 0, 0, 0, 0, 0, 0, 0,
1329 172, 173, 0, 87, 88, 89, 90, 91, 92, 93,
1330 94, 0, 0, 0, 95, 0, 0, 56, 96, 175,
1331 176, 177, 178, 179, 0, 0, 0, 63, 64, 108,
1332 97, 98, 99, 100, 101, 102, 0, 103, 0, 104,
1333 0, 0, 0, 0, 105, 0, 106, 107, 284, 285,
1334 286, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1335 0, 284, 285, 286, 0, 0, 0, 155, 156, 157,
1336 158, 0, 287, 0, 0, 0, 56, 51, 0, 0,
1337 52, 53, 0, 0, 0, 287, 63, 64, 108, 0,
1338 0, 54, 0, 0, 0, 55, 159, 160, 161, 162,
1339 163, 164, 165, 166, 0, 56, 57, 0, 0, 58,
1340 59, 0, 60, 61, 62, 63, 64, 0, 65, 66,
1341 67, 51, 68, 69, 52, 53, 0, 0, 0, 70,
1342 0, 0, 0, 71, 0, 54, 0, 0, 0, 55,
1343 0, 0, 0, 0, 0, 0, 0, 0, 0, 56,
1344 57, 0, 0, 58, 59, 0, 60, 61, 62, 63,
1345 64, 0, 65, 66, 67, 51, 68, 69, 52, 53,
1346 0, 0, 0, 70, 234, 0, 0, 71, 0, 54,
1347 0, 0, 0, 55, 0, 0, 0, 0, 0, 0,
1348 0, 0, 0, 56, 57, 0, 0, 58, 59, 0,
1349 60, 61, 62, 63, 64, 0, 65, 66, 67, 51,
1350 68, 69, 52, 53, 0, 0, 0, 70, 236, 0,
1351 0, 71, 0, 54, 0, 0, 0, 55, 0, 0,
1352 0, 0, 0, 0, 0, 0, 0, 56, 57, 0,
1353 0, 58, 59, 0, 60, 61, 62, 63, 64, 0,
1354 65, 66, 67, 51, 68, 69, 52, 53, 0, 0,
1355 0, 70, 0, 0, 0, 71, 0, 54, 0, 0,
1356 0, 55, 0, 0, 0, 51, 0, 0, 52, 53,
1357 0, 56, 57, 0, 0, 58, 59, 0, 60, 262,
1358 62, 63, 64, 55, 65, 66, 67, 0, 68, 69,
1359 0, 0, 0, 56, 57, 70, 0, 58, 59, 71,
1360 60, 61, 62, 63, 64, 0, 65, 66, 67, 0,
1361 68, 69, 169, 0, 0, 0, 0, 70, 0, 0,
1362 0, 71, 0, 172, 173, 0, 0, 0, 0, 0,
1363 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1364 0, 0, 175, 176, 177, 178, 179
1365 };
1366
1367 static const yytype_int16 yycheck[] =
1368 {
1369 29, 6, 7, 38, 99, 53, 101, 11, 38, 46,
1370 187, 13, 189, 5, 49, 11, 24, 50, 47, 49,
1371 289, 82, 22, 0, 0, 54, 23, 82, 20, 50,
1372 84, 111, 36, 84, 11, 11, 13, 13, 23, 23,
1373 36, 70, 54, 54, 29, 50, 100, 39, 0, 100,
1374 0, 337, 44, 339, 46, 88, 40, 41, 138, 36,
1375 36, 11, 12, 13, 92, 334, 95, 88, 76, 102,
1376 20, 99, 322, 102, 103, 104, 111, 78, 86, 87,
1377 22, 31, 82, 85, 22, 82, 336, 11, 12, 13,
1378 90, 103, 103, 90, 142, 130, 20, 55, 68, 136,
1379 19, 20, 21, 138, 133, 134, 98, 31, 85, 85,
1380 68, 69, 141, 80, 51, 82, 108, 67, 147, 148,
1381 149, 150, 72, 73, 43, 80, 95, 96, 97, 84,
1382 159, 160, 161, 162, 163, 164, 165, 166, 167, 168,
1383 95, 38, 53, 67, 136, 42, 83, 80, 72, 73,
1384 71, 84, 82, 90, 91, 79, 53, 186, 69, 70,
1385 90, 51, 90, 198, 77, 194, 195, 80, 198, 204,
1386 199, 100, 69, 70, 204, 210, 205, 272, 182, 88,
1387 89, 92, 23, 40, 41, 214, 182, 222, 29, 218,
1388 270, 88, 222, 83, 274, 100, 225, 374, 375, 279,
1389 90, 91, 93, 94, 100, 182, 182, 99, 92, 101,
1390 100, 169, 170, 171, 172, 173, 174, 175, 176, 177,
1391 178, 179, 302, 100, 229, 42, 99, 322, 101, 100,
1392 25, 26, 27, 28, 263, 270, 53, 84, 99, 274,
1393 101, 336, 277, 99, 279, 101, 326, 277, 22, 278,
1394 148, 149, 69, 70, 32, 284, 285, 286, 287, 54,
1395 55, 56, 57, 58, 59, 60, 61, 302, 106, 107,
1396 100, 351, 22, 54, 354, 22, 22, 306, 101, 359,
1397 79, 316, 92, 99, 99, 320, 316, 22, 317, 29,
1398 320, 326, 99, 328, 329, 101, 376, 102, 328, 379,
1399 63, 64, 65, 295, 84, 15, 101, 103, 49, 88,
1400 390, 74, 75, 393, 99, 92, 351, 352, 36, 354,
1401 45, 356, 352, 99, 359, 84, 356, 11, 12, 13,
1402 93, 94, 95, 96, 97, 99, 20, 58, 59, 60,
1403 61, 376, 37, 378, 379, 88, 381, 31, 378, 101,
1404 101, 381, 31, 182, 342, 390, 342, 367, 393, 315,
1405 343, 186, 391, 3, 4, 5, 6, 7, 8, 9,
1406 10, 324, 329, 365, 14, 76, 125, 376, 18, 293,
1407 220, 317, 22, 67, 25, 26, 27, 28, 288, 73,
1408 30, 31, 32, 33, 34, 35, -1, 37, -1, 39,
1409 -1, -1, -1, -1, 44, -1, 46, 47, 93, 94,
1410 95, 96, 97, 54, 55, 56, 57, 58, 59, 60,
1411 61, -1, 3, 4, 5, 6, 7, 8, 9, 10,
1412 -1, -1, -1, 14, -1, -1, 76, 18, -1, 22,
1413 -1, 22, 25, 26, 27, 28, 86, 87, 88, 30,
1414 31, 32, 33, 34, 35, -1, 37, -1, 39, 99,
1415 101, -1, -1, 44, -1, 46, 47, -1, -1, -1,
1416 -1, 54, 55, 56, 57, 58, 59, 60, 61, -1,
1417 -1, 3, 4, 5, 6, 7, 8, 9, 10, -1,
1418 -1, -1, 14, -1, -1, 76, 18, -1, -1, -1,
1419 22, 25, 26, 27, 28, 86, 87, 88, 30, 31,
1420 32, 33, 34, 35, -1, 37, -1, 39, 99, 74,
1421 75, 43, 44, 45, 46, 47, -1, -1, -1, -1,
1422 54, 55, 56, 57, 58, 59, 60, 61, 93, 94,
1423 95, 96, 97, -1, 3, 4, 5, 6, 7, 8,
1424 9, 10, -1, -1, 76, 14, 15, 16, 17, 18,
1425 -1, -1, -1, -1, 86, 87, 88, -1, -1, -1,
1426 -1, 30, 31, 32, 33, 34, 35, 101, 37, -1,
1427 39, 0, -1, -1, -1, 44, -1, 46, 47, -1,
1428 -1, -1, 11, 12, 13, -1, -1, -1, -1, -1,
1429 -1, 20, -1, 3, 4, 5, 6, 7, 8, 9,
1430 10, -1, 31, -1, 14, -1, -1, 76, 18, -1,
1431 -1, -1, -1, 23, -1, -1, -1, 86, 87, 88,
1432 30, 31, 32, 33, 34, 35, -1, 37, -1, 39,
1433 40, 41, -1, -1, 44, -1, 46, 47, 67, -1,
1434 -1, 11, 12, 13, 73, -1, -1, -1, -1, -1,
1435 20, -1, 3, 4, 5, 6, 7, 8, 9, 10,
1436 -1, 31, -1, 14, -1, -1, 76, 18, -1, -1,
1437 -1, -1, 23, -1, -1, -1, 86, 87, 88, 30,
1438 31, 32, 33, 34, 35, -1, 37, -1, 39, 40,
1439 41, -1, -1, 44, -1, 46, 47, 67, -1, -1,
1440 -1, 71, -1, 73, -1, -1, -1, -1, -1, -1,
1441 -1, 3, 4, 5, 6, 7, 8, 9, 10, -1,
1442 -1, -1, 14, -1, -1, 76, 18, 25, 26, 27,
1443 28, -1, -1, -1, -1, 86, 87, 88, 30, 31,
1444 32, 33, 34, 35, -1, 37, -1, 39, -1, -1,
1445 -1, 43, 44, 45, 46, 47, 54, 55, 56, 57,
1446 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
1447 -1, 3, 4, 5, 6, 7, 8, 9, 10, -1,
1448 -1, -1, 14, -1, 76, -1, 18, 25, 26, 27,
1449 28, 23, -1, -1, 86, 87, 88, 29, 30, 31,
1450 32, 33, 34, 35, -1, 37, -1, 39, -1, -1,
1451 -1, -1, 44, -1, 46, 47, -1, 55, 56, 57,
1452 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
1453 3, 4, 5, 6, 7, 8, 9, 10, -1, -1,
1454 -1, 14, -1, -1, 76, 18, 25, 26, 27, 28,
1455 23, -1, -1, -1, 86, 87, 88, 30, 31, 32,
1456 33, 34, 35, -1, 37, -1, 39, -1, -1, -1,
1457 -1, 44, -1, 46, 47, -1, -1, 56, 57, 58,
1458 59, 60, 61, -1, -1, -1, -1, -1, -1, 3,
1459 4, 5, 6, 7, 8, 9, 10, -1, -1, -1,
1460 14, -1, -1, 76, 18, 25, 26, 27, 28, 23,
1461 -1, -1, -1, 86, 87, 88, 30, 31, 32, 33,
1462 34, 35, -1, 37, -1, 39, -1, -1, -1, -1,
1463 44, -1, 46, 47, -1, -1, 56, 57, 58, 59,
1464 60, 61, -1, -1, -1, -1, -1, -1, 3, 4,
1465 5, 6, 7, 8, 9, 10, -1, -1, -1, 14,
1466 -1, -1, 76, 18, -1, -1, -1, -1, 23, -1,
1467 -1, -1, 86, 87, 88, 30, 31, 32, 33, 34,
1468 35, -1, 37, -1, 39, -1, -1, -1, -1, 44,
1469 -1, 46, 47, -1, -1, -1, -1, -1, -1, -1,
1470 -1, -1, -1, -1, -1, -1, -1, 3, 4, 5,
1471 6, 7, 8, 9, 10, -1, -1, -1, 14, -1,
1472 -1, 76, 18, -1, -1, -1, -1, 23, -1, -1,
1473 -1, 86, 87, 88, 30, 31, 32, 33, 34, 35,
1474 -1, 37, -1, 39, -1, -1, -1, -1, 44, -1,
1475 46, 47, -1, 63, 64, 65, -1, -1, -1, -1,
1476 -1, -1, -1, -1, 74, 75, 3, 4, 5, 6,
1477 7, 8, 9, 10, -1, -1, -1, 14, 15, -1,
1478 76, 18, 92, 93, 94, 95, 96, 97, -1, -1,
1479 86, 87, 88, 30, 31, 32, 33, 34, 35, -1,
1480 37, -1, 39, -1, -1, -1, -1, 44, -1, 46,
1481 47, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1482 -1, -1, -1, -1, -1, 3, 4, 5, 6, 7,
1483 8, 9, 10, -1, -1, -1, 14, -1, -1, 76,
1484 18, -1, -1, -1, -1, 23, -1, -1, -1, 86,
1485 87, 88, 30, 31, 32, 33, 34, 35, -1, 37,
1486 -1, 39, -1, -1, -1, -1, 44, -1, 46, 47,
1487 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1488 -1, -1, -1, -1, 3, 4, 5, 6, 7, 8,
1489 9, 10, -1, -1, -1, 14, -1, -1, 76, 18,
1490 -1, -1, -1, -1, 23, -1, -1, -1, 86, 87,
1491 88, 30, 31, 32, 33, 34, 35, -1, 37, -1,
1492 39, -1, -1, -1, -1, 44, -1, 46, 47, 63,
1493 -1, 65, -1, -1, -1, -1, -1, -1, -1, -1,
1494 74, 75, -1, 3, 4, 5, 6, 7, 8, 9,
1495 10, -1, -1, -1, 14, -1, -1, 76, 18, 93,
1496 94, 95, 96, 97, -1, -1, -1, 86, 87, 88,
1497 30, 31, 32, 33, 34, 35, -1, 37, -1, 39,
1498 -1, -1, -1, -1, 44, -1, 46, 47, 19, 20,
1499 21, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1500 -1, 19, 20, 21, -1, -1, -1, 25, 26, 27,
1501 28, -1, 43, -1, -1, -1, 76, 48, -1, -1,
1502 51, 52, -1, -1, -1, 43, 86, 87, 88, -1,
1503 -1, 62, -1, -1, -1, 66, 54, 55, 56, 57,
1504 58, 59, 60, 61, -1, 76, 77, -1, -1, 80,
1505 81, -1, 83, 84, 85, 86, 87, -1, 89, 90,
1506 91, 48, 93, 94, 51, 52, -1, -1, -1, 100,
1507 -1, -1, -1, 104, -1, 62, -1, -1, -1, 66,
1508 -1, -1, -1, -1, -1, -1, -1, -1, -1, 76,
1509 77, -1, -1, 80, 81, -1, 83, 84, 85, 86,
1510 87, -1, 89, 90, 91, 48, 93, 94, 51, 52,
1511 -1, -1, -1, 100, 101, -1, -1, 104, -1, 62,
1512 -1, -1, -1, 66, -1, -1, -1, -1, -1, -1,
1513 -1, -1, -1, 76, 77, -1, -1, 80, 81, -1,
1514 83, 84, 85, 86, 87, -1, 89, 90, 91, 48,
1515 93, 94, 51, 52, -1, -1, -1, 100, 101, -1,
1516 -1, 104, -1, 62, -1, -1, -1, 66, -1, -1,
1517 -1, -1, -1, -1, -1, -1, -1, 76, 77, -1,
1518 -1, 80, 81, -1, 83, 84, 85, 86, 87, -1,
1519 89, 90, 91, 48, 93, 94, 51, 52, -1, -1,
1520 -1, 100, -1, -1, -1, 104, -1, 62, -1, -1,
1521 -1, 66, -1, -1, -1, 48, -1, -1, 51, 52,
1522 -1, 76, 77, -1, -1, 80, 81, -1, 83, 84,
1523 85, 86, 87, 66, 89, 90, 91, -1, 93, 94,
1524 -1, -1, -1, 76, 77, 100, -1, 80, 81, 104,
1525 83, 84, 85, 86, 87, -1, 89, 90, 91, -1,
1526 93, 94, 63, -1, -1, -1, -1, 100, -1, -1,
1527 -1, 104, -1, 74, 75, -1, -1, -1, -1, -1,
1528 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1529 -1, -1, 93, 94, 95, 96, 97
1530 };
1531
1532 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1533 symbol of state STATE-NUM. */
1534 static const yytype_uint8 yystos[] =
1535 {
1536 0, 11, 12, 13, 20, 31, 67, 71, 73, 106,
1537 107, 108, 109, 111, 112, 116, 117, 119, 120, 122,
1538 123, 126, 82, 138, 80, 82, 115, 82, 90, 118,
1539 115, 115, 82, 0, 109, 116, 108, 78, 22, 38,
1540 42, 53, 69, 70, 88, 121, 22, 118, 124, 22,
1541 68, 48, 51, 52, 62, 66, 76, 77, 80, 81,
1542 83, 84, 85, 86, 87, 89, 90, 91, 93, 94,
1543 100, 104, 170, 172, 173, 174, 175, 176, 177, 179,
1544 181, 92, 121, 72, 113, 110, 111, 3, 4, 5,
1545 6, 7, 8, 9, 10, 14, 18, 30, 31, 32,
1546 33, 34, 35, 37, 39, 44, 46, 47, 88, 120,
1547 122, 139, 140, 141, 142, 143, 144, 146, 151, 152,
1548 154, 162, 169, 179, 182, 183, 184, 187, 188, 190,
1549 191, 118, 127, 118, 118, 124, 125, 170, 139, 114,
1550 115, 100, 100, 177, 178, 170, 172, 100, 100, 100,
1551 100, 172, 172, 170, 90, 25, 26, 27, 28, 54,
1552 55, 56, 57, 58, 59, 60, 61, 160, 161, 63,
1553 64, 65, 74, 75, 92, 93, 94, 95, 96, 97,
1554 176, 92, 108, 84, 147, 148, 149, 100, 147, 100,
1555 147, 80, 84, 158, 159, 159, 159, 170, 189, 118,
1556 95, 157, 158, 186, 22, 158, 170, 170, 170, 118,
1557 163, 164, 164, 164, 118, 23, 140, 184, 24, 179,
1558 193, 100, 22, 170, 23, 118, 124, 23, 92, 99,
1559 170, 177, 170, 180, 101, 180, 101, 180, 170, 101,
1560 170, 170, 170, 170, 170, 170, 170, 170, 170, 170,
1561 172, 172, 172, 172, 172, 172, 172, 172, 172, 172,
1562 172, 113, 84, 150, 170, 170, 171, 171, 170, 170,
1563 139, 170, 54, 22, 139, 170, 22, 43, 45, 139,
1564 165, 166, 167, 170, 19, 20, 21, 43, 170, 194,
1565 195, 22, 192, 192, 50, 88, 128, 129, 130, 131,
1566 132, 133, 139, 115, 101, 101, 99, 101, 101, 101,
1567 101, 79, 92, 170, 99, 99, 16, 17, 153, 158,
1568 185, 23, 40, 41, 155, 156, 139, 170, 22, 99,
1569 170, 170, 170, 170, 194, 195, 29, 196, 197, 196,
1570 118, 101, 102, 99, 23, 170, 84, 145, 150, 171,
1571 145, 139, 189, 15, 139, 157, 103, 23, 156, 139,
1572 167, 157, 23, 197, 23, 49, 134, 135, 136, 131,
1573 132, 50, 133, 92, 99, 99, 139, 23, 103, 139,
1574 23, 103, 118, 36, 137, 136, 84, 171, 171, 153,
1575 139, 45, 168, 139, 88, 101, 101, 170
1576 };
1577
1578 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1579 static const yytype_uint8 yyr1[] =
1580 {
1581 0, 105, 106, 107, 107, 108, 108, 108, 108, 109,
1582 109, 110, 110, 111, 111, 112, 112, 113, 113, 114,
1583 114, 115, 115, 116, 116, 116, 116, 116, 116, 117,
1584 117, 118, 118, 119, 119, 119, 120, 120, 121, 121,
1585 121, 122, 122, 123, 124, 125, 125, 125, 125, 126,
1586 127, 128, 128, 129, 129, 129, 130, 130, 131, 131,
1587 132, 132, 133, 133, 134, 134, 135, 135, 136, 137,
1588 137, 138, 139, 139, 140, 140, 140, 140, 140, 140,
1589 140, 140, 140, 140, 140, 141, 142, 142, 143, 143,
1590 143, 143, 144, 144, 144, 144, 144, 144, 144, 145,
1591 145, 146, 146, 146, 147, 147, 148, 148, 148, 148,
1592 149, 150, 151, 151, 151, 152, 153, 153, 153, 154,
1593 155, 155, 156, 156, 157, 157, 158, 158, 159, 160,
1594 160, 161, 161, 162, 163, 164, 164, 165, 165, 166,
1595 166, 167, 167, 167, 168, 168, 169, 169, 170, 170,
1596 170, 170, 170, 170, 170, 170, 170, 170, 170, 170,
1597 171, 171, 172, 172, 172, 172, 172, 172, 172, 172,
1598 172, 172, 172, 172, 173, 173, 173, 173, 173, 173,
1599 173, 174, 174, 174, 174, 174, 174, 174, 174, 175,
1600 175, 176, 176, 177, 177, 177, 178, 178, 179, 179,
1601 179, 179, 179, 180, 180, 181, 181, 182, 182, 183,
1602 185, 184, 186, 186, 187, 188, 188, 189, 190, 190,
1603 191, 192, 193, 193, 193, 194, 194, 195, 195, 195,
1604 195, 196, 196, 197
1605 };
1606
1607 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
1608 static const yytype_uint8 yyr2[] =
1609 {
1610 0, 2, 1, 1, 3, 1, 1, 2, 2, 1,
1611 6, 0, 1, 3, 4, 2, 5, 0, 1, 1,
1612 3, 1, 1, 5, 4, 6, 1, 1, 1, 1,
1613 1, 1, 1, 3, 4, 3, 0, 2, 1, 1,
1614 1, 2, 4, 2, 2, 1, 1, 2, 2, 2,
1615 6, 0, 1, 1, 1, 3, 0, 1, 1, 3,
1616 1, 3, 2, 1, 0, 1, 1, 2, 2, 0,
1617 2, 1, 1, 2, 1, 1, 1, 1, 1, 1,
1618 1, 1, 1, 1, 1, 3, 2, 3, 1, 1,
1619 1, 2, 2, 2, 8, 2, 8, 1, 1, 1,
1620 1, 3, 3, 2, 0, 1, 1, 2, 3, 2,
1621 1, 5, 1, 1, 1, 5, 0, 4, 2, 5,
1622 1, 2, 4, 3, 1, 3, 1, 1, 1, 1,
1623 1, 1, 1, 7, 1, 0, 1, 0, 1, 1,
1624 3, 1, 2, 2, 0, 2, 2, 2, 2, 3,
1625 3, 3, 3, 3, 3, 3, 3, 3, 3, 1,
1626 0, 1, 1, 3, 3, 3, 3, 3, 3, 3,
1627 3, 3, 3, 3, 1, 3, 4, 1, 2, 2,
1628 2, 1, 1, 1, 1, 1, 2, 2, 1, 1,
1629 2, 1, 1, 1, 1, 4, 1, 3, 4, 3,
1630 4, 4, 3, 1, 3, 1, 1, 1, 2, 4,
1631 0, 6, 1, 1, 3, 1, 2, 1, 5, 5,
1632 1, 1, 2, 3, 2, 1, 2, 2, 2, 2,
1633 2, 1, 2, 4
1634 };
1635
1636
1637 #define yyerrok (yyerrstatus = 0)
1638 #define yyclearin (yychar = YYEMPTY)
1639 #define YYEMPTY (-2)
1640 #define YYEOF 0
1641
1642 #define YYACCEPT goto yyacceptlab
1643 #define YYABORT goto yyabortlab
1644 #define YYERROR goto yyerrorlab
1645
1646
1647 #define YYRECOVERING() (!!yyerrstatus)
1648
1649 #define YYBACKUP(Token, Value) \
1650 do \
1651 if (yychar == YYEMPTY) \
1652 { \
1653 yychar = (Token); \
1654 yylval = (Value); \
1655 YYPOPSTACK (yylen); \
1656 yystate = *yyssp; \
1657 goto yybackup; \
1658 } \
1659 else \
1660 { \
1661 yyerror (YY_("syntax error: cannot back up")); \
1662 YYERROR; \
1663 } \
1664 while (0)
1665
1666 /* Error token number */
1667 #define YYTERROR 1
1668 #define YYERRCODE 256
1669
1670
1671 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
1672 If N is 0, then set CURRENT to the empty location which ends
1673 the previous symbol: RHS[0] (always defined). */
1674
1675 #ifndef YYLLOC_DEFAULT
1676 # define YYLLOC_DEFAULT(Current, Rhs, N) \
1677 do \
1678 if (N) \
1679 { \
1680 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
1681 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
1682 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
1683 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
1684 } \
1685 else \
1686 { \
1687 (Current).first_line = (Current).last_line = \
1688 YYRHSLOC (Rhs, 0).last_line; \
1689 (Current).first_column = (Current).last_column = \
1690 YYRHSLOC (Rhs, 0).last_column; \
1691 } \
1692 while (0)
1693 #endif
1694
1695 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
1696
1697
1698 /* Enable debugging if requested. */
1699 #if YYDEBUG
1700
1701 # ifndef YYFPRINTF
1702 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1703 # define YYFPRINTF fprintf
1704 # endif
1705
1706 # define YYDPRINTF(Args) \
1707 do { \
1708 if (yydebug) \
1709 YYFPRINTF Args; \
1710 } while (0)
1711
1712
1713 /* YY_LOCATION_PRINT -- Print the location on the stream.
1714 This macro was not mandated originally: define only if we know
1715 we won't break user code: when these are the locations we know. */
1716
1717 #ifndef YY_LOCATION_PRINT
1718 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1719
1720 /* Print *YYLOCP on YYO. Private, do not rely on its existence. */
1721
1722 YY_ATTRIBUTE_UNUSED
1723 static unsigned
yy_location_print_(FILE * yyo,YYLTYPE const * const yylocp)1724 yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
1725 {
1726 unsigned res = 0;
1727 int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
1728 if (0 <= yylocp->first_line)
1729 {
1730 res += YYFPRINTF (yyo, "%d", yylocp->first_line);
1731 if (0 <= yylocp->first_column)
1732 res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
1733 }
1734 if (0 <= yylocp->last_line)
1735 {
1736 if (yylocp->first_line < yylocp->last_line)
1737 {
1738 res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
1739 if (0 <= end_col)
1740 res += YYFPRINTF (yyo, ".%d", end_col);
1741 }
1742 else if (0 <= end_col && yylocp->first_column < end_col)
1743 res += YYFPRINTF (yyo, "-%d", end_col);
1744 }
1745 return res;
1746 }
1747
1748 # define YY_LOCATION_PRINT(File, Loc) \
1749 yy_location_print_ (File, &(Loc))
1750
1751 # else
1752 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1753 # endif
1754 #endif
1755
1756
1757 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1758 do { \
1759 if (yydebug) \
1760 { \
1761 YYFPRINTF (stderr, "%s ", Title); \
1762 yy_symbol_print (stderr, \
1763 Type, Value, Location); \
1764 YYFPRINTF (stderr, "\n"); \
1765 } \
1766 } while (0)
1767
1768
1769 /*----------------------------------------.
1770 | Print this symbol's value on YYOUTPUT. |
1771 `----------------------------------------*/
1772
1773 static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep,YYLTYPE const * const yylocationp)1774 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
1775 {
1776 FILE *yyo = yyoutput;
1777 YYUSE (yyo);
1778 YYUSE (yylocationp);
1779 if (!yyvaluep)
1780 return;
1781 # ifdef YYPRINT
1782 if (yytype < YYNTOKENS)
1783 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1784 # endif
1785 YYUSE (yytype);
1786 }
1787
1788
1789 /*--------------------------------.
1790 | Print this symbol on YYOUTPUT. |
1791 `--------------------------------*/
1792
1793 static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep,YYLTYPE const * const yylocationp)1794 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
1795 {
1796 YYFPRINTF (yyoutput, "%s %s (",
1797 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
1798
1799 YY_LOCATION_PRINT (yyoutput, *yylocationp);
1800 YYFPRINTF (yyoutput, ": ");
1801 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp);
1802 YYFPRINTF (yyoutput, ")");
1803 }
1804
1805 /*------------------------------------------------------------------.
1806 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1807 | TOP (included). |
1808 `------------------------------------------------------------------*/
1809
1810 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)1811 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1812 {
1813 YYFPRINTF (stderr, "Stack now");
1814 for (; yybottom <= yytop; yybottom++)
1815 {
1816 int yybot = *yybottom;
1817 YYFPRINTF (stderr, " %d", yybot);
1818 }
1819 YYFPRINTF (stderr, "\n");
1820 }
1821
1822 # define YY_STACK_PRINT(Bottom, Top) \
1823 do { \
1824 if (yydebug) \
1825 yy_stack_print ((Bottom), (Top)); \
1826 } while (0)
1827
1828
1829 /*------------------------------------------------.
1830 | Report that the YYRULE is going to be reduced. |
1831 `------------------------------------------------*/
1832
1833 static void
yy_reduce_print(yytype_int16 * yyssp,YYSTYPE * yyvsp,YYLTYPE * yylsp,int yyrule)1834 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
1835 {
1836 unsigned long int yylno = yyrline[yyrule];
1837 int yynrhs = yyr2[yyrule];
1838 int yyi;
1839 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1840 yyrule - 1, yylno);
1841 /* The symbols being reduced. */
1842 for (yyi = 0; yyi < yynrhs; yyi++)
1843 {
1844 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1845 yy_symbol_print (stderr,
1846 yystos[yyssp[yyi + 1 - yynrhs]],
1847 &(yyvsp[(yyi + 1) - (yynrhs)])
1848 , &(yylsp[(yyi + 1) - (yynrhs)]) );
1849 YYFPRINTF (stderr, "\n");
1850 }
1851 }
1852
1853 # define YY_REDUCE_PRINT(Rule) \
1854 do { \
1855 if (yydebug) \
1856 yy_reduce_print (yyssp, yyvsp, yylsp, Rule); \
1857 } while (0)
1858
1859 /* Nonzero means print parse trace. It is left uninitialized so that
1860 multiple parsers can coexist. */
1861 int yydebug;
1862 #else /* !YYDEBUG */
1863 # define YYDPRINTF(Args)
1864 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1865 # define YY_STACK_PRINT(Bottom, Top)
1866 # define YY_REDUCE_PRINT(Rule)
1867 #endif /* !YYDEBUG */
1868
1869
1870 /* YYINITDEPTH -- initial size of the parser's stacks. */
1871 #ifndef YYINITDEPTH
1872 # define YYINITDEPTH 200
1873 #endif
1874
1875 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1876 if the built-in stack extension method is used).
1877
1878 Do not make this value too large; the results are undefined if
1879 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1880 evaluated with infinite-precision integer arithmetic. */
1881
1882 #ifndef YYMAXDEPTH
1883 # define YYMAXDEPTH 10000
1884 #endif
1885
1886
1887 #if YYERROR_VERBOSE
1888
1889 # ifndef yystrlen
1890 # if defined __GLIBC__ && defined _STRING_H
1891 # define yystrlen strlen
1892 # else
1893 /* Return the length of YYSTR. */
1894 static YYSIZE_T
yystrlen(const char * yystr)1895 yystrlen (const char *yystr)
1896 {
1897 YYSIZE_T yylen;
1898 for (yylen = 0; yystr[yylen]; yylen++)
1899 continue;
1900 return yylen;
1901 }
1902 # endif
1903 # endif
1904
1905 # ifndef yystpcpy
1906 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1907 # define yystpcpy stpcpy
1908 # else
1909 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1910 YYDEST. */
1911 static char *
yystpcpy(char * yydest,const char * yysrc)1912 yystpcpy (char *yydest, const char *yysrc)
1913 {
1914 char *yyd = yydest;
1915 const char *yys = yysrc;
1916
1917 while ((*yyd++ = *yys++) != '\0')
1918 continue;
1919
1920 return yyd - 1;
1921 }
1922 # endif
1923 # endif
1924
1925 # ifndef yytnamerr
1926 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1927 quotes and backslashes, so that it's suitable for yyerror. The
1928 heuristic is that double-quoting is unnecessary unless the string
1929 contains an apostrophe, a comma, or backslash (other than
1930 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1931 null, do not copy; instead, return the length of what the result
1932 would have been. */
1933 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)1934 yytnamerr (char *yyres, const char *yystr)
1935 {
1936 if (*yystr == '"')
1937 {
1938 YYSIZE_T yyn = 0;
1939 char const *yyp = yystr;
1940
1941 for (;;)
1942 switch (*++yyp)
1943 {
1944 case '\'':
1945 case ',':
1946 goto do_not_strip_quotes;
1947
1948 case '\\':
1949 if (*++yyp != '\\')
1950 goto do_not_strip_quotes;
1951 /* Fall through. */
1952 default:
1953 if (yyres)
1954 yyres[yyn] = *yyp;
1955 yyn++;
1956 break;
1957
1958 case '"':
1959 if (yyres)
1960 yyres[yyn] = '\0';
1961 return yyn;
1962 }
1963 do_not_strip_quotes: ;
1964 }
1965
1966 if (! yyres)
1967 return yystrlen (yystr);
1968
1969 return yystpcpy (yyres, yystr) - yyres;
1970 }
1971 # endif
1972
1973 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1974 about the unexpected token YYTOKEN for the state stack whose top is
1975 YYSSP.
1976
1977 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1978 not large enough to hold the message. In that case, also set
1979 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1980 required number of bytes is too large to store. */
1981 static int
yysyntax_error(YYSIZE_T * yymsg_alloc,char ** yymsg,yytype_int16 * yyssp,int yytoken)1982 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1983 yytype_int16 *yyssp, int yytoken)
1984 {
1985 YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1986 YYSIZE_T yysize = yysize0;
1987 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1988 /* Internationalized format string. */
1989 const char *yyformat = YY_NULLPTR;
1990 /* Arguments of yyformat. */
1991 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1992 /* Number of reported tokens (one for the "unexpected", one per
1993 "expected"). */
1994 int yycount = 0;
1995
1996 /* There are many possibilities here to consider:
1997 - If this state is a consistent state with a default action, then
1998 the only way this function was invoked is if the default action
1999 is an error action. In that case, don't check for expected
2000 tokens because there are none.
2001 - The only way there can be no lookahead present (in yychar) is if
2002 this state is a consistent state with a default action. Thus,
2003 detecting the absence of a lookahead is sufficient to determine
2004 that there is no unexpected or expected token to report. In that
2005 case, just report a simple "syntax error".
2006 - Don't assume there isn't a lookahead just because this state is a
2007 consistent state with a default action. There might have been a
2008 previous inconsistent state, consistent state with a non-default
2009 action, or user semantic action that manipulated yychar.
2010 - Of course, the expected token list depends on states to have
2011 correct lookahead information, and it depends on the parser not
2012 to perform extra reductions after fetching a lookahead from the
2013 scanner and before detecting a syntax error. Thus, state merging
2014 (from LALR or IELR) and default reductions corrupt the expected
2015 token list. However, the list is correct for canonical LR with
2016 one exception: it will still contain any token that will not be
2017 accepted due to an error action in a later state.
2018 */
2019 if (yytoken != YYEMPTY)
2020 {
2021 int yyn = yypact[*yyssp];
2022 yyarg[yycount++] = yytname[yytoken];
2023 if (!yypact_value_is_default (yyn))
2024 {
2025 /* Start YYX at -YYN if negative to avoid negative indexes in
2026 YYCHECK. In other words, skip the first -YYN actions for
2027 this state because they are default actions. */
2028 int yyxbegin = yyn < 0 ? -yyn : 0;
2029 /* Stay within bounds of both yycheck and yytname. */
2030 int yychecklim = YYLAST - yyn + 1;
2031 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
2032 int yyx;
2033
2034 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2035 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
2036 && !yytable_value_is_error (yytable[yyx + yyn]))
2037 {
2038 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
2039 {
2040 yycount = 1;
2041 yysize = yysize0;
2042 break;
2043 }
2044 yyarg[yycount++] = yytname[yyx];
2045 {
2046 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
2047 if (! (yysize <= yysize1
2048 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
2049 return 2;
2050 yysize = yysize1;
2051 }
2052 }
2053 }
2054 }
2055
2056 switch (yycount)
2057 {
2058 # define YYCASE_(N, S) \
2059 case N: \
2060 yyformat = S; \
2061 break
2062 YYCASE_(0, YY_("syntax error"));
2063 YYCASE_(1, YY_("syntax error, unexpected %s"));
2064 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
2065 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
2066 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
2067 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
2068 # undef YYCASE_
2069 }
2070
2071 {
2072 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
2073 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
2074 return 2;
2075 yysize = yysize1;
2076 }
2077
2078 if (*yymsg_alloc < yysize)
2079 {
2080 *yymsg_alloc = 2 * yysize;
2081 if (! (yysize <= *yymsg_alloc
2082 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
2083 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
2084 return 1;
2085 }
2086
2087 /* Avoid sprintf, as that infringes on the user's name space.
2088 Don't have undefined behavior even if the translation
2089 produced a string with the wrong number of "%s"s. */
2090 {
2091 char *yyp = *yymsg;
2092 int yyi = 0;
2093 while ((*yyp = *yyformat) != '\0')
2094 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
2095 {
2096 yyp += yytnamerr (yyp, yyarg[yyi++]);
2097 yyformat += 2;
2098 }
2099 else
2100 {
2101 yyp++;
2102 yyformat++;
2103 }
2104 }
2105 return 0;
2106 }
2107 #endif /* YYERROR_VERBOSE */
2108
2109 /*-----------------------------------------------.
2110 | Release the memory associated to this symbol. |
2111 `-----------------------------------------------*/
2112
2113 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep,YYLTYPE * yylocationp)2114 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
2115 {
2116 YYUSE (yyvaluep);
2117 YYUSE (yylocationp);
2118 if (!yymsg)
2119 yymsg = "Deleting";
2120 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2121
2122 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2123 YYUSE (yytype);
2124 YY_IGNORE_MAYBE_UNINITIALIZED_END
2125 }
2126
2127
2128
2129
2130 /* The lookahead symbol. */
2131 int yychar;
2132
2133 /* The semantic value of the lookahead symbol. */
2134 YYSTYPE yylval;
2135 /* Location data for the lookahead symbol. */
2136 YYLTYPE yylloc
2137 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
2138 = { 1, 1, 1, 1 }
2139 # endif
2140 ;
2141 /* Number of syntax errors so far. */
2142 int yynerrs;
2143
2144
2145 /*----------.
2146 | yyparse. |
2147 `----------*/
2148
2149 int
yyparse(void)2150 yyparse (void)
2151 {
2152 int yystate;
2153 /* Number of tokens to shift before error messages enabled. */
2154 int yyerrstatus;
2155
2156 /* The stacks and their tools:
2157 'yyss': related to states.
2158 'yyvs': related to semantic values.
2159 'yyls': related to locations.
2160
2161 Refer to the stacks through separate pointers, to allow yyoverflow
2162 to reallocate them elsewhere. */
2163
2164 /* The state stack. */
2165 yytype_int16 yyssa[YYINITDEPTH];
2166 yytype_int16 *yyss;
2167 yytype_int16 *yyssp;
2168
2169 /* The semantic value stack. */
2170 YYSTYPE yyvsa[YYINITDEPTH];
2171 YYSTYPE *yyvs;
2172 YYSTYPE *yyvsp;
2173
2174 /* The location stack. */
2175 YYLTYPE yylsa[YYINITDEPTH];
2176 YYLTYPE *yyls;
2177 YYLTYPE *yylsp;
2178
2179 /* The locations where the error started and ended. */
2180 YYLTYPE yyerror_range[3];
2181
2182 YYSIZE_T yystacksize;
2183
2184 int yyn;
2185 int yyresult;
2186 /* Lookahead token as an internal (translated) token number. */
2187 int yytoken = 0;
2188 /* The variables used to return semantic value and location from the
2189 action routines. */
2190 YYSTYPE yyval;
2191 YYLTYPE yyloc;
2192
2193 #if YYERROR_VERBOSE
2194 /* Buffer for error messages, and its allocated size. */
2195 char yymsgbuf[128];
2196 char *yymsg = yymsgbuf;
2197 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
2198 #endif
2199
2200 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
2201
2202 /* The number of symbols on the RHS of the reduced rule.
2203 Keep to zero when no symbol should be popped. */
2204 int yylen = 0;
2205
2206 yyssp = yyss = yyssa;
2207 yyvsp = yyvs = yyvsa;
2208 yylsp = yyls = yylsa;
2209 yystacksize = YYINITDEPTH;
2210
2211 YYDPRINTF ((stderr, "Starting parse\n"));
2212
2213 yystate = 0;
2214 yyerrstatus = 0;
2215 yynerrs = 0;
2216 yychar = YYEMPTY; /* Cause a token to be read. */
2217 yylsp[0] = yylloc;
2218 goto yysetstate;
2219
2220 /*------------------------------------------------------------.
2221 | yynewstate -- Push a new state, which is found in yystate. |
2222 `------------------------------------------------------------*/
2223 yynewstate:
2224 /* In all cases, when you get here, the value and location stacks
2225 have just been pushed. So pushing a state here evens the stacks. */
2226 yyssp++;
2227
2228 yysetstate:
2229 *yyssp = yystate;
2230
2231 if (yyss + yystacksize - 1 <= yyssp)
2232 {
2233 /* Get the current used size of the three stacks, in elements. */
2234 YYSIZE_T yysize = yyssp - yyss + 1;
2235
2236 #ifdef yyoverflow
2237 {
2238 /* Give user a chance to reallocate the stack. Use copies of
2239 these so that the &'s don't force the real ones into
2240 memory. */
2241 YYSTYPE *yyvs1 = yyvs;
2242 yytype_int16 *yyss1 = yyss;
2243 YYLTYPE *yyls1 = yyls;
2244
2245 /* Each stack pointer address is followed by the size of the
2246 data in use in that stack, in bytes. This used to be a
2247 conditional around just the two extra args, but that might
2248 be undefined if yyoverflow is a macro. */
2249 yyoverflow (YY_("memory exhausted"),
2250 &yyss1, yysize * sizeof (*yyssp),
2251 &yyvs1, yysize * sizeof (*yyvsp),
2252 &yyls1, yysize * sizeof (*yylsp),
2253 &yystacksize);
2254
2255 yyls = yyls1;
2256 yyss = yyss1;
2257 yyvs = yyvs1;
2258 }
2259 #else /* no yyoverflow */
2260 # ifndef YYSTACK_RELOCATE
2261 goto yyexhaustedlab;
2262 # else
2263 /* Extend the stack our own way. */
2264 if (YYMAXDEPTH <= yystacksize)
2265 goto yyexhaustedlab;
2266 yystacksize *= 2;
2267 if (YYMAXDEPTH < yystacksize)
2268 yystacksize = YYMAXDEPTH;
2269
2270 {
2271 yytype_int16 *yyss1 = yyss;
2272 union yyalloc *yyptr =
2273 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2274 if (! yyptr)
2275 goto yyexhaustedlab;
2276 YYSTACK_RELOCATE (yyss_alloc, yyss);
2277 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
2278 YYSTACK_RELOCATE (yyls_alloc, yyls);
2279 # undef YYSTACK_RELOCATE
2280 if (yyss1 != yyssa)
2281 YYSTACK_FREE (yyss1);
2282 }
2283 # endif
2284 #endif /* no yyoverflow */
2285
2286 yyssp = yyss + yysize - 1;
2287 yyvsp = yyvs + yysize - 1;
2288 yylsp = yyls + yysize - 1;
2289
2290 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2291 (unsigned long int) yystacksize));
2292
2293 if (yyss + yystacksize - 1 <= yyssp)
2294 YYABORT;
2295 }
2296
2297 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
2298
2299 if (yystate == YYFINAL)
2300 YYACCEPT;
2301
2302 goto yybackup;
2303
2304 /*-----------.
2305 | yybackup. |
2306 `-----------*/
2307 yybackup:
2308
2309 /* Do appropriate processing given the current state. Read a
2310 lookahead token if we need one and don't already have one. */
2311
2312 /* First try to decide what to do without reference to lookahead token. */
2313 yyn = yypact[yystate];
2314 if (yypact_value_is_default (yyn))
2315 goto yydefault;
2316
2317 /* Not known => get a lookahead token if don't already have one. */
2318
2319 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
2320 if (yychar == YYEMPTY)
2321 {
2322 YYDPRINTF ((stderr, "Reading a token: "));
2323 yychar = yylex ();
2324 }
2325
2326 if (yychar <= YYEOF)
2327 {
2328 yychar = yytoken = YYEOF;
2329 YYDPRINTF ((stderr, "Now at end of input.\n"));
2330 }
2331 else
2332 {
2333 yytoken = YYTRANSLATE (yychar);
2334 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
2335 }
2336
2337 /* If the proper action on seeing token YYTOKEN is to reduce or to
2338 detect an error, take that action. */
2339 yyn += yytoken;
2340 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
2341 goto yydefault;
2342 yyn = yytable[yyn];
2343 if (yyn <= 0)
2344 {
2345 if (yytable_value_is_error (yyn))
2346 goto yyerrlab;
2347 yyn = -yyn;
2348 goto yyreduce;
2349 }
2350
2351 /* Count tokens shifted since error; after three, turn off error
2352 status. */
2353 if (yyerrstatus)
2354 yyerrstatus--;
2355
2356 /* Shift the lookahead token. */
2357 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
2358
2359 /* Discard the shifted token. */
2360 yychar = YYEMPTY;
2361
2362 yystate = yyn;
2363 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2364 *++yyvsp = yylval;
2365 YY_IGNORE_MAYBE_UNINITIALIZED_END
2366 *++yylsp = yylloc;
2367 goto yynewstate;
2368
2369
2370 /*-----------------------------------------------------------.
2371 | yydefault -- do the default action for the current state. |
2372 `-----------------------------------------------------------*/
2373 yydefault:
2374 yyn = yydefact[yystate];
2375 if (yyn == 0)
2376 goto yyerrlab;
2377 goto yyreduce;
2378
2379
2380 /*-----------------------------.
2381 | yyreduce -- Do a reduction. |
2382 `-----------------------------*/
2383 yyreduce:
2384 /* yyn is the number of a rule to reduce with. */
2385 yylen = yyr2[yyn];
2386
2387 /* If YYLEN is nonzero, implement the default value of the action:
2388 '$$ = $1'.
2389
2390 Otherwise, the following line sets YYVAL to garbage.
2391 This behavior is undocumented and Bison
2392 users should not rely upon it. Assigning to YYVAL
2393 unconditionally makes the parser a bit smaller, and it avoids a
2394 GCC warning that YYVAL may be used uninitialized. */
2395 yyval = yyvsp[1-yylen];
2396
2397 /* Default location. */
2398 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
2399 YY_REDUCE_PRINT (yyn);
2400 switch (yyn)
2401 {
2402 case 2:
2403 #line 485 "gram.y" /* yacc.c:1646 */
2404 {
2405 if (error_count == 0) {
2406 if (genstmt.head) {
2407 genstmt.tail->next = (yyvsp[0].stmtlist).head;
2408 genstmt.tail = (yyvsp[0].stmtlist).tail;
2409 } else
2410 genstmt = (yyvsp[0].stmtlist);
2411 optimize_tree(genstmt.head);
2412 if (error_count)
2413 YYERROR;
2414 mark(genstmt.head);
2415 if (error_count)
2416 YYERROR;
2417 apply_deferred_init();
2418 fixup_exceptions();
2419 dataseg_layout();
2420 if (optimization_level)
2421 regex_layout();
2422 compile_tree(genstmt.head);
2423 if (!optimization_level)
2424 regex_layout();
2425 }
2426 }
2427 #line 2428 "gram.c" /* yacc.c:1646 */
2428 break;
2429
2430 case 4:
2431 #line 512 "gram.y" /* yacc.c:1646 */
2432 {
2433 (yyval.stmtlist) = (yyvsp[-1].stmtlist);
2434 }
2435 #line 2436 "gram.c" /* yacc.c:1646 */
2436 break;
2437
2438 case 5:
2439 #line 518 "gram.y" /* yacc.c:1646 */
2440 {
2441 (yyval.stmtlist).head = (yyval.stmtlist).tail = (yyvsp[0].node);
2442 }
2443 #line 2444 "gram.c" /* yacc.c:1646 */
2444 break;
2445
2446 case 7:
2447 #line 523 "gram.y" /* yacc.c:1646 */
2448 {
2449 if ((yyvsp[0].node)) {
2450 if ((yyvsp[-1].stmtlist).tail)
2451 (yyvsp[-1].stmtlist).tail->next = (yyvsp[0].node);
2452 else
2453 (yyvsp[-1].stmtlist).head = (yyvsp[0].node);
2454 (yyvsp[-1].stmtlist).tail = (yyvsp[0].node);
2455 }
2456 (yyval.stmtlist) = (yyvsp[-1].stmtlist);
2457 }
2458 #line 2459 "gram.c" /* yacc.c:1646 */
2459 break;
2460
2461 case 8:
2462 #line 534 "gram.y" /* yacc.c:1646 */
2463 {
2464 if ((yyvsp[0].stmtlist).tail) {
2465 if ((yyvsp[-1].stmtlist).tail) {
2466 (yyval.stmtlist).head = (yyvsp[-1].stmtlist).head;
2467 (yyvsp[-1].stmtlist).tail->next = (yyvsp[0].stmtlist).head;
2468 (yyval.stmtlist).tail = (yyvsp[0].stmtlist).tail;
2469 } else
2470 (yyval.stmtlist) = (yyvsp[0].stmtlist);
2471 }
2472 }
2473 #line 2474 "gram.c" /* yacc.c:1646 */
2474 break;
2475
2476 case 9:
2477 #line 547 "gram.y" /* yacc.c:1646 */
2478 {
2479 (yyval.stmtlist).head = (yyval.stmtlist).tail = NULL;
2480 }
2481 #line 2482 "gram.c" /* yacc.c:1646 */
2482 break;
2483
2484 case 10:
2485 #line 551 "gram.y" /* yacc.c:1646 */
2486 {
2487 (yyval.stmtlist) = (yyvsp[-2].stmtlist);
2488 pop_top_module();
2489 }
2490 #line 2491 "gram.c" /* yacc.c:1646 */
2491 break;
2492
2493 case 11:
2494 #line 558 "gram.y" /* yacc.c:1646 */
2495 {
2496 parse_warning(_("missing module declaration"));
2497 }
2498 #line 2499 "gram.c" /* yacc.c:1646 */
2499 break;
2500
2501 case 13:
2502 #line 565 "gram.y" /* yacc.c:1646 */
2503 {
2504 if (top_module->dclname) {
2505 struct mu_locus_range lr;
2506 lr.beg = (yylsp[-2]).beg;
2507 lr.end = (yylsp[0]).end;
2508 parse_error_locus(&lr,
2509 _("duplicate module declaration"));
2510 } else
2511 top_module->dclname = (yyvsp[-1].literal)->text;
2512 }
2513 #line 2514 "gram.c" /* yacc.c:1646 */
2514 break;
2515
2516 case 14:
2517 #line 576 "gram.y" /* yacc.c:1646 */
2518 {
2519 if (top_module->dclname) {
2520 struct mu_locus_range lr;
2521 lr.beg = (yylsp[-3]).beg;
2522 lr.end = (yylsp[0]).end;
2523 parse_error_locus(&lr,
2524 _("duplicate module declaration"));
2525 } else {
2526 if (((yyvsp[-1].number) & (SYM_STATIC|SYM_PUBLIC)) == 0)
2527 parse_error_locus(&(yylsp[-1]),
2528 _("invalid module declaration"));
2529 top_module->dclname = (yyvsp[-2].literal)->text;
2530 top_module->flags = (yyvsp[-1].number);
2531 }
2532 }
2533 #line 2534 "gram.c" /* yacc.c:1646 */
2534 break;
2535
2536 case 15:
2537 #line 594 "gram.y" /* yacc.c:1646 */
2538 {
2539 require_module((yyvsp[0].literal)->text, NULL);
2540 }
2541 #line 2542 "gram.c" /* yacc.c:1646 */
2542 break;
2543
2544 case 16:
2545 #line 598 "gram.y" /* yacc.c:1646 */
2546 {
2547 require_module((yyvsp[-3].literal)->text, (yyvsp[-1].import_rule_list).head);
2548 }
2549 #line 2550 "gram.c" /* yacc.c:1646 */
2550 break;
2551
2552 case 18:
2553 #line 605 "gram.y" /* yacc.c:1646 */
2554 {
2555 lex_bye();
2556 }
2557 #line 2558 "gram.c" /* yacc.c:1646 */
2558 break;
2559
2560 case 19:
2561 #line 611 "gram.y" /* yacc.c:1646 */
2562 {
2563 struct import_rule *rule = import_rule_create((yyvsp[0].literal));
2564 (yyval.import_rule_list).head = (yyval.import_rule_list).tail = rule;
2565 }
2566 #line 2567 "gram.c" /* yacc.c:1646 */
2567 break;
2568
2569 case 20:
2570 #line 616 "gram.y" /* yacc.c:1646 */
2571 {
2572 struct import_rule *rule = import_rule_create((yyvsp[0].literal));
2573 (yyval.import_rule_list).tail->next = rule;
2574 (yyval.import_rule_list).tail = rule;
2575 }
2576 #line 2577 "gram.c" /* yacc.c:1646 */
2577 break;
2578
2579 case 23:
2580 #line 628 "gram.y" /* yacc.c:1646 */
2581 {
2582 (yyval.node) = alloc_node(node_type_progdecl, &(yylsp[-4]));
2583 (yyval.node)->v.progdecl.tag = (yyvsp[-3].state);
2584 (yyval.node)->v.progdecl.auto_count = forget_autos(PARMCOUNT(),
2585 0, 0);
2586 (yyval.node)->v.progdecl.tree = (yyvsp[-1].stmtlist).head;
2587
2588 outer_context = inner_context = context_none;
2589 state_tag = smtp_state_none;
2590 }
2591 #line 2592 "gram.c" /* yacc.c:1646 */
2592 break;
2593
2594 case 24:
2595 #line 639 "gram.y" /* yacc.c:1646 */
2596 {
2597 static NODE *progspecial[2];
2598 NODE *np = progspecial[(yyvsp[-3].progspecial).code];
2599
2600 if (!np) {
2601 np = alloc_node(node_type_progdecl, &(yylsp[-3]));
2602 (yyval.node) = progspecial[(yyvsp[-3].progspecial).code] = np;
2603 np->v.progdecl.tag = state_tag;
2604 np->v.progdecl.tree = (yyvsp[-1].stmtlist).head;
2605 np->v.progdecl.auto_count = 0;
2606 } else {
2607 NODE *cur;
2608 for (cur = np->v.progdecl.tree; cur->next;
2609 cur = cur->next)
2610 ;
2611 cur->next = (yyvsp[-1].stmtlist).head;
2612 (yyval.node) = NULL;
2613 }
2614
2615 np->v.progdecl.auto_count = forget_autos(PARMCOUNT(),
2616 np->v.progdecl.auto_count,
2617 0);
2618 outer_context = inner_context = context_none;
2619 state_tag = smtp_state_none;
2620 }
2621 #line 2622 "gram.c" /* yacc.c:1646 */
2622 break;
2623
2624 case 25:
2625 #line 665 "gram.y" /* yacc.c:1646 */
2626 {
2627 if ((yyvsp[-5].number) & SYM_PRECIOUS)
2628 parse_error_locus(&(yylsp[-4]),
2629 _("`precious' used with func"));
2630 if (((yyvsp[-5].number) & (SYM_STATIC|SYM_PUBLIC)) ==
2631 (SYM_STATIC|SYM_PUBLIC))
2632 parse_error_locus(&(yylsp[-4]),
2633 _("`static' and `public' "
2634 "used together"));
2635 func->sym.flags = (yyvsp[-5].number);
2636 func->node = (yyvsp[-1].stmtlist).head;
2637 (yyval.node) = declare_function(func, &(yylsp[-4]),
2638 forget_autos(PARMCOUNT() + FUNC_HIDDEN_ARGS(func),
2639 0, FUNC_HIDDEN_ARGS(func)));
2640 outer_context = inner_context = context_none;
2641 func = NULL;
2642 }
2643 #line 2644 "gram.c" /* yacc.c:1646 */
2644 break;
2645
2646 case 26:
2647 #line 683 "gram.y" /* yacc.c:1646 */
2648 {
2649 (yyval.node) = NULL;
2650 }
2651 #line 2652 "gram.c" /* yacc.c:1646 */
2652 break;
2653
2654 case 27:
2655 #line 687 "gram.y" /* yacc.c:1646 */
2656 {
2657 (yyval.node) = NULL;
2658 }
2659 #line 2660 "gram.c" /* yacc.c:1646 */
2660 break;
2661
2662 case 28:
2663 #line 691 "gram.y" /* yacc.c:1646 */
2664 {
2665 (yyval.node) = NULL;
2666 }
2667 #line 2668 "gram.c" /* yacc.c:1646 */
2668 break;
2669
2670 case 29:
2671 #line 697 "gram.y" /* yacc.c:1646 */
2672 {
2673 state_tag = smtp_state_begin;
2674 outer_context = inner_context = context_handler;
2675 (yyval.progspecial).code = PS_BEGIN;
2676 }
2677 #line 2678 "gram.c" /* yacc.c:1646 */
2678 break;
2679
2680 case 30:
2681 #line 703 "gram.y" /* yacc.c:1646 */
2682 {
2683 state_tag = smtp_state_end;
2684 outer_context = inner_context = context_handler;
2685 (yyval.progspecial).code = PS_END;
2686 }
2687 #line 2688 "gram.c" /* yacc.c:1646 */
2688 break;
2689
2690 case 32:
2691 #line 712 "gram.y" /* yacc.c:1646 */
2692 {
2693 (yyval.literal) = literal_lookup((yyvsp[0].var)->sym.name);
2694 }
2695 #line 2696 "gram.c" /* yacc.c:1646 */
2696 break;
2697
2698 case 33:
2699 #line 718 "gram.y" /* yacc.c:1646 */
2700 {
2701 struct variable *var;
2702
2703 if (((yyvsp[-2].number) & (SYM_STATIC|SYM_PUBLIC))
2704 == (SYM_STATIC|SYM_PUBLIC))
2705 parse_error_locus(&(yylsp[-2]),
2706 _("`static' and `public' "
2707 "used together"));
2708 var = vardecl((yyvsp[0].literal)->text, (yyvsp[-1].type), storage_extern, &(yylsp[0]));
2709 if (!var)
2710 YYERROR;
2711 var->sym.flags |= (yyvsp[-2].number);
2712 }
2713 #line 2714 "gram.c" /* yacc.c:1646 */
2714 break;
2715
2716 case 34:
2717 #line 732 "gram.y" /* yacc.c:1646 */
2718 {
2719 struct value value;
2720 struct variable *var;
2721
2722 if (((yyvsp[-3].number) & (SYM_STATIC|SYM_PUBLIC))
2723 == (SYM_STATIC|SYM_PUBLIC))
2724 parse_error_locus(&(yylsp[-3]),
2725 _("`static' and `public' "
2726 "used together"));
2727
2728 var = vardecl((yyvsp[-1].literal)->text, (yyvsp[-2].type), storage_extern, &(yylsp[-2]));
2729 if (!var)
2730 YYERROR;
2731 var->sym.flags |= (yyvsp[-3].number);
2732
2733 if (optimization_level)
2734 optimize((yyvsp[0].node));
2735 value.type = node_type((yyvsp[0].node));
2736
2737 switch ((yyvsp[0].node)->type) {
2738 case node_type_string:
2739 value.v.literal = (yyvsp[0].node)->v.literal;
2740 break;
2741
2742 case node_type_number:
2743 value.v.number = (yyvsp[0].node)->v.number;
2744 break;
2745
2746 default:
2747 yyerror("initializer element is not constant");
2748 YYERROR;
2749
2750 }
2751 if (initialize_variable(var, &value, &(yylsp[-1])))
2752 YYERROR;
2753 }
2754 #line 2755 "gram.c" /* yacc.c:1646 */
2755 break;
2756
2757 case 35:
2758 #line 770 "gram.y" /* yacc.c:1646 */
2759 {
2760 struct value value;
2761
2762 if (optimization_level)
2763 optimize((yyvsp[0].node));
2764 value.type = node_type((yyvsp[0].node));
2765
2766 switch ((yyvsp[0].node)->type) {
2767 case node_type_string:
2768 value.v.literal = (yyvsp[0].node)->v.literal;
2769 break;
2770
2771 case node_type_number:
2772 value.v.number = (yyvsp[0].node)->v.number;
2773 break;
2774
2775 default:
2776 yyerror("initializer element is not constant");
2777 YYERROR;
2778 }
2779 if (!externdecl((yyvsp[-1].literal)->text, &value, &(yylsp[-1])))
2780 YYERROR;
2781 }
2782 #line 2783 "gram.c" /* yacc.c:1646 */
2783 break;
2784
2785 case 36:
2786 #line 796 "gram.y" /* yacc.c:1646 */
2787 {
2788 (yyval.number) = 0;
2789 }
2790 #line 2791 "gram.c" /* yacc.c:1646 */
2791 break;
2792
2793 case 37:
2794 #line 800 "gram.y" /* yacc.c:1646 */
2795 {
2796 if ((yyvsp[-1].number) & (yyvsp[0].number))
2797 parse_warning(_("duplicate `%s'"),
2798 symbit_to_qualifier((yyvsp[0].number)));
2799 (yyval.number) = (yyvsp[-1].number) | (yyvsp[0].number);
2800 }
2801 #line 2802 "gram.c" /* yacc.c:1646 */
2802 break;
2803
2804 case 38:
2805 #line 809 "gram.y" /* yacc.c:1646 */
2806 {
2807 (yyval.number) = SYM_PRECIOUS;
2808 }
2809 #line 2810 "gram.c" /* yacc.c:1646 */
2810 break;
2811
2812 case 39:
2813 #line 813 "gram.y" /* yacc.c:1646 */
2814 {
2815 (yyval.number) = SYM_STATIC;
2816 }
2817 #line 2818 "gram.c" /* yacc.c:1646 */
2818 break;
2819
2820 case 40:
2821 #line 817 "gram.y" /* yacc.c:1646 */
2822 {
2823 (yyval.number) = SYM_PUBLIC;
2824 }
2825 #line 2826 "gram.c" /* yacc.c:1646 */
2826 break;
2827
2828 case 41:
2829 #line 824 "gram.y" /* yacc.c:1646 */
2830 {
2831 (yyvsp[0].enumlist).cv->sym.flags = (yyvsp[-1].number);
2832 (yyval.node) = NULL;
2833 }
2834 #line 2835 "gram.c" /* yacc.c:1646 */
2835 break;
2836
2837 case 42:
2838 #line 829 "gram.y" /* yacc.c:1646 */
2839 {
2840 struct enumlist *elist;
2841 while ((elist = (yyvsp[-1].enumlist).prev)) {
2842 elist->cv->sym.flags = (yyvsp[-3].number);
2843 elist = elist->prev;
2844 free((yyvsp[-1].enumlist).prev);
2845 (yyvsp[-1].enumlist).prev = elist;
2846 }
2847 (yyval.node) = NULL;
2848 }
2849 #line 2850 "gram.c" /* yacc.c:1646 */
2850 break;
2851
2852 case 43:
2853 #line 842 "gram.y" /* yacc.c:1646 */
2854 {
2855 if ((yyvsp[-1].number) & SYM_PRECIOUS)
2856 parse_error_locus(&(yylsp[-1]),
2857 _("`precious' used with const"));
2858 if (((yyvsp[-1].number) & (SYM_STATIC|SYM_PUBLIC)) ==
2859 (SYM_STATIC|SYM_PUBLIC))
2860 parse_error_locus(&(yylsp[-1]),
2861 _("`static' and `public' "
2862 "used together"));
2863 (yyval.number) = (yyvsp[-1].number);
2864 }
2865 #line 2866 "gram.c" /* yacc.c:1646 */
2866 break;
2867
2868 case 44:
2869 #line 857 "gram.y" /* yacc.c:1646 */
2870 {
2871 struct value value;
2872 struct variable *pvar;
2873
2874 /* FIXME: This is necessary because constants can be
2875 referred to the same way as variables. */
2876 if (pvar = variable_lookup((yyvsp[-1].literal)->text)) {
2877 parse_warning(_("constant name `%s' clashes with a variable name"),
2878 (yyvsp[-1].literal)->text);
2879 parse_warning_locus(&pvar->sym.locus,
2880 _("this is the location of the "
2881 "previous definition"));
2882 }
2883
2884 if (optimization_level)
2885 optimize((yyvsp[0].node));
2886
2887 switch ((yyvsp[0].node)->type) {
2888 case node_type_string:
2889 value.type = dtype_string;
2890 value.v.literal = (yyvsp[0].node)->v.literal;
2891 break;
2892
2893 case node_type_number:
2894 value.type = dtype_number;
2895 value.v.number = (yyvsp[0].node)->v.number;
2896 break;
2897
2898 default:
2899 yyerror(_("initializer element is not constant"));
2900 YYERROR;
2901 }
2902
2903 (yyval.enumlist).cv = define_constant((yyvsp[-1].literal)->text, &value, 0, &(yylsp[-1]));
2904 (yyval.enumlist).prev = NULL;
2905 }
2906 #line 2907 "gram.c" /* yacc.c:1646 */
2907 break;
2908
2909 case 45:
2910 #line 896 "gram.y" /* yacc.c:1646 */
2911 {
2912 struct enumlist *elist;
2913 struct value value;
2914 struct variable *pvar;
2915
2916 if (pvar = variable_lookup((yyvsp[0].literal)->text)) {
2917 parse_warning(_("constant name `%s' clashes with a variable name"),
2918 (yyvsp[0].literal)->text);
2919 parse_warning_locus(&pvar->sym.locus,
2920 _("this is the location of the "
2921 "previous definition"));
2922 }
2923
2924 value.type = dtype_number;
2925 value.v.number = 0;
2926
2927 elist = mu_alloc(sizeof(*elist));
2928
2929 elist->cv = define_constant((yyvsp[0].literal)->text, &value, 0, &(yylsp[0]));
2930 elist->prev = NULL;
2931 (yyval.enumlist).cv = NULL;
2932 (yyval.enumlist).prev = elist;
2933 }
2934 #line 2935 "gram.c" /* yacc.c:1646 */
2935 break;
2936
2937 case 46:
2938 #line 920 "gram.y" /* yacc.c:1646 */
2939 {
2940 struct enumlist *elist = mu_alloc(sizeof(*elist));
2941 elist->cv = (yyvsp[0].enumlist).cv;
2942 elist->prev = NULL;
2943 (yyval.enumlist).cv = NULL;
2944 (yyval.enumlist).prev = elist;
2945 }
2946 #line 2947 "gram.c" /* yacc.c:1646 */
2947 break;
2948
2949 case 47:
2950 #line 928 "gram.y" /* yacc.c:1646 */
2951 {
2952 if ((yyvsp[-1].enumlist).prev->cv->value.type == dtype_number) {
2953 struct enumlist *elist = mu_alloc(sizeof(*elist));
2954 struct value value;
2955
2956 value.type = dtype_number;
2957 value.v.number = (yyvsp[-1].enumlist).prev->cv->value.v.number + 1;
2958
2959 elist->cv = define_constant((yyvsp[0].literal)->text, &value, 0,
2960 &(yylsp[0]));
2961 elist->prev = (yyvsp[-1].enumlist).prev;
2962 (yyval.enumlist).prev = elist;
2963 } else {
2964 yyerror(_("initializer element is not numeric"));
2965 YYERROR;
2966 }
2967 }
2968 #line 2969 "gram.c" /* yacc.c:1646 */
2969 break;
2970
2971 case 48:
2972 #line 946 "gram.y" /* yacc.c:1646 */
2973 {
2974 struct enumlist *elist = mu_alloc(sizeof(*elist));
2975 elist->cv = (yyvsp[0].enumlist).cv;
2976 elist->prev = (yyvsp[-1].enumlist).prev;
2977 (yyvsp[-1].enumlist).prev = elist;
2978 (yyval.enumlist) = (yyvsp[-1].enumlist);
2979 }
2980 #line 2981 "gram.c" /* yacc.c:1646 */
2981 break;
2982
2983 case 49:
2984 #line 956 "gram.y" /* yacc.c:1646 */
2985 {
2986 define_exception((yyvsp[0].literal), &(yylsp[-1]));
2987 }
2988 #line 2989 "gram.c" /* yacc.c:1646 */
2989 break;
2990
2991 case 50:
2992 #line 962 "gram.y" /* yacc.c:1646 */
2993 {
2994 data_type_t *ptypes = NULL;
2995
2996 if ((yyvsp[-3].parmlist).count) {
2997 int i;
2998 struct parmtype *p;
2999
3000 ptypes = mu_alloc((yyvsp[-3].parmlist).count * sizeof *ptypes);
3001 for (i = 0, p = (yyvsp[-3].parmlist).head; p; i++) {
3002 struct parmtype *next = p->next;
3003 ptypes[i] = p->type;
3004 free(p);
3005 p = next;
3006 }
3007 }
3008
3009 (yyval.function) = func = function_install((yyvsp[-5].literal)->text,
3010 (yyvsp[-3].parmlist).count, (yyvsp[-3].parmlist).optcount,
3011 (yyvsp[-3].parmlist).varargs,
3012 ptypes, (yyvsp[0].type),
3013 &(yylsp[-5]));
3014 if ((yyvsp[-1].list)) {
3015 mu_list_foreach((yyvsp[-1].list), _create_alias, (yyval.function));
3016 mu_list_destroy(&(yyvsp[-1].list));
3017 }
3018 outer_context = inner_context = context_function;
3019 }
3020 #line 3021 "gram.c" /* yacc.c:1646 */
3021 break;
3022
3023 case 51:
3024 #line 992 "gram.y" /* yacc.c:1646 */
3025 {
3026 (yyval.parmlist).count = (yyval.parmlist).optcount = 0;
3027 (yyval.parmlist).varargs = 0;
3028 }
3029 #line 3030 "gram.c" /* yacc.c:1646 */
3030 break;
3031
3032 case 54:
3033 #line 1001 "gram.y" /* yacc.c:1646 */
3034 {
3035 (yyval.parmlist).count = (yyval.parmlist).optcount = 0;
3036 (yyval.parmlist).varargs = 1;
3037 }
3038 #line 3039 "gram.c" /* yacc.c:1646 */
3039 break;
3040
3041 case 55:
3042 #line 1006 "gram.y" /* yacc.c:1646 */
3043 {
3044 (yyvsp[-2].parmlist).count += (yyvsp[0].parmlist).count;
3045 (yyvsp[-2].parmlist).optcount = (yyvsp[0].parmlist).count;
3046 (yyvsp[-2].parmlist).varargs = (yyvsp[0].parmlist).varargs;
3047 if ((yyvsp[-2].parmlist).tail)
3048 (yyvsp[-2].parmlist).tail->next = (yyvsp[0].parmlist).head;
3049 else
3050 (yyvsp[-2].parmlist).head = (yyvsp[0].parmlist).head;
3051 (yyvsp[-2].parmlist).tail = (yyvsp[0].parmlist).tail;
3052 (yyval.parmlist) = (yyvsp[-2].parmlist);
3053 }
3054 #line 3055 "gram.c" /* yacc.c:1646 */
3055 break;
3056
3057 case 56:
3058 #line 1020 "gram.y" /* yacc.c:1646 */
3059 {
3060 (yyval.parmlist).count = 0;
3061 (yyval.parmlist).varargs = 0;
3062 (yyval.parmlist).head = (yyval.parmlist).tail = NULL;
3063 }
3064 #line 3065 "gram.c" /* yacc.c:1646 */
3065 break;
3066
3067 case 58:
3068 #line 1029 "gram.y" /* yacc.c:1646 */
3069 {
3070 (yyval.parmlist).count = 1;
3071 (yyval.parmlist).varargs = 0;
3072 (yyval.parmlist).optcount = 0;
3073 (yyval.parmlist).head = (yyval.parmlist).tail = (yyvsp[0].parm);
3074 }
3075 #line 3076 "gram.c" /* yacc.c:1646 */
3076 break;
3077
3078 case 59:
3079 #line 1036 "gram.y" /* yacc.c:1646 */
3080 {
3081 (yyvsp[-2].parmlist).count++;
3082 (yyvsp[-2].parmlist).tail->next = (yyvsp[0].parm);
3083 (yyvsp[-2].parmlist).tail = (yyvsp[0].parm);
3084 (yyval.parmlist) = (yyvsp[-2].parmlist);
3085 }
3086 #line 3087 "gram.c" /* yacc.c:1646 */
3087 break;
3088
3089 case 61:
3090 #line 1046 "gram.y" /* yacc.c:1646 */
3091 {
3092 (yyvsp[-2].parmlist).varargs = 1;
3093 (yyval.parmlist) = (yyvsp[-2].parmlist);
3094 }
3095 #line 3096 "gram.c" /* yacc.c:1646 */
3096 break;
3097
3098 case 62:
3099 #line 1053 "gram.y" /* yacc.c:1646 */
3100 {
3101 if (!vardecl((yyvsp[0].literal)->text, (yyvsp[-1].type), storage_param, &(yylsp[0])))
3102 YYERROR;
3103 (yyval.parm) = mu_alloc(sizeof *(yyval.parm));
3104 (yyval.parm)->next = NULL;
3105 (yyval.parm)->type = (yyvsp[-1].type);
3106 }
3107 #line 3108 "gram.c" /* yacc.c:1646 */
3108 break;
3109
3110 case 63:
3111 #line 1062 "gram.y" /* yacc.c:1646 */
3112 {
3113 parse_warning_locus(&(yylsp[0]),
3114 _("unnamed formal parameters are deprecated"));
3115 (yyval.parm) = mu_alloc(sizeof *(yyval.parm));
3116 (yyval.parm)->next = NULL;
3117 (yyval.parm)->type = (yyvsp[0].type);
3118 }
3119 #line 3120 "gram.c" /* yacc.c:1646 */
3120 break;
3121
3122 case 64:
3123 #line 1072 "gram.y" /* yacc.c:1646 */
3124 {
3125 (yyval.list) = NULL;
3126 }
3127 #line 3128 "gram.c" /* yacc.c:1646 */
3128 break;
3129
3130 case 66:
3131 #line 1079 "gram.y" /* yacc.c:1646 */
3132 {
3133 mu_list_create(&(yyval.list));
3134 mu_list_append((yyval.list), (yyvsp[0].literal));
3135 }
3136 #line 3137 "gram.c" /* yacc.c:1646 */
3137 break;
3138
3139 case 67:
3140 #line 1084 "gram.y" /* yacc.c:1646 */
3141 {
3142 mu_list_append((yyvsp[-1].list), (yyvsp[0].literal));
3143 (yyval.list) = (yyvsp[-1].list);
3144 }
3145 #line 3146 "gram.c" /* yacc.c:1646 */
3146 break;
3147
3148 case 68:
3149 #line 1091 "gram.y" /* yacc.c:1646 */
3150 {
3151 (yyval.literal) = (yyvsp[0].literal);
3152 }
3153 #line 3154 "gram.c" /* yacc.c:1646 */
3154 break;
3155
3156 case 69:
3157 #line 1097 "gram.y" /* yacc.c:1646 */
3158 {
3159 (yyval.type) = dtype_unspecified;
3160 }
3161 #line 3162 "gram.c" /* yacc.c:1646 */
3162 break;
3163
3164 case 70:
3165 #line 1101 "gram.y" /* yacc.c:1646 */
3166 {
3167 (yyval.type) = (yyvsp[0].type);
3168 }
3169 #line 3170 "gram.c" /* yacc.c:1646 */
3170 break;
3171
3172 case 71:
3173 #line 1107 "gram.y" /* yacc.c:1646 */
3174 {
3175 (yyval.state) = string_to_state((yyvsp[0].literal)->text);
3176 if ((yyval.state) == smtp_state_none)
3177 parse_error_locus(&(yylsp[0]),
3178 _("unknown smtp state tag: %s"),
3179 (yyvsp[0].literal)->text);
3180 state_tag = (yyval.state);
3181 outer_context = inner_context = context_handler;
3182 }
3183 #line 3184 "gram.c" /* yacc.c:1646 */
3184 break;
3185
3186 case 72:
3187 #line 1119 "gram.y" /* yacc.c:1646 */
3188 {
3189 if ((yyvsp[0].node))
3190 (yyvsp[0].node)->next = NULL;
3191 (yyval.stmtlist).head = (yyval.stmtlist).tail = (yyvsp[0].node);
3192 }
3193 #line 3194 "gram.c" /* yacc.c:1646 */
3194 break;
3195
3196 case 73:
3197 #line 1125 "gram.y" /* yacc.c:1646 */
3198 {
3199 if ((yyvsp[0].node)) {
3200 if ((yyvsp[-1].stmtlist).tail)
3201 (yyvsp[-1].stmtlist).tail->next = (yyvsp[0].node);
3202 else
3203 (yyvsp[-1].stmtlist).head = (yyvsp[0].node);
3204 (yyvsp[-1].stmtlist).tail = (yyvsp[0].node);
3205 }
3206 (yyval.stmtlist) = (yyvsp[-1].stmtlist);
3207 }
3208 #line 3209 "gram.c" /* yacc.c:1646 */
3209 break;
3210
3211 case 81:
3212 #line 1145 "gram.y" /* yacc.c:1646 */
3213 {
3214 if (node_type((yyvsp[0].node)) != dtype_unspecified)
3215 parse_warning(_("return from %s is ignored"),
3216 (yyvsp[0].node)->type == node_type_builtin ?
3217 (yyvsp[0].node)->v.builtin.builtin->name :
3218 (yyvsp[0].node)->v.call.func->sym.name);
3219 }
3220 #line 3221 "gram.c" /* yacc.c:1646 */
3221 break;
3222
3223 case 85:
3224 #line 1158 "gram.y" /* yacc.c:1646 */
3225 {
3226 struct variable *var;
3227 data_type_t t = node_type((yyvsp[0].node));
3228
3229 if (t == dtype_unspecified) {
3230 parse_error_locus(&(yylsp[0]),
3231 _("unspecified value not ignored as "
3232 "it should be"));
3233 YYERROR;
3234 }
3235
3236 var = variable_lookup((yyvsp[-1].literal)->text);
3237 if (!var) {
3238 var = vardecl((yyvsp[-1].literal)->text, t, storage_auto, &(yylsp[-1]));
3239 if (!var)
3240 YYERROR;
3241 }
3242 (yyval.node) = create_asgn_node(var, (yyvsp[0].node), &(yylsp[-2]));
3243 if (!(yyval.node))
3244 YYERROR;
3245 }
3246 #line 3247 "gram.c" /* yacc.c:1646 */
3247 break;
3248
3249 case 86:
3250 #line 1182 "gram.y" /* yacc.c:1646 */
3251 {
3252 if (!vardecl((yyvsp[0].literal)->text, (yyvsp[-1].type), storage_auto, &(yylsp[0])))
3253 YYERROR;
3254 (yyval.node) = NULL;
3255 }
3256 #line 3257 "gram.c" /* yacc.c:1646 */
3257 break;
3258
3259 case 87:
3260 #line 1188 "gram.y" /* yacc.c:1646 */
3261 {
3262 struct variable *var = vardecl((yyvsp[-1].literal)->text, (yyvsp[-2].type),
3263 storage_auto, &(yylsp[-1]));
3264 if (!var)
3265 YYERROR;
3266 (yyval.node) = create_asgn_node(var, (yyvsp[0].node), &(yylsp[-2]));
3267 if (!(yyval.node))
3268 YYERROR;
3269 }
3270 #line 3271 "gram.c" /* yacc.c:1646 */
3271 break;
3272
3273 case 88:
3274 #line 1200 "gram.y" /* yacc.c:1646 */
3275 {
3276 if (inner_context == context_handler) {
3277 if (state_tag == smtp_state_begin)
3278 parse_error_locus(&(yylsp[0]),
3279 _("Sendmail action is not "
3280 "allowed in begin block"));
3281 else if (state_tag == smtp_state_end)
3282 parse_error_locus(&(yylsp[0]),
3283 _("Sendmail action is not "
3284 "allowed in end block"));
3285 }
3286 }
3287 #line 3288 "gram.c" /* yacc.c:1646 */
3288 break;
3289
3290 case 89:
3291 #line 1213 "gram.y" /* yacc.c:1646 */
3292 {
3293 if (inner_context == context_handler
3294 && state_tag == smtp_state_end)
3295 parse_error_locus(&(yylsp[0]),
3296 _("header action is not allowed "
3297 "in end block"));
3298 }
3299 #line 3300 "gram.c" /* yacc.c:1646 */
3300 break;
3301
3302 case 90:
3303 #line 1221 "gram.y" /* yacc.c:1646 */
3304 {
3305 (yyval.node) = alloc_node(node_type_noop, &(yylsp[0]));
3306 }
3307 #line 3308 "gram.c" /* yacc.c:1646 */
3308 break;
3309
3310 case 91:
3311 #line 1225 "gram.y" /* yacc.c:1646 */
3312 {
3313 (yyval.node) = alloc_node(node_type_echo, &(yylsp[-1]));
3314 (yyval.node)->v.node = cast_to(dtype_string, (yyvsp[0].node));
3315 }
3316 #line 3317 "gram.c" /* yacc.c:1646 */
3317 break;
3318
3319 case 92:
3320 #line 1233 "gram.y" /* yacc.c:1646 */
3321 {
3322 if ((yyvsp[0].ret).code || (yyvsp[0].ret).xcode || (yyvsp[0].ret).message)
3323 parse_warning(_("arguments are ignored for accept"));
3324 (yyval.node) = alloc_node(node_type_result, &(yylsp[-1]));
3325 (yyval.node)->v.ret = (yyvsp[0].ret);
3326 (yyval.node)->v.ret.stat = SMFIS_ACCEPT;
3327 }
3328 #line 3329 "gram.c" /* yacc.c:1646 */
3329 break;
3330
3331 case 93:
3332 #line 1241 "gram.y" /* yacc.c:1646 */
3333 {
3334 (yyval.node) = alloc_node(node_type_result, &(yylsp[-1]));
3335 (yyval.node)->v.ret = (yyvsp[0].ret);
3336 (yyval.node)->v.ret.stat = SMFIS_REJECT;
3337 }
3338 #line 3339 "gram.c" /* yacc.c:1646 */
3339 break;
3340
3341 case 94:
3342 #line 1247 "gram.y" /* yacc.c:1646 */
3343 {
3344 (yyval.node) = alloc_node(node_type_result, &(yylsp[-7]));
3345 (yyval.node)->v.ret.stat = SMFIS_REJECT;
3346 (yyval.node)->v.ret.code = (yyvsp[-5].node) ? cast_to(dtype_string, (yyvsp[-5].node)) : NULL;
3347 (yyval.node)->v.ret.xcode = (yyvsp[-3].node) ? cast_to(dtype_string, (yyvsp[-3].node)) : NULL;
3348 (yyval.node)->v.ret.message = (yyvsp[-1].node) ? cast_to(dtype_string, (yyvsp[-1].node)) : NULL;
3349 }
3350 #line 3351 "gram.c" /* yacc.c:1646 */
3351 break;
3352
3353 case 95:
3354 #line 1255 "gram.y" /* yacc.c:1646 */
3355 {
3356 (yyval.node) = alloc_node(node_type_result, &(yylsp[-1]));
3357 (yyval.node)->v.ret = (yyvsp[0].ret);
3358 (yyval.node)->v.ret.stat = SMFIS_TEMPFAIL;
3359 }
3360 #line 3361 "gram.c" /* yacc.c:1646 */
3361 break;
3362
3363 case 96:
3364 #line 1261 "gram.y" /* yacc.c:1646 */
3365 {
3366 (yyval.node) = alloc_node(node_type_result, &(yylsp[-7]));
3367 (yyval.node)->v.ret.stat = SMFIS_TEMPFAIL;
3368 (yyval.node)->v.ret.code = (yyvsp[-5].node) ? cast_to(dtype_string, (yyvsp[-5].node)) : NULL;
3369 (yyval.node)->v.ret.xcode = (yyvsp[-3].node) ? cast_to(dtype_string, (yyvsp[-3].node)) : NULL;
3370 (yyval.node)->v.ret.message = (yyvsp[-1].node) ? cast_to(dtype_string, (yyvsp[-1].node)) : NULL;
3371 }
3372 #line 3373 "gram.c" /* yacc.c:1646 */
3373 break;
3374
3375 case 97:
3376 #line 1269 "gram.y" /* yacc.c:1646 */
3377 {
3378 (yyval.node) = alloc_node(node_type_result, &(yylsp[0]));
3379 memset(&(yyval.node)->v.ret, 0, sizeof (yyval.node)->v.ret);
3380 (yyval.node)->v.ret.stat = SMFIS_CONTINUE;
3381 }
3382 #line 3383 "gram.c" /* yacc.c:1646 */
3383 break;
3384
3385 case 98:
3386 #line 1275 "gram.y" /* yacc.c:1646 */
3387 {
3388 (yyval.node) = alloc_node(node_type_result, &(yylsp[0]));
3389 memset(&(yyval.node)->v.ret, 0, sizeof (yyval.node)->v.ret);
3390 (yyval.node)->v.ret.stat = SMFIS_DISCARD;
3391 }
3392 #line 3393 "gram.c" /* yacc.c:1646 */
3393 break;
3394
3395 case 100:
3396 #line 1284 "gram.y" /* yacc.c:1646 */
3397 {
3398 (yyval.node) = alloc_node(node_type_string, &(yylsp[0]));
3399 (yyval.node)->v.literal = (yyvsp[0].literal);
3400 }
3401 #line 3402 "gram.c" /* yacc.c:1646 */
3402 break;
3403
3404 case 101:
3405 #line 1293 "gram.y" /* yacc.c:1646 */
3406 {
3407 (yyval.node) = alloc_node(node_type_header, &(yylsp[-2]));
3408 (yyval.node)->v.hdr.opcode = header_add;
3409 (yyval.node)->v.hdr.name = (yyvsp[-1].literal);
3410 (yyval.node)->v.hdr.value = cast_to(dtype_string, (yyvsp[0].node));
3411 }
3412 #line 3413 "gram.c" /* yacc.c:1646 */
3413 break;
3414
3415 case 102:
3416 #line 1300 "gram.y" /* yacc.c:1646 */
3417 {
3418 (yyval.node) = alloc_node(node_type_header, &(yylsp[-2]));
3419 (yyval.node)->v.hdr.opcode = header_replace;
3420 (yyval.node)->v.hdr.name = (yyvsp[-1].literal);
3421 (yyval.node)->v.hdr.value = cast_to(dtype_string, (yyvsp[0].node));
3422 }
3423 #line 3424 "gram.c" /* yacc.c:1646 */
3424 break;
3425
3426 case 103:
3427 #line 1307 "gram.y" /* yacc.c:1646 */
3428 {
3429 (yyval.node) = alloc_node(node_type_header, &(yylsp[-1]));
3430 (yyval.node)->v.hdr.opcode = header_delete;
3431 (yyval.node)->v.hdr.name = (yyvsp[0].literal);
3432 (yyval.node)->v.hdr.value = NULL;
3433 }
3434 #line 3435 "gram.c" /* yacc.c:1646 */
3435 break;
3436
3437 case 104:
3438 #line 1316 "gram.y" /* yacc.c:1646 */
3439 {
3440 memset(&(yyval.ret), 0, sizeof (yyval.ret));
3441 }
3442 #line 3443 "gram.c" /* yacc.c:1646 */
3443 break;
3444
3445 case 106:
3446 #line 1323 "gram.y" /* yacc.c:1646 */
3447 {
3448 (yyval.ret).code = alloc_node(node_type_string, &(yylsp[0]));
3449 (yyval.ret).code->v.literal = (yyvsp[0].literal);
3450 (yyval.ret).xcode = NULL;
3451 (yyval.ret).message = NULL;
3452 }
3453 #line 3454 "gram.c" /* yacc.c:1646 */
3454 break;
3455
3456 case 107:
3457 #line 1330 "gram.y" /* yacc.c:1646 */
3458 {
3459 (yyval.ret).code = alloc_node(node_type_string, &(yylsp[-1]));
3460 (yyval.ret).code->v.literal = (yyvsp[-1].literal);
3461 (yyval.ret).xcode = alloc_node(node_type_string, &(yylsp[0]));
3462 (yyval.ret).xcode->v.literal = (yyvsp[0].literal);
3463 (yyval.ret).message = NULL;
3464 }
3465 #line 3466 "gram.c" /* yacc.c:1646 */
3466 break;
3467
3468 case 108:
3469 #line 1338 "gram.y" /* yacc.c:1646 */
3470 {
3471 (yyval.ret).code = alloc_node(node_type_string, &(yylsp[-2]));
3472 (yyval.ret).code->v.literal = (yyvsp[-2].literal);
3473 (yyval.ret).xcode = alloc_node(node_type_string, &(yylsp[-1]));
3474 (yyval.ret).xcode->v.literal = (yyvsp[-1].literal);
3475 (yyval.ret).message = cast_to(dtype_string, (yyvsp[0].node));
3476 }
3477 #line 3478 "gram.c" /* yacc.c:1646 */
3478 break;
3479
3480 case 109:
3481 #line 1346 "gram.y" /* yacc.c:1646 */
3482 {
3483 (yyval.ret).code = alloc_node(node_type_string, &(yylsp[-1]));
3484 (yyval.ret).code->v.literal = (yyvsp[-1].literal);
3485 (yyval.ret).xcode = NULL;
3486 (yyval.ret).message = cast_to(dtype_string, (yyvsp[0].node));
3487 }
3488 #line 3489 "gram.c" /* yacc.c:1646 */
3489 break;
3490
3491 case 110:
3492 #line 1355 "gram.y" /* yacc.c:1646 */
3493 {
3494 char buf[4];
3495
3496 if ((yyvsp[0].number) < 200 || (yyvsp[0].number) > 599) {
3497 yyerror(_("invalid SMTP reply code"));
3498 buf[0] = 0;
3499 } else
3500 snprintf(buf, sizeof(buf), "%lu", (yyvsp[0].number));
3501 (yyval.literal) = string_alloc(buf, strlen(buf));
3502 }
3503 #line 3504 "gram.c" /* yacc.c:1646 */
3504 break;
3505
3506 case 111:
3507 #line 1368 "gram.y" /* yacc.c:1646 */
3508 {
3509 char buf[sizeof("5.999.999")];
3510
3511 /* RFC 1893:
3512 The syntax of the new status codes is defined as:
3513
3514 status-code = class "." subject "." detail
3515 class = "2"/"4"/"5"
3516 subject = 1*3digit
3517 detail = 1*3digit
3518 */
3519 if (((yyvsp[-4].number) != 2 && (yyvsp[-4].number) != 4 && (yyvsp[-4].number) !=5)
3520 || (yyvsp[-2].number) > 999 || (yyvsp[0].number) > 999) {
3521 yyerror(_("invalid extended reply code"));
3522 buf[0] = 0;
3523 } else
3524 snprintf(buf, sizeof(buf), "%lu.%lu.%lu",
3525 (yyvsp[-4].number), (yyvsp[-2].number), (yyvsp[0].number));
3526 (yyval.literal) = string_alloc(buf, strlen(buf));
3527 }
3528 #line 3529 "gram.c" /* yacc.c:1646 */
3529 break;
3530
3531 case 115:
3532 #line 1396 "gram.y" /* yacc.c:1646 */
3533 {
3534 (yyval.node) = alloc_node(node_type_if, &(yylsp[-4]));
3535 (yyval.node)->v.cond.cond = (yyvsp[-3].node);
3536 (yyval.node)->v.cond.if_true = (yyvsp[-2].stmtlist).head;
3537 (yyval.node)->v.cond.if_false = (yyvsp[-1].node);
3538 }
3539 #line 3540 "gram.c" /* yacc.c:1646 */
3540 break;
3541
3542 case 116:
3543 #line 1405 "gram.y" /* yacc.c:1646 */
3544 {
3545 (yyval.node) = NULL;
3546 }
3547 #line 3548 "gram.c" /* yacc.c:1646 */
3548 break;
3549
3550 case 117:
3551 #line 1409 "gram.y" /* yacc.c:1646 */
3552 {
3553 (yyval.node) = alloc_node(node_type_if, &(yylsp[-3]));
3554 (yyval.node)->v.cond.cond = (yyvsp[-2].node);
3555 (yyval.node)->v.cond.if_true = (yyvsp[-1].stmtlist).head;
3556 (yyval.node)->v.cond.if_false = (yyvsp[0].node);
3557 }
3558 #line 3559 "gram.c" /* yacc.c:1646 */
3559 break;
3560
3561 case 118:
3562 #line 1416 "gram.y" /* yacc.c:1646 */
3563 {
3564 (yyval.node) = (yyvsp[0].stmtlist).head;
3565 }
3566 #line 3567 "gram.c" /* yacc.c:1646 */
3567 break;
3568
3569 case 119:
3570 #line 1422 "gram.y" /* yacc.c:1646 */
3571 {
3572 struct case_stmt *defcase = NULL, *pcase, *prev;
3573
3574 (yyval.node) = alloc_node(node_type_switch, &(yylsp[-4]));
3575 (yyval.node)->v.switch_stmt.node = (yyvsp[-3].node);
3576
3577 /* Make sure there is only one default case and
3578 place it at the beginning of the list */
3579 pcase = (yyvsp[-1].case_list).head;
3580 if (!pcase->valist) {
3581 defcase = pcase;
3582 (yyvsp[-1].case_list).head = (yyvsp[-1].case_list).head->next;
3583 }
3584 prev = pcase;
3585 pcase = pcase->next;
3586 while (pcase) {
3587 if (!pcase->valist) {
3588 if (defcase) {
3589 parse_error_locus(&pcase->locus,
3590 _("duplicate default statement"));
3591 parse_error_locus(&defcase->locus,
3592 _("previously defined here"));
3593 YYERROR;
3594 }
3595 defcase = pcase;
3596 prev->next = pcase->next;
3597 } else
3598 prev = pcase;
3599 pcase = pcase->next;
3600 }
3601
3602 if (!defcase) {
3603 defcase = mu_alloc(sizeof *defcase);
3604 mu_locus_range_init(&defcase->locus);
3605 mu_locus_range_copy(&defcase->locus, &(yylsp[0]));
3606 defcase->valist = NULL;
3607 defcase->node = alloc_node(node_type_noop,
3608 &defcase->locus);
3609 }
3610 defcase->next = (yyvsp[-1].case_list).head;
3611 (yyval.node)->v.switch_stmt.cases = defcase;
3612 }
3613 #line 3614 "gram.c" /* yacc.c:1646 */
3614 break;
3615
3616 case 120:
3617 #line 1467 "gram.y" /* yacc.c:1646 */
3618 {
3619 (yyval.case_list).head = (yyval.case_list).tail = (yyvsp[0].case_stmt);
3620 }
3621 #line 3622 "gram.c" /* yacc.c:1646 */
3622 break;
3623
3624 case 121:
3625 #line 1471 "gram.y" /* yacc.c:1646 */
3626 {
3627 (yyval.case_list).tail->next = (yyvsp[0].case_stmt);
3628 (yyval.case_list).tail = (yyvsp[0].case_stmt);
3629 }
3630 #line 3631 "gram.c" /* yacc.c:1646 */
3631 break;
3632
3633 case 122:
3634 #line 1478 "gram.y" /* yacc.c:1646 */
3635 {
3636 (yyval.case_stmt) = mu_alloc(sizeof *(yyval.case_stmt));
3637 (yyval.case_stmt)->next = NULL;
3638 mu_locus_range_init (&(yyval.case_stmt)->locus);
3639 mu_locus_range_copy (&(yyval.case_stmt)->locus, &(yylsp[-3]));
3640 (yyval.case_stmt)->valist = (yyvsp[-2].valist_list).head;
3641 (yyval.case_stmt)->node = (yyvsp[0].stmtlist).head;
3642 }
3643 #line 3644 "gram.c" /* yacc.c:1646 */
3644 break;
3645
3646 case 123:
3647 #line 1487 "gram.y" /* yacc.c:1646 */
3648 {
3649 (yyval.case_stmt) = mu_alloc(sizeof *(yyval.case_stmt));
3650 (yyval.case_stmt)->next = NULL;
3651 mu_locus_range_init (&(yyval.case_stmt)->locus);
3652 mu_locus_range_copy (&(yyval.case_stmt)->locus, &(yylsp[-2]));
3653 (yyval.case_stmt)->valist = NULL;
3654 (yyval.case_stmt)->node = (yyvsp[0].stmtlist).head;
3655 }
3656 #line 3657 "gram.c" /* yacc.c:1646 */
3657 break;
3658
3659 case 124:
3660 #line 1498 "gram.y" /* yacc.c:1646 */
3661 {
3662 (yyval.valist_list).head = (yyval.valist_list).tail = mu_alloc(sizeof((yyval.valist_list).head[0]));
3663 (yyval.valist_list).head->next = NULL;
3664 (yyval.valist_list).head->value = (yyvsp[0].value);
3665 }
3666 #line 3667 "gram.c" /* yacc.c:1646 */
3667 break;
3668
3669 case 125:
3670 #line 1504 "gram.y" /* yacc.c:1646 */
3671 {
3672 struct valist *p = mu_alloc(sizeof(*p));
3673 p->value = (yyvsp[0].value);
3674 p->next = NULL;
3675 (yyvsp[-2].valist_list).tail->next = p;
3676 (yyvsp[-2].valist_list).tail = p;
3677 (yyval.valist_list) = (yyvsp[-2].valist_list);
3678 }
3679 #line 3680 "gram.c" /* yacc.c:1646 */
3680 break;
3681
3682 case 126:
3683 #line 1515 "gram.y" /* yacc.c:1646 */
3684 {
3685 (yyval.value).type = dtype_string;
3686 (yyval.value).v.literal = (yyvsp[0].literal);
3687 }
3688 #line 3689 "gram.c" /* yacc.c:1646 */
3689 break;
3690
3691 case 127:
3692 #line 1520 "gram.y" /* yacc.c:1646 */
3693 {
3694 (yyval.value).type = dtype_number;
3695 (yyval.value).v.number = (yyvsp[0].number);
3696 }
3697 #line 3698 "gram.c" /* yacc.c:1646 */
3698 break;
3699
3700 case 128:
3701 #line 1527 "gram.y" /* yacc.c:1646 */
3702 {
3703 if ((yyvsp[0].value).type != dtype_string) {
3704 parse_error_locus(&(yylsp[0]),
3705 _("expected string, but found %s"),
3706 type_to_string((yyvsp[0].value).type));
3707 /* Make sure we return something usable: */
3708 (yyval.literal) = string_alloc("ERROR", 5);
3709 } else
3710 (yyval.literal) = (yyvsp[0].value).v.literal;
3711 }
3712 #line 3713 "gram.c" /* yacc.c:1646 */
3713 break;
3714
3715 case 129:
3716 #line 1540 "gram.y" /* yacc.c:1646 */
3717 {
3718 (yyval.matchtype).qualifier = 0;
3719 }
3720 #line 3721 "gram.c" /* yacc.c:1646 */
3721 break;
3722
3723 case 130:
3724 #line 1544 "gram.y" /* yacc.c:1646 */
3725 {
3726 (yyval.matchtype).qualifier = QUALIFIER_MX;
3727 }
3728 #line 3729 "gram.c" /* yacc.c:1646 */
3729 break;
3730
3731 case 131:
3732 #line 1550 "gram.y" /* yacc.c:1646 */
3733 {
3734 (yyval.matchtype).qualifier = 0;
3735 }
3736 #line 3737 "gram.c" /* yacc.c:1646 */
3737 break;
3738
3739 case 132:
3740 #line 1554 "gram.y" /* yacc.c:1646 */
3741 {
3742 (yyval.matchtype).qualifier = QUALIFIER_MX;
3743 }
3744 #line 3745 "gram.c" /* yacc.c:1646 */
3745 break;
3746
3747 case 133:
3748 #line 1563 "gram.y" /* yacc.c:1646 */
3749 {
3750 leave_loop();
3751 (yyvsp[-4].loop).end_while = (yyvsp[0].node);
3752 (yyval.node) = alloc_node(node_type_loop, &(yylsp[-6]));
3753 (yyvsp[-4].loop).body = (yyvsp[-2].stmtlist).head;
3754 (yyvsp[-4].loop).ident = (yyvsp[-5].literal);
3755 (yyval.node)->v.loop = (yyvsp[-4].loop);
3756 }
3757 #line 3758 "gram.c" /* yacc.c:1646 */
3758 break;
3759
3760 case 134:
3761 #line 1574 "gram.y" /* yacc.c:1646 */
3762 {
3763 enter_loop((yyvsp[0].literal), NULL, NULL);
3764 }
3765 #line 3766 "gram.c" /* yacc.c:1646 */
3766 break;
3767
3768 case 135:
3769 #line 1580 "gram.y" /* yacc.c:1646 */
3770 {
3771 (yyval.literal) = NULL;
3772 }
3773 #line 3774 "gram.c" /* yacc.c:1646 */
3774 break;
3775
3776 case 137:
3777 #line 1587 "gram.y" /* yacc.c:1646 */
3778 {
3779 memset(&(yyval.loop), 0, sizeof (yyval.loop));
3780 }
3781 #line 3782 "gram.c" /* yacc.c:1646 */
3782 break;
3783
3784 case 139:
3785 #line 1594 "gram.y" /* yacc.c:1646 */
3786 {
3787 memset(&(yyval.loop), 0, sizeof (yyval.loop));
3788 switch ((yyvsp[0].pollarg).kw) {
3789 case 0:
3790 (yyval.loop).stmt = (yyvsp[0].pollarg).expr;
3791 break;
3792
3793 case T_FOR:
3794 (yyval.loop).for_stmt = (yyvsp[0].pollarg).expr;
3795 break;
3796
3797 case T_WHILE:
3798 (yyval.loop).beg_while = (yyvsp[0].pollarg).expr;
3799 break;
3800
3801 default:
3802 abort();
3803 }
3804 }
3805 #line 3806 "gram.c" /* yacc.c:1646 */
3806 break;
3807
3808 case 140:
3809 #line 1614 "gram.y" /* yacc.c:1646 */
3810 {
3811 switch ((yyvsp[0].pollarg).kw) {
3812 case 0:
3813 if ((yyval.loop).stmt)
3814 parse_error_locus(&(yylsp[0]),
3815 _("duplicate loop increment"));
3816 (yyval.loop).stmt = (yyvsp[0].pollarg).expr;
3817 break;
3818
3819 case T_FOR:
3820 if ((yyval.loop).for_stmt)
3821 parse_error_locus(&(yylsp[0]),
3822 _("duplicate for statement"));
3823 (yyval.loop).for_stmt = (yyvsp[0].pollarg).expr;
3824 break;
3825
3826 case T_WHILE:
3827 if ((yyval.loop).beg_while)
3828 parse_error_locus(&(yylsp[0]),
3829 _("duplicate while statement"));
3830 (yyval.loop).beg_while = (yyvsp[0].pollarg).expr;
3831 break;
3832
3833 default:
3834 abort();
3835 }
3836 }
3837 #line 3838 "gram.c" /* yacc.c:1646 */
3838 break;
3839
3840 case 141:
3841 #line 1644 "gram.y" /* yacc.c:1646 */
3842 {
3843 (yyval.pollarg).kw = 0;
3844 (yyval.pollarg).expr = (yyvsp[0].stmtlist).head;
3845 }
3846 #line 3847 "gram.c" /* yacc.c:1646 */
3847 break;
3848
3849 case 142:
3850 #line 1649 "gram.y" /* yacc.c:1646 */
3851 {
3852 (yyval.pollarg).kw = T_FOR;
3853 (yyval.pollarg).expr = (yyvsp[0].stmtlist).head;
3854 }
3855 #line 3856 "gram.c" /* yacc.c:1646 */
3856 break;
3857
3858 case 143:
3859 #line 1654 "gram.y" /* yacc.c:1646 */
3860 {
3861 (yyval.pollarg).kw = T_WHILE;
3862 (yyval.pollarg).expr = (yyvsp[0].node);
3863 }
3864 #line 3865 "gram.c" /* yacc.c:1646 */
3865 break;
3866
3867 case 144:
3868 #line 1661 "gram.y" /* yacc.c:1646 */
3869 {
3870 (yyval.node) = NULL;
3871 }
3872 #line 3873 "gram.c" /* yacc.c:1646 */
3873 break;
3874
3875 case 145:
3876 #line 1665 "gram.y" /* yacc.c:1646 */
3877 {
3878 (yyval.node) = (yyvsp[0].node);
3879 }
3880 #line 3881 "gram.c" /* yacc.c:1646 */
3881 break;
3882
3883 case 146:
3884 #line 1671 "gram.y" /* yacc.c:1646 */
3885 {
3886 if (!within_loop((yyvsp[0].literal))) {
3887 if ((yyvsp[0].literal))
3888 parse_error_locus(&(yylsp[0]),
3889 _("no such loop: %s"),
3890 (yyvsp[0].literal)->text);
3891 parse_error_locus(&(yylsp[-1]),
3892 _("`break' used outside of `loop'"));
3893 YYERROR;
3894 }
3895 (yyval.node) = alloc_node(node_type_break, &(yylsp[-1]));
3896 (yyval.node)->v.literal = (yyvsp[0].literal);
3897 }
3898 #line 3899 "gram.c" /* yacc.c:1646 */
3899 break;
3900
3901 case 147:
3902 #line 1685 "gram.y" /* yacc.c:1646 */
3903 {
3904 if (!within_loop((yyvsp[0].literal))) {
3905 if ((yyvsp[0].literal)) {
3906 parse_error_locus(&(yylsp[0]),
3907 _("no such loop: %s"),
3908 (yyvsp[0].literal)->text);
3909 parse_error_locus(&(yylsp[-1]),
3910 _("`next' used outside `loop'"));
3911 YYERROR;
3912 } else {
3913 parse_error_locus(&(yylsp[-1]),
3914 _("`next' is used outside `loop'; "
3915 "did you mean `pass'?"));
3916 YYERROR;
3917 }
3918 } else {
3919 (yyval.node) = alloc_node(node_type_next, &(yylsp[-1]));
3920 (yyval.node)->v.literal = (yyvsp[0].literal);
3921 }
3922 }
3923 #line 3924 "gram.c" /* yacc.c:1646 */
3924 break;
3925
3926 case 148:
3927 #line 1710 "gram.y" /* yacc.c:1646 */
3928 {
3929 (yyval.node) = alloc_node(node_type_un, &(yylsp[-1]));
3930 (yyval.node)->v.un.opcode = unary_not;
3931 (yyval.node)->v.un.arg = cast_to(dtype_number, (yyvsp[0].node));
3932 }
3933 #line 3934 "gram.c" /* yacc.c:1646 */
3934 break;
3935
3936 case 149:
3937 #line 1716 "gram.y" /* yacc.c:1646 */
3938 {
3939 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1]));
3940 (yyval.node)->v.bin.opcode = bin_eq;
3941 (yyval.node)->v.bin.arg[0] = (yyvsp[-2].node);
3942 (yyval.node)->v.bin.arg[1] = cast_to(node_type((yyvsp[-2].node)), (yyvsp[0].node));
3943 }
3944 #line 3945 "gram.c" /* yacc.c:1646 */
3945 break;
3946
3947 case 150:
3948 #line 1723 "gram.y" /* yacc.c:1646 */
3949 {
3950 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1]));
3951 (yyval.node)->v.bin.opcode = bin_ne;
3952 (yyval.node)->v.bin.arg[0] = (yyvsp[-2].node);
3953 (yyval.node)->v.bin.arg[1] = cast_to(node_type((yyvsp[-2].node)), (yyvsp[0].node));
3954 }
3955 #line 3956 "gram.c" /* yacc.c:1646 */
3956 break;
3957
3958 case 151:
3959 #line 1730 "gram.y" /* yacc.c:1646 */
3960 {
3961 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1]));
3962 (yyval.node)->v.bin.opcode = bin_lt;
3963 (yyval.node)->v.bin.arg[0] = (yyvsp[-2].node);
3964 (yyval.node)->v.bin.arg[1] = cast_to(node_type((yyvsp[-2].node)), (yyvsp[0].node));
3965 }
3966 #line 3967 "gram.c" /* yacc.c:1646 */
3967 break;
3968
3969 case 152:
3970 #line 1737 "gram.y" /* yacc.c:1646 */
3971 {
3972 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1]));
3973 (yyval.node)->v.bin.opcode = bin_le;
3974 (yyval.node)->v.bin.arg[0] = (yyvsp[-2].node);
3975 (yyval.node)->v.bin.arg[1] = cast_to(node_type((yyvsp[-2].node)), (yyvsp[0].node));
3976 }
3977 #line 3978 "gram.c" /* yacc.c:1646 */
3978 break;
3979
3980 case 153:
3981 #line 1744 "gram.y" /* yacc.c:1646 */
3982 {
3983 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1]));
3984 (yyval.node)->v.bin.opcode = bin_gt;
3985 (yyval.node)->v.bin.arg[0] = (yyvsp[-2].node);
3986 (yyval.node)->v.bin.arg[1] = cast_to(node_type((yyvsp[-2].node)), (yyvsp[0].node));
3987 }
3988 #line 3989 "gram.c" /* yacc.c:1646 */
3989 break;
3990
3991 case 154:
3992 #line 1751 "gram.y" /* yacc.c:1646 */
3993 {
3994 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1]));
3995 (yyval.node)->v.bin.opcode = bin_ge;
3996 (yyval.node)->v.bin.arg[0] = (yyvsp[-2].node);
3997 (yyval.node)->v.bin.arg[1] = cast_to(node_type((yyvsp[-2].node)), (yyvsp[0].node));
3998 }
3999 #line 4000 "gram.c" /* yacc.c:1646 */
4000 break;
4001
4002 case 155:
4003 #line 1758 "gram.y" /* yacc.c:1646 */
4004 {
4005 NODE *p;
4006
4007 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1]));
4008 (yyval.node)->v.bin.opcode = bin_match;
4009 (yyval.node)->v.bin.qualifier = (yyvsp[-1].matchtype).qualifier;
4010 (yyval.node)->v.bin.arg[0] = cast_to(dtype_string, (yyvsp[-2].node));
4011 (yyval.node)->v.bin.arg[1] = p = alloc_node(node_type_regcomp,
4012 &(yylsp[-1]));
4013 p->v.regcomp_data.expr = cast_to(dtype_string, (yyvsp[0].node));
4014 p->v.regcomp_data.flags = regex_flags;
4015 p->v.regcomp_data.regind = -1;
4016 }
4017 #line 4018 "gram.c" /* yacc.c:1646 */
4018 break;
4019
4020 case 156:
4021 #line 1772 "gram.y" /* yacc.c:1646 */
4022 {
4023 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1]));
4024 (yyval.node)->v.bin.opcode = bin_fnmatch;
4025 (yyval.node)->v.bin.qualifier = (yyvsp[-1].matchtype).qualifier;
4026 (yyval.node)->v.bin.arg[0] = cast_to(dtype_string, (yyvsp[-2].node));
4027 (yyval.node)->v.bin.arg[1] = cast_to(dtype_string, (yyvsp[0].node));
4028 }
4029 #line 4030 "gram.c" /* yacc.c:1646 */
4030 break;
4031
4032 case 157:
4033 #line 1780 "gram.y" /* yacc.c:1646 */
4034 {
4035 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1]));
4036 (yyval.node)->v.bin.opcode = bin_or;
4037 (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node));
4038 (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node));
4039 }
4040 #line 4041 "gram.c" /* yacc.c:1646 */
4041 break;
4042
4043 case 158:
4044 #line 1787 "gram.y" /* yacc.c:1646 */
4045 {
4046 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1]));
4047 (yyval.node)->v.bin.opcode = bin_and;
4048 (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node));
4049 (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node));
4050 }
4051 #line 4052 "gram.c" /* yacc.c:1646 */
4052 break;
4053
4054 case 160:
4055 #line 1797 "gram.y" /* yacc.c:1646 */
4056 {
4057 (yyval.node) = NULL;
4058 }
4059 #line 4060 "gram.c" /* yacc.c:1646 */
4060 break;
4061
4062 case 163:
4063 #line 1805 "gram.y" /* yacc.c:1646 */
4064 {
4065 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2]));
4066 (yyval.node)->v.bin.opcode = bin_add;
4067 (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node));
4068 (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node));
4069 }
4070 #line 4071 "gram.c" /* yacc.c:1646 */
4071 break;
4072
4073 case 164:
4074 #line 1812 "gram.y" /* yacc.c:1646 */
4075 {
4076 (yyval.node) = alloc_node(node_type_concat, &(yylsp[-1]));
4077 (yyval.node)->v.concat.arg[0] = cast_to(dtype_string, (yyvsp[-2].node));
4078 (yyval.node)->v.concat.arg[1] = cast_to(dtype_string, (yyvsp[0].node));
4079 }
4080 #line 4081 "gram.c" /* yacc.c:1646 */
4081 break;
4082
4083 case 165:
4084 #line 1818 "gram.y" /* yacc.c:1646 */
4085 {
4086 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2]));
4087 (yyval.node)->v.bin.opcode = bin_sub;
4088 (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node));
4089 (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node));
4090 }
4091 #line 4092 "gram.c" /* yacc.c:1646 */
4092 break;
4093
4094 case 166:
4095 #line 1825 "gram.y" /* yacc.c:1646 */
4096 {
4097 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2]));
4098 (yyval.node)->v.bin.opcode = bin_mul;
4099 (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node));
4100 (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node));
4101 }
4102 #line 4103 "gram.c" /* yacc.c:1646 */
4103 break;
4104
4105 case 167:
4106 #line 1832 "gram.y" /* yacc.c:1646 */
4107 {
4108 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2]));
4109 (yyval.node)->v.bin.opcode = bin_div;
4110 (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node));
4111 (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node));
4112 }
4113 #line 4114 "gram.c" /* yacc.c:1646 */
4114 break;
4115
4116 case 168:
4117 #line 1839 "gram.y" /* yacc.c:1646 */
4118 {
4119 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2]));
4120 (yyval.node)->v.bin.opcode = bin_mod;
4121 (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node));
4122 (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node));
4123 }
4124 #line 4125 "gram.c" /* yacc.c:1646 */
4125 break;
4126
4127 case 169:
4128 #line 1846 "gram.y" /* yacc.c:1646 */
4129 {
4130 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2]));
4131 (yyval.node)->v.bin.opcode = bin_logand;
4132 (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node));
4133 (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node));
4134 }
4135 #line 4136 "gram.c" /* yacc.c:1646 */
4136 break;
4137
4138 case 170:
4139 #line 1853 "gram.y" /* yacc.c:1646 */
4140 {
4141 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2]));
4142 (yyval.node)->v.bin.opcode = bin_logor;
4143 (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node));
4144 (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node));
4145 }
4146 #line 4147 "gram.c" /* yacc.c:1646 */
4147 break;
4148
4149 case 171:
4150 #line 1860 "gram.y" /* yacc.c:1646 */
4151 {
4152 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2]));
4153 (yyval.node)->v.bin.opcode = bin_logxor;
4154 (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node));
4155 (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node));
4156 }
4157 #line 4158 "gram.c" /* yacc.c:1646 */
4158 break;
4159
4160 case 172:
4161 #line 1867 "gram.y" /* yacc.c:1646 */
4162 {
4163 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2]));
4164 (yyval.node)->v.bin.opcode = bin_shl;
4165 (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node));
4166 (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node));
4167 }
4168 #line 4169 "gram.c" /* yacc.c:1646 */
4169 break;
4170
4171 case 173:
4172 #line 1874 "gram.y" /* yacc.c:1646 */
4173 {
4174 (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2]));
4175 (yyval.node)->v.bin.opcode = bin_shr;
4176 (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node));
4177 (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node));
4178 }
4179 #line 4180 "gram.c" /* yacc.c:1646 */
4180 break;
4181
4182 case 174:
4183 #line 1883 "gram.y" /* yacc.c:1646 */
4184 {
4185 if (node_type((yyvsp[0].node)) == dtype_unspecified)
4186 parse_error(_("unspecified value not ignored as it should be"));
4187 }
4188 #line 4189 "gram.c" /* yacc.c:1646 */
4189 break;
4190
4191 case 175:
4192 #line 1888 "gram.y" /* yacc.c:1646 */
4193 {
4194 (yyval.node) = (yyvsp[-1].node);
4195 }
4196 #line 4197 "gram.c" /* yacc.c:1646 */
4197 break;
4198
4199 case 176:
4200 #line 1892 "gram.y" /* yacc.c:1646 */
4201 {
4202 (yyval.node) = cast_to((yyvsp[-3].type), (yyvsp[-1].node));
4203 }
4204 #line 4205 "gram.c" /* yacc.c:1646 */
4205 break;
4206
4207 case 178:
4208 #line 1897 "gram.y" /* yacc.c:1646 */
4209 {
4210 (yyval.node) = alloc_node(node_type_un, &(yylsp[-1]));
4211 (yyval.node)->v.un.opcode = unary_minus;
4212 (yyval.node)->v.un.arg = cast_to(dtype_number, (yyvsp[0].node));
4213 }
4214 #line 4215 "gram.c" /* yacc.c:1646 */
4215 break;
4216
4217 case 179:
4218 #line 1903 "gram.y" /* yacc.c:1646 */
4219 {
4220 (yyval.node) = (yyvsp[0].node);
4221 }
4222 #line 4223 "gram.c" /* yacc.c:1646 */
4223 break;
4224
4225 case 180:
4226 #line 1907 "gram.y" /* yacc.c:1646 */
4227 {
4228 (yyval.node) = alloc_node(node_type_un, &(yylsp[-1]));
4229 (yyval.node)->v.un.opcode = unary_lognot;
4230 (yyval.node)->v.un.arg = cast_to(dtype_number, (yyvsp[0].node));
4231 }
4232 #line 4233 "gram.c" /* yacc.c:1646 */
4233 break;
4234
4235 case 181:
4236 #line 1915 "gram.y" /* yacc.c:1646 */
4237 {
4238 (yyval.node) = create_node_symbol((yyvsp[0].literal), &(yylsp[0]));
4239 }
4240 #line 4241 "gram.c" /* yacc.c:1646 */
4241 break;
4242
4243 case 182:
4244 #line 1919 "gram.y" /* yacc.c:1646 */
4245 {
4246 (yyval.node) = alloc_node(node_type_number, &(yylsp[0]));
4247 (yyval.node)->v.number = (yyvsp[0].number);
4248 }
4249 #line 4250 "gram.c" /* yacc.c:1646 */
4250 break;
4251
4252 case 183:
4253 #line 1924 "gram.y" /* yacc.c:1646 */
4254 {
4255 (yyval.node) = create_node_backref((yyvsp[0].number), &(yylsp[0]));
4256 }
4257 #line 4258 "gram.c" /* yacc.c:1646 */
4258 break;
4259
4260 case 185:
4261 #line 1929 "gram.y" /* yacc.c:1646 */
4262 {
4263 (yyval.node) = create_node_argcount(&(yylsp[0]));
4264 }
4265 #line 4266 "gram.c" /* yacc.c:1646 */
4266 break;
4267
4268 case 186:
4269 #line 1933 "gram.y" /* yacc.c:1646 */
4270 {
4271 (yyval.node) = alloc_node(node_type_offset, &(yylsp[-1]));
4272 (yyval.node)->v.var_ref.variable = (yyvsp[0].var);
4273 (yyval.node)->v.var_ref.nframes = catch_nesting;
4274 }
4275 #line 4276 "gram.c" /* yacc.c:1646 */
4276 break;
4277
4278 case 187:
4279 #line 1939 "gram.y" /* yacc.c:1646 */
4280 {
4281 (yyval.node) = alloc_node(node_type_vaptr, &(yylsp[-1]));
4282 (yyval.node)->v.node = (yyvsp[0].node);
4283 }
4284 #line 4285 "gram.c" /* yacc.c:1646 */
4285 break;
4286
4287 case 190:
4288 #line 1948 "gram.y" /* yacc.c:1646 */
4289 {
4290 (yyval.node) = alloc_node(node_type_concat, &(yylsp[0]));
4291 (yyval.node)->v.concat.arg[0] = (yyvsp[-1].node);
4292 (yyval.node)->v.concat.arg[1] = (yyvsp[0].node);
4293 }
4294 #line 4295 "gram.c" /* yacc.c:1646 */
4295 break;
4296
4297 case 191:
4298 #line 1956 "gram.y" /* yacc.c:1646 */
4299 {
4300 (yyval.node) = alloc_node(node_type_string, &(yylsp[0]));
4301 (yyval.node)->v.literal = (yyvsp[0].literal);
4302 }
4303 #line 4304 "gram.c" /* yacc.c:1646 */
4304 break;
4305
4306 case 193:
4307 #line 1964 "gram.y" /* yacc.c:1646 */
4308 {
4309 (yyval.node) = create_node_variable((yyvsp[0].var), &(yylsp[0]));
4310 }
4311 #line 4312 "gram.c" /* yacc.c:1646 */
4312 break;
4313
4314 case 194:
4315 #line 1968 "gram.y" /* yacc.c:1646 */
4316 {
4317 (yyval.node) = create_node_arg((yyvsp[0].number), &(yylsp[0]));
4318 }
4319 #line 4320 "gram.c" /* yacc.c:1646 */
4320 break;
4321
4322 case 195:
4323 #line 1972 "gram.y" /* yacc.c:1646 */
4324 {
4325 if (outer_context == context_function) {
4326 if (func->varargs) {
4327 (yyval.node) = alloc_node(node_type_argx, &(yylsp[-3]));
4328 (yyval.node)->v.argx.nargs = PARMCOUNT() +
4329 FUNC_HIDDEN_ARGS(func);
4330 (yyval.node)->v.argx.node = (yyvsp[-1].node);
4331 } else {
4332 (yyval.node) = alloc_node(node_type_noop, &(yylsp[-3]));
4333 parse_error_locus(&(yylsp[-3]),
4334 _("$(expr) is allowed only "
4335 "in a function with "
4336 "variable number of "
4337 "arguments"));
4338 }
4339 } else {
4340 (yyval.node) = alloc_node(node_type_noop, &(yylsp[-3]));
4341 parse_error_locus(&(yylsp[-3]),
4342 _("$(expr) is allowed only "
4343 "in a function with "
4344 "variable number of "
4345 "arguments"));
4346 }
4347 }
4348 #line 4349 "gram.c" /* yacc.c:1646 */
4349 break;
4350
4351 case 197:
4352 #line 2000 "gram.y" /* yacc.c:1646 */
4353 {
4354 (yyval.node) = (yyvsp[-1].node);
4355 }
4356 #line 4357 "gram.c" /* yacc.c:1646 */
4357 break;
4358
4359 case 198:
4360 #line 2006 "gram.y" /* yacc.c:1646 */
4361 {
4362 if (check_builtin_usage((yyvsp[-3].builtin), &(yylsp[-3])))
4363 YYERROR;
4364
4365 if ((yyvsp[-3].builtin)->flags & MFD_BUILTIN_REGEX_FLAGS) {
4366 NODE *p = alloc_node(node_type_number, &(yylsp[-3]));
4367 p->v.number = regex_flags;
4368 p->next = (yyvsp[-1].arglist).head;
4369 (yyvsp[-1].arglist).head = p;
4370 (yyvsp[-1].arglist).count++;
4371 }
4372
4373 if ((yyvsp[-1].arglist).count < (yyvsp[-3].builtin)->parmcount - (yyvsp[-3].builtin)->optcount) {
4374 parse_error_locus(&(yylsp[-3]),
4375 _("too few arguments in call to `%s'"),
4376 (yyvsp[-3].builtin)->name);
4377 YYERROR;
4378 } else if ((yyvsp[-1].arglist).count > (yyvsp[-3].builtin)->parmcount
4379 && !((yyvsp[-3].builtin)->flags & MFD_BUILTIN_VARIADIC)) {
4380 parse_error_locus(&(yylsp[-3]),
4381 _("too many arguments in call to `%s'"),
4382 (yyvsp[-3].builtin)->name);
4383 YYERROR;
4384 } else {
4385 (yyval.node) = alloc_node(node_type_builtin, &(yylsp[-3]));
4386 (yyval.node)->v.builtin.builtin = (yyvsp[-3].builtin);
4387 (yyval.node)->v.builtin.args =
4388 reverse(cast_arg_list((yyvsp[-1].arglist).head,
4389 (yyvsp[-3].builtin)->parmcount,
4390 (yyvsp[-3].builtin)->parmtype,
4391 (yyval.node)->v.builtin.builtin->flags & MFD_BUILTIN_NO_PROMOTE));
4392 }
4393 }
4394 #line 4395 "gram.c" /* yacc.c:1646 */
4395 break;
4396
4397 case 199:
4398 #line 2040 "gram.y" /* yacc.c:1646 */
4399 {
4400 if (check_builtin_usage((yyvsp[-2].builtin), &(yylsp[-2])))
4401 YYERROR;
4402 if ((yyvsp[-2].builtin)->parmcount - (yyvsp[-2].builtin)->optcount) {
4403 parse_error_locus(&(yylsp[-2]),
4404 _("too few arguments in call to `%s'"),
4405 (yyvsp[-2].builtin)->name);
4406 YYERROR;
4407 } else {
4408 (yyval.node) = alloc_node(node_type_builtin, &(yylsp[-2]));
4409 (yyval.node)->v.builtin.builtin = (yyvsp[-2].builtin);
4410 (yyval.node)->v.builtin.args = NULL;
4411 }
4412 }
4413 #line 4414 "gram.c" /* yacc.c:1646 */
4414 break;
4415
4416 case 200:
4417 #line 2055 "gram.y" /* yacc.c:1646 */
4418 {
4419 NODE *arg, *expr;
4420
4421 if ((yyvsp[-1].arglist).count < 2) {
4422 parse_error_locus(&(yylsp[-3]),
4423 _("too few arguments in call to `%s'"),
4424 "sed");
4425 YYERROR;
4426 }
4427
4428 arg = cast_to(dtype_string, (yyvsp[-1].arglist).head);
4429 expr = (yyvsp[-1].arglist).head->next;
4430 /* Break the link between the args lest any eventual
4431 optimizations cause grief later in mark phase. */
4432 (yyvsp[-1].arglist).head->next = NULL;
4433
4434 do {
4435 NODE *comp, *next;
4436 struct mu_locus_range lr;
4437
4438 comp = alloc_node(node_type_sedcomp, &expr->locus);
4439 comp->v.sedcomp.index = next_transform_index();
4440 comp->v.sedcomp.expr = cast_to(dtype_string, expr);
4441 comp->v.sedcomp.flags = regex_flags;
4442
4443 lr.beg = (yylsp[-3]).beg;
4444 lr.end = expr->locus.end;
4445
4446 (yyval.node) = alloc_node(node_type_sed, &lr);
4447 (yyval.node)->v.sed.comp = comp;
4448 (yyval.node)->v.sed.arg = arg;
4449
4450 next = expr->next;
4451 expr->next = NULL;
4452 expr = next;
4453
4454 arg = (yyval.node);
4455 } while (expr);
4456 }
4457 #line 4458 "gram.c" /* yacc.c:1646 */
4458 break;
4459
4460 case 201:
4461 #line 2095 "gram.y" /* yacc.c:1646 */
4462 {
4463 if (check_func_usage((yyvsp[-3].function), &(yylsp[-3])))
4464 YYERROR;
4465 (yyval.node) = function_call((yyvsp[-3].function), (yyvsp[-1].arglist).count, (yyvsp[-1].arglist).head);
4466 if (!(yyval.node))
4467 YYERROR;
4468 }
4469 #line 4470 "gram.c" /* yacc.c:1646 */
4470 break;
4471
4472 case 202:
4473 #line 2103 "gram.y" /* yacc.c:1646 */
4474 {
4475 if (check_func_usage((yyvsp[-2].function), &(yylsp[-2])))
4476 YYERROR;
4477 (yyval.node) = function_call((yyvsp[-2].function), 0, NULL);
4478 if (!(yyval.node))
4479 YYERROR;
4480 }
4481 #line 4482 "gram.c" /* yacc.c:1646 */
4482 break;
4483
4484 case 203:
4485 #line 2113 "gram.y" /* yacc.c:1646 */
4486 {
4487 (yyvsp[0].node)->next = NULL;
4488 (yyval.arglist).head = (yyval.arglist).tail = (yyvsp[0].node);
4489 (yyval.arglist).count = 1;
4490 }
4491 #line 4492 "gram.c" /* yacc.c:1646 */
4492 break;
4493
4494 case 204:
4495 #line 2119 "gram.y" /* yacc.c:1646 */
4496 {
4497 (yyvsp[-2].arglist).tail->next = (yyvsp[0].node);
4498 (yyvsp[-2].arglist).tail = (yyvsp[0].node);
4499 (yyvsp[-2].arglist).count++;
4500 (yyval.arglist) = (yyvsp[-2].arglist);
4501 }
4502 #line 4503 "gram.c" /* yacc.c:1646 */
4503 break;
4504
4505 case 205:
4506 #line 2128 "gram.y" /* yacc.c:1646 */
4507 {
4508 add_xref((yyvsp[0].var), &(yylsp[0]));
4509 }
4510 #line 4511 "gram.c" /* yacc.c:1646 */
4511 break;
4512
4513 case 206:
4514 #line 2132 "gram.y" /* yacc.c:1646 */
4515 {
4516 YYERROR;
4517 }
4518 #line 4519 "gram.c" /* yacc.c:1646 */
4519 break;
4520
4521 case 207:
4522 #line 2138 "gram.y" /* yacc.c:1646 */
4523 {
4524 if (outer_context == context_function) {
4525 func->exmask->all |= (yyval.node)->v.catch.exmask->all;
4526 bitmask_merge(&func->exmask->bm,
4527 &(yyval.node)->v.catch.exmask->bm);
4528 }
4529 }
4530 #line 4531 "gram.c" /* yacc.c:1646 */
4531 break;
4532
4533 case 208:
4534 #line 2146 "gram.y" /* yacc.c:1646 */
4535 {
4536 (yyval.node) = alloc_node(node_type_try, &(yylsp[-1]));
4537 (yyval.node)->v.try.node = (yyvsp[-1].node);
4538 (yyval.node)->v.try.catch = (yyvsp[0].node);
4539 }
4540 #line 4541 "gram.c" /* yacc.c:1646 */
4541 break;
4542
4543 case 209:
4544 #line 2154 "gram.y" /* yacc.c:1646 */
4545 {
4546 (yyval.node) = (yyvsp[-1].stmtlist).head;
4547 }
4548 #line 4549 "gram.c" /* yacc.c:1646 */
4549 break;
4550
4551 case 210:
4552 #line 2161 "gram.y" /* yacc.c:1646 */
4553 { (yyval.tie_in) = inner_context;
4554 inner_context = context_catch;
4555 catch_nesting++; }
4556 #line 4557 "gram.c" /* yacc.c:1646 */
4557 break;
4558
4559 case 211:
4560 #line 2165 "gram.y" /* yacc.c:1646 */
4561 {
4562 int i;
4563 struct valist *p;
4564
4565 inner_context = (yyvsp[-2].tie_in);
4566 catch_nesting--;
4567 (yyval.node) = alloc_node(node_type_catch, &(yylsp[-5]));
4568 (yyval.node)->v.catch.exmask = exmask_create();
4569 (yyval.node)->v.catch.context = outer_context;/*??*/
4570 (yyval.node)->v.catch.exmask->all = (yyvsp[-4].catchlist).all;
4571 if (!(yyvsp[-4].catchlist).all) {
4572 for (i = 0, p = (yyvsp[-4].catchlist).valist; p; p = p->next, i++) {
4573 if (p->value.type != dtype_number) {
4574 parse_error_locus(&(yylsp[-5]),
4575 _("expected numeric value, but found `%s'"),
4576 p->value.v.literal->text);
4577 continue;
4578 }
4579 bitmask_set(&(yyval.node)->v.catch.exmask->bm,
4580 p->value.v.number);
4581 }
4582 }
4583 (yyval.node)->v.catch.node = (yyvsp[-1].stmtlist).head;
4584 }
4585 #line 4586 "gram.c" /* yacc.c:1646 */
4586 break;
4587
4588 case 212:
4589 #line 2192 "gram.y" /* yacc.c:1646 */
4590 {
4591 (yyval.catchlist).all = 1;
4592 }
4593 #line 4594 "gram.c" /* yacc.c:1646 */
4594 break;
4595
4596 case 213:
4597 #line 2196 "gram.y" /* yacc.c:1646 */
4598 {
4599 (yyval.catchlist).all = 0;
4600 (yyval.catchlist).valist = (yyvsp[0].valist_list).head;
4601 }
4602 #line 4603 "gram.c" /* yacc.c:1646 */
4603 break;
4604
4605 case 214:
4606 #line 2203 "gram.y" /* yacc.c:1646 */
4607 {
4608 (yyval.node) = alloc_node(node_type_throw, &(yylsp[-2]));
4609 if ((yyvsp[-1].value).type != dtype_number)
4610 parse_error_locus(&(yylsp[-1]),
4611 _("exception code not a number"));
4612 else if ((yyvsp[-1].value).v.number > exception_count)
4613 parse_error_locus(&(yylsp[-1]),
4614 _("invalid exception number: %lu"),
4615 (yyvsp[-1].value).v.number);
4616
4617 (yyval.node)->v.throw.code = (yyvsp[-1].value).v.number;
4618 (yyval.node)->v.throw.expr = cast_to(dtype_string, (yyvsp[0].node));
4619 }
4620 #line 4621 "gram.c" /* yacc.c:1646 */
4621 break;
4622
4623 case 215:
4624 #line 2219 "gram.y" /* yacc.c:1646 */
4625 {
4626 if (!func)
4627 parse_error_locus(&(yylsp[0]),
4628 _("`return' outside of a function"));
4629 else if (func->rettype != dtype_unspecified)
4630 parse_error_locus(&(yylsp[0]),
4631 _("`return' with no value, in function "
4632 "returning non-void"));
4633 (yyval.node) = alloc_node(node_type_return, &(yylsp[0]));
4634 (yyval.node)->v.node = NULL;
4635 }
4636 #line 4637 "gram.c" /* yacc.c:1646 */
4637 break;
4638
4639 case 216:
4640 #line 2231 "gram.y" /* yacc.c:1646 */
4641 {
4642 if (!func)
4643 parse_error_locus(&(yylsp[-1]),
4644 _("`return' outside of a function"));
4645 else {
4646 (yyval.node) = alloc_node(node_type_return, &(yylsp[-1]));
4647 if (func->rettype == dtype_unspecified) {
4648 parse_error_locus(&(yylsp[-1]),
4649 _("`return' with a value, in function "
4650 "returning void"));
4651 (yyval.node)->v.node = NULL;
4652 }
4653 else
4654 (yyval.node)->v.node = cast_to(func->rettype, (yyvsp[0].node));
4655 }
4656 }
4657 #line 4658 "gram.c" /* yacc.c:1646 */
4658 break;
4659
4660 case 217:
4661 #line 2250 "gram.y" /* yacc.c:1646 */
4662 {
4663 switch (node_type((yyvsp[0].node))) {
4664 case dtype_string:
4665 (yyval.node) = alloc_node(node_type_bin, &(yylsp[0]));
4666 (yyval.node)->v.bin.opcode = bin_ne;
4667 (yyval.node)->v.bin.arg[0] = (yyvsp[0].node);
4668 (yyval.node)->v.bin.arg[1] = alloc_node(node_type_string, &(yylsp[0]));
4669 (yyval.node)->v.bin.arg[1]->v.literal = literal_lookup("");
4670 break;
4671
4672 case dtype_number:
4673 case dtype_pointer:
4674 (yyval.node) = (yyvsp[0].node);
4675 break;
4676
4677 default:
4678 parse_error_locus(&(yylsp[0]),
4679 _("unspecified data type in conditional expression: please, report"));
4680 YYERROR;
4681 }
4682 }
4683 #line 4684 "gram.c" /* yacc.c:1646 */
4684 break;
4685
4686 case 218:
4687 #line 2278 "gram.y" /* yacc.c:1646 */
4688 {
4689 NODE *sel, *np;
4690 NODE *head = NULL, *tail;
4691 struct function *fp;
4692
4693 fp = function_lookup((yyvsp[-3].poll).client_addr ?
4694 "strictpoll" : "stdpoll");
4695 if (!fp) {
4696 parse_error_locus(&(yylsp[-4]),
4697 _("`on poll' used without prior `require poll'"));
4698 YYERROR;
4699 }
4700
4701 /* Build argument list */
4702 if ((yyvsp[-3].poll).client_addr) {
4703 head = tail = (yyvsp[-3].poll).client_addr;
4704 tail = (yyvsp[-3].poll).email;
4705 if (!tail) {
4706 parse_error_locus(&(yylsp[-3]),
4707 _("recipient address not specified "
4708 "in `on poll' construct"));
4709 YYERROR;
4710 }
4711 tail->next = NULL;
4712 head->next = tail;
4713 } else
4714 head = tail = (yyvsp[-3].poll).email;
4715
4716 if ((yyvsp[-3].poll).ehlo)
4717 np = (yyvsp[-3].poll).ehlo;
4718 else {
4719 /* FIXME: Pass NULL? */
4720 np = alloc_node(node_type_variable, &(yylsp[-3]));
4721 np->v.var_ref.variable =
4722 variable_lookup("ehlo_domain");
4723 np->v.var_ref.nframes = 0;
4724 }
4725 tail->next = np;
4726 tail = np;
4727
4728 if ((yyvsp[-3].poll).mailfrom)
4729 np = (yyvsp[-3].poll).mailfrom;
4730 else {
4731 /* FIXME: Pass NULL? */
4732 np = alloc_node(node_type_variable, &(yylsp[-3]));
4733 np->v.var_ref.variable =
4734 variable_lookup("mailfrom_address");
4735 np->v.var_ref.nframes = 0;
4736 }
4737 tail->next = np;
4738 tail = np;
4739
4740 sel = function_call(fp, nodelistlength(head), head);
4741
4742 (yyval.node) = alloc_node(node_type_switch, &(yylsp[-4]));
4743 (yyval.node)->v.switch_stmt.node = sel;
4744 (yyval.node)->v.switch_stmt.cases = (yyvsp[-1].case_list).head;
4745 }
4746 #line 4747 "gram.c" /* yacc.c:1646 */
4747 break;
4748
4749 case 219:
4750 #line 2337 "gram.y" /* yacc.c:1646 */
4751 {
4752 (yyval.node) = alloc_node(node_type_switch, &(yylsp[-4]));
4753 (yyval.node)->v.switch_stmt.node = (yyvsp[-3].node);
4754 (yyval.node)->v.switch_stmt.cases = (yyvsp[-1].case_list).head;
4755 }
4756 #line 4757 "gram.c" /* yacc.c:1646 */
4757 break;
4758
4759 case 220:
4760 #line 2345 "gram.y" /* yacc.c:1646 */
4761 {
4762 tie_in_onblock(1);
4763 }
4764 #line 4765 "gram.c" /* yacc.c:1646 */
4765 break;
4766
4767 case 221:
4768 #line 2351 "gram.y" /* yacc.c:1646 */
4769 {
4770 tie_in_onblock(0);
4771 }
4772 #line 4773 "gram.c" /* yacc.c:1646 */
4773 break;
4774
4775 case 222:
4776 #line 2357 "gram.y" /* yacc.c:1646 */
4777 {
4778 struct pollarg arg;
4779
4780 arg.kw = T_FOR;
4781 arg.expr = (yyvsp[0].node);
4782 memset(&(yyval.poll), 0, sizeof (yyval.poll));
4783 set_poll_arg(&(yyval.poll), arg.kw, arg.expr);
4784 }
4785 #line 4786 "gram.c" /* yacc.c:1646 */
4786 break;
4787
4788 case 223:
4789 #line 2366 "gram.y" /* yacc.c:1646 */
4790 {
4791 struct pollarg arg;
4792
4793 arg.kw = T_FOR;
4794 arg.expr = (yyvsp[-1].node);
4795 set_poll_arg(&(yyvsp[0].poll), arg.kw, arg.expr);
4796 (yyval.poll) = (yyvsp[0].poll);
4797 }
4798 #line 4799 "gram.c" /* yacc.c:1646 */
4799 break;
4800
4801 case 224:
4802 #line 2375 "gram.y" /* yacc.c:1646 */
4803 {
4804 (yyval.poll) = (yyvsp[0].poll);
4805 }
4806 #line 4807 "gram.c" /* yacc.c:1646 */
4807 break;
4808
4809 case 225:
4810 #line 2381 "gram.y" /* yacc.c:1646 */
4811 {
4812 memset(&(yyval.poll), 0, sizeof (yyval.poll));
4813 set_poll_arg(&(yyval.poll), (yyvsp[0].pollarg).kw, (yyvsp[0].pollarg).expr);
4814 }
4815 #line 4816 "gram.c" /* yacc.c:1646 */
4816 break;
4817
4818 case 226:
4819 #line 2386 "gram.y" /* yacc.c:1646 */
4820 {
4821 set_poll_arg(&(yyvsp[-1].poll), (yyvsp[0].pollarg).kw, (yyvsp[0].pollarg).expr);
4822 (yyval.poll) = (yyvsp[-1].poll);
4823 }
4824 #line 4825 "gram.c" /* yacc.c:1646 */
4825 break;
4826
4827 case 227:
4828 #line 2393 "gram.y" /* yacc.c:1646 */
4829 {
4830 (yyval.pollarg).kw = T_FOR;
4831 (yyval.pollarg).expr = (yyvsp[0].node);
4832 }
4833 #line 4834 "gram.c" /* yacc.c:1646 */
4834 break;
4835
4836 case 228:
4837 #line 2398 "gram.y" /* yacc.c:1646 */
4838 {
4839 (yyval.pollarg).kw = T_HOST;
4840 (yyval.pollarg).expr = (yyvsp[0].node);
4841 }
4842 #line 4843 "gram.c" /* yacc.c:1646 */
4843 break;
4844
4845 case 229:
4846 #line 2403 "gram.y" /* yacc.c:1646 */
4847 {
4848 (yyval.pollarg).kw = T_AS;
4849 (yyval.pollarg).expr = (yyvsp[0].node);
4850 }
4851 #line 4852 "gram.c" /* yacc.c:1646 */
4852 break;
4853
4854 case 230:
4855 #line 2408 "gram.y" /* yacc.c:1646 */
4856 {
4857 (yyval.pollarg).kw = T_FROM;
4858 (yyval.pollarg).expr = (yyvsp[0].node);
4859 }
4860 #line 4861 "gram.c" /* yacc.c:1646 */
4861 break;
4862
4863 case 231:
4864 #line 2416 "gram.y" /* yacc.c:1646 */
4865 {
4866 (yyval.case_list).head = (yyval.case_list).tail = (yyvsp[0].case_stmt);
4867 }
4868 #line 4869 "gram.c" /* yacc.c:1646 */
4869 break;
4870
4871 case 232:
4872 #line 2420 "gram.y" /* yacc.c:1646 */
4873 {
4874 (yyvsp[-1].case_list).tail->next = (yyvsp[0].case_stmt);
4875 (yyvsp[-1].case_list).tail = (yyvsp[0].case_stmt);
4876 (yyval.case_list) = (yyvsp[-1].case_list);
4877 }
4878 #line 4879 "gram.c" /* yacc.c:1646 */
4879 break;
4880
4881 case 233:
4882 #line 2428 "gram.y" /* yacc.c:1646 */
4883 {
4884 struct valist *p;
4885
4886 for (p = (yyvsp[-2].valist_list).head; p; p = p->next) {
4887 if (p->value.type == dtype_string) {
4888 parse_error_locus(&(yylsp[-2]),
4889 _("invalid data type, "
4890 "expected number"));
4891 /* Try to continue */
4892 p->value.type = dtype_number;
4893 p->value.v.number = 0;
4894 }
4895 }
4896
4897 (yyval.case_stmt) = mu_alloc(sizeof *(yyval.case_stmt));
4898 (yyval.case_stmt)->next = NULL;
4899 mu_locus_range_init (&(yyval.case_stmt)->locus);
4900 mu_locus_range_copy (&(yyval.case_stmt)->locus, &(yylsp[-3]));
4901 (yyval.case_stmt)->valist = (yyvsp[-2].valist_list).head;
4902 (yyval.case_stmt)->node = (yyvsp[0].stmtlist).head;
4903 }
4904 #line 4905 "gram.c" /* yacc.c:1646 */
4905 break;
4906
4907
4908 #line 4909 "gram.c" /* yacc.c:1646 */
4909 default: break;
4910 }
4911 /* User semantic actions sometimes alter yychar, and that requires
4912 that yytoken be updated with the new translation. We take the
4913 approach of translating immediately before every use of yytoken.
4914 One alternative is translating here after every semantic action,
4915 but that translation would be missed if the semantic action invokes
4916 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
4917 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
4918 incorrect destructor might then be invoked immediately. In the
4919 case of YYERROR or YYBACKUP, subsequent parser actions might lead
4920 to an incorrect destructor call or verbose syntax error message
4921 before the lookahead is translated. */
4922 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
4923
4924 YYPOPSTACK (yylen);
4925 yylen = 0;
4926 YY_STACK_PRINT (yyss, yyssp);
4927
4928 *++yyvsp = yyval;
4929 *++yylsp = yyloc;
4930
4931 /* Now 'shift' the result of the reduction. Determine what state
4932 that goes to, based on the state we popped back to and the rule
4933 number reduced by. */
4934
4935 yyn = yyr1[yyn];
4936
4937 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
4938 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4939 yystate = yytable[yystate];
4940 else
4941 yystate = yydefgoto[yyn - YYNTOKENS];
4942
4943 goto yynewstate;
4944
4945
4946 /*--------------------------------------.
4947 | yyerrlab -- here on detecting error. |
4948 `--------------------------------------*/
4949 yyerrlab:
4950 /* Make sure we have latest lookahead translation. See comments at
4951 user semantic actions for why this is necessary. */
4952 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
4953
4954 /* If not already recovering from an error, report this error. */
4955 if (!yyerrstatus)
4956 {
4957 ++yynerrs;
4958 #if ! YYERROR_VERBOSE
4959 yyerror (YY_("syntax error"));
4960 #else
4961 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
4962 yyssp, yytoken)
4963 {
4964 char const *yymsgp = YY_("syntax error");
4965 int yysyntax_error_status;
4966 yysyntax_error_status = YYSYNTAX_ERROR;
4967 if (yysyntax_error_status == 0)
4968 yymsgp = yymsg;
4969 else if (yysyntax_error_status == 1)
4970 {
4971 if (yymsg != yymsgbuf)
4972 YYSTACK_FREE (yymsg);
4973 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
4974 if (!yymsg)
4975 {
4976 yymsg = yymsgbuf;
4977 yymsg_alloc = sizeof yymsgbuf;
4978 yysyntax_error_status = 2;
4979 }
4980 else
4981 {
4982 yysyntax_error_status = YYSYNTAX_ERROR;
4983 yymsgp = yymsg;
4984 }
4985 }
4986 yyerror (yymsgp);
4987 if (yysyntax_error_status == 2)
4988 goto yyexhaustedlab;
4989 }
4990 # undef YYSYNTAX_ERROR
4991 #endif
4992 }
4993
4994 yyerror_range[1] = yylloc;
4995
4996 if (yyerrstatus == 3)
4997 {
4998 /* If just tried and failed to reuse lookahead token after an
4999 error, discard it. */
5000
5001 if (yychar <= YYEOF)
5002 {
5003 /* Return failure if at end of input. */
5004 if (yychar == YYEOF)
5005 YYABORT;
5006 }
5007 else
5008 {
5009 yydestruct ("Error: discarding",
5010 yytoken, &yylval, &yylloc);
5011 yychar = YYEMPTY;
5012 }
5013 }
5014
5015 /* Else will try to reuse lookahead token after shifting the error
5016 token. */
5017 goto yyerrlab1;
5018
5019
5020 /*---------------------------------------------------.
5021 | yyerrorlab -- error raised explicitly by YYERROR. |
5022 `---------------------------------------------------*/
5023 yyerrorlab:
5024
5025 /* Pacify compilers like GCC when the user code never invokes
5026 YYERROR and the label yyerrorlab therefore never appears in user
5027 code. */
5028 if (/*CONSTCOND*/ 0)
5029 goto yyerrorlab;
5030
5031 yyerror_range[1] = yylsp[1-yylen];
5032 /* Do not reclaim the symbols of the rule whose action triggered
5033 this YYERROR. */
5034 YYPOPSTACK (yylen);
5035 yylen = 0;
5036 YY_STACK_PRINT (yyss, yyssp);
5037 yystate = *yyssp;
5038 goto yyerrlab1;
5039
5040
5041 /*-------------------------------------------------------------.
5042 | yyerrlab1 -- common code for both syntax error and YYERROR. |
5043 `-------------------------------------------------------------*/
5044 yyerrlab1:
5045 yyerrstatus = 3; /* Each real token shifted decrements this. */
5046
5047 for (;;)
5048 {
5049 yyn = yypact[yystate];
5050 if (!yypact_value_is_default (yyn))
5051 {
5052 yyn += YYTERROR;
5053 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5054 {
5055 yyn = yytable[yyn];
5056 if (0 < yyn)
5057 break;
5058 }
5059 }
5060
5061 /* Pop the current state because it cannot handle the error token. */
5062 if (yyssp == yyss)
5063 YYABORT;
5064
5065 yyerror_range[1] = *yylsp;
5066 yydestruct ("Error: popping",
5067 yystos[yystate], yyvsp, yylsp);
5068 YYPOPSTACK (1);
5069 yystate = *yyssp;
5070 YY_STACK_PRINT (yyss, yyssp);
5071 }
5072
5073 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
5074 *++yyvsp = yylval;
5075 YY_IGNORE_MAYBE_UNINITIALIZED_END
5076
5077 yyerror_range[2] = yylloc;
5078 /* Using YYLLOC is tempting, but would change the location of
5079 the lookahead. YYLOC is available though. */
5080 YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
5081 *++yylsp = yyloc;
5082
5083 /* Shift the error token. */
5084 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
5085
5086 yystate = yyn;
5087 goto yynewstate;
5088
5089
5090 /*-------------------------------------.
5091 | yyacceptlab -- YYACCEPT comes here. |
5092 `-------------------------------------*/
5093 yyacceptlab:
5094 yyresult = 0;
5095 goto yyreturn;
5096
5097 /*-----------------------------------.
5098 | yyabortlab -- YYABORT comes here. |
5099 `-----------------------------------*/
5100 yyabortlab:
5101 yyresult = 1;
5102 goto yyreturn;
5103
5104 #if !defined yyoverflow || YYERROR_VERBOSE
5105 /*-------------------------------------------------.
5106 | yyexhaustedlab -- memory exhaustion comes here. |
5107 `-------------------------------------------------*/
5108 yyexhaustedlab:
5109 yyerror (YY_("memory exhausted"));
5110 yyresult = 2;
5111 /* Fall through. */
5112 #endif
5113
5114 yyreturn:
5115 if (yychar != YYEMPTY)
5116 {
5117 /* Make sure we have latest lookahead translation. See comments at
5118 user semantic actions for why this is necessary. */
5119 yytoken = YYTRANSLATE (yychar);
5120 yydestruct ("Cleanup: discarding lookahead",
5121 yytoken, &yylval, &yylloc);
5122 }
5123 /* Do not reclaim the symbols of the rule whose action triggered
5124 this YYABORT or YYACCEPT. */
5125 YYPOPSTACK (yylen);
5126 YY_STACK_PRINT (yyss, yyssp);
5127 while (yyssp != yyss)
5128 {
5129 yydestruct ("Cleanup: popping",
5130 yystos[*yyssp], yyvsp, yylsp);
5131 YYPOPSTACK (1);
5132 }
5133 #ifndef yyoverflow
5134 if (yyss != yyssa)
5135 YYSTACK_FREE (yyss);
5136 #endif
5137 #if YYERROR_VERBOSE
5138 if (yymsg != yymsgbuf)
5139 YYSTACK_FREE (yymsg);
5140 #endif
5141 return yyresult;
5142 }
5143 #line 2451 "gram.y" /* yacc.c:1906 */
5144
5145
5146 int
yyerror(char const * s)5147 yyerror(char const *s)
5148 {
5149 parse_error("%s", s);
5150 return 0;
5151 }
5152
5153 struct stream_state
5154 {
5155 int mode;
5156 struct mu_locus_range loc;
5157 int sevmask;
5158 };
5159
5160 void
stream_state_save(mu_stream_t str,struct stream_state * st)5161 stream_state_save(mu_stream_t str, struct stream_state *st)
5162 {
5163 mu_stream_ioctl(mu_strerr, MU_IOCTL_LOGSTREAM,
5164 MU_IOCTL_LOGSTREAM_GET_MODE, &st->mode);
5165 mu_locus_range_init(&st->loc);
5166 mu_stream_ioctl(mu_strerr, MU_IOCTL_LOGSTREAM,
5167 MU_IOCTL_LOGSTREAM_GET_LOCUS_RANGE, &st->loc);
5168 mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
5169 MU_IOCTL_LOGSTREAM_GET_SEVERITY_MASK,
5170 &st->sevmask);
5171 }
5172
5173 void
stream_state_restore(mu_stream_t str,struct stream_state * st)5174 stream_state_restore(mu_stream_t str, struct stream_state *st)
5175 {
5176 mu_stream_ioctl(mu_strerr, MU_IOCTL_LOGSTREAM,
5177 MU_IOCTL_LOGSTREAM_SET_MODE, &st->mode);
5178 mu_stream_ioctl(mu_strerr, MU_IOCTL_LOGSTREAM,
5179 MU_IOCTL_LOGSTREAM_SET_LOCUS_RANGE, &st->loc);
5180 mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
5181 MU_IOCTL_LOGSTREAM_SET_SEVERITY_MASK,
5182 &st->sevmask);
5183 mu_locus_range_deinit(&st->loc);
5184 }
5185
5186 int
parse_program(char * name,int ydebug)5187 parse_program(char *name, int ydebug)
5188 {
5189 int rc;
5190 struct stream_state st;
5191 int mode;
5192
5193 stream_state_save(mu_strerr, &st);
5194
5195 mode = st.mode | MU_LOGMODE_LOCUS | MU_LOGMODE_SEVERITY;
5196 mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
5197 MU_IOCTL_LOGSTREAM_SET_MODE, &mode);
5198 mode = MU_DEBUG_LEVEL_MASK (MU_DIAG_ERROR);
5199 mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
5200 MU_IOCTL_LOGSTREAM_SET_SEVERITY_MASK,
5201 &mode);
5202
5203 yydebug = ydebug;
5204 if (lex_new_source(name, 0))
5205 return -1;
5206 outer_context = inner_context = context_none;
5207 catch_nesting = 0;
5208 code_immediate(NULL, ptr); /* Reserve 0 slot */
5209 rc = yyparse() + error_count;
5210
5211 stream_state_restore(mu_strerr, &st);
5212
5213 return rc;
5214 }
5215
5216 static void
alloc_locus(struct mu_locus_range const * locus)5217 alloc_locus(struct mu_locus_range const *locus)
5218 {
5219 struct literal *lit;
5220 if (locus->beg.mu_file) {
5221 lit = string_alloc(locus->beg.mu_file,
5222 strlen(locus->beg.mu_file));
5223 lit->flags |= SYM_REFERENCED;
5224 }
5225 if (!mu_locus_point_same_file(&locus->beg, &locus->end)) {
5226 lit = string_alloc(locus->end.mu_file,
5227 strlen(locus->end.mu_file));
5228 lit->flags |= SYM_REFERENCED;
5229 }
5230 }
5231
5232 NODE *
alloc_node(enum node_type type,struct mu_locus_range const * locus)5233 alloc_node(enum node_type type, struct mu_locus_range const *locus)
5234 {
5235 NODE *node = malloc(sizeof(*node));
5236 if (!node) {
5237 yyerror("Not enough memory");
5238 abort();
5239 }
5240 node->type = type;
5241 mu_locus_range_init (&node->locus);
5242 mu_locus_range_copy (&node->locus, locus);
5243 alloc_locus(locus);
5244 node->next = NULL;
5245 return node;
5246 }
5247
5248 void
free_node(NODE * node)5249 free_node(NODE *node)
5250 {
5251 mu_locus_range_deinit(&node->locus);
5252 free(node);
5253 }
5254
5255 void
copy_node(NODE * dest,NODE * src)5256 copy_node(NODE *dest, NODE *src)
5257 {
5258 dest->type = src->type;
5259 mu_locus_range_copy (&dest->locus, &src->locus);
5260 dest->v = src->v;
5261 }
5262
5263 void
free_subtree(NODE * node)5264 free_subtree(NODE *node)
5265 {
5266 /*FIXME*/
5267 }
5268
5269 void
free_parser_data()5270 free_parser_data()
5271 {
5272 /*FIXME*/
5273 }
5274
5275
5276 /* Print parse tree */
5277
5278 static void print_node_list(NODE *node, int indent);
5279 static void print_node_list_reverse(NODE *node, int level);
5280 static void print_node(NODE *node, int indent);
5281 void print_stat(sfsistat stat);
5282 static int dbg_setreply(void *data, char *code, char *xcode, char *message);
5283 static void dbg_msgmod(void *data, struct msgmod_closure *clos);
5284
5285 static void
print_level(int level)5286 print_level(int level)
5287 {
5288 level *= 2;
5289 printf("%*.*s", level, level, "");
5290 }
5291
5292 static void
print_bin_op(enum bin_opcode opcode)5293 print_bin_op(enum bin_opcode opcode)
5294 {
5295 char *p;
5296 switch (opcode) {
5297 case bin_and:
5298 p = "AND";
5299 break;
5300
5301 case bin_or:
5302 p = "OR";
5303 break;
5304
5305 case bin_eq:
5306 p = "EQ";
5307 break;
5308
5309 case bin_ne:
5310 p = "NE";
5311 break;
5312
5313 case bin_lt:
5314 p = "LT";
5315 break;
5316
5317 case bin_le:
5318 p = "LE";
5319 break;
5320
5321 case bin_gt:
5322 p = "GT";
5323 break;
5324
5325 case bin_ge:
5326 p = "GE";
5327 break;
5328
5329 case bin_match:
5330 p = "MATCH";
5331 break;
5332
5333 case bin_fnmatch:
5334 p = "FNMATCH";
5335 break;
5336
5337 case bin_add:
5338 p = "ADD";
5339 break;
5340
5341 case bin_sub:
5342 p = "SUB";
5343 break;
5344
5345 case bin_mul:
5346 p = "MUL";
5347 break;
5348
5349 case bin_div:
5350 p = "DIV";
5351 break;
5352
5353 case bin_mod:
5354 p = "MOD";
5355 break;
5356
5357 case bin_logand:
5358 p = "LOGAND";
5359 break;
5360
5361 case bin_logor:
5362 p = "LOGOR";
5363 break;
5364
5365 case bin_logxor:
5366 p = "LOGXOR";
5367 break;
5368
5369 case bin_shl:
5370 p = "SHL";
5371 break;
5372
5373 case bin_shr:
5374 p = "SHR";
5375 break;
5376
5377 default:
5378 p = "UNKNOWN_OP";
5379 }
5380 printf("%s", p);
5381 }
5382
5383 static void
print_quoted_string(const char * str)5384 print_quoted_string(const char *str)
5385 {
5386 for (; *str; str++) {
5387 if (mu_isprint(*str))
5388 putchar(*str);
5389 else {
5390 putchar('\\');
5391 switch (*str) {
5392 case '\a':
5393 putchar('a');
5394 break;
5395 case '\b':
5396 putchar('b');
5397 break;
5398 case '\f':
5399 putchar('f');
5400 break;
5401 case '\n':
5402 putchar('n');
5403 break;
5404 case '\r':
5405 putchar('r');
5406 break;
5407 case '\t':
5408 putchar('t');
5409 break;
5410 default:
5411 printf("%03o", *str);
5412 }
5413 }
5414 }
5415 }
5416
5417 struct node_drv {
5418 void (*print) (NODE *, int);
5419 void (*mark) (NODE *);
5420 void (*code) (NODE *, struct mu_locus_range const **);
5421 void (*optimize) (NODE *);
5422 };
5423
5424 static void traverse_tree(NODE *node);
5425 static void code_node(NODE *node);
5426 static void code_node(NODE *node);
5427 static void optimize_node(NODE *node);
5428 static void optimize(NODE *node);
5429 static void record_switch(struct switch_stmt *sw);
5430
5431 #include "drivers.c"
5432 #include "node-tab.c"
5433
5434 struct node_drv *
find_node_drv(enum node_type type)5435 find_node_drv(enum node_type type)
5436 {
5437 if (type >= NELEMS(nodetab)) {
5438 parse_error(_("INTERNAL ERROR at %s:%d, "
5439 "unexpected node type %d"),
5440 __FILE__, __LINE__,
5441 type);
5442 abort();
5443 }
5444 return nodetab + type;
5445 }
5446
5447 static void
print_node(NODE * node,int level)5448 print_node(NODE *node, int level)
5449 {
5450 struct node_drv *nd = find_node_drv(node->type);
5451 if (nd->print)
5452 nd->print(node, level);
5453 }
5454
5455 static void
print_node_list(NODE * node,int level)5456 print_node_list(NODE *node, int level)
5457 {
5458 for (; node; node = node->next)
5459 print_node(node, level);
5460 }
5461
5462 static void
print_node_list_reverse(NODE * node,int level)5463 print_node_list_reverse(NODE *node, int level)
5464 {
5465 if (node) {
5466 print_node_list_reverse(node->next, level);
5467 print_node(node, level);
5468 }
5469 }
5470
5471 int
function_enumerator(void * sym,void * data)5472 function_enumerator(void *sym, void *data)
5473 {
5474 int i;
5475 struct function *fsym = sym;
5476 struct function *f =
5477 (struct function *)symbol_resolve_alias(&fsym->sym);
5478 struct module *mod = data;
5479
5480 if (f->sym.module != mod)
5481 return 0;
5482 printf("function %s (", f->sym.name);
5483 for (i = 0; i < f->parmcount; i++) {
5484 printf("%s", type_to_string(f->parmtype[i]));
5485 if (i < f->parmcount-1)
5486 putchar(',');
5487 }
5488 putchar(')');
5489 if (f->rettype != dtype_unspecified)
5490 printf(" returns %s", type_to_string(f->rettype));
5491 printf(":\n");
5492 print_node_list(f->node, 0);
5493 printf("END function %s\n", f->sym.name);
5494 return 0;
5495 }
5496
5497 void
print_syntax_tree()5498 print_syntax_tree()
5499 {
5500 struct module **modv;
5501 size_t i, modc;
5502
5503 enum smtp_state tag;
5504
5505 printf("State handlers:\n");
5506 printf("---------------\n");
5507 for (tag = smtp_state_first; tag < smtp_state_count; tag++) {
5508 if (root_node[tag]) {
5509 printf("%s:\n", state_to_string(tag));
5510 print_node_list(root_node[tag], 0);
5511 putchar('\n');
5512 }
5513 }
5514 printf("User functions:\n");
5515 printf("---------------\n");
5516
5517 collect_modules(&modv, &modc);
5518 for (i = 0; i < modc; i++) {
5519 size_t n;
5520
5521 n = printf("Module %s (%s)\n", modv[i]->name,
5522 modv[i]->file);
5523 while (n--)
5524 putchar('-');
5525 putchar('\n');
5526 symtab_enumerate(MODULE_SYMTAB(modv[i], namespace_function),
5527 function_enumerator, modv[i]);
5528 putchar('\n');
5529 }
5530 free(modv);
5531 }
5532
5533
5534 /* Cross-reference support */
5535
5536 struct collect_data {
5537 mu_opool_t pool;
5538 size_t count;
5539 };
5540
5541 static int
variable_enumerator(void * item,void * data)5542 variable_enumerator(void *item, void *data)
5543 {
5544 struct variable *var = item;
5545 struct collect_data *p = data;
5546 if (var->sym.flags & (SYM_VOLATILE | SYM_REFERENCED)) {
5547 mu_opool_append(p->pool, &var, sizeof var);
5548 p->count++;
5549 }
5550 return 0;
5551 }
5552
5553 int
print_locus(void * item,void * data)5554 print_locus(void *item, void *data)
5555 {
5556 struct mu_locus_range *loc = item;
5557 struct mu_locus_range **prev = data;
5558 int c;
5559
5560 if (!*prev) {
5561 *prev = loc;
5562 printf("%s", loc->beg.mu_file);
5563 c = ':';
5564 } else if (mu_locus_point_same_file (&(*prev)->beg, &loc->beg)) {
5565 *prev = loc;
5566 printf(", %s", loc->beg.mu_file);
5567 c = ':';
5568 } else
5569 c = ',';
5570 printf("%c%u", c, loc->beg.mu_line);
5571 return 0;
5572 }
5573
5574 void
print_xref_var(struct variable * var)5575 print_xref_var(struct variable *var)
5576 {
5577 struct mu_locus_range *prev = NULL;
5578 var = (struct variable *)symbol_resolve_alias(&var->sym);
5579 printf("%-32.32s %6s %lu ",
5580 var->sym.name, type_to_string(var->type),
5581 (unsigned long)var->off);
5582 mu_list_foreach(var->xref, print_locus, &prev);
5583 printf("\n");
5584 }
5585
5586 int
vp_comp(const void * a,const void * b)5587 vp_comp(const void *a, const void *b)
5588 {
5589 struct variable * const *va = a, * const *vb = b;
5590 return strcmp((*va)->sym.name, (*vb)->sym.name);
5591 }
5592
5593 void
print_xref()5594 print_xref()
5595 {
5596 struct collect_data cd;
5597 struct variable **vp;
5598 size_t i;
5599
5600 mu_opool_create(&cd.pool, MU_OPOOL_ENOMEMABRT);
5601 cd.count = 0;
5602 symtab_enumerate(TOP_MODULE_SYMTAB(namespace_variable),
5603 variable_enumerator, &cd);
5604 printf("Cross-references:\n");
5605 printf("-----------------\n");
5606
5607 vp = mu_opool_finish(cd.pool, NULL);
5608 qsort(vp, cd.count, sizeof *vp, vp_comp);
5609 for (i = 0; i < cd.count; i++, vp++)
5610 print_xref_var(*vp);
5611 mu_opool_destroy(&cd.pool);
5612 }
5613
5614
5615 static mu_list_t smtp_macro_list[gacopyz_stage_max];
5616
5617 static enum gacopyz_stage
smtp_to_gacopyz_stage(enum smtp_state tag)5618 smtp_to_gacopyz_stage(enum smtp_state tag)
5619 {
5620 switch (tag) {
5621 case smtp_state_connect:
5622 return gacopyz_stage_conn;
5623 case smtp_state_helo:
5624 return gacopyz_stage_helo;
5625 case smtp_state_envfrom:
5626 return gacopyz_stage_mail;
5627 case smtp_state_envrcpt:
5628 return gacopyz_stage_rcpt;
5629 case smtp_state_data:
5630 case smtp_state_header:
5631 case smtp_state_body:
5632 return gacopyz_stage_data;
5633 case smtp_state_eoh:
5634 return gacopyz_stage_eoh;
5635 case smtp_state_eom:
5636 return gacopyz_stage_eom;
5637 default:
5638 break;
5639 }
5640 return gacopyz_stage_none;
5641 }
5642
5643 static int
compare_macro_names(const void * item,const void * data)5644 compare_macro_names (const void *item, const void *data)
5645 {
5646 const char *elt;
5647 size_t elen;
5648 const char *arg;
5649 size_t alen;
5650
5651 elt = item;
5652 elen = strlen (elt);
5653 if (elt[0] == '{') {
5654 elt++;
5655 elen -= 2;
5656 }
5657
5658 arg = data;
5659 alen = strlen (arg);
5660 if (arg[0] == '{') {
5661 arg++;
5662 alen -= 2;
5663 }
5664
5665 if (alen != elen)
5666 return 1;
5667 return memcmp (elt, arg, alen);
5668 }
5669
5670 void
register_macro(enum smtp_state state,const char * macro)5671 register_macro(enum smtp_state state, const char *macro)
5672 {
5673 enum gacopyz_stage ind = smtp_to_gacopyz_stage(state);
5674
5675 if (ind == gacopyz_stage_none)
5676 return;
5677 if (!smtp_macro_list[ind]) {
5678 mu_list_create(&smtp_macro_list[ind]);
5679 mu_list_set_comparator(smtp_macro_list[ind],
5680 compare_macro_names);
5681 }
5682 /* FIXME: MU: 2nd arg should be const? */
5683 if (mu_list_locate(smtp_macro_list[ind], (void*) macro, NULL)) {
5684 char *cmacro;
5685 if (macro[1] == 0 || macro[0] == '{')
5686 cmacro = mu_strdup (macro);
5687 else {
5688 size_t mlen = strlen (macro);
5689 cmacro = mu_alloc (mlen + 3);
5690 cmacro[0] = '{';
5691 memcpy (cmacro + 1, macro, mlen);
5692 cmacro[mlen + 1] = '}';
5693 cmacro[mlen + 2] = 0;
5694 }
5695 mu_list_append(smtp_macro_list[ind], cmacro);
5696 }
5697 }
5698
5699 static int
print_macro(void * item,void * data)5700 print_macro(void *item, void *data)
5701 {
5702 int *p = data;
5703 if (*p) {
5704 printf(" ");
5705 *p = 0;
5706 } else
5707 printf(", ");
5708 printf("%s", (char*) item);
5709 return 0;
5710 }
5711
5712 void
print_used_macros()5713 print_used_macros()
5714 {
5715 enum gacopyz_stage i;
5716
5717 for (i = 0; i < gacopyz_stage_max; i++) {
5718 if (smtp_macro_list[i]) {
5719 int n = 1;
5720 printf("%s", gacopyz_stage_name[i]);
5721 mu_list_foreach(smtp_macro_list[i], print_macro, &n);
5722 printf("\n");
5723 }
5724 }
5725 }
5726
5727 struct macro_acc {
5728 size_t size;
5729 char *buf;
5730 };
5731
5732 static int
add_macro_size(void * item,void * data)5733 add_macro_size(void *item, void *data)
5734 {
5735 char *macro = (char*) item;
5736 struct macro_acc *mp = data;
5737 mp->size += strlen(macro) + 1;
5738 return 0;
5739 }
5740
5741 static int
concat_macro(void * item,void * data)5742 concat_macro(void *item, void *data)
5743 {
5744 char *macro = (char*) item;
5745 struct macro_acc *mp = data;
5746 size_t len = strlen(macro);
5747 char *pbuf = mp->buf + mp->size;
5748 memcpy(pbuf, macro, len);
5749 pbuf[len++] = ' ';
5750 mp->size += len;
5751 return 0;
5752 }
5753
5754 char *
get_stage_macro_string(enum gacopyz_stage i)5755 get_stage_macro_string(enum gacopyz_stage i)
5756 {
5757 struct macro_acc acc;
5758 size_t size;
5759 mu_list_t list = smtp_macro_list[i];
5760 if (!list)
5761 return NULL;
5762
5763 acc.size = 0;
5764 mu_list_foreach(list, add_macro_size, &acc);
5765 if (!acc.size)
5766 return NULL;
5767 size = acc.size;
5768
5769 acc.size = 0;
5770 acc.buf = mu_alloc (size);
5771 mu_list_foreach(list, concat_macro, &acc);
5772 acc.buf[size-1] = 0;
5773 return acc.buf;
5774 }
5775
5776
5777 /* Code generation */
5778
5779 static void
code_node(NODE * node)5780 code_node(NODE *node)
5781 {
5782 if (!node)
5783 error_count++;
5784 else {
5785 static struct mu_locus_range const *old_locus;
5786 struct node_drv *nd = find_node_drv(node->type);
5787 if (nd->code)
5788 nd->code(node, &old_locus);
5789 }
5790 }
5791
5792 static void
traverse_tree(NODE * node)5793 traverse_tree(NODE *node)
5794 {
5795 for (; node; node = node->next)
5796 code_node(node);
5797 }
5798
5799 static void
optimize_node(NODE * node)5800 optimize_node(NODE *node)
5801 {
5802 if (!node)
5803 error_count++;
5804 else {
5805 struct node_drv *nd = find_node_drv(node->type);
5806 if (nd->optimize)
5807 nd->optimize(node);
5808 }
5809 }
5810
5811 static void
optimize(NODE * node)5812 optimize(NODE *node)
5813 {
5814 for (; node; node = node->next)
5815 optimize_node(node);
5816 }
5817
5818 static int
optimize_tree(NODE * node)5819 optimize_tree(NODE *node)
5820 {
5821 if (optimization_level)
5822 optimize(node);
5823 return error_count;
5824 }
5825
5826
5827 static struct switch_stmt *switch_root;
5828
5829 static void
record_switch(struct switch_stmt * sw)5830 record_switch(struct switch_stmt *sw)
5831 {
5832 sw->next = switch_root;
5833 switch_root = sw;
5834 }
5835
5836
5837 static struct exmask *exmask_root;
5838
5839 struct exmask *
exmask_create()5840 exmask_create()
5841 {
5842 struct exmask *p = mu_alloc(sizeof(*p));
5843 p->next = exmask_root;
5844 p->off = 0;
5845 p->all = 0;
5846 bitmask_init(&p->bm);
5847 exmask_root = p;
5848 return p;
5849 }
5850
5851
5852
5853 static void
mark_node(NODE * node)5854 mark_node(NODE *node)
5855 {
5856 if (!node)
5857 error_count++;
5858 else {
5859 struct node_drv *nd = find_node_drv(node->type);
5860 if (nd->mark)
5861 nd->mark(node);
5862 }
5863 }
5864
5865 static void
mark(NODE * node)5866 mark(NODE *node)
5867 {
5868 for (; node; node = node->next)
5869 mark_node(node);
5870 }
5871
5872
5873 static int
codegen(prog_counter_t * pc,NODE * node,struct exmask * exmask,int finalize,size_t nautos)5874 codegen(prog_counter_t *pc, NODE *node, struct exmask *exmask,
5875 int finalize, size_t nautos)
5876 {
5877 int save_mask;
5878
5879 if (error_count)
5880 return 1;
5881
5882 *pc = code_get_counter();
5883 jump_pc = 0;
5884 if (nautos) {
5885 code_op(opcode_stkalloc);
5886 code_immediate(nautos, uint);
5887 }
5888 save_mask = exmask && bitmask_nset(&exmask->bm);
5889 if (save_mask) {
5890 code_op(opcode_saveex);
5891 code_exmask(exmask);
5892 }
5893 traverse_tree(node);
5894
5895 jump_fixup(jump_pc, code_get_counter());
5896 if (save_mask)
5897 code_op(opcode_restex);
5898
5899 if (finalize)
5900 code_op(opcode_nil);
5901 else
5902 code_op(opcode_return);
5903
5904 return 0;
5905 }
5906
5907 static void
compile_tree(NODE * node)5908 compile_tree(NODE *node)
5909 {
5910 struct node_drv *nd;
5911 struct mu_locus_range const *plocus;
5912
5913 for (; node; node = node->next) {
5914 switch (node->type) {
5915 case node_type_progdecl:
5916 case node_type_funcdecl:
5917 nd = find_node_drv(node->type);
5918 if (!nd->code)
5919 abort();
5920 nd->code(node, &plocus);
5921 break;
5922
5923 default:
5924 parse_error_locus(&node->locus,
5925 _("INTERNAL ERROR at %s:%d, "
5926 "unexpected node type %d"),
5927 __FILE__, __LINE__,
5928 node->type);
5929 break;
5930 }
5931 }
5932 }
5933
5934
5935
5936
5937 enum regex_mode { regex_enable, regex_disable, regex_set };
5938
5939 static mf_stack_t regex_stack;
5940
5941 void
regex_push()5942 regex_push()
5943 {
5944 if (!regex_stack)
5945 regex_stack = mf_stack_create(sizeof regex_flags, 0);
5946 mf_stack_push(regex_stack, ®ex_flags);
5947 }
5948
5949 void
regex_pop()5950 regex_pop()
5951 {
5952 if (!regex_stack || mf_stack_pop(regex_stack, ®ex_flags))
5953 parse_error(_("nothing to pop"));
5954 }
5955
5956 static void
pragma_regex(int argc,char ** argv,const char * text)5957 pragma_regex(int argc, char **argv, const char *text)
5958 {
5959 enum regex_mode mode = regex_set;
5960 int i = 1;
5961
5962 if (strcmp(argv[i], "push") == 0) {
5963 regex_push();
5964 i++;
5965 } else if (strcmp(argv[i], "pop") == 0) {
5966 regex_pop();
5967 i++;
5968 }
5969
5970 for (; i < argc; i++) {
5971 int bit;
5972 char *p = argv[i];
5973 switch (p[0]) {
5974 case '+':
5975 mode = regex_enable;
5976 p++;
5977 break;
5978
5979 case '-':
5980 mode = regex_disable;
5981 p++;
5982 break;
5983
5984 case '=':
5985 mode = regex_set;
5986 p++;
5987 break;
5988 }
5989
5990 if (strcmp (p, REG_EXTENDED_NAME) == 0)
5991 bit = REG_EXTENDED;
5992 else if (strcmp (p, REG_ICASE_NAME) == 0)
5993 bit = REG_ICASE;
5994 else if (strcmp (p, REG_NEWLINE_NAME) == 0)
5995 bit = REG_NEWLINE;
5996 else {
5997 parse_error(_("unknown regexp flag: %s"), p);
5998 return;
5999 }
6000
6001 switch (mode) {
6002 case regex_disable:
6003 regex_flags &= ~bit;
6004 break;
6005 case regex_enable:
6006 regex_flags |= bit;
6007 break;
6008 case regex_set:
6009 regex_flags = bit;
6010 break;
6011 }
6012 }
6013 }
6014
6015 static int
strtosize(const char * text,size_t * psize)6016 strtosize(const char *text, size_t *psize)
6017 {
6018 unsigned long size;
6019 size_t factor = 1;
6020 char *p;
6021
6022 size = strtoul(text, &p, 0);
6023 if (size == ULONG_MAX && errno == ERANGE) {
6024 parse_error(_("invalid size: numeric overflow occurred"));
6025 return 2;
6026 }
6027
6028 switch (*p) {
6029 case 't':
6030 case 'T':
6031 factor = 1024;
6032 case 'g':
6033 case 'G':
6034 factor *= 1024;
6035 case 'm':
6036 case 'M':
6037 factor *= 1024;
6038 case 'k':
6039 case 'K':
6040 factor *= 1024;
6041 p++;
6042 if (*p && (*p == 'b' || *p == 'B'))
6043 p++;
6044 break;
6045
6046 case 0:
6047 factor = 1;
6048 break;
6049
6050 default:
6051 parse_error(_("invalid size suffix (near %s)"), p);
6052 return 1;
6053 }
6054
6055 if (((size_t)-1) / factor < size) {
6056 parse_error(_("invalid size: numeric overflow occurred"));
6057 return 2;
6058 }
6059
6060 *psize = size * factor;
6061
6062 return 0;
6063 }
6064
6065 static void
pragma_stacksize(int argc,char ** argv,const char * text)6066 pragma_stacksize(int argc, char **argv, const char *text)
6067 {
6068 size_t size, incr = stack_expand_incr, max_size = stack_max_size;
6069 enum stack_expand_policy policy = stack_expand_policy;
6070
6071 switch (argc) {
6072 case 4:
6073 if (strtosize(argv[3], &max_size))
6074 return;
6075 case 3:
6076 if (strcmp(argv[2], "twice") == 0)
6077 policy = stack_expand_twice;
6078 else {
6079 policy = stack_expand_add;
6080
6081 if (strtosize(argv[2], &incr))
6082 return;
6083 }
6084 case 2:
6085 if (strtosize(argv[1], &size))
6086 return;
6087 }
6088
6089 stack_size = size;
6090 stack_expand_incr = incr;
6091 stack_expand_policy = policy;
6092 stack_max_size = max_size;
6093 }
6094
6095 void
pragma_setup()6096 pragma_setup()
6097 {
6098 install_pragma("regex", 2, 0, pragma_regex);
6099 install_pragma("stacksize", 2, 4, pragma_stacksize);
6100 }
6101
6102
6103
6104 /* Test run */
6105 struct sfsistat_tab {
6106 char *name;
6107 sfsistat stat;
6108 } sfsistat_tab[] = {
6109 { "accept", SMFIS_ACCEPT },
6110 { "continue", SMFIS_CONTINUE },
6111 { "discard", SMFIS_DISCARD },
6112 { "reject", SMFIS_REJECT },
6113 { "tempfail", SMFIS_TEMPFAIL },
6114 { NULL }
6115 };
6116
6117 const char *
sfsistat_str(sfsistat stat)6118 sfsistat_str(sfsistat stat)
6119 {
6120 struct sfsistat_tab *p;
6121 for (p = sfsistat_tab; p->name; p++)
6122 if (p->stat == stat)
6123 return p->name;
6124 return NULL;
6125 }
6126
6127 void
print_stat(sfsistat stat)6128 print_stat(sfsistat stat)
6129 {
6130 struct sfsistat_tab *p;
6131 for (p = sfsistat_tab; p->name; p++)
6132 if (p->stat == stat) {
6133 printf("%s", p->name);
6134 return;
6135 }
6136 printf("%d", stat);
6137 }
6138
6139 const char *
msgmod_opcode_str(enum msgmod_opcode opcode)6140 msgmod_opcode_str(enum msgmod_opcode opcode)
6141 {
6142 switch (opcode) {
6143 case header_add:
6144 return "ADD HEADER";
6145
6146 case header_replace:
6147 return "REPLACE HEADER";
6148
6149 case header_delete:
6150 return "DELETE HEADER";
6151
6152 case header_insert:
6153 return "INSERT HEADER";
6154
6155 case rcpt_add:
6156 return "ADD RECIPIENT";
6157
6158 case rcpt_delete:
6159 return "DELETE RECIPIENT";
6160
6161 case quarantine:
6162 return "QUARANTINE";
6163
6164 case body_repl:
6165 return "REPLACE BODY";
6166
6167 case body_repl_fd:
6168 return "REPLACE BODY FROM FILE";
6169
6170 case set_from:
6171 return "SET FROM";
6172
6173 }
6174 return "UNKNOWN HEADER COMMAND";
6175 }
6176
6177 static int
dbg_setreply(void * data,char * code,char * xcode,char * message)6178 dbg_setreply(void *data, char *code, char *xcode, char *message)
6179 {
6180 if (code) {
6181 printf("SET REPLY %s", code);
6182 if (xcode)
6183 printf(" %s", xcode);
6184 if (message)
6185 printf(" %s", message);
6186 printf("\n");
6187 }
6188 return 0;
6189 }
6190
6191 static void
dbg_msgmod(void * data,struct msgmod_closure * clos)6192 dbg_msgmod(void *data, struct msgmod_closure *clos)
6193 {
6194 if (!clos)
6195 printf("clearing msgmod list\n");
6196 else
6197 printf("%s %s: %s %u\n", msgmod_opcode_str(clos->opcode),
6198 SP(clos->name), SP(clos->value), clos->idx);
6199 }
6200
6201 static const char *
dbg_dict_getsym(void * data,const char * str)6202 dbg_dict_getsym (void *data, const char *str)
6203 {
6204 return dict_getsym ((mu_assoc_t)data, str);
6205 }
6206
6207 void
mailfromd_test(int argc,char ** argv)6208 mailfromd_test(int argc, char **argv)
6209 {
6210 int i;
6211 mu_assoc_t dict = NULL;
6212 eval_environ_t env;
6213 char *p, *end;
6214 long n;
6215 sfsistat status;
6216 char *args[9] = {0,0,0,0,0,0,0,0,0};
6217
6218 dict_init(&dict);
6219 env = create_environment(NULL,
6220 dbg_dict_getsym, dbg_setreply, dbg_msgmod,
6221 dict);
6222 env_init(env);
6223 xeval(env, smtp_state_begin);
6224
6225 env_init(env);
6226 for (i = 0; i < argc; i++) {
6227 if (p = strchr(argv[i], '=')) {
6228 char *ident = argv[i];
6229 *p++ = 0;
6230 if (mu_isdigit(*ident) && *ident != 0
6231 && ident[1] == 0)
6232 args[*ident - '0' - 1] = p;
6233 else
6234 dict_install(dict, argv[i], p);
6235 }
6236 }
6237
6238 for (i = state_parms[test_state].cnt; i--; ) {
6239 switch (state_parms[test_state].types[i]) {
6240 case dtype_string:
6241 env_push_string(env, args[i] ? args[i] : "");
6242 break;
6243 case dtype_number:
6244 if (args[i]) {
6245 n = strtol(args[i], &end, 0);
6246 if (*end)
6247 mu_error(_("$%d is not a number"),
6248 i+1);
6249 } else
6250 n = 0;
6251 env_push_number(env, n);
6252 break;
6253 default:
6254 abort();
6255 }
6256 }
6257
6258 test_message_data_init(env);
6259
6260 env_make_frame(env);
6261
6262 xeval(env, test_state);
6263 env_leave_frame(env, state_parms[test_state].cnt);
6264 env_final_gc(env);
6265
6266 status = environment_get_status(env);
6267
6268 env_init(env);
6269 xeval(env, smtp_state_end);
6270
6271 printf("State %s: ", state_to_string(test_state));
6272 print_stat(status);
6273 printf("\n");
6274 destroy_environment(env);
6275 }
6276
6277 void
mailfromd_run(prog_counter_t entry_point,int argc,char ** argv)6278 mailfromd_run(prog_counter_t entry_point, int argc, char **argv)
6279 {
6280 int rc, i;
6281 mu_assoc_t dict = NULL;
6282 eval_environ_t env;
6283
6284 dict_init(&dict);
6285 env = create_environment(NULL,
6286 dbg_dict_getsym, dbg_setreply, dbg_msgmod,
6287 dict);
6288
6289 env_init(env);
6290 test_message_data_init(env);
6291
6292 env_push_number(env, 0);
6293
6294 for (i = argc - 1; i >= 0; i--)
6295 env_push_string(env, argv[i]);
6296 env_push_number(env, argc);
6297
6298 env_make_frame0(env);
6299 rc = eval_environment(env, entry_point);
6300 env_final_gc(env);
6301 rc = mf_c_val(env_get_reg(env), int);
6302 destroy_environment(env);
6303 exit(rc);
6304 }
6305
6306 static struct tagtable {
6307 char *name;
6308 enum smtp_state tag;
6309 } tagtable[] = {
6310 { "none", smtp_state_none },
6311 { "begin", smtp_state_begin },
6312 { "connect", smtp_state_connect },
6313 { "helo", smtp_state_helo },
6314 { "envfrom", smtp_state_envfrom },
6315 { "envrcpt", smtp_state_envrcpt },
6316 { "data", smtp_state_data },
6317 { "header", smtp_state_header },
6318 { "eoh", smtp_state_eoh },
6319 { "body", smtp_state_body },
6320 { "eom", smtp_state_eom },
6321 { "end", smtp_state_end },
6322 };
6323
6324 enum smtp_state
string_to_state(const char * name)6325 string_to_state(const char *name)
6326 {
6327 struct tagtable *p;
6328
6329 for (p = tagtable; p < tagtable + sizeof tagtable/sizeof tagtable[0];
6330 p++)
6331 if (strcasecmp (p->name, name) == 0)
6332 return p->tag;
6333
6334 return smtp_state_none;
6335 }
6336
6337 const char *
state_to_string(enum smtp_state state)6338 state_to_string(enum smtp_state state)
6339 {
6340 if (state < sizeof tagtable/sizeof tagtable[0])
6341 return tagtable[state].name;
6342 abort();
6343 }
6344
6345 static NODE *
_reverse(NODE * list,NODE ** root)6346 _reverse(NODE *list, NODE **root)
6347 {
6348 NODE *next;
6349
6350 if (list->next == NULL) {
6351 *root = list;
6352 return list;
6353 }
6354 next = _reverse(list->next, root);
6355 next->next = list;
6356 list->next = NULL;
6357 return list;
6358 }
6359
6360 NODE *
reverse(NODE * in)6361 reverse(NODE *in)
6362 {
6363 NODE *root;
6364 if (!in)
6365 return in;
6366 _reverse(in, &root);
6367 return root;
6368 }
6369
6370 size_t
nodelistlength(NODE * p)6371 nodelistlength(NODE *p)
6372 {
6373 size_t len = 0;
6374 for (; p; p = p->next)
6375 len++;
6376 return len;
6377 }
6378
6379 static NODE *
create_asgn_node(struct variable * var,NODE * expr,struct mu_locus_range const * loc)6380 create_asgn_node(struct variable *var, NODE *expr,
6381 struct mu_locus_range const *loc)
6382 {
6383 NODE *node;
6384 data_type_t t = node_type(expr);
6385
6386 if (t == dtype_unspecified) {
6387 parse_error(_("unspecified value not ignored as it should be"));
6388 return NULL;
6389 }
6390 node = alloc_node(node_type_asgn, loc);
6391 node->v.asgn.var = var;
6392 node->v.asgn.nframes = catch_nesting;
6393 node->v.asgn.node = cast_to(var->type, expr);
6394 var->initialized = 1;
6395 return node;
6396 }
6397
6398
6399 NODE *
function_call(struct function * function,size_t count,NODE * subtree)6400 function_call(struct function *function, size_t count, NODE *subtree)
6401 {
6402 NODE *np = NULL;
6403 if (count < function->parmcount - function->optcount) {
6404 parse_error(_("too few arguments in call to `%s'"),
6405 function->sym.name);
6406 } else if (count > function->parmcount && !function->varargs) {
6407 parse_error(_("too many arguments in call to `%s'"),
6408 function->sym.name);
6409 } else {
6410 np = alloc_node(node_type_call, &yylloc);
6411 np->v.call.func = function;
6412 np->v.call.args = reverse(cast_arg_list(subtree,
6413 function->parmcount,
6414 function->parmtype,
6415 0));
6416 }
6417 return np;
6418 }
6419
6420 data_type_t
node_type(NODE * node)6421 node_type(NODE *node)
6422 {
6423 switch (node->type) {
6424 case node_type_string:
6425 case node_type_symbol:
6426 case node_type_sed:
6427 case node_type_concat:
6428 case node_type_argx:
6429 case node_type_backref:
6430 return dtype_string;
6431
6432 case node_type_number:
6433 case node_type_bin:
6434 case node_type_un:
6435 case node_type_sedcomp:
6436 case node_type_offset:
6437 case node_type_vaptr:
6438 return dtype_number;
6439
6440 case node_type_if:
6441 return dtype_unspecified;
6442
6443 case node_type_builtin:
6444 return node->v.builtin.builtin->rettype;
6445
6446 case node_type_variable:
6447 return node->v.var_ref.variable->type;
6448
6449 case node_type_arg:
6450 return node->v.arg.data_type;
6451
6452 case node_type_call:
6453 return node->v.call.func->rettype;
6454
6455 case node_type_return:
6456 if (node->v.node)
6457 return node_type(node->v.node);
6458 break;
6459
6460 case node_type_cast:
6461 return node->v.cast.data_type;
6462
6463 case node_type_result:
6464 case node_type_header:
6465 case node_type_asgn:
6466 case node_type_regex:
6467 case node_type_regcomp:
6468 case node_type_catch:
6469 case node_type_try:
6470 case node_type_throw:
6471 case node_type_echo:
6472 case node_type_switch:
6473 case node_type_funcdecl:
6474 case node_type_progdecl:
6475 case node_type_noop:
6476 case node_type_next:
6477 case node_type_break:
6478 case node_type_loop:
6479 case max_node_type:
6480 break;
6481 }
6482 return dtype_unspecified;
6483 }
6484
6485 NODE *
cast_to(data_type_t type,NODE * node)6486 cast_to(data_type_t type, NODE *node)
6487 {
6488 NODE *np;
6489 data_type_t ntype = node_type(node);
6490
6491 switch (ntype) {
6492 case dtype_string:
6493 case dtype_number:
6494 if (type == ntype)
6495 return node;
6496 break;
6497
6498 case dtype_pointer:
6499 if (type == ntype)
6500 return node;
6501 break;
6502
6503 case dtype_unspecified:
6504 parse_error(_("cannot convert %s to %s"), type_to_string(ntype),
6505 type_to_string(type));
6506 return NULL;
6507
6508 default:
6509 abort();
6510 }
6511 np = alloc_node(node_type_cast, &yylloc);
6512 np->v.cast.data_type = type;
6513 np->v.cast.node = node;
6514 node->next = NULL;
6515 return np;
6516 }
6517
6518 NODE *
cast_arg_list(NODE * args,size_t parmc,data_type_t * parmtype,int disable_prom)6519 cast_arg_list(NODE *args, size_t parmc, data_type_t *parmtype, int disable_prom)
6520 {
6521 NODE *head = NULL, *tail = NULL;
6522
6523 while (args) {
6524 NODE *next = args->next;
6525 NODE *p;
6526 data_type_t type;
6527
6528 if (parmc) {
6529 type = *parmtype++;
6530 parmc--;
6531 } else if (disable_prom)
6532 type = node_type(args);
6533 else
6534 type = dtype_string;
6535
6536 p = cast_to(type, args);
6537
6538 if (head)
6539 tail->next = p;
6540 else
6541 head = p;
6542 tail = p;
6543 args = next;
6544 }
6545 return head;
6546 }
6547
6548 void
add_xref(struct variable * var,struct mu_locus_range const * locus)6549 add_xref(struct variable *var, struct mu_locus_range const *locus)
6550 {
6551 if (script_dump_xref) {
6552 /* FIXME: either change type to mu_locus_point, or
6553 change print_locus above */
6554 struct mu_locus_range *elt = mu_zalloc(sizeof *elt);
6555 if (!var->xref)
6556 mu_list_create(&var->xref);
6557 mu_locus_range_copy(elt, locus);
6558 mu_list_append(var->xref, elt);
6559 }
6560 }
6561
6562 struct variable *
vardecl(const char * name,data_type_t type,storage_class_t sc,struct mu_locus_range const * loc)6563 vardecl(const char *name, data_type_t type, storage_class_t sc,
6564 struct mu_locus_range const *loc)
6565 {
6566 struct variable *var;
6567 const struct constant *cptr;
6568
6569 if (!loc)
6570 loc = &yylloc;
6571 if (type == dtype_unspecified) {
6572 parse_error(_("cannot define variable of unspecified type"));
6573 return NULL;
6574 }
6575 var = variable_install(name);
6576 if (var->type == dtype_unspecified) {
6577 /* the variable has just been added: go straight to
6578 initializing it */;
6579 } else if (sc != var->storage_class) {
6580 struct variable *vp;
6581
6582 switch (sc) {
6583 case storage_extern:
6584 parse_error(_("INTERNAL ERROR at %s:%d, declaring %s %s"),
6585 __FILE__, __LINE__,
6586 storage_class_str(sc), name);
6587 abort();
6588
6589 case storage_auto:
6590 if (var->storage_class == storage_param) {
6591 parse_warning_locus(loc,
6592 _("automatic variable `%s' "
6593 "is shadowing a parameter"),
6594 var->sym.name);
6595 } else
6596 parse_warning_locus(loc,
6597 _("automatic variable `%s' "
6598 "is shadowing a global"),
6599 var->sym.name);
6600 unregister_auto(var);
6601 break;
6602
6603 case storage_param:
6604 parse_warning_locus(loc,
6605 _("parameter `%s' is shadowing a "
6606 "global"),
6607 name);
6608 }
6609
6610 /* Do the shadowing */
6611 vp = variable_replace(var->sym.name, NULL);
6612 vp->shadowed = var;
6613 var = vp;
6614 } else {
6615 switch (sc) {
6616 case storage_extern:
6617 if (var->type != type) {
6618 parse_error_locus(loc,
6619 _("redeclaring `%s' as different "
6620 "data type"),
6621 name);
6622 parse_error_locus(&var->sym.locus,
6623 _("this is the location of the "
6624 "previous definition"));
6625 return NULL;
6626 }
6627 break;
6628
6629 case storage_auto:
6630 if (var->type != type) {
6631 parse_error_locus(loc,
6632 _("redeclaring `%s' as different "
6633 "data type"),
6634 name);
6635 parse_error_locus(&var->sym.locus,
6636 _("this is the location of the "
6637 "previous definition"));
6638 return NULL;
6639 } else {
6640 parse_error_locus(loc,
6641 _("duplicate variable: %s"),
6642 name);
6643 return NULL;
6644 }
6645 break;
6646
6647 case storage_param:
6648 parse_error_locus(loc, _("duplicate parameter: %s"),
6649 name);
6650 return NULL;
6651 }
6652 }
6653
6654 /* FIXME: This is necessary because constants can be
6655 referred to the same way as variables. */
6656 if (cptr = constant_lookup(name)) {
6657 parse_warning_locus(loc,
6658 _("variable name `%s' clashes with a constant name"),
6659 name);
6660 parse_warning_locus(&cptr->sym.locus,
6661 _("this is the location of the "
6662 "previous definition"));
6663 }
6664
6665 var->type = type;
6666 var->storage_class = sc;
6667 switch (sc) {
6668 case storage_extern:
6669 add_xref(var, loc);
6670 break;
6671 case storage_auto:
6672 case storage_param:
6673 register_auto(var);
6674 }
6675 mu_locus_range_copy(&var->sym.locus, loc);
6676 return var;
6677 }
6678
6679 static int
cast_value(data_type_t type,struct value * value)6680 cast_value(data_type_t type, struct value *value)
6681 {
6682 if (type != value->type) {
6683 char buf[NUMERIC_BUFSIZE_BOUND];
6684 char *p;
6685
6686 switch (type) {
6687 default:
6688 abort();
6689
6690 case dtype_string:
6691 snprintf(buf, sizeof buf, "%ld", value->v.number);
6692 value->v.literal = string_alloc(buf, strlen(buf));
6693 break;
6694
6695 case dtype_number:
6696 value->v.number = strtol(value->v.literal->text,
6697 &p, 10);
6698 if (*p) {
6699 parse_error(_("cannot convert `%s' to number"),
6700 value->v.literal->text);
6701 return 1;
6702 }
6703 break;
6704 }
6705 value->type = type;
6706 }
6707 return 0;
6708 }
6709
6710 static struct variable *
externdecl(const char * name,struct value * value,struct mu_locus_range const * loc)6711 externdecl(const char *name, struct value *value,
6712 struct mu_locus_range const *loc)
6713 {
6714 struct variable *var = vardecl(name, value->type, storage_extern, loc);
6715 if (!var)
6716 return NULL;
6717 if (initialize_variable(var, value, loc))
6718 return NULL;
6719 return var;
6720 }
6721
6722
6723 struct deferred_decl {
6724 struct deferred_decl *next;
6725 struct literal *name;
6726 struct value value;
6727 struct mu_locus_range locus;
6728 };
6729
6730 struct deferred_decl *deferred_decl;
6731
6732 void
defer_initialize_variable(const char * arg,const char * val,struct mu_locus_range const * ploc)6733 defer_initialize_variable(const char *arg, const char *val,
6734 struct mu_locus_range const *ploc)
6735 {
6736 struct deferred_decl *p;
6737 struct literal *name = string_alloc(arg, strlen(arg));
6738 for (p = deferred_decl; p; p = p->next)
6739 if (p->name == name) {
6740 parse_warning_locus(NULL, _("redefining variable %s"),
6741 name->text);
6742 p->value.type = dtype_string;
6743 p->value.v.literal = string_alloc(val, strlen(val));
6744 mu_locus_range_copy (&p->locus, ploc);
6745 return;
6746 }
6747 p = mu_alloc(sizeof *p);
6748 p->name = name;
6749 p->value.type = dtype_string;
6750 p->value.v.literal = string_alloc(val, strlen(val));
6751 mu_locus_range_init (&p->locus);
6752 mu_locus_range_copy (&p->locus, ploc);
6753 p->next = deferred_decl;
6754 deferred_decl = p;
6755 }
6756
6757 static void
apply_deferred_init()6758 apply_deferred_init()
6759 {
6760 struct deferred_decl *p;
6761 for (p = deferred_decl; p; p = p->next) {
6762 struct variable *var = variable_lookup(p->name->text);
6763 if (!var) {
6764 mu_error(_("<command line>: warning: "
6765 "no such variable: %s"),
6766 p->name->text);
6767 continue;
6768 }
6769 if (initialize_variable(var, &p->value, &p->locus))
6770 parse_error_locus(&p->locus,
6771 _("error initialising variable %s: incompatible types"),
6772 p->name->text);
6773 }
6774 }
6775
6776
6777 struct declvar {
6778 struct declvar *next;
6779 struct mu_locus_range locus;
6780 struct variable *var;
6781 struct value val;
6782 };
6783
6784 static struct declvar *declvar;
6785
6786 void
set_poll_arg(struct poll_data * poll,int kw,NODE * expr)6787 set_poll_arg(struct poll_data *poll, int kw, NODE *expr)
6788 {
6789 switch (kw) {
6790 case T_FOR:
6791 poll->email = expr;
6792 break;
6793
6794 case T_HOST:
6795 poll->client_addr = expr;
6796 break;
6797
6798 case T_AS:
6799 poll->mailfrom = expr;
6800 break;
6801
6802 case T_FROM:
6803 poll->ehlo = expr;
6804 break;
6805
6806 default:
6807 abort();
6808 }
6809 }
6810
6811 int
initialize_variable(struct variable * var,struct value * val,struct mu_locus_range const * locus)6812 initialize_variable(struct variable *var, struct value *val,
6813 struct mu_locus_range const *locus)
6814 {
6815 struct declvar *dv;
6816
6817 if (cast_value(var->type, val))
6818 return 1;
6819 for (dv = declvar; dv; dv = dv->next)
6820 if (dv->var == var) {
6821 if (dv->locus.beg.mu_file) {
6822 parse_warning_locus(locus,
6823 _("variable `%s' already initialized"),
6824 var->sym.name);
6825 parse_warning_locus(&dv->locus,
6826 _("this is the location of the "
6827 "previous initialization"));
6828 }
6829
6830 if (locus)
6831 mu_locus_range_copy (&dv->locus, locus);
6832 else
6833 mu_locus_range_deinit (&dv->locus);
6834 dv->val = *val;
6835 return 0;
6836 }
6837
6838 dv = mu_alloc(sizeof *dv);
6839 dv->next = declvar;
6840 dv->var = var;
6841 mu_locus_range_init (&dv->locus);
6842 if (locus)
6843 mu_locus_range_copy (&dv->locus, locus);
6844 dv->val = *val;
6845 declvar = dv;
6846 var->sym.flags |= SYM_INITIALIZED;
6847 return 0;
6848 }
6849
6850
6851 void
ensure_initialized_variable(const char * name,struct value * val)6852 ensure_initialized_variable(const char *name, struct value *val)
6853 {
6854 struct declvar *dv;
6855 struct variable *var = variable_lookup(name);
6856
6857 if (!var) {
6858 mu_error(_("INTERNAL ERROR at %s:%d: variable to be "
6859 "initialized is not declared"),
6860 __FILE__, __LINE__);
6861 abort();
6862 }
6863 if (var->type != val->type)
6864 mu_error(_("INTERNAL ERROR at %s:%d: variable to be "
6865 "initialized has wrong type"),
6866 __FILE__, __LINE__);
6867 for (dv = declvar; dv; dv = dv->next)
6868 if (dv->var == var)
6869 return;
6870 dv = mu_alloc(sizeof *dv);
6871 mu_locus_range_init (&dv->locus);
6872 dv->var = var;
6873 dv->val = *val;
6874 dv->next = declvar;
6875 declvar = dv;
6876 }
6877
6878 static int
_ds_variable_count_fun(void * sym,void * data)6879 _ds_variable_count_fun(void *sym, void *data)
6880 {
6881 struct variable *var = sym;
6882
6883 if ((var->sym.flags & (SYM_VOLATILE | SYM_REFERENCED))
6884 && !(var->sym.flags & SYM_PASSTOGGLE)) {
6885 var->sym.flags |= SYM_PASSTOGGLE;
6886 variable_count++;
6887 if (var->type == dtype_string)
6888 dataseg_reloc_count++;
6889 if (var->sym.flags & SYM_PRECIOUS)
6890 precious_count++;
6891 }
6892 return 0;
6893 }
6894
6895 static int
_ds_variable_fill_fun(void * sym,void * data)6896 _ds_variable_fill_fun(void *sym, void *data)
6897 {
6898 struct variable *var = sym;
6899
6900 if (var->sym.flags & SYM_PASSTOGGLE) {
6901 var->sym.flags &= ~SYM_PASSTOGGLE;
6902 struct variable ***vtabptr = data;
6903 **vtabptr = var;
6904 ++*vtabptr;
6905 }
6906 return 0;
6907 }
6908
6909 static int
_ds_reloc_fun(void * sym,void * data)6910 _ds_reloc_fun(void *sym, void *data)
6911 {
6912 struct variable *var = sym;
6913 size_t *pi = data;
6914
6915 if ((var->sym.flags & (SYM_VOLATILE | SYM_REFERENCED))
6916 && !(var->sym.flags & SYM_PASSTOGGLE)
6917 && var->type == dtype_string) {
6918 var->sym.flags |= SYM_PASSTOGGLE;
6919 dataseg_reloc[(*pi)++] = var->off;
6920 }
6921 return 0;
6922 }
6923
6924 static int
_ds_literal_count_fun(void * sym,void * data)6925 _ds_literal_count_fun(void *sym, void *data)
6926 {
6927 struct literal *lit = sym;
6928 size_t *offset = data;
6929 if (!(lit->flags & SYM_VOLATILE) && (lit->flags & SYM_REFERENCED)) {
6930 lit->off = *offset;
6931 *offset += B2STACK(strlen(lit->text) + 1);
6932 }
6933 return 0;
6934 }
6935
6936 static int
_ds_literal_copy_fun(void * sym,void * data)6937 _ds_literal_copy_fun(void *sym, void *data)
6938 {
6939 struct literal *lit = sym;
6940 if (!(lit->flags & SYM_VOLATILE) && (lit->flags & SYM_REFERENCED))
6941 strcpy((char*)(dataseg + lit->off), lit->text);
6942 return 0;
6943 }
6944
6945 static int
vtab_comp(const void * a,const void * b)6946 vtab_comp(const void *a, const void *b)
6947 {
6948 const struct variable *vp1 = *(const struct variable **)a;
6949 const struct variable *vp2 = *(const struct variable **)b;
6950
6951 if ((vp1->sym.flags & SYM_PRECIOUS)
6952 && !(vp2->sym.flags & SYM_PRECIOUS))
6953 return 1;
6954 else if ((vp2->sym.flags & SYM_PRECIOUS)
6955 && !(vp1->sym.flags & SYM_PRECIOUS))
6956 return -1;
6957 return 0;
6958 }
6959
6960 static int
place_exc(const struct constant * cp,const struct literal * lit,void * data)6961 place_exc(const struct constant *cp, const struct literal *lit, void *data)
6962 {
6963 STKVAL *tab = data;
6964 tab[cp->value.v.number] = (STKVAL) lit->off;
6965 return 0;
6966 }
6967
6968 static void
dataseg_layout()6969 dataseg_layout()
6970 {
6971 struct declvar *dv;
6972 size_t i;
6973 struct switch_stmt *sw;
6974 struct variable **vtab, **pvtab;
6975 struct exmask *exmask;
6976
6977 /* Count used variables and estimate the number of relocations
6978 needed */
6979 dataseg_reloc_count = 0;
6980 module_symtab_enumerate(namespace_variable,
6981 _ds_variable_count_fun,
6982 NULL);
6983
6984 /* Fill variable pointer array and make sure precious variables
6985 occupy its bottom part */
6986 vtab = mu_calloc(variable_count, sizeof(vtab[0]));
6987 pvtab = vtab;
6988 module_symtab_enumerate(namespace_variable,
6989 _ds_variable_fill_fun,
6990 &pvtab);
6991 qsort(vtab, variable_count, sizeof(vtab[0]), vtab_comp);
6992
6993 /* Compute variable offsets. Offset 0 is reserved for NULL symbol */
6994 for (i = 0; i < variable_count; i++) {
6995 vtab[i]->off = i + 1;
6996 if (vtab[i]->addrptr)
6997 *vtab[i]->addrptr = vtab[i]->off;
6998 }
6999
7000 /* Free the array */
7001 free(vtab);
7002
7003 /* Mark literals used to initialize variables as referenced */
7004 for (dv = declvar; dv; dv = dv->next) {
7005 if ((dv->var->sym.flags & (SYM_VOLATILE | SYM_REFERENCED))
7006 && dv->var->type == dtype_string) {
7007 dv->val.v.literal->flags |= SYM_REFERENCED;
7008 }
7009 }
7010
7011 datasize = variable_count + 1;
7012 dvarsize = datasize - precious_count;
7013
7014 /* Count referenced literals and adjust the data size */
7015 symtab_enumerate(stab_literal, _ds_literal_count_fun, &datasize);
7016
7017 /* Account for switch translation tables */
7018 for (sw = switch_root; sw; sw = sw->next) {
7019 sw->off = datasize;
7020 datasize += sw->tabsize;
7021 }
7022
7023 /* Account for exception masks */
7024 for (exmask = exmask_root; exmask; exmask = exmask->next) {
7025 exmask->off = datasize;
7026 if (exmask->all) {
7027 size_t i;
7028 for (i = 0; i < exception_count; i++)
7029 bitmask_set(&exmask->bm, i);
7030 }
7031 datasize += exmask->bm.bm_size + 1;
7032 }
7033
7034 /* Account for exception name table */
7035 datasize += exception_count;
7036
7037 /* Allocate data segment and relocation table */
7038 dataseg = mu_calloc(datasize, sizeof(STKVAL));
7039 dataseg_reloc = mu_calloc(dataseg_reloc_count, sizeof *dataseg_reloc);
7040
7041 /* Fill relocation table */
7042 i = 0;
7043 module_symtab_enumerate(namespace_variable, _ds_reloc_fun, &i);
7044
7045 /* Initialize variables */
7046 for (dv = declvar; dv; dv = dv->next) {
7047 if (dv->var->sym.flags & (SYM_VOLATILE | SYM_REFERENCED)) {
7048 switch (dv->var->type) {
7049 case dtype_string:
7050 dataseg[dv->var->off] =
7051 (STKVAL) dv->val.v.literal->off;
7052 break;
7053
7054 case dtype_number:
7055 dataseg[dv->var->off] =
7056 (STKVAL) dv->val.v.number;
7057 break;
7058
7059 default:
7060 abort();
7061 }
7062 }
7063 }
7064
7065 /* Place literals */
7066 symtab_enumerate(stab_literal, _ds_literal_copy_fun, NULL);
7067
7068 /* Initialize exception masks */
7069 for (exmask = exmask_root; exmask; exmask = exmask->next) {
7070 size_t i, off = exmask->off;
7071
7072 dataseg[off++] = (STKVAL) exmask->bm.bm_size;
7073 for (i = 0; i < exmask->bm.bm_size; i++)
7074 dataseg[off++] = (STKVAL) exmask->bm.bm_bits[i++];
7075 }
7076
7077 /* Initialize exception name table */
7078 enumerate_exceptions(place_exc, dataseg + EXTABIND);
7079 }
7080
7081
7082 static int
_regex_compile_fun(void * sym,void * data)7083 _regex_compile_fun(void *sym, void *data)
7084 {
7085 struct literal *lit = sym;
7086 if (lit->regex) {
7087 struct sym_regex *rp;
7088 for (rp = lit->regex; rp; rp = rp->next)
7089 register_regex(rp);
7090 }
7091 return 0;
7092 }
7093
7094 void
regex_layout()7095 regex_layout()
7096 {
7097 symtab_enumerate(stab_literal, _regex_compile_fun, NULL);
7098 finalize_regex();
7099 }
7100
7101
7102 static struct variable *auto_list;
7103
7104 static void
register_auto(struct variable * var)7105 register_auto(struct variable *var)
7106 {
7107 var->next = auto_list;
7108 auto_list = var;
7109 }
7110
7111 static void
unregister_auto(struct variable * var)7112 unregister_auto(struct variable *var)
7113 {
7114 struct variable *p = auto_list, *prev = NULL;
7115 while (p) {
7116 struct variable *next = p->next;
7117 if (p == var) {
7118 if (prev)
7119 prev->next = next;
7120 else
7121 auto_list = next;
7122 p->next = NULL;
7123 return;
7124 }
7125 prev = p;
7126 p = next;
7127 }
7128 }
7129
7130 /* FIXME: Redo shadowing via a separate table? */
7131 static size_t
forget_autos(size_t nparam,size_t auto_count,size_t hidden_arg)7132 forget_autos(size_t nparam, size_t auto_count, size_t hidden_arg)
7133 {
7134 size_t param_count = 0;
7135 struct variable *var = auto_list;
7136 while (var) {
7137 struct variable *next = var->next;
7138 switch (var->storage_class) {
7139 case storage_auto:
7140 var->off = auto_count++;
7141 break;
7142 case storage_param:
7143 var->off = nparam - param_count++;
7144 var->ord = var->off - (hidden_arg ? 1 : 0) - 1;
7145 break;
7146 default:
7147 abort();
7148 }
7149 while (var->storage_class != storage_extern) {
7150 struct variable *shadowed = var->shadowed;
7151 if (!shadowed) {
7152 symtab_remove(TOP_MODULE_SYMTAB(namespace_variable),
7153 var->sym.name);
7154 break;
7155 }
7156 var->shadowed = NULL;
7157 var = variable_replace(var->sym.name, shadowed);
7158 }
7159 var = next;
7160 }
7161 auto_list = NULL;
7162 return auto_count;
7163 }
7164
7165 const char *
storage_class_str(storage_class_t sc)7166 storage_class_str(storage_class_t sc)
7167 {
7168 switch (sc) {
7169 case storage_extern:
7170 return "extern";
7171 case storage_auto:
7172 return "auto";
7173 case storage_param:
7174 return "param";
7175 }
7176 return "unknown?";
7177 }
7178
7179
7180 const char *
function_name()7181 function_name()
7182 {
7183 switch (outer_context) {
7184 case context_function:
7185 return func->sym.name;
7186 case context_handler:
7187 return state_to_string(state_tag);
7188 default:
7189 return "";
7190 }
7191 }
7192
7193 NODE *
declare_function(struct function * func,struct mu_locus_range const * loc,size_t nautos)7194 declare_function(struct function *func, struct mu_locus_range const *loc,
7195 size_t nautos)
7196 {
7197 NODE *node = alloc_node(node_type_funcdecl, loc);
7198 node->v.funcdecl.func = func;
7199 node->v.funcdecl.auto_count = nautos;
7200 node->v.funcdecl.tree = func->node;
7201 return node;
7202 }
7203
7204
7205 NODE *
create_node_variable(struct variable * var,struct mu_locus_range const * locus)7206 create_node_variable(struct variable *var, struct mu_locus_range const *locus)
7207 {
7208 NODE *node;
7209
7210 variable_check_initialized(var, locus);
7211 node = alloc_node(node_type_variable, locus);
7212 node->v.var_ref.variable = var;
7213 node->v.var_ref.nframes = catch_nesting;
7214 return node;
7215 }
7216
7217 NODE *
create_node_argcount(struct mu_locus_range const * locus)7218 create_node_argcount(struct mu_locus_range const *locus)
7219 {
7220 NODE *node;
7221
7222 if (outer_context == context_function) {
7223 if (func->optcount || func->varargs) {
7224 node = alloc_node(node_type_arg, locus);
7225 node->v.arg.data_type = dtype_number;
7226 node->v.arg.number = 1;
7227 } else {
7228 node = alloc_node(node_type_number, locus);
7229 node->v.number = parminfo[outer_context].parmcount();
7230 }
7231 } else {
7232 node = alloc_node(node_type_number, locus);
7233 node->v.number = parminfo[outer_context].parmcount();
7234 }
7235 return node;
7236 }
7237
7238 NODE *
create_node_arg(long num,struct mu_locus_range const * locus)7239 create_node_arg(long num, struct mu_locus_range const *locus)
7240 {
7241 NODE *node;
7242
7243 if (inner_context == context_function && func->varargs)
7244 ;
7245 else if (num > PARMCOUNT())
7246 parse_error(_("argument number too high"));
7247 node = alloc_node(node_type_arg, locus);
7248 node->v.arg.data_type = PARMTYPE(num);
7249 node->v.arg.number = num;
7250 if (inner_context == context_function)
7251 node->v.arg.number += FUNC_HIDDEN_ARGS(func);
7252 return node;
7253 }
7254
7255 NODE *
create_node_symbol(struct literal * lit,struct mu_locus_range const * locus)7256 create_node_symbol(struct literal *lit, struct mu_locus_range const *locus)
7257 {
7258 NODE *node;
7259 register_macro(state_tag, lit->text);
7260 node = alloc_node(node_type_symbol, locus);
7261 node->v.literal = lit;
7262 return node;
7263 }
7264
7265 NODE *
create_node_backref(long num,struct mu_locus_range const * locus)7266 create_node_backref(long num, struct mu_locus_range const *locus)
7267 {
7268 NODE *node = alloc_node(node_type_backref, locus);
7269 node->v.number = num;
7270 return node;
7271 }
7272
7273 static inline int
variable_is_initialized(struct variable * var)7274 variable_is_initialized(struct variable *var)
7275 {
7276 return var->storage_class != storage_auto || var->initialized;
7277 }
7278
7279 void
variable_check_initialized(struct variable * var,struct mu_locus_range const * loc)7280 variable_check_initialized(struct variable *var,
7281 struct mu_locus_range const *loc)
7282 {
7283 if (!variable_is_initialized(var)) {
7284 parse_warning_locus(loc,
7285 _("use of uninitialized variable '%s'"),
7286 var->sym.name);
7287 var->initialized = 1;
7288 }
7289 }
7290