/* A Bison parser, made by GNU Bison 3.0.4. */ /* Bison implementation for Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ #define YYBISON_VERSION "3.0.4" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 0 /* Push parsers. */ #define YYPUSH 0 /* Pull parsers. */ #define YYPULL 1 /* Copy the first part of user declarations. */ #line 1 "gram.y" /* yacc.c:339 */ /* This file is part of Mailfromd. Copyright (C) 2005-2020 Sergey Poznyakoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include "mailfromd.h" #include #include "prog.h" #include "optab.h" static void free_node(NODE *node); static void set_poll_arg(struct poll_data *poll, int kw, NODE *expr); static int codegen(prog_counter_t *pc, NODE *node, struct exmask *exmask, int finalize, size_t nautos); static void mark(NODE *node); static void dataseg_layout(void); static void regex_layout(void); static int optimize_tree(NODE *node); static void compile_tree(NODE *node); static NODE *reverse(NODE *in); static size_t nodelistlength(NODE *list); static NODE *function_call(struct function *function, size_t count, NODE *subtree); static NODE *declare_function(struct function *func, struct mu_locus_range const *loc, size_t nautos); static data_type_t node_type(NODE *node); static NODE *cast_arg_list(NODE *args, size_t parmc, data_type_t *parmtype, int disable_prom); void add_xref(struct variable *var, struct mu_locus_range const *locus); static struct variable *vardecl(const char *name, data_type_t type, storage_class_t sc, struct mu_locus_range const *loc); static struct variable *externdecl(const char *name, struct value *value, struct mu_locus_range const *loc); static int initialize_variable(struct variable *var, struct value *val, struct mu_locus_range const *locus); static void apply_deferred_init(void); static NODE *create_asgn_node(struct variable *var, NODE *expr, struct mu_locus_range const *loc); NODE *defined_parm(struct variable *var, struct mu_locus_range const *locus); static void register_auto(struct variable *var); static void unregister_auto(struct variable *var); static size_t forget_autos(size_t nparam, size_t prev, size_t hidden_arg); static void optimize(NODE *node); static NODE *root_node[smtp_state_count]; prog_counter_t entry_point[smtp_state_count]; #define PS_BEGIN 0 #define PS_END 1 int regex_flags; /* Should default to REG_NOSUB ? */ unsigned error_count; /* Number of detected errors */ size_t variable_count = 0; /* Number of variables in the data segment. */ size_t precious_count = 0; static enum smtp_state state_tag; /* State tag of the currently processed PROG */ static struct function *func; /* The currently compiled function */ static prog_counter_t jump_pc; /* Pointer to the chain of jmp instructions */ /* Outermost context decides how to code exits from catches. Innermost context is used to access parameters. */ enum lexical_context outer_context, inner_context; size_t catch_nesting; /* Nesting level for catch statements */ static struct stmtlist genstmt; /* List of generated statements */ /* State handlers and their positional parameters */ struct state_parms { int cnt; /* Number or positional parameters */ data_type_t types[4]; /* Their data types */ } state_parms[] = { { 0, }, /* smtp_state_none */ { 0, }, /* smtp_state_begin */ { 4, { dtype_string, dtype_number, dtype_number, dtype_string } }, /* smtp_state_connect */ { 1, { dtype_string } }, /* smtp_state_helo */ { 2, { dtype_string, dtype_string } }, /* smtp_state_envfrom */ { 2, { dtype_string, dtype_string } }, /* smtp_state_envrcpt */ { 0, }, /* smtp_state_data */ { 2, { dtype_string, dtype_string } }, /* smtp_state_header */ { 0, }, /* smtp_state_eoh */ { 2, { dtype_pointer, dtype_number } }, /* smtp_state_body */ { 0, }, /* smtp_state_eom */ { 0, } /* smtp_state_end */ }; struct parmtype { struct parmtype *next; data_type_t type; }; static int parmcount_none() { return 0; } static data_type_t parmtype_none(int n) { return dtype_unspecified; } static int parmcount_handler() { return state_parms[state_tag].cnt; } static data_type_t parmtype_handler(int n) { return state_parms[state_tag].types[n-1]; } static int parmcount_catch() { return 2; } static data_type_t parmtype_catch(int n) { switch (n) { case 1: return dtype_number; case 2: return dtype_string; } abort(); } static int parmcount_function() { return func->parmcount; } static data_type_t parmtype_function(int n) { if (func->varargs && n > func->parmcount) return dtype_string; return func->parmtype[n-1]; } struct parminfo { int (*parmcount)(void); data_type_t (*parmtype)(int n); } parminfo[] = { { parmcount_none, parmtype_none }, { parmcount_handler, parmtype_handler }, { parmcount_catch, parmtype_catch }, { parmcount_function, parmtype_function }, }; #define PARMCOUNT() parminfo[inner_context].parmcount() #define PARMTYPE(n) parminfo[inner_context].parmtype(n) #define FUNC_HIDDEN_ARGS(f) (((f)->optcount || (f)->varargs) ? 1 : 0) data_type_t string_to_type(const char *s) { if (strcmp(s, "n") == 0) return dtype_number; else if (strcmp(s, "s") == 0) return dtype_string; else return dtype_unspecified; } const char * type_to_string(data_type_t t) { switch (t) { case dtype_number: return "number"; case dtype_string: return "string"; case dtype_unspecified: return "unspecified"; case dtype_pointer: return "pointer"; default: abort(); } } static int check_func_usage(struct function *fp, struct mu_locus_range const *locus) { switch (outer_context) { case context_handler: if (fp->statemask && !(STATMASK(state_tag) & fp->statemask)) { parse_error_locus(locus, _("function `%s' cannot be used in " "prog `%s'"), fp->sym.name, state_to_string(state_tag)); return 1; } break; case context_function: func->statemask |= fp->statemask; break; default: break; } return 0; } static int check_builtin_usage(const struct builtin *bp, struct mu_locus_range const *locus) { switch (outer_context) { case context_handler: if (bp->statemask && !(STATMASK(state_tag) & bp->statemask)) { parse_error_locus(locus, _("built-in function `%s' cannot be used in " "prog `%s'"), bp->name, state_to_string(state_tag)); return 1; } break; case context_function: func->statemask |= bp->statemask; break; default: break; } if (bp->flags & MFD_BUILTIN_CAPTURE) capture_on(); return 0; } static void jump_fixup(prog_counter_t pos, prog_counter_t endpos); #define LITERAL_TEXT(lit) ((lit) ? (lit)->text : NULL) #define LITERAL_OFF(lit) ((lit) ? (lit)->off : 0) static int _create_alias(void *item, void *data) { struct literal *lit = item; struct function *fun = data; /* FIXME: Ideally we should pass a locus of `lit' instead of fun->locus. However, its only purpose is for use in redefinition diagnostic messages and these are never produced, because the grammar catches these errors earlier. This might change in the future. 2008-09-14 */ install_alias(lit->text, fun, &fun->sym.locus); return 0; } #line 355 "gram.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus # define YY_NULLPTR nullptr # else # define YY_NULLPTR 0 # endif # endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 1 #endif /* In a future release of Bison, this section will be replaced by #include "y.tab.h". */ #ifndef YY_YY_GRAM_H_INCLUDED # define YY_YY_GRAM_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 1 #endif #if YYDEBUG extern int yydebug; #endif /* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { T_ACCEPT = 258, T_REJECT = 259, T_TEMPFAIL = 260, T_CONTINUE = 261, T_DISCARD = 262, T_ADD = 263, T_REPLACE = 264, T_DELETE = 265, T_PROG = 266, T_BEGIN = 267, T_END = 268, T_IF = 269, T_FI = 270, T_ELSE = 271, T_ELIF = 272, T_ON = 273, T_HOST = 274, T_FROM = 275, T_AS = 276, T_DO = 277, T_DONE = 278, T_POLL = 279, T_MATCHES = 280, T_FNMATCHES = 281, T_MXMATCHES = 282, T_MXFNMATCHES = 283, T_WHEN = 284, T_PASS = 285, T_SET = 286, T_CATCH = 287, T_TRY = 288, T_THROW = 289, T_ECHO = 290, T_RETURNS = 291, T_RETURN = 292, T_FUNC = 293, T_SWITCH = 294, T_CASE = 295, T_DEFAULT = 296, T_CONST = 297, T_FOR = 298, T_LOOP = 299, T_WHILE = 300, T_BREAK = 301, T_NEXT = 302, T_ARGCOUNT = 303, T_ALIAS = 304, T_DOTS = 305, T_ARGX = 306, T_VAPTR = 307, T_PRECIOUS = 308, T_OR = 309, T_AND = 310, T_EQ = 311, T_NE = 312, T_LT = 313, T_LE = 314, T_GT = 315, T_GE = 316, T_NOT = 317, T_LOGAND = 318, T_LOGOR = 319, T_LOGXOR = 320, T_LOGNOT = 321, T_REQUIRE = 322, T_IMPORT = 323, T_STATIC = 324, T_PUBLIC = 325, T_MODULE = 326, T_BYE = 327, T_DCLEX = 328, T_SHL = 329, T_SHR = 330, T_COMPOSE = 331, T_MODBEG = 332, T_MODEND = 333, T_STRING = 334, T_SYMBOL = 335, T_IDENTIFIER = 336, T_ARG = 337, T_NUMBER = 338, T_BACKREF = 339, T_BUILTIN = 340, T_FUNCTION = 341, T_TYPE = 342, T_TYPECAST = 343, T_VARIABLE = 344, T_BOGUS = 345, T_UMINUS = 346 }; #endif /* Tokens. */ #define T_ACCEPT 258 #define T_REJECT 259 #define T_TEMPFAIL 260 #define T_CONTINUE 261 #define T_DISCARD 262 #define T_ADD 263 #define T_REPLACE 264 #define T_DELETE 265 #define T_PROG 266 #define T_BEGIN 267 #define T_END 268 #define T_IF 269 #define T_FI 270 #define T_ELSE 271 #define T_ELIF 272 #define T_ON 273 #define T_HOST 274 #define T_FROM 275 #define T_AS 276 #define T_DO 277 #define T_DONE 278 #define T_POLL 279 #define T_MATCHES 280 #define T_FNMATCHES 281 #define T_MXMATCHES 282 #define T_MXFNMATCHES 283 #define T_WHEN 284 #define T_PASS 285 #define T_SET 286 #define T_CATCH 287 #define T_TRY 288 #define T_THROW 289 #define T_ECHO 290 #define T_RETURNS 291 #define T_RETURN 292 #define T_FUNC 293 #define T_SWITCH 294 #define T_CASE 295 #define T_DEFAULT 296 #define T_CONST 297 #define T_FOR 298 #define T_LOOP 299 #define T_WHILE 300 #define T_BREAK 301 #define T_NEXT 302 #define T_ARGCOUNT 303 #define T_ALIAS 304 #define T_DOTS 305 #define T_ARGX 306 #define T_VAPTR 307 #define T_PRECIOUS 308 #define T_OR 309 #define T_AND 310 #define T_EQ 311 #define T_NE 312 #define T_LT 313 #define T_LE 314 #define T_GT 315 #define T_GE 316 #define T_NOT 317 #define T_LOGAND 318 #define T_LOGOR 319 #define T_LOGXOR 320 #define T_LOGNOT 321 #define T_REQUIRE 322 #define T_IMPORT 323 #define T_STATIC 324 #define T_PUBLIC 325 #define T_MODULE 326 #define T_BYE 327 #define T_DCLEX 328 #define T_SHL 329 #define T_SHR 330 #define T_COMPOSE 331 #define T_MODBEG 332 #define T_MODEND 333 #define T_STRING 334 #define T_SYMBOL 335 #define T_IDENTIFIER 336 #define T_ARG 337 #define T_NUMBER 338 #define T_BACKREF 339 #define T_BUILTIN 340 #define T_FUNCTION 341 #define T_TYPE 342 #define T_TYPECAST 343 #define T_VARIABLE 344 #define T_BOGUS 345 #define T_UMINUS 346 /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { #line 294 "gram.y" /* yacc.c:355 */ struct literal *literal; struct stmtlist stmtlist; NODE *node; struct return_node ret; struct poll_data poll; struct pollarg { int kw; NODE *expr; } pollarg; struct arglist { NODE *head; NODE *tail; size_t count; } arglist; long number; const struct builtin *builtin; struct variable *var; enum smtp_state state; struct { int qualifier; } matchtype; data_type_t type; struct parmtype *parm; struct parmlist { struct parmtype *head, *tail; size_t count; size_t optcount; int varargs; } parmlist; enum lexical_context tie_in; struct function *function; struct { struct valist *head, *tail; } valist_list; struct { int all; struct valist *valist; } catchlist; struct valist *valist; struct value value; struct { struct case_stmt *head, *tail; } case_list ; struct case_stmt *case_stmt; struct loop_node loop; struct { int code; } progspecial; struct enumlist { struct constant *cv; struct enumlist *prev; } enumlist; mu_list_t list; struct import_rule_list import_rule_list; char *string; #line 635 "gram.c" /* yacc.c:355 */ }; typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 #endif /* Location type. */ #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED typedef struct YYLTYPE YYLTYPE; struct YYLTYPE { int first_line; int first_column; int last_line; int last_column; }; # define YYLTYPE_IS_DECLARED 1 # define YYLTYPE_IS_TRIVIAL 1 #endif extern YYSTYPE yylval; extern YYLTYPE yylloc; int yyparse (void); #endif /* !YY_YY_GRAM_H_INCLUDED */ /* Copy the second part of user declarations. */ #line 666 "gram.c" /* yacc.c:358 */ #ifdef short # undef short #endif #ifdef YYTYPE_UINT8 typedef YYTYPE_UINT8 yytype_uint8; #else typedef unsigned char yytype_uint8; #endif #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; #else typedef signed char yytype_int8; #endif #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else typedef unsigned short int yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else typedef short int yytype_int16; #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif ! defined YYSIZE_T # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned int # endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ # define YY_(Msgid) Msgid # endif #endif #ifndef YY_ATTRIBUTE # if (defined __GNUC__ \ && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C # define YY_ATTRIBUTE(Spec) __attribute__(Spec) # else # define YY_ATTRIBUTE(Spec) /* empty */ # endif #endif #ifndef YY_ATTRIBUTE_PURE # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) #endif #ifndef YY_ATTRIBUTE_UNUSED # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) #endif #if !defined _Noreturn \ && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) # if defined _MSC_VER && 1200 <= _MSC_VER # define _Noreturn __declspec (noreturn) # else # define _Noreturn YY_ATTRIBUTE ((__noreturn__)) # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) #else # define YYUSE(E) /* empty */ #endif #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value #endif #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN # define YY_IGNORE_MAYBE_UNINITIALIZED_END #endif #ifndef YY_INITIAL_VALUE # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # elif defined __BUILTIN_VA_ARG_INCR # include /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS # include /* INFRINGES ON USER NAME SPACE */ /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's 'empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined EXIT_SUCCESS void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined EXIT_SUCCESS void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { yytype_int16 yyss_alloc; YYSTYPE yyvs_alloc; YYLTYPE yyls_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED /* Copy COUNT objects from SRC to DST. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ while (0) # endif # endif #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ #define YYFINAL 33 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 1597 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 104 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 92 /* YYNRULES -- Number of rules. */ #define YYNRULES 231 /* YYNSTATES -- Number of states. */ #define YYNSTATES 393 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 346 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex, without out-of-bounds checking. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 96, 2, 2, 99, 100, 94, 92, 98, 93, 91, 95, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 102, 101, 2, 2, 2, 2, 103, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 481, 481, 507, 508, 514, 518, 519, 530, 543, 547, 555, 558, 561, 572, 590, 594, 600, 601, 607, 612, 620, 621, 624, 635, 661, 679, 683, 687, 693, 699, 707, 708, 714, 728, 765, 793, 796, 805, 809, 813, 820, 825, 838, 852, 892, 916, 924, 942, 952, 958, 989, 993, 996, 997, 1002, 1017, 1022, 1025, 1032, 1041, 1042, 1049, 1058, 1069, 1072, 1075, 1080, 1087, 1094, 1097, 1103, 1115, 1121, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1149, 1150, 1151, 1154, 1178, 1184, 1196, 1209, 1217, 1221, 1229, 1237, 1243, 1251, 1257, 1265, 1271, 1279, 1280, 1289, 1296, 1303, 1313, 1316, 1319, 1326, 1334, 1342, 1351, 1364, 1387, 1388, 1389, 1392, 1402, 1405, 1412, 1418, 1463, 1467, 1474, 1483, 1494, 1500, 1511, 1516, 1523, 1536, 1540, 1546, 1550, 1559, 1570, 1577, 1580, 1584, 1587, 1590, 1610, 1640, 1645, 1650, 1658, 1661, 1667, 1681, 1706, 1712, 1719, 1726, 1733, 1740, 1747, 1754, 1768, 1776, 1783, 1790, 1794, 1797, 1800, 1801, 1808, 1814, 1821, 1828, 1835, 1842, 1849, 1856, 1863, 1870, 1879, 1884, 1888, 1892, 1893, 1899, 1903, 1911, 1915, 1920, 1924, 1925, 1929, 1935, 1940, 1943, 1944, 1952, 1957, 1960, 1964, 1968, 1995, 1996, 2002, 2027, 2042, 2050, 2060, 2066, 2075, 2079, 2085, 2093, 2101, 2109, 2108, 2139, 2143, 2150, 2166, 2178, 2201, 2260, 2268, 2274, 2280, 2289, 2298, 2304, 2309, 2316, 2321, 2326, 2331, 2339, 2343, 2351 }; #endif #if YYDEBUG || YYERROR_VERBOSE || 1 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "\"accept\"", "\"reject\"", "\"tempfail\"", "\"continue\"", "\"discard\"", "\"add\"", "\"replace\"", "\"delete\"", "\"prog\"", "\"begin\"", "\"end\"", "\"if\"", "\"fi\"", "\"else\"", "\"elif\"", "\"on\"", "\"host\"", "\"from\"", "\"as\"", "\"do\"", "\"done\"", "\"poll\"", "\"matches\"", "\"fnmatches\"", "\"mx matches\"", "\"mx fnmatches\"", "\"when\"", "\"pass\"", "\"set\"", "\"catch\"", "\"try\"", "\"throw\"", "\"echo\"", "\"returns\"", "\"return\"", "\"func\"", "\"switch\"", "\"case\"", "\"default\"", "\"const\"", "\"for\"", "\"loop\"", "\"while\"", "\"break\"", "\"next\"", "\"$#\"", "\"alias\"", "\"...\"", "\"$(n)\"", "\"vaptr\"", "\"precious\"", "\"or\"", "\"and\"", "\"==\"", "\"!=\"", "\"<\"", "\"<=\"", "\">\"", "\">=\"", "\"!\"", "\"&\"", "\"|\"", "\"^\"", "\"~\"", "\"require\"", "\"import\"", "\"static\"", "\"public\"", "\"module\"", "\"bye\"", "\"dclex\"", "\"<<\"", "\">>\"", "\"composed string\"", "T_MODBEG", "T_MODEND", "\"string\"", "\"MTA macro\"", "\"identifier\"", "\"$n\"", "\"number\"", "\"back reference\"", "\"builtin function\"", "\"function\"", "\"data type\"", "\"typecast\"", "\"variable\"", "T_BOGUS", "'.'", "'+'", "'-'", "'*'", "'/'", "'%'", "T_UMINUS", "','", "'('", "')'", "';'", "':'", "'@'", "$accept", "input", "program", "decllist", "modcntl", "opt_moddecl", "moddecl", "require", "bye", "imports", "literal", "decl", "progspecial", "varname", "vardecl", "qualifiers", "qualifier", "constdecl", "qualconst", "constdefn", "enumlist", "exdecl", "fundecl", "parmdecl", "params", "opt_parmlist", "parmlist", "fparmlist", "parm", "aliasdecl", "aliases", "alias", "retdecl", "state_ident", "stmtlist", "stmt", "asgn", "autodcl", "action", "sendmail_action", "maybe_xcode_expr", "header_action", "maybe_triplet", "triplet", "code", "xcode", "condition", "if_cond", "else_cond", "case_cond", "cond_branches", "cond_branch", "valist", "value", "string", "matches", "fnmatches", "loopstmt", "loop_ident", "opt_ident", "opt_loop_parms", "loop_parm_list", "loop_parm", "opt_while", "jumpstmt", "expr", "maybe_expr", "simp_expr", "atom_expr", "atom", "strcat", "strval", "argref", "paren_argref", "funcall", "arglist", "variable", "catch", "try_block", "simple_catch", "@1", "catchlist", "throw", "return", "on_cond", "on", "do", "pollstmt", "pollarglist", "pollarg", "branches", "branch", YY_NULLPTR }; #endif # ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 46, 43, 45, 42, 47, 37, 346, 44, 40, 41, 59, 58, 64 }; # endif #define YYPACT_NINF -271 #define yypact_value_is_default(Yystate) \ (!!((Yystate) == (-271))) #define YYTABLE_NINF -232 #define yytable_value_is_error(Yytable_value) \ (!!((Yytable_value) == (-232))) /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ static const yytype_int16 yypact[] = { 236, -57, -271, -271, 42, 9, 42, 42, 10, 43, -271, 449, -271, 311, 31, -271, 102, -271, -9, -271, -1, -271, -271, 117, -271, -271, 84, -271, -271, 1318, -271, 101, -271, -271, -271, -271, 315, 94, 1150, 9, -271, -271, -271, -271, 9, -271, 9, 1318, -271, 1150, 42, -271, 70, 69, 1318, 1404, -271, -271, -271, -271, -271, -271, 86, 91, 123, -271, -271, 1404, 1404, 1318, 140, 1192, 1462, -271, -271, -28, -271, -271, -271, -271, -271, 142, -271, -271, 311, -271, 158, -47, -42, -271, -271, 74, 74, 74, 1318, -271, -271, 9, -13, 228, 74, 1318, 1318, 1318, 9, 9, 9, 9, -15, -271, 835, -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, 230, -271, -271, -271, -271, -2, 167, 246, 1318, 1318, -271, -10, 1192, 880, -52, -271, 1318, 7, -271, -271, 407, -271, 1232, 1275, 1318, -271, -271, 87, -271, -271, -271, -271, -271, 1318, 1318, 1318, 1318, 1318, 1318, 1318, 1318, 1318, 1318, 1404, 1404, 1404, 1404, 1404, 1404, 1404, 1404, 1404, 1404, 1404, -271, -271, 1203, -271, -271, -271, 1361, 1318, -271, 1318, -271, -271, -271, -271, 1318, 1318, -271, 480, 1318, -271, 215, -271, 248, 1150, 1318, 1192, 1192, 1147, -271, 539, -271, -271, -271, 1318, -271, -271, -271, 1179, 250, 250, -24, 1150, 1192, -271, 1318, -271, -271, -271, 42, 578, 175, -271, 1192, 80, -271, 96, 636, -271, 1474, 407, 1491, 1491, 166, 166, 166, 166, 1491, 1491, 124, 1501, 381, 165, 165, 1496, 108, 108, -271, -271, -271, 199, 187, 1318, 1192, 1192, 183, 184, 1192, 1192, 584, 1192, 74, -271, 925, 1192, 121, 1150, 1318, 361, 262, 189, -271, 1192, 1318, 1318, 1318, 1318, 1485, 106, -271, -271, 256, 256, -271, 9, 190, -271, 191, 134, -271, -271, 970, -271, -271, -271, 1318, -271, -271, -271, -271, 208, 1192, 1361, 1361, 1150, 1318, 280, -271, 1150, -271, 74, 196, 45, -271, 406, 1192, 1150, 745, 1192, 1192, 1192, 1192, 106, -271, 74, 93, -271, 127, -271, 251, 214, 0, -271, 1192, 211, 206, -271, -271, 210, 1015, 480, -271, 1060, -38, 1150, -271, -271, 1105, -271, -20, -271, -271, -271, 9, 270, 251, -271, 219, -271, -271, -271, 235, 1318, 1318, 584, -271, 1150, 642, 275, 1150, -271, 234, -271, -271, -271, 225, 232, -271, 700, 1318, -271, 790, -271, -271, -271, 1192 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. Performed when YYTABLE does not specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { 36, 0, 29, 30, 0, 0, 0, 0, 0, 0, 2, 36, 6, 36, 9, 5, 0, 26, 0, 27, 0, 28, 71, 0, 21, 22, 0, 31, 32, 0, 15, 0, 49, 1, 8, 7, 36, 11, 36, 0, 43, 38, 39, 40, 0, 37, 0, 0, 41, 36, 0, 185, 0, 0, 0, 0, 192, 191, 181, 194, 182, 183, 0, 0, 0, 204, 205, 0, 0, 0, 0, 35, 159, 162, 177, 188, 189, 184, 174, 193, 13, 0, 18, 4, 36, 12, 104, 104, 104, 97, 98, 0, 0, 0, 0, 218, 90, 0, 0, 0, 0, 0, 214, 0, 135, 135, 135, 0, 0, 82, 36, 72, 76, 77, 75, 88, 89, 74, 112, 113, 83, 84, 81, 78, 0, 206, 79, 80, 114, 0, 0, 0, 33, 45, 46, 0, 44, 36, 0, 19, 0, 0, 196, 187, 148, 180, 0, 0, 0, 179, 178, 0, 186, 129, 131, 130, 132, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 190, 14, 36, 110, 92, 105, 106, 160, 93, 160, 95, 126, 127, 128, 0, 0, 103, 36, 0, 211, 212, 124, 0, 36, 0, 91, 215, 0, 136, 36, 134, 146, 147, 86, 24, 73, 207, 0, 0, 0, 51, 36, 34, 42, 47, 48, 23, 16, 0, 0, 0, 199, 202, 0, 201, 0, 0, 175, 157, 158, 149, 150, 151, 152, 153, 154, 155, 156, 169, 170, 171, 172, 173, 164, 163, 165, 166, 167, 168, 0, 182, 107, 109, 161, 0, 0, 101, 102, 36, 85, 0, 209, 36, 213, 0, 36, 0, 36, 0, 138, 139, 87, 0, 0, 0, 0, 220, 222, 223, 219, 0, 0, 54, 63, 0, 52, 0, 57, 53, 58, 36, 20, 195, 197, 0, 198, 200, 176, 10, 0, 108, 160, 160, 36, 0, 0, 125, 36, 208, 0, 0, 0, 120, 36, 143, 36, 36, 226, 228, 227, 225, 221, 224, 0, 0, 229, 0, 62, 64, 0, 0, 25, 203, 0, 0, 100, 99, 0, 36, 36, 115, 36, 0, 36, 119, 121, 36, 140, 0, 217, 230, 216, 0, 69, 65, 66, 60, 55, 61, 59, 0, 160, 160, 36, 210, 36, 36, 144, 36, 68, 0, 50, 67, 111, 0, 0, 117, 36, 0, 133, 36, 70, 94, 96, 145 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { -271, -271, -271, -8, -4, -271, 293, -271, 154, -271, -5, 1, -271, 3, -271, 17, 306, 56, -271, -36, -271, -271, -271, -271, -271, -271, 6, 8, 2, -271, -271, -14, -271, -271, -18, -75, -271, -271, -271, -271, 34, -271, 156, -271, -271, 163, -271, -271, -22, -271, -271, 32, -222, -89, 82, -271, -271, -271, -271, 159, -271, -271, 28, -271, -271, -29, -181, 38, -271, -271, -271, 279, -34, -271, -35, 209, -271, -271, -271, 237, -271, -271, -271, -271, -271, -271, 143, -271, 75, -270, 73, -95 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { -1, 9, 10, 11, 12, 84, 13, 14, 83, 138, 26, 15, 16, 206, 17, 108, 45, 109, 20, 48, 135, 21, 131, 292, 293, 294, 295, 296, 297, 361, 362, 363, 379, 23, 275, 111, 112, 113, 114, 115, 342, 116, 182, 183, 184, 343, 117, 118, 313, 119, 319, 320, 198, 191, 192, 165, 166, 120, 207, 208, 276, 277, 278, 387, 121, 261, 344, 72, 73, 74, 75, 76, 77, 143, 78, 231, 79, 123, 124, 125, 315, 200, 126, 127, 128, 129, 288, 217, 285, 286, 332, 333 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int16 yytable[] = { 71, 30, 31, 122, 262, 36, 263, 34, 29, 199, 134, 202, 35, 221, 122, 330, 268, 18, 136, 142, 110, 46, 215, 47, 22, 144, 290, 40, 18, 39, 18, 137, 34, 40, 268, 213, 181, 35, 41, 225, 151, 181, 130, 33, 41, 139, 226, 132, 56, 133, 366, 57, 185, 18, 42, 43, 19, 187, 52, 330, 42, 43, 213, 291, 373, 195, 189, 19, 352, 19, 190, 27, 203, 204, 205, 122, 180, -56, 44, 28, 27, 197, 376, 62, 63, 317, 318, 291, 28, 59, 27, 32, 19, 145, 216, 350, 65, 66, 28, 223, 196, 18, 122, 220, 136, 149, 150, 228, 37, 356, 211, 227, 153, 154, 155, 156, 357, 230, 230, 234, 52, 24, 331, 25, 38, 280, 281, 282, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 222, 49, 19, 157, 158, 159, 160, 161, 162, 163, 164, 283, 359, 59, 50, 189, 41, 260, 331, 190, 65, 66, 122, 317, 318, 264, 265, 7, 122, 267, 141, 140, 42, 43, 122, 271, 193, 194, 34, 266, 302, 314, 303, 35, 279, 270, 122, 146, 284, 235, 382, 383, 147, 213, 80, 136, 302, 213, 304, 18, 170, 171, 213, 298, 175, 176, 177, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 173, 174, 175, 176, 177, 299, 148, 213, -232, -232, -232, -232, 199, 152, 308, 122, 338, 179, -60, 122, 19, 358, 122, 358, 122, 181, 199, 186, 188, 322, 213, 1, 2, 3, 201, 325, 326, 327, 328, 321, 4, 173, 174, 175, 176, 177, 98, 122, 209, 210, 218, 5, 219, 268, 269, 213, 287, 340, 213, 301, 122, 306, 307, 213, 122, 309, 310, 347, 323, 331, 122, 324, 122, 122, 336, 341, 337, 346, 335, 348, 213, 349, 351, 213, 360, 291, 368, 6, 369, 354, 378, 7, 370, 8, 213, 122, 122, 213, 122, -17, 122, 338, 381, 122, 386, 389, 1, 2, 3, 390, 1, 2, 3, 371, 85, 4, 391, 374, 257, 4, 122, 81, 122, 122, 367, 122, 5, 364, 345, 365, 5, 259, 380, 384, 122, 353, 355, 122, 178, 385, 233, 392, 388, 329, 289, 214, 334, 377, 86, 87, 88, 89, 90, 91, 92, 93, 0, 0, 0, 94, 0, 0, 6, 95, 0, 0, 6, -141, 8, 0, 0, 82, 8, 0, 0, 96, 97, 98, 99, 100, 101, 0, 102, 0, 103, 0, 0, 0, 0, 104, 0, 105, 106, 86, 87, 88, 89, 90, 91, 92, 93, 0, 0, 0, 94, 0, 0, 0, 95, 0, 0, 0, -142, 0, 0, 0, 153, 154, 155, 156, 96, 97, 98, 99, 100, 101, 0, 102, 167, 103, 62, 63, 107, -3, 104, 0, 105, 106, 0, 170, 171, 0, 0, -141, 1, 2, 3, 159, 160, 161, 162, 163, 164, 4, 0, 0, 0, 173, 174, 175, 176, 177, 0, 0, 5, 0, 0, 86, 87, 88, 89, 90, 91, 92, 93, 62, 63, 107, 94, 0, 0, 0, 95, 0, 0, 0, 0, 0, -142, 153, 154, 155, 156, 0, 96, 97, 98, 99, 100, 101, 6, 102, 0, 103, 0, 0, 8, 0, 104, 0, 105, 106, 0, 0, 0, 0, 0, 0, 157, 158, 159, 160, 161, 162, 163, 164, 86, 87, 88, 89, 90, 91, 92, 93, 0, 0, 0, 94, 0, 0, 0, 95, 0, 0, 0, -137, 0, 0, 0, 62, 63, 107, 0, 96, 97, 98, 99, 100, 101, 0, 102, 0, 103, 0, 0, 0, 273, 104, 274, 105, 106, 86, 87, 88, 89, 90, 91, 92, 93, 0, 0, 0, 94, -116, 311, 312, 95, 153, 154, 155, 156, 0, 0, 0, 0, 0, 0, 0, 96, 97, 98, 99, 100, 101, 0, 102, 0, 103, 62, 63, 107, 0, 104, 0, 105, 106, 157, 158, 159, 160, 161, 162, 163, 164, 0, 0, 0, 0, 0, 86, 87, 88, 89, 90, 91, 92, 93, 0, 0, 0, 94, 0, 0, 0, 95, 153, 154, 155, 156, -123, 0, 0, 0, 62, 63, 107, 96, 97, 98, 99, 100, 101, 300, 102, 0, 103, -123, -123, 0, 0, 104, 0, 105, 106, 157, 158, 159, 160, 161, 162, 163, 164, 0, 0, 0, 0, 0, 86, 87, 88, 89, 90, 91, 92, 93, 0, 0, 0, 94, 0, 0, 0, 95, 0, 0, 0, 0, -122, 0, 0, 0, 62, 63, 107, 96, 97, 98, 99, 100, 101, 305, 102, 0, 103, -122, -122, 0, 0, 104, 0, 105, 106, 86, 87, 88, 89, 90, 91, 92, 93, 0, 0, 0, 94, 0, 0, 0, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 97, 98, 99, 100, 101, 0, 102, 0, 103, 62, 63, 107, 273, 104, 274, 105, 106, 86, 87, 88, 89, 90, 91, 92, 93, 0, 0, 0, 94, 0, 0, 0, 95, 0, 0, 0, 0, -231, 0, 0, 0, 0, 0, -231, 96, 97, 98, 99, 100, 101, 0, 102, 0, 103, 62, 63, 107, 0, 104, 0, 105, 106, 86, 87, 88, 89, 90, 91, 92, 93, 0, 0, 0, 94, 0, 0, 0, 95, 0, 0, 0, 0, 212, 0, 0, 0, 0, 0, 0, 96, 97, 98, 99, 100, 101, 0, 102, 0, 103, 62, 63, 107, 0, 104, 0, 105, 106, 86, 87, 88, 89, 90, 91, 92, 93, 0, 0, 0, 94, 0, 0, 0, 95, 0, 0, 0, 0, 224, 0, 0, 0, 0, 0, 0, 96, 97, 98, 99, 100, 101, 0, 102, 0, 103, 62, 63, 107, 0, 104, 0, 105, 106, 86, 87, 88, 89, 90, 91, 92, 93, 0, 0, 0, 94, 0, 0, 0, 95, 0, 0, 0, 0, 316, 0, 0, 0, 0, 0, 0, 96, 97, 98, 99, 100, 101, 0, 102, 0, 103, 62, 63, 107, 0, 104, 0, 105, 106, 86, 87, 88, 89, 90, 91, 92, 93, 0, 0, 0, 94, 0, 0, 0, 95, 0, 0, 0, 0, 339, 0, 0, 0, 0, 0, 0, 96, 97, 98, 99, 100, 101, 0, 102, 0, 103, 62, 63, 107, 0, 104, 0, 105, 106, 86, 87, 88, 89, 90, 91, 92, 93, 0, 0, 0, 94, -118, 0, 0, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 97, 98, 99, 100, 101, 0, 102, 0, 103, 62, 63, 107, 0, 104, 0, 105, 106, 86, 87, 88, 89, 90, 91, 92, 93, 0, 0, 0, 94, 0, 0, 0, 95, 0, 0, 0, 0, 372, 0, 0, 0, 0, 0, 0, 96, 97, 98, 99, 100, 101, 0, 102, 0, 103, 62, 63, 107, 0, 104, 0, 105, 106, 86, 87, 88, 89, 90, 91, 92, 93, 0, 0, 0, 94, 0, 0, 0, 95, 0, 0, 0, 0, 375, 0, 0, 0, 0, 0, 0, 96, 97, 98, 99, 100, 101, 0, 102, 0, 103, 62, 63, 107, 0, 104, 0, 105, 106, 86, 87, 88, 89, 90, 91, 92, 93, 0, 0, 0, 94, 0, 0, 0, 95, 272, 0, 0, 153, 154, 155, 156, 0, 0, 0, 0, 96, 97, 98, 99, 100, 101, 0, 102, 0, 103, 62, 63, 107, 0, 104, 0, 105, 106, 280, 281, 282, 157, 158, 159, 160, 161, 162, 163, 164, 0, 0, 0, 0, 0, 1, 2, 3, 153, 154, 155, 156, 0, 283, 4, 0, 0, 0, 51, 0, 0, 52, 53, 0, 0, 5, 62, 63, 107, 0, 0, 0, 54, 0, 0, 0, 55, 157, 158, 159, 160, 161, 162, 163, 164, 0, 56, 0, 0, 57, 58, 0, 59, 60, 61, 62, 63, 0, 64, 65, 66, 6, 67, 68, 0, 0, 82, 8, 0, 69, 0, 51, -17, 70, 52, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 57, 58, 0, 59, 60, 61, 62, 63, 0, 64, 65, 66, 51, 67, 68, 52, 53, 0, 0, 0, 69, 229, 0, 0, 70, 0, 54, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 57, 58, 0, 59, 60, 61, 62, 63, 0, 64, 65, 66, 51, 67, 68, 52, 53, 0, 0, 0, 69, 232, 0, 0, 70, 0, 54, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 57, 58, 0, 59, 60, 61, 62, 63, 0, 64, 65, 66, 51, 67, 68, 52, 53, 0, 0, 0, 69, 0, 0, 0, 70, 0, 54, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 57, 58, 0, 59, 258, 61, 62, 63, 0, 64, 65, 66, 51, 67, 68, 52, 53, 0, 0, 0, 69, 0, 0, 0, 70, 0, 0, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 57, 58, 0, 59, 60, 61, 62, 63, 0, 64, 65, 66, 0, 67, 68, 0, 153, 154, 155, 156, 69, 280, 281, 282, 70, 0, 0, 153, 154, 155, 156, 0, 0, -232, -232, -232, -232, 0, 0, 0, 0, 0, 167, 168, 169, 283, 158, 159, 160, 161, 162, 163, 164, 170, 171, 0, 157, 158, 159, 160, 161, 162, 163, 164, -232, -232, 161, 162, 163, 164, 172, 173, 174, 175, 176, 177, 167, 168, 169, 0, 0, 167, 0, 169, 0, 0, 0, 170, 171, 0, 0, 0, 170, 171, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 173, 174, 175, 176, 177, 173, 174, 175, 176, 177 }; static const yytype_int16 yycheck[] = { 29, 6, 7, 38, 185, 13, 187, 11, 5, 98, 46, 100, 11, 23, 49, 285, 54, 0, 47, 53, 38, 22, 24, 20, 81, 54, 50, 42, 11, 38, 13, 49, 36, 42, 54, 110, 83, 36, 53, 91, 69, 83, 39, 0, 53, 50, 98, 44, 76, 46, 50, 79, 99, 36, 69, 70, 0, 99, 51, 329, 69, 70, 137, 87, 102, 94, 79, 11, 23, 13, 83, 81, 101, 102, 103, 110, 84, 101, 87, 89, 81, 94, 102, 85, 86, 40, 41, 87, 89, 82, 81, 81, 36, 55, 129, 317, 89, 90, 89, 135, 97, 84, 137, 132, 133, 67, 68, 141, 77, 331, 107, 140, 25, 26, 27, 28, 23, 146, 147, 148, 51, 79, 29, 81, 22, 19, 20, 21, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 135, 22, 84, 54, 55, 56, 57, 58, 59, 60, 61, 43, 23, 82, 68, 79, 53, 184, 29, 83, 89, 90, 195, 40, 41, 192, 193, 71, 201, 196, 99, 99, 69, 70, 207, 202, 92, 93, 180, 195, 98, 268, 100, 180, 211, 201, 219, 99, 215, 100, 369, 370, 99, 266, 91, 222, 98, 270, 100, 180, 74, 75, 275, 219, 94, 95, 96, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 92, 93, 94, 95, 96, 226, 99, 298, 58, 59, 60, 61, 317, 89, 259, 266, 98, 91, 100, 270, 180, 332, 273, 334, 275, 83, 331, 87, 88, 274, 321, 11, 12, 13, 22, 280, 281, 282, 283, 273, 20, 92, 93, 94, 95, 96, 32, 298, 105, 106, 99, 31, 22, 54, 22, 346, 22, 302, 349, 100, 311, 78, 91, 354, 315, 98, 98, 312, 22, 29, 321, 98, 323, 324, 100, 83, 101, 311, 291, 15, 371, 315, 102, 374, 49, 87, 91, 67, 98, 323, 36, 71, 98, 73, 385, 346, 347, 388, 349, 0, 351, 98, 83, 354, 45, 87, 11, 12, 13, 100, 11, 12, 13, 347, 37, 20, 100, 351, 180, 20, 371, 31, 373, 374, 338, 376, 31, 337, 310, 337, 31, 184, 362, 371, 385, 319, 324, 388, 75, 373, 147, 386, 376, 284, 217, 124, 289, 360, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, 14, -1, -1, 67, 18, -1, -1, 67, 22, 73, -1, -1, 72, 73, -1, -1, 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, -1, -1, -1, -1, 44, -1, 46, 47, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, 14, -1, -1, -1, 18, -1, -1, -1, 22, -1, -1, -1, 25, 26, 27, 28, 30, 31, 32, 33, 34, 35, -1, 37, 63, 39, 85, 86, 87, 0, 44, -1, 46, 47, -1, 74, 75, -1, -1, 98, 11, 12, 13, 56, 57, 58, 59, 60, 61, 20, -1, -1, -1, 92, 93, 94, 95, 96, -1, -1, 31, -1, -1, 3, 4, 5, 6, 7, 8, 9, 10, 85, 86, 87, 14, -1, -1, -1, 18, -1, -1, -1, -1, -1, 98, 25, 26, 27, 28, -1, 30, 31, 32, 33, 34, 35, 67, 37, -1, 39, -1, -1, 73, -1, 44, -1, 46, 47, -1, -1, -1, -1, -1, -1, 54, 55, 56, 57, 58, 59, 60, 61, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, 14, -1, -1, -1, 18, -1, -1, -1, 22, -1, -1, -1, 85, 86, 87, -1, 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, -1, -1, -1, 43, 44, 45, 46, 47, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, 14, 15, 16, 17, 18, 25, 26, 27, 28, -1, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, 85, 86, 87, -1, 44, -1, 46, 47, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, 14, -1, -1, -1, 18, 25, 26, 27, 28, 23, -1, -1, -1, 85, 86, 87, 30, 31, 32, 33, 34, 35, 100, 37, -1, 39, 40, 41, -1, -1, 44, -1, 46, 47, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, 14, -1, -1, -1, 18, -1, -1, -1, -1, 23, -1, -1, -1, 85, 86, 87, 30, 31, 32, 33, 34, 35, 100, 37, -1, 39, 40, 41, -1, -1, 44, -1, 46, 47, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, 14, -1, -1, -1, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, 85, 86, 87, 43, 44, 45, 46, 47, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, 14, -1, -1, -1, 18, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, 29, 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, 85, 86, 87, -1, 44, -1, 46, 47, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, 14, -1, -1, -1, 18, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, 85, 86, 87, -1, 44, -1, 46, 47, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, 14, -1, -1, -1, 18, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, 85, 86, 87, -1, 44, -1, 46, 47, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, 14, -1, -1, -1, 18, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, 85, 86, 87, -1, 44, -1, 46, 47, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, 14, -1, -1, -1, 18, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, 85, 86, 87, -1, 44, -1, 46, 47, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, 14, 15, -1, -1, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, 85, 86, 87, -1, 44, -1, 46, 47, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, 14, -1, -1, -1, 18, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, 85, 86, 87, -1, 44, -1, 46, 47, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, 14, -1, -1, -1, 18, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, 85, 86, 87, -1, 44, -1, 46, 47, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, 14, -1, -1, -1, 18, 22, -1, -1, 25, 26, 27, 28, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, -1, 37, -1, 39, 85, 86, 87, -1, 44, -1, 46, 47, 19, 20, 21, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, 11, 12, 13, 25, 26, 27, 28, -1, 43, 20, -1, -1, -1, 48, -1, -1, 51, 52, -1, -1, 31, 85, 86, 87, -1, -1, -1, 62, -1, -1, -1, 66, 54, 55, 56, 57, 58, 59, 60, 61, -1, 76, -1, -1, 79, 80, -1, 82, 83, 84, 85, 86, -1, 88, 89, 90, 67, 92, 93, -1, -1, 72, 73, -1, 99, -1, 48, 78, 103, 51, 52, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 66, -1, -1, -1, -1, -1, -1, -1, -1, -1, 76, -1, -1, 79, 80, -1, 82, 83, 84, 85, 86, -1, 88, 89, 90, 48, 92, 93, 51, 52, -1, -1, -1, 99, 100, -1, -1, 103, -1, 62, -1, -1, -1, 66, -1, -1, -1, -1, -1, -1, -1, -1, -1, 76, -1, -1, 79, 80, -1, 82, 83, 84, 85, 86, -1, 88, 89, 90, 48, 92, 93, 51, 52, -1, -1, -1, 99, 100, -1, -1, 103, -1, 62, -1, -1, -1, 66, -1, -1, -1, -1, -1, -1, -1, -1, -1, 76, -1, -1, 79, 80, -1, 82, 83, 84, 85, 86, -1, 88, 89, 90, 48, 92, 93, 51, 52, -1, -1, -1, 99, -1, -1, -1, 103, -1, 62, -1, -1, -1, 66, -1, -1, -1, -1, -1, -1, -1, -1, -1, 76, -1, -1, 79, 80, -1, 82, 83, 84, 85, 86, -1, 88, 89, 90, 48, 92, 93, 51, 52, -1, -1, -1, 99, -1, -1, -1, 103, -1, -1, -1, -1, -1, 66, -1, -1, -1, -1, -1, -1, -1, -1, -1, 76, -1, -1, 79, 80, -1, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, 25, 26, 27, 28, 99, 19, 20, 21, 103, -1, -1, 25, 26, 27, 28, -1, -1, 25, 26, 27, 28, -1, -1, -1, -1, -1, 63, 64, 65, 43, 55, 56, 57, 58, 59, 60, 61, 74, 75, -1, 54, 55, 56, 57, 58, 59, 60, 61, 56, 57, 58, 59, 60, 61, 91, 92, 93, 94, 95, 96, 63, 64, 65, -1, -1, 63, -1, 65, -1, -1, -1, 74, 75, -1, -1, -1, 74, 75, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 92, 93, 94, 95, 96, 92, 93, 94, 95, 96 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 11, 12, 13, 20, 31, 67, 71, 73, 105, 106, 107, 108, 110, 111, 115, 116, 118, 119, 121, 122, 125, 81, 137, 79, 81, 114, 81, 89, 117, 114, 114, 81, 0, 108, 115, 107, 77, 22, 38, 42, 53, 69, 70, 87, 120, 22, 117, 123, 22, 68, 48, 51, 52, 62, 66, 76, 79, 80, 82, 83, 84, 85, 86, 88, 89, 90, 92, 93, 99, 103, 169, 171, 172, 173, 174, 175, 176, 178, 180, 91, 120, 72, 112, 109, 110, 3, 4, 5, 6, 7, 8, 9, 10, 14, 18, 30, 31, 32, 33, 34, 35, 37, 39, 44, 46, 47, 87, 119, 121, 138, 139, 140, 141, 142, 143, 145, 150, 151, 153, 161, 168, 178, 181, 182, 183, 186, 187, 188, 189, 117, 126, 117, 117, 123, 124, 169, 138, 113, 114, 99, 99, 176, 177, 169, 171, 99, 99, 99, 171, 171, 169, 89, 25, 26, 27, 28, 54, 55, 56, 57, 58, 59, 60, 61, 159, 160, 63, 64, 65, 74, 75, 91, 92, 93, 94, 95, 96, 175, 91, 107, 83, 146, 147, 148, 99, 146, 99, 146, 79, 83, 157, 158, 158, 158, 169, 117, 94, 156, 157, 185, 22, 157, 169, 169, 169, 117, 162, 163, 163, 163, 117, 23, 139, 183, 24, 178, 191, 99, 22, 169, 23, 117, 123, 23, 91, 98, 169, 176, 100, 169, 179, 100, 179, 169, 100, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 112, 83, 149, 169, 169, 170, 170, 169, 169, 138, 169, 54, 22, 138, 169, 22, 43, 45, 138, 164, 165, 166, 169, 19, 20, 21, 43, 169, 192, 193, 22, 190, 190, 50, 87, 127, 128, 129, 130, 131, 132, 138, 114, 100, 100, 98, 100, 100, 100, 78, 91, 169, 98, 98, 16, 17, 152, 157, 184, 23, 40, 41, 154, 155, 138, 169, 22, 98, 169, 169, 169, 169, 192, 193, 29, 194, 195, 194, 117, 100, 101, 98, 23, 169, 83, 144, 149, 170, 144, 138, 169, 15, 138, 156, 102, 23, 155, 138, 166, 156, 23, 195, 23, 49, 133, 134, 135, 130, 131, 50, 132, 91, 98, 98, 138, 23, 102, 138, 23, 102, 117, 36, 136, 135, 83, 170, 170, 152, 138, 45, 167, 138, 87, 100, 100, 169 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { 0, 104, 105, 106, 106, 107, 107, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 115, 115, 115, 115, 116, 116, 117, 117, 118, 118, 118, 119, 119, 120, 120, 120, 121, 121, 122, 123, 124, 124, 124, 124, 125, 126, 127, 127, 128, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 136, 136, 137, 138, 138, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 140, 141, 141, 142, 142, 142, 142, 143, 143, 143, 143, 143, 143, 143, 144, 144, 145, 145, 145, 146, 146, 147, 147, 147, 147, 148, 149, 150, 150, 150, 151, 152, 152, 152, 153, 154, 154, 155, 155, 156, 156, 157, 157, 158, 159, 159, 160, 160, 161, 162, 163, 163, 164, 164, 165, 165, 166, 166, 166, 167, 167, 168, 168, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 170, 170, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 172, 172, 172, 172, 172, 172, 172, 173, 173, 173, 173, 173, 173, 173, 173, 174, 174, 175, 175, 176, 176, 176, 177, 177, 178, 178, 178, 178, 179, 179, 180, 180, 181, 181, 182, 184, 183, 185, 185, 186, 187, 187, 188, 188, 189, 190, 191, 191, 191, 192, 192, 193, 193, 193, 193, 194, 194, 195 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 1, 1, 3, 1, 1, 2, 2, 1, 6, 0, 1, 3, 4, 2, 5, 0, 1, 1, 3, 1, 1, 5, 4, 6, 1, 1, 1, 1, 1, 1, 1, 3, 4, 3, 0, 2, 1, 1, 1, 2, 4, 2, 2, 1, 1, 2, 2, 2, 6, 0, 1, 1, 1, 3, 0, 1, 1, 3, 1, 3, 2, 1, 0, 1, 1, 2, 2, 0, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 3, 1, 1, 1, 2, 2, 2, 8, 2, 8, 1, 1, 1, 1, 3, 3, 2, 0, 1, 1, 2, 3, 2, 1, 5, 1, 1, 1, 5, 0, 4, 2, 5, 1, 2, 4, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 7, 1, 0, 1, 0, 1, 1, 3, 1, 2, 2, 0, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 0, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 3, 4, 1, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, 1, 1, 4, 1, 3, 4, 3, 4, 3, 1, 3, 1, 1, 1, 2, 4, 0, 6, 1, 1, 3, 1, 2, 5, 5, 1, 1, 2, 3, 2, 1, 2, 2, 2, 2, 2, 1, 2, 4 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY) \ { \ yychar = (Token); \ yylval = (Value); \ YYPOPSTACK (yylen); \ yystate = *yyssp; \ goto yybackup; \ } \ else \ { \ yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (0) /* Error token number */ #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ if (N) \ { \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ } \ else \ { \ (Current).first_line = (Current).last_line = \ YYRHSLOC (Rhs, 0).last_line; \ (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ while (0) #endif #define YYRHSLOC(Rhs, K) ((Rhs)[K]) /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) /* YY_LOCATION_PRINT -- Print the location on the stream. This macro was not mandated originally: define only if we know we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL /* Print *YYLOCP on YYO. Private, do not rely on its existence. */ YY_ATTRIBUTE_UNUSED static unsigned yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) { unsigned res = 0; int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0; if (0 <= yylocp->first_line) { res += YYFPRINTF (yyo, "%d", yylocp->first_line); if (0 <= yylocp->first_column) res += YYFPRINTF (yyo, ".%d", yylocp->first_column); } if (0 <= yylocp->last_line) { if (yylocp->first_line < yylocp->last_line) { res += YYFPRINTF (yyo, "-%d", yylocp->last_line); if (0 <= end_col) res += YYFPRINTF (yyo, ".%d", end_col); } else if (0 <= end_col && yylocp->first_column < end_col) res += YYFPRINTF (yyo, "-%d", end_col); } return res; } # define YY_LOCATION_PRINT(File, Loc) \ yy_location_print_ (File, &(Loc)) # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif #endif # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value, Location); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) /*----------------------------------------. | Print this symbol's value on YYOUTPUT. | `----------------------------------------*/ static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) { FILE *yyo = yyoutput; YYUSE (yyo); YYUSE (yylocationp); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # endif YYUSE (yytype); } /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) { YYFPRINTF (yyoutput, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); YY_LOCATION_PRINT (yyoutput, *yylocationp); YYFPRINTF (yyoutput, ": "); yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp); YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) { int yybot = *yybottom; YYFPRINTF (stderr, " %d", yybot); } YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule) { unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], &(yyvsp[(yyi + 1) - (yynrhs)]) , &(yylsp[(yyi + 1) - (yynrhs)]) ); YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyssp, yyvsp, yylsp, Rule); \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ static YYSIZE_T yystrlen (const char *yystr) { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * yystpcpy (char *yydest, const char *yysrc) { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (! yyres) return yystrlen (yystr); return yystpcpy (yyres, yystr) - yyres; } # endif /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message about the unexpected token YYTOKEN for the state stack whose top is YYSSP. Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is not large enough to hold the message. In that case, also set *YYMSG_ALLOC to the required number of bytes. Return 2 if the required number of bytes is too large to store. */ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULLPTR; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per "expected"). */ int yycount = 0; /* There are many possibilities here to consider: - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected tokens because there are none. - The only way there can be no lookahead present (in yychar) is if this state is a consistent state with a default action. Thus, detecting the absence of a lookahead is sufficient to determine that there is no unexpected or expected token to report. In that case, just report a simple "syntax error". - Don't assume there isn't a lookahead just because this state is a consistent state with a default action. There might have been a previous inconsistent state, consistent state with a non-default action, or user semantic action that manipulated yychar. - Of course, the expected token list depends on states to have correct lookahead information, and it depends on the parser not to perform extra reductions after fetching a lookahead from the scanner and before detecting a syntax error. Thus, state merging (from LALR or IELR) and default reductions corrupt the expected token list. However, the list is correct for canonical LR with one exception: it will still contain any token that will not be accepted due to an error action in a later state. */ if (yytoken != YYEMPTY) { int yyn = yypact[*yyssp]; yyarg[yycount++] = yytname[yytoken]; if (!yypact_value_is_default (yyn)) { /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. In other words, skip the first -YYN actions for this state because they are default actions. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yyx; for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR && !yytable_value_is_error (yytable[yyx + yyn])) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; break; } yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } } } } switch (yycount) { # define YYCASE_(N, S) \ case N: \ yyformat = S; \ break YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); # undef YYCASE_ } { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; yysize = yysize1; } if (*yymsg_alloc < yysize) { *yymsg_alloc = 2 * yysize; if (! (yysize <= *yymsg_alloc && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; return 1; } /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ { char *yyp = *yymsg; int yyi = 0; while ((*yyp = *yyformat) != '\0') if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyformat += 2; } else { yyp++; yyformat++; } } return 0; } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) { YYUSE (yyvaluep); YYUSE (yylocationp); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN YYUSE (yytype); YY_IGNORE_MAYBE_UNINITIALIZED_END } /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Location data for the lookahead symbol. */ YYLTYPE yylloc # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL = { 1, 1, 1, 1 } # endif ; /* Number of syntax errors so far. */ int yynerrs; /*----------. | yyparse. | `----------*/ int yyparse (void) { int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: 'yyss': related to states. 'yyvs': related to semantic values. 'yyls': related to locations. Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yytype_int16 yyssa[YYINITDEPTH]; yytype_int16 *yyss; yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; /* The location stack. */ YYLTYPE yylsa[YYINITDEPTH]; YYLTYPE *yyls; YYLTYPE *yylsp; /* The locations where the error started and ended. */ YYLTYPE yyerror_range[3]; YYSIZE_T yystacksize; int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; YYLTYPE yyloc; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; yyssp = yyss = yyssa; yyvsp = yyvs = yyvsa; yylsp = yyls = yylsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ yylsp[0] = yylloc; goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; YYLTYPE *yyls1 = yyls; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yyls1, yysize * sizeof (*yylsp), &yystacksize); yyls = yyls1; yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); YYSTACK_RELOCATE (yyls_alloc, yyls); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; yylsp = yyls + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = yylex (); } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yytable_value_is_error (yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; } /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token. */ yychar = YYEMPTY; yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END *++yylsp = yylloc; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: '$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; /* Default location. */ YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: #line 482 "gram.y" /* yacc.c:1646 */ { if (error_count == 0) { if (genstmt.head) { genstmt.tail->next = (yyvsp[0].stmtlist).head; genstmt.tail = (yyvsp[0].stmtlist).tail; } else genstmt = (yyvsp[0].stmtlist); optimize_tree(genstmt.head); if (error_count) YYERROR; mark(genstmt.head); if (error_count) YYERROR; apply_deferred_init(); fixup_exceptions(); dataseg_layout(); if (optimization_level) regex_layout(); compile_tree(genstmt.head); if (!optimization_level) regex_layout(); } } #line 2422 "gram.c" /* yacc.c:1646 */ break; case 4: #line 509 "gram.y" /* yacc.c:1646 */ { (yyval.stmtlist) = (yyvsp[-1].stmtlist); } #line 2430 "gram.c" /* yacc.c:1646 */ break; case 5: #line 515 "gram.y" /* yacc.c:1646 */ { (yyval.stmtlist).head = (yyval.stmtlist).tail = (yyvsp[0].node); } #line 2438 "gram.c" /* yacc.c:1646 */ break; case 7: #line 520 "gram.y" /* yacc.c:1646 */ { if ((yyvsp[0].node)) { if ((yyvsp[-1].stmtlist).tail) (yyvsp[-1].stmtlist).tail->next = (yyvsp[0].node); else (yyvsp[-1].stmtlist).head = (yyvsp[0].node); (yyvsp[-1].stmtlist).tail = (yyvsp[0].node); } (yyval.stmtlist) = (yyvsp[-1].stmtlist); } #line 2453 "gram.c" /* yacc.c:1646 */ break; case 8: #line 531 "gram.y" /* yacc.c:1646 */ { if ((yyvsp[0].stmtlist).tail) { if ((yyvsp[-1].stmtlist).tail) { (yyval.stmtlist).head = (yyvsp[-1].stmtlist).head; (yyvsp[-1].stmtlist).tail->next = (yyvsp[0].stmtlist).head; (yyval.stmtlist).tail = (yyvsp[0].stmtlist).tail; } else (yyval.stmtlist) = (yyvsp[0].stmtlist); } } #line 2468 "gram.c" /* yacc.c:1646 */ break; case 9: #line 544 "gram.y" /* yacc.c:1646 */ { (yyval.stmtlist).head = (yyval.stmtlist).tail = NULL; } #line 2476 "gram.c" /* yacc.c:1646 */ break; case 10: #line 548 "gram.y" /* yacc.c:1646 */ { (yyval.stmtlist) = (yyvsp[-2].stmtlist); pop_top_module(); } #line 2485 "gram.c" /* yacc.c:1646 */ break; case 11: #line 555 "gram.y" /* yacc.c:1646 */ { parse_warning(_("missing module declaration")); } #line 2493 "gram.c" /* yacc.c:1646 */ break; case 13: #line 562 "gram.y" /* yacc.c:1646 */ { if (top_module->dclname) { struct mu_locus_range lr; lr.beg = (yylsp[-2]).beg; lr.end = (yylsp[0]).end; parse_error_locus(&lr, _("duplicate module declaration")); } else top_module->dclname = (yyvsp[-1].literal)->text; } #line 2508 "gram.c" /* yacc.c:1646 */ break; case 14: #line 573 "gram.y" /* yacc.c:1646 */ { if (top_module->dclname) { struct mu_locus_range lr; lr.beg = (yylsp[-3]).beg; lr.end = (yylsp[0]).end; parse_error_locus(&lr, _("duplicate module declaration")); } else { if (((yyvsp[-1].number) & (SYM_STATIC|SYM_PUBLIC)) == 0) parse_error_locus(&(yylsp[-1]), _("invalid module declaration")); top_module->dclname = (yyvsp[-2].literal)->text; top_module->flags = (yyvsp[-1].number); } } #line 2528 "gram.c" /* yacc.c:1646 */ break; case 15: #line 591 "gram.y" /* yacc.c:1646 */ { require_module((yyvsp[0].literal)->text, NULL); } #line 2536 "gram.c" /* yacc.c:1646 */ break; case 16: #line 595 "gram.y" /* yacc.c:1646 */ { require_module((yyvsp[-3].literal)->text, (yyvsp[-1].import_rule_list).head); } #line 2544 "gram.c" /* yacc.c:1646 */ break; case 18: #line 602 "gram.y" /* yacc.c:1646 */ { lex_bye(); } #line 2552 "gram.c" /* yacc.c:1646 */ break; case 19: #line 608 "gram.y" /* yacc.c:1646 */ { struct import_rule *rule = import_rule_create((yyvsp[0].literal)); (yyval.import_rule_list).head = (yyval.import_rule_list).tail = rule; } #line 2561 "gram.c" /* yacc.c:1646 */ break; case 20: #line 613 "gram.y" /* yacc.c:1646 */ { struct import_rule *rule = import_rule_create((yyvsp[0].literal)); (yyval.import_rule_list).tail->next = rule; (yyval.import_rule_list).tail = rule; } #line 2571 "gram.c" /* yacc.c:1646 */ break; case 23: #line 625 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_progdecl, &(yylsp[-4])); (yyval.node)->v.progdecl.tag = (yyvsp[-3].state); (yyval.node)->v.progdecl.auto_count = forget_autos(PARMCOUNT(), 0, 0); (yyval.node)->v.progdecl.tree = (yyvsp[-1].stmtlist).head; outer_context = inner_context = context_none; state_tag = smtp_state_none; } #line 2586 "gram.c" /* yacc.c:1646 */ break; case 24: #line 636 "gram.y" /* yacc.c:1646 */ { static NODE *progspecial[2]; NODE *np = progspecial[(yyvsp[-3].progspecial).code]; if (!np) { np = alloc_node(node_type_progdecl, &(yylsp[-3])); (yyval.node) = progspecial[(yyvsp[-3].progspecial).code] = np; np->v.progdecl.tag = state_tag; np->v.progdecl.tree = (yyvsp[-1].stmtlist).head; np->v.progdecl.auto_count = 0; } else { NODE *cur; for (cur = np->v.progdecl.tree; cur->next; cur = cur->next) ; cur->next = (yyvsp[-1].stmtlist).head; (yyval.node) = NULL; } np->v.progdecl.auto_count = forget_autos(PARMCOUNT(), np->v.progdecl.auto_count, 0); outer_context = inner_context = context_none; state_tag = smtp_state_none; } #line 2616 "gram.c" /* yacc.c:1646 */ break; case 25: #line 662 "gram.y" /* yacc.c:1646 */ { if ((yyvsp[-5].number) & SYM_PRECIOUS) parse_error_locus(&(yylsp[-4]), _("`precious' used with func")); if (((yyvsp[-5].number) & (SYM_STATIC|SYM_PUBLIC)) == (SYM_STATIC|SYM_PUBLIC)) parse_error_locus(&(yylsp[-4]), _("`static' and `public' " "used together")); func->sym.flags = (yyvsp[-5].number); func->node = (yyvsp[-1].stmtlist).head; (yyval.node) = declare_function(func, &(yylsp[-4]), forget_autos(PARMCOUNT() + FUNC_HIDDEN_ARGS(func), 0, FUNC_HIDDEN_ARGS(func))); outer_context = inner_context = context_none; func = NULL; } #line 2638 "gram.c" /* yacc.c:1646 */ break; case 26: #line 680 "gram.y" /* yacc.c:1646 */ { (yyval.node) = NULL; } #line 2646 "gram.c" /* yacc.c:1646 */ break; case 27: #line 684 "gram.y" /* yacc.c:1646 */ { (yyval.node) = NULL; } #line 2654 "gram.c" /* yacc.c:1646 */ break; case 28: #line 688 "gram.y" /* yacc.c:1646 */ { (yyval.node) = NULL; } #line 2662 "gram.c" /* yacc.c:1646 */ break; case 29: #line 694 "gram.y" /* yacc.c:1646 */ { state_tag = smtp_state_begin; outer_context = inner_context = context_handler; (yyval.progspecial).code = PS_BEGIN; } #line 2672 "gram.c" /* yacc.c:1646 */ break; case 30: #line 700 "gram.y" /* yacc.c:1646 */ { state_tag = smtp_state_end; outer_context = inner_context = context_handler; (yyval.progspecial).code = PS_END; } #line 2682 "gram.c" /* yacc.c:1646 */ break; case 32: #line 709 "gram.y" /* yacc.c:1646 */ { (yyval.literal) = literal_lookup((yyvsp[0].var)->sym.name); } #line 2690 "gram.c" /* yacc.c:1646 */ break; case 33: #line 715 "gram.y" /* yacc.c:1646 */ { struct variable *var; if (((yyvsp[-2].number) & (SYM_STATIC|SYM_PUBLIC)) == (SYM_STATIC|SYM_PUBLIC)) parse_error_locus(&(yylsp[-2]), _("`static' and `public' " "used together")); var = vardecl((yyvsp[0].literal)->text, (yyvsp[-1].type), storage_extern, &(yylsp[0])); if (!var) YYERROR; var->sym.flags |= (yyvsp[-2].number); } #line 2708 "gram.c" /* yacc.c:1646 */ break; case 34: #line 729 "gram.y" /* yacc.c:1646 */ { struct value value; struct variable *var; if (((yyvsp[-3].number) & (SYM_STATIC|SYM_PUBLIC)) == (SYM_STATIC|SYM_PUBLIC)) parse_error_locus(&(yylsp[-3]), _("`static' and `public' " "used together")); var = vardecl((yyvsp[-1].literal)->text, (yyvsp[-2].type), storage_extern, &(yylsp[-2])); if (!var) YYERROR; var->sym.flags |= (yyvsp[-3].number); if (optimization_level) optimize((yyvsp[0].node)); value.type = node_type((yyvsp[0].node)); switch ((yyvsp[0].node)->type) { case node_type_string: value.v.literal = (yyvsp[0].node)->v.literal; break; case node_type_number: value.v.number = (yyvsp[0].node)->v.number; break; default: yyerror("initializer element is not constant"); YYERROR; } if (initialize_variable(var, &value, &(yylsp[-1]))) YYERROR; } #line 2749 "gram.c" /* yacc.c:1646 */ break; case 35: #line 767 "gram.y" /* yacc.c:1646 */ { struct value value; if (optimization_level) optimize((yyvsp[0].node)); value.type = node_type((yyvsp[0].node)); switch ((yyvsp[0].node)->type) { case node_type_string: value.v.literal = (yyvsp[0].node)->v.literal; break; case node_type_number: value.v.number = (yyvsp[0].node)->v.number; break; default: yyerror("initializer element is not constant"); YYERROR; } if (!externdecl((yyvsp[-1].literal)->text, &value, &(yylsp[-1]))) YYERROR; } #line 2777 "gram.c" /* yacc.c:1646 */ break; case 36: #line 793 "gram.y" /* yacc.c:1646 */ { (yyval.number) = 0; } #line 2785 "gram.c" /* yacc.c:1646 */ break; case 37: #line 797 "gram.y" /* yacc.c:1646 */ { if ((yyvsp[-1].number) & (yyvsp[0].number)) parse_warning(_("duplicate `%s'"), symbit_to_qualifier((yyvsp[0].number))); (yyval.number) = (yyvsp[-1].number) | (yyvsp[0].number); } #line 2796 "gram.c" /* yacc.c:1646 */ break; case 38: #line 806 "gram.y" /* yacc.c:1646 */ { (yyval.number) = SYM_PRECIOUS; } #line 2804 "gram.c" /* yacc.c:1646 */ break; case 39: #line 810 "gram.y" /* yacc.c:1646 */ { (yyval.number) = SYM_STATIC; } #line 2812 "gram.c" /* yacc.c:1646 */ break; case 40: #line 814 "gram.y" /* yacc.c:1646 */ { (yyval.number) = SYM_PUBLIC; } #line 2820 "gram.c" /* yacc.c:1646 */ break; case 41: #line 821 "gram.y" /* yacc.c:1646 */ { (yyvsp[0].enumlist).cv->sym.flags = (yyvsp[-1].number); (yyval.node) = NULL; } #line 2829 "gram.c" /* yacc.c:1646 */ break; case 42: #line 826 "gram.y" /* yacc.c:1646 */ { struct enumlist *elist; while ((elist = (yyvsp[-1].enumlist).prev)) { elist->cv->sym.flags = (yyvsp[-3].number); elist = elist->prev; free((yyvsp[-1].enumlist).prev); (yyvsp[-1].enumlist).prev = elist; } (yyval.node) = NULL; } #line 2844 "gram.c" /* yacc.c:1646 */ break; case 43: #line 839 "gram.y" /* yacc.c:1646 */ { if ((yyvsp[-1].number) & SYM_PRECIOUS) parse_error_locus(&(yylsp[-1]), _("`precious' used with const")); if (((yyvsp[-1].number) & (SYM_STATIC|SYM_PUBLIC)) == (SYM_STATIC|SYM_PUBLIC)) parse_error_locus(&(yylsp[-1]), _("`static' and `public' " "used together")); (yyval.number) = (yyvsp[-1].number); } #line 2860 "gram.c" /* yacc.c:1646 */ break; case 44: #line 854 "gram.y" /* yacc.c:1646 */ { struct value value; struct variable *pvar; /* FIXME: This is necessary because constants can be referred to the same way as variables. */ if (pvar = variable_lookup((yyvsp[-1].literal)->text)) { parse_warning(_("constant name `%s' clashes with a variable name"), (yyvsp[-1].literal)->text); parse_warning_locus(&pvar->sym.locus, _("this is the location of the " "previous definition")); } if (optimization_level) optimize((yyvsp[0].node)); switch ((yyvsp[0].node)->type) { case node_type_string: value.type = dtype_string; value.v.literal = (yyvsp[0].node)->v.literal; break; case node_type_number: value.type = dtype_number; value.v.number = (yyvsp[0].node)->v.number; break; default: yyerror(_("initializer element is not constant")); YYERROR; } (yyval.enumlist).cv = define_constant((yyvsp[-1].literal)->text, &value, 0, &(yylsp[-1])); (yyval.enumlist).prev = NULL; } #line 2901 "gram.c" /* yacc.c:1646 */ break; case 45: #line 893 "gram.y" /* yacc.c:1646 */ { struct enumlist *elist; struct value value; struct variable *pvar; if (pvar = variable_lookup((yyvsp[0].literal)->text)) { parse_warning(_("constant name `%s' clashes with a variable name"), (yyvsp[0].literal)->text); parse_warning_locus(&pvar->sym.locus, _("this is the location of the " "previous definition")); } value.type = dtype_number; value.v.number = 0; elist = mu_alloc(sizeof(*elist)); elist->cv = define_constant((yyvsp[0].literal)->text, &value, 0, &(yylsp[0])); elist->prev = NULL; (yyval.enumlist).cv = NULL; (yyval.enumlist).prev = elist; } #line 2929 "gram.c" /* yacc.c:1646 */ break; case 46: #line 917 "gram.y" /* yacc.c:1646 */ { struct enumlist *elist = mu_alloc(sizeof(*elist)); elist->cv = (yyvsp[0].enumlist).cv; elist->prev = NULL; (yyval.enumlist).cv = NULL; (yyval.enumlist).prev = elist; } #line 2941 "gram.c" /* yacc.c:1646 */ break; case 47: #line 925 "gram.y" /* yacc.c:1646 */ { if ((yyvsp[-1].enumlist).prev->cv->value.type == dtype_number) { struct enumlist *elist = mu_alloc(sizeof(*elist)); struct value value; value.type = dtype_number; value.v.number = (yyvsp[-1].enumlist).prev->cv->value.v.number + 1; elist->cv = define_constant((yyvsp[0].literal)->text, &value, 0, &(yylsp[0])); elist->prev = (yyvsp[-1].enumlist).prev; (yyval.enumlist).prev = elist; } else { yyerror(_("initializer element is not numeric")); YYERROR; } } #line 2963 "gram.c" /* yacc.c:1646 */ break; case 48: #line 943 "gram.y" /* yacc.c:1646 */ { struct enumlist *elist = mu_alloc(sizeof(*elist)); elist->cv = (yyvsp[0].enumlist).cv; elist->prev = (yyvsp[-1].enumlist).prev; (yyvsp[-1].enumlist).prev = elist; (yyval.enumlist) = (yyvsp[-1].enumlist); } #line 2975 "gram.c" /* yacc.c:1646 */ break; case 49: #line 953 "gram.y" /* yacc.c:1646 */ { define_exception((yyvsp[0].literal), &(yylsp[-1])); } #line 2983 "gram.c" /* yacc.c:1646 */ break; case 50: #line 959 "gram.y" /* yacc.c:1646 */ { data_type_t *ptypes = NULL; if ((yyvsp[-3].parmlist).count) { int i; struct parmtype *p; ptypes = mu_alloc((yyvsp[-3].parmlist).count * sizeof *ptypes); for (i = 0, p = (yyvsp[-3].parmlist).head; p; i++) { struct parmtype *next = p->next; ptypes[i] = p->type; free(p); p = next; } } (yyval.function) = func = function_install((yyvsp[-5].literal)->text, (yyvsp[-3].parmlist).count, (yyvsp[-3].parmlist).optcount, (yyvsp[-3].parmlist).varargs, ptypes, (yyvsp[0].type), &(yylsp[-5])); if ((yyvsp[-1].list)) { mu_list_foreach((yyvsp[-1].list), _create_alias, (yyval.function)); mu_list_destroy(&(yyvsp[-1].list)); } outer_context = inner_context = context_function; } #line 3015 "gram.c" /* yacc.c:1646 */ break; case 51: #line 989 "gram.y" /* yacc.c:1646 */ { (yyval.parmlist).count = (yyval.parmlist).optcount = 0; (yyval.parmlist).varargs = 0; } #line 3024 "gram.c" /* yacc.c:1646 */ break; case 54: #line 998 "gram.y" /* yacc.c:1646 */ { (yyval.parmlist).count = (yyval.parmlist).optcount = 0; (yyval.parmlist).varargs = 1; } #line 3033 "gram.c" /* yacc.c:1646 */ break; case 55: #line 1003 "gram.y" /* yacc.c:1646 */ { (yyvsp[-2].parmlist).count += (yyvsp[0].parmlist).count; (yyvsp[-2].parmlist).optcount = (yyvsp[0].parmlist).count; (yyvsp[-2].parmlist).varargs = (yyvsp[0].parmlist).varargs; if ((yyvsp[-2].parmlist).tail) (yyvsp[-2].parmlist).tail->next = (yyvsp[0].parmlist).head; else (yyvsp[-2].parmlist).head = (yyvsp[0].parmlist).head; (yyvsp[-2].parmlist).tail = (yyvsp[0].parmlist).tail; (yyval.parmlist) = (yyvsp[-2].parmlist); } #line 3049 "gram.c" /* yacc.c:1646 */ break; case 56: #line 1017 "gram.y" /* yacc.c:1646 */ { (yyval.parmlist).count = 0; (yyval.parmlist).varargs = 0; (yyval.parmlist).head = (yyval.parmlist).tail = NULL; } #line 3059 "gram.c" /* yacc.c:1646 */ break; case 58: #line 1026 "gram.y" /* yacc.c:1646 */ { (yyval.parmlist).count = 1; (yyval.parmlist).varargs = 0; (yyval.parmlist).optcount = 0; (yyval.parmlist).head = (yyval.parmlist).tail = (yyvsp[0].parm); } #line 3070 "gram.c" /* yacc.c:1646 */ break; case 59: #line 1033 "gram.y" /* yacc.c:1646 */ { (yyvsp[-2].parmlist).count++; (yyvsp[-2].parmlist).tail->next = (yyvsp[0].parm); (yyvsp[-2].parmlist).tail = (yyvsp[0].parm); (yyval.parmlist) = (yyvsp[-2].parmlist); } #line 3081 "gram.c" /* yacc.c:1646 */ break; case 61: #line 1043 "gram.y" /* yacc.c:1646 */ { (yyvsp[-2].parmlist).varargs = 1; (yyval.parmlist) = (yyvsp[-2].parmlist); } #line 3090 "gram.c" /* yacc.c:1646 */ break; case 62: #line 1050 "gram.y" /* yacc.c:1646 */ { if (!vardecl((yyvsp[0].literal)->text, (yyvsp[-1].type), storage_param, &(yylsp[0]))) YYERROR; (yyval.parm) = mu_alloc(sizeof *(yyval.parm)); (yyval.parm)->next = NULL; (yyval.parm)->type = (yyvsp[-1].type); } #line 3102 "gram.c" /* yacc.c:1646 */ break; case 63: #line 1059 "gram.y" /* yacc.c:1646 */ { parse_warning_locus(&(yylsp[0]), _("unnamed formal parameters are deprecated")); (yyval.parm) = mu_alloc(sizeof *(yyval.parm)); (yyval.parm)->next = NULL; (yyval.parm)->type = (yyvsp[0].type); } #line 3114 "gram.c" /* yacc.c:1646 */ break; case 64: #line 1069 "gram.y" /* yacc.c:1646 */ { (yyval.list) = NULL; } #line 3122 "gram.c" /* yacc.c:1646 */ break; case 66: #line 1076 "gram.y" /* yacc.c:1646 */ { mu_list_create(&(yyval.list)); mu_list_append((yyval.list), (yyvsp[0].literal)); } #line 3131 "gram.c" /* yacc.c:1646 */ break; case 67: #line 1081 "gram.y" /* yacc.c:1646 */ { mu_list_append((yyvsp[-1].list), (yyvsp[0].literal)); (yyval.list) = (yyvsp[-1].list); } #line 3140 "gram.c" /* yacc.c:1646 */ break; case 68: #line 1088 "gram.y" /* yacc.c:1646 */ { (yyval.literal) = (yyvsp[0].literal); } #line 3148 "gram.c" /* yacc.c:1646 */ break; case 69: #line 1094 "gram.y" /* yacc.c:1646 */ { (yyval.type) = dtype_unspecified; } #line 3156 "gram.c" /* yacc.c:1646 */ break; case 70: #line 1098 "gram.y" /* yacc.c:1646 */ { (yyval.type) = (yyvsp[0].type); } #line 3164 "gram.c" /* yacc.c:1646 */ break; case 71: #line 1104 "gram.y" /* yacc.c:1646 */ { (yyval.state) = string_to_state((yyvsp[0].literal)->text); if ((yyval.state) == smtp_state_none) parse_error_locus(&(yylsp[0]), _("unknown smtp state tag: %s"), (yyvsp[0].literal)->text); state_tag = (yyval.state); outer_context = inner_context = context_handler; } #line 3178 "gram.c" /* yacc.c:1646 */ break; case 72: #line 1116 "gram.y" /* yacc.c:1646 */ { if ((yyvsp[0].node)) (yyvsp[0].node)->next = NULL; (yyval.stmtlist).head = (yyval.stmtlist).tail = (yyvsp[0].node); } #line 3188 "gram.c" /* yacc.c:1646 */ break; case 73: #line 1122 "gram.y" /* yacc.c:1646 */ { if ((yyvsp[0].node)) { if ((yyvsp[-1].stmtlist).tail) (yyvsp[-1].stmtlist).tail->next = (yyvsp[0].node); else (yyvsp[-1].stmtlist).head = (yyvsp[0].node); (yyvsp[-1].stmtlist).tail = (yyvsp[0].node); } (yyval.stmtlist) = (yyvsp[-1].stmtlist); } #line 3203 "gram.c" /* yacc.c:1646 */ break; case 81: #line 1142 "gram.y" /* yacc.c:1646 */ { if (node_type((yyvsp[0].node)) != dtype_unspecified) parse_warning(_("return from %s is ignored"), (yyvsp[0].node)->type == node_type_builtin ? (yyvsp[0].node)->v.builtin.builtin->name : (yyvsp[0].node)->v.call.func->sym.name); } #line 3215 "gram.c" /* yacc.c:1646 */ break; case 85: #line 1155 "gram.y" /* yacc.c:1646 */ { struct variable *var; data_type_t t = node_type((yyvsp[0].node)); if (t == dtype_unspecified) { parse_error_locus(&(yylsp[0]), _("unspecified value not ignored as " "it should be")); YYERROR; } var = variable_lookup((yyvsp[-1].literal)->text); if (!var) { var = vardecl((yyvsp[-1].literal)->text, t, storage_auto, &(yylsp[-1])); if (!var) YYERROR; } (yyval.node) = create_asgn_node(var, (yyvsp[0].node), &(yylsp[-2])); if (!(yyval.node)) YYERROR; } #line 3241 "gram.c" /* yacc.c:1646 */ break; case 86: #line 1179 "gram.y" /* yacc.c:1646 */ { if (!vardecl((yyvsp[0].literal)->text, (yyvsp[-1].type), storage_auto, &(yylsp[0]))) YYERROR; (yyval.node) = NULL; } #line 3251 "gram.c" /* yacc.c:1646 */ break; case 87: #line 1185 "gram.y" /* yacc.c:1646 */ { struct variable *var = vardecl((yyvsp[-1].literal)->text, (yyvsp[-2].type), storage_auto, &(yylsp[-1])); if (!var) YYERROR; (yyval.node) = create_asgn_node(var, (yyvsp[0].node), &(yylsp[-2])); if (!(yyval.node)) YYERROR; } #line 3265 "gram.c" /* yacc.c:1646 */ break; case 88: #line 1197 "gram.y" /* yacc.c:1646 */ { if (inner_context == context_handler) { if (state_tag == smtp_state_begin) parse_error_locus(&(yylsp[0]), _("Sendmail action is not " "allowed in begin block")); else if (state_tag == smtp_state_end) parse_error_locus(&(yylsp[0]), _("Sendmail action is not " "allowed in end block")); } } #line 3282 "gram.c" /* yacc.c:1646 */ break; case 89: #line 1210 "gram.y" /* yacc.c:1646 */ { if (inner_context == context_handler && state_tag == smtp_state_end) parse_error_locus(&(yylsp[0]), _("header action is not allowed " "in end block")); } #line 3294 "gram.c" /* yacc.c:1646 */ break; case 90: #line 1218 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_noop, &(yylsp[0])); } #line 3302 "gram.c" /* yacc.c:1646 */ break; case 91: #line 1222 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_echo, &(yylsp[-1])); (yyval.node)->v.node = cast_to(dtype_string, (yyvsp[0].node)); } #line 3311 "gram.c" /* yacc.c:1646 */ break; case 92: #line 1230 "gram.y" /* yacc.c:1646 */ { if ((yyvsp[0].ret).code || (yyvsp[0].ret).xcode || (yyvsp[0].ret).message) parse_warning(_("arguments are ignored for accept")); (yyval.node) = alloc_node(node_type_result, &(yylsp[-1])); (yyval.node)->v.ret = (yyvsp[0].ret); (yyval.node)->v.ret.stat = SMFIS_ACCEPT; } #line 3323 "gram.c" /* yacc.c:1646 */ break; case 93: #line 1238 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_result, &(yylsp[-1])); (yyval.node)->v.ret = (yyvsp[0].ret); (yyval.node)->v.ret.stat = SMFIS_REJECT; } #line 3333 "gram.c" /* yacc.c:1646 */ break; case 94: #line 1244 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_result, &(yylsp[-7])); (yyval.node)->v.ret.stat = SMFIS_REJECT; (yyval.node)->v.ret.code = (yyvsp[-5].node) ? cast_to(dtype_string, (yyvsp[-5].node)) : NULL; (yyval.node)->v.ret.xcode = (yyvsp[-3].node) ? cast_to(dtype_string, (yyvsp[-3].node)) : NULL; (yyval.node)->v.ret.message = (yyvsp[-1].node) ? cast_to(dtype_string, (yyvsp[-1].node)) : NULL; } #line 3345 "gram.c" /* yacc.c:1646 */ break; case 95: #line 1252 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_result, &(yylsp[-1])); (yyval.node)->v.ret = (yyvsp[0].ret); (yyval.node)->v.ret.stat = SMFIS_TEMPFAIL; } #line 3355 "gram.c" /* yacc.c:1646 */ break; case 96: #line 1258 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_result, &(yylsp[-7])); (yyval.node)->v.ret.stat = SMFIS_TEMPFAIL; (yyval.node)->v.ret.code = (yyvsp[-5].node) ? cast_to(dtype_string, (yyvsp[-5].node)) : NULL; (yyval.node)->v.ret.xcode = (yyvsp[-3].node) ? cast_to(dtype_string, (yyvsp[-3].node)) : NULL; (yyval.node)->v.ret.message = (yyvsp[-1].node) ? cast_to(dtype_string, (yyvsp[-1].node)) : NULL; } #line 3367 "gram.c" /* yacc.c:1646 */ break; case 97: #line 1266 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_result, &(yylsp[0])); memset(&(yyval.node)->v.ret, 0, sizeof (yyval.node)->v.ret); (yyval.node)->v.ret.stat = SMFIS_CONTINUE; } #line 3377 "gram.c" /* yacc.c:1646 */ break; case 98: #line 1272 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_result, &(yylsp[0])); memset(&(yyval.node)->v.ret, 0, sizeof (yyval.node)->v.ret); (yyval.node)->v.ret.stat = SMFIS_DISCARD; } #line 3387 "gram.c" /* yacc.c:1646 */ break; case 100: #line 1281 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_string, &(yylsp[0])); (yyval.node)->v.literal = (yyvsp[0].literal); } #line 3396 "gram.c" /* yacc.c:1646 */ break; case 101: #line 1290 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_header, &(yylsp[-2])); (yyval.node)->v.hdr.opcode = header_add; (yyval.node)->v.hdr.name = (yyvsp[-1].literal); (yyval.node)->v.hdr.value = cast_to(dtype_string, (yyvsp[0].node)); } #line 3407 "gram.c" /* yacc.c:1646 */ break; case 102: #line 1297 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_header, &(yylsp[-2])); (yyval.node)->v.hdr.opcode = header_replace; (yyval.node)->v.hdr.name = (yyvsp[-1].literal); (yyval.node)->v.hdr.value = cast_to(dtype_string, (yyvsp[0].node)); } #line 3418 "gram.c" /* yacc.c:1646 */ break; case 103: #line 1304 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_header, &(yylsp[-1])); (yyval.node)->v.hdr.opcode = header_delete; (yyval.node)->v.hdr.name = (yyvsp[0].literal); (yyval.node)->v.hdr.value = NULL; } #line 3429 "gram.c" /* yacc.c:1646 */ break; case 104: #line 1313 "gram.y" /* yacc.c:1646 */ { memset(&(yyval.ret), 0, sizeof (yyval.ret)); } #line 3437 "gram.c" /* yacc.c:1646 */ break; case 106: #line 1320 "gram.y" /* yacc.c:1646 */ { (yyval.ret).code = alloc_node(node_type_string, &(yylsp[0])); (yyval.ret).code->v.literal = (yyvsp[0].literal); (yyval.ret).xcode = NULL; (yyval.ret).message = NULL; } #line 3448 "gram.c" /* yacc.c:1646 */ break; case 107: #line 1327 "gram.y" /* yacc.c:1646 */ { (yyval.ret).code = alloc_node(node_type_string, &(yylsp[-1])); (yyval.ret).code->v.literal = (yyvsp[-1].literal); (yyval.ret).xcode = alloc_node(node_type_string, &(yylsp[0])); (yyval.ret).xcode->v.literal = (yyvsp[0].literal); (yyval.ret).message = NULL; } #line 3460 "gram.c" /* yacc.c:1646 */ break; case 108: #line 1335 "gram.y" /* yacc.c:1646 */ { (yyval.ret).code = alloc_node(node_type_string, &(yylsp[-2])); (yyval.ret).code->v.literal = (yyvsp[-2].literal); (yyval.ret).xcode = alloc_node(node_type_string, &(yylsp[-1])); (yyval.ret).xcode->v.literal = (yyvsp[-1].literal); (yyval.ret).message = cast_to(dtype_string, (yyvsp[0].node)); } #line 3472 "gram.c" /* yacc.c:1646 */ break; case 109: #line 1343 "gram.y" /* yacc.c:1646 */ { (yyval.ret).code = alloc_node(node_type_string, &(yylsp[-1])); (yyval.ret).code->v.literal = (yyvsp[-1].literal); (yyval.ret).xcode = NULL; (yyval.ret).message = cast_to(dtype_string, (yyvsp[0].node)); } #line 3483 "gram.c" /* yacc.c:1646 */ break; case 110: #line 1352 "gram.y" /* yacc.c:1646 */ { char buf[4]; if ((yyvsp[0].number) < 200 || (yyvsp[0].number) > 599) { yyerror(_("invalid SMTP reply code")); buf[0] = 0; } else snprintf(buf, sizeof(buf), "%lu", (yyvsp[0].number)); (yyval.literal) = string_alloc(buf, strlen(buf)); } #line 3498 "gram.c" /* yacc.c:1646 */ break; case 111: #line 1365 "gram.y" /* yacc.c:1646 */ { char buf[sizeof("5.999.999")]; /* RFC 1893: The syntax of the new status codes is defined as: status-code = class "." subject "." detail class = "2"/"4"/"5" subject = 1*3digit detail = 1*3digit */ if (((yyvsp[-4].number) != 2 && (yyvsp[-4].number) != 4 && (yyvsp[-4].number) !=5) || (yyvsp[-2].number) > 999 || (yyvsp[0].number) > 999) { yyerror(_("invalid extended reply code")); buf[0] = 0; } else snprintf(buf, sizeof(buf), "%lu.%lu.%lu", (yyvsp[-4].number), (yyvsp[-2].number), (yyvsp[0].number)); (yyval.literal) = string_alloc(buf, strlen(buf)); } #line 3523 "gram.c" /* yacc.c:1646 */ break; case 115: #line 1393 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_if, &(yylsp[-4])); (yyval.node)->v.cond.cond = (yyvsp[-3].node); (yyval.node)->v.cond.if_true = (yyvsp[-2].stmtlist).head; (yyval.node)->v.cond.if_false = (yyvsp[-1].node); } #line 3534 "gram.c" /* yacc.c:1646 */ break; case 116: #line 1402 "gram.y" /* yacc.c:1646 */ { (yyval.node) = NULL; } #line 3542 "gram.c" /* yacc.c:1646 */ break; case 117: #line 1406 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_if, &(yylsp[-3])); (yyval.node)->v.cond.cond = (yyvsp[-2].node); (yyval.node)->v.cond.if_true = (yyvsp[-1].stmtlist).head; (yyval.node)->v.cond.if_false = (yyvsp[0].node); } #line 3553 "gram.c" /* yacc.c:1646 */ break; case 118: #line 1413 "gram.y" /* yacc.c:1646 */ { (yyval.node) = (yyvsp[0].stmtlist).head; } #line 3561 "gram.c" /* yacc.c:1646 */ break; case 119: #line 1419 "gram.y" /* yacc.c:1646 */ { struct case_stmt *defcase = NULL, *pcase, *prev; (yyval.node) = alloc_node(node_type_switch, &(yylsp[-4])); (yyval.node)->v.switch_stmt.node = (yyvsp[-3].node); /* Make sure there is only one default case and place it at the beginning of the list */ pcase = (yyvsp[-1].case_list).head; if (!pcase->valist) { defcase = pcase; (yyvsp[-1].case_list).head = (yyvsp[-1].case_list).head->next; } prev = pcase; pcase = pcase->next; while (pcase) { if (!pcase->valist) { if (defcase) { parse_error_locus(&pcase->locus, _("duplicate default statement")); parse_error_locus(&defcase->locus, _("previously defined here")); YYERROR; } defcase = pcase; prev->next = pcase->next; } else prev = pcase; pcase = pcase->next; } if (!defcase) { defcase = mu_alloc(sizeof *defcase); mu_locus_range_init(&defcase->locus); mu_locus_range_copy(&defcase->locus, &(yylsp[0])); defcase->valist = NULL; defcase->node = alloc_node(node_type_noop, &defcase->locus); } defcase->next = (yyvsp[-1].case_list).head; (yyval.node)->v.switch_stmt.cases = defcase; } #line 3608 "gram.c" /* yacc.c:1646 */ break; case 120: #line 1464 "gram.y" /* yacc.c:1646 */ { (yyval.case_list).head = (yyval.case_list).tail = (yyvsp[0].case_stmt); } #line 3616 "gram.c" /* yacc.c:1646 */ break; case 121: #line 1468 "gram.y" /* yacc.c:1646 */ { (yyval.case_list).tail->next = (yyvsp[0].case_stmt); (yyval.case_list).tail = (yyvsp[0].case_stmt); } #line 3625 "gram.c" /* yacc.c:1646 */ break; case 122: #line 1475 "gram.y" /* yacc.c:1646 */ { (yyval.case_stmt) = mu_alloc(sizeof *(yyval.case_stmt)); (yyval.case_stmt)->next = NULL; mu_locus_range_init (&(yyval.case_stmt)->locus); mu_locus_range_copy (&(yyval.case_stmt)->locus, &(yylsp[-3])); (yyval.case_stmt)->valist = (yyvsp[-2].valist_list).head; (yyval.case_stmt)->node = (yyvsp[0].stmtlist).head; } #line 3638 "gram.c" /* yacc.c:1646 */ break; case 123: #line 1484 "gram.y" /* yacc.c:1646 */ { (yyval.case_stmt) = mu_alloc(sizeof *(yyval.case_stmt)); (yyval.case_stmt)->next = NULL; mu_locus_range_init (&(yyval.case_stmt)->locus); mu_locus_range_copy (&(yyval.case_stmt)->locus, &(yylsp[-2])); (yyval.case_stmt)->valist = NULL; (yyval.case_stmt)->node = (yyvsp[0].stmtlist).head; } #line 3651 "gram.c" /* yacc.c:1646 */ break; case 124: #line 1495 "gram.y" /* yacc.c:1646 */ { (yyval.valist_list).head = (yyval.valist_list).tail = mu_alloc(sizeof((yyval.valist_list).head[0])); (yyval.valist_list).head->next = NULL; (yyval.valist_list).head->value = (yyvsp[0].value); } #line 3661 "gram.c" /* yacc.c:1646 */ break; case 125: #line 1501 "gram.y" /* yacc.c:1646 */ { struct valist *p = mu_alloc(sizeof(*p)); p->value = (yyvsp[0].value); p->next = NULL; (yyvsp[-2].valist_list).tail->next = p; (yyvsp[-2].valist_list).tail = p; (yyval.valist_list) = (yyvsp[-2].valist_list); } #line 3674 "gram.c" /* yacc.c:1646 */ break; case 126: #line 1512 "gram.y" /* yacc.c:1646 */ { (yyval.value).type = dtype_string; (yyval.value).v.literal = (yyvsp[0].literal); } #line 3683 "gram.c" /* yacc.c:1646 */ break; case 127: #line 1517 "gram.y" /* yacc.c:1646 */ { (yyval.value).type = dtype_number; (yyval.value).v.number = (yyvsp[0].number); } #line 3692 "gram.c" /* yacc.c:1646 */ break; case 128: #line 1524 "gram.y" /* yacc.c:1646 */ { if ((yyvsp[0].value).type != dtype_string) { parse_error_locus(&(yylsp[0]), _("expected string, but found %s"), type_to_string((yyvsp[0].value).type)); /* Make sure we return something usable: */ (yyval.literal) = string_alloc("ERROR", 5); } else (yyval.literal) = (yyvsp[0].value).v.literal; } #line 3707 "gram.c" /* yacc.c:1646 */ break; case 129: #line 1537 "gram.y" /* yacc.c:1646 */ { (yyval.matchtype).qualifier = 0; } #line 3715 "gram.c" /* yacc.c:1646 */ break; case 130: #line 1541 "gram.y" /* yacc.c:1646 */ { (yyval.matchtype).qualifier = QUALIFIER_MX; } #line 3723 "gram.c" /* yacc.c:1646 */ break; case 131: #line 1547 "gram.y" /* yacc.c:1646 */ { (yyval.matchtype).qualifier = 0; } #line 3731 "gram.c" /* yacc.c:1646 */ break; case 132: #line 1551 "gram.y" /* yacc.c:1646 */ { (yyval.matchtype).qualifier = QUALIFIER_MX; } #line 3739 "gram.c" /* yacc.c:1646 */ break; case 133: #line 1560 "gram.y" /* yacc.c:1646 */ { leave_loop(); (yyvsp[-4].loop).end_while = (yyvsp[0].node); (yyval.node) = alloc_node(node_type_loop, &(yylsp[-6])); (yyvsp[-4].loop).body = (yyvsp[-2].stmtlist).head; (yyvsp[-4].loop).ident = (yyvsp[-5].literal); (yyval.node)->v.loop = (yyvsp[-4].loop); } #line 3752 "gram.c" /* yacc.c:1646 */ break; case 134: #line 1571 "gram.y" /* yacc.c:1646 */ { enter_loop((yyvsp[0].literal), NULL, NULL); } #line 3760 "gram.c" /* yacc.c:1646 */ break; case 135: #line 1577 "gram.y" /* yacc.c:1646 */ { (yyval.literal) = NULL; } #line 3768 "gram.c" /* yacc.c:1646 */ break; case 137: #line 1584 "gram.y" /* yacc.c:1646 */ { memset(&(yyval.loop), 0, sizeof (yyval.loop)); } #line 3776 "gram.c" /* yacc.c:1646 */ break; case 139: #line 1591 "gram.y" /* yacc.c:1646 */ { memset(&(yyval.loop), 0, sizeof (yyval.loop)); switch ((yyvsp[0].pollarg).kw) { case 0: (yyval.loop).stmt = (yyvsp[0].pollarg).expr; break; case T_FOR: (yyval.loop).for_stmt = (yyvsp[0].pollarg).expr; break; case T_WHILE: (yyval.loop).beg_while = (yyvsp[0].pollarg).expr; break; default: abort(); } } #line 3800 "gram.c" /* yacc.c:1646 */ break; case 140: #line 1611 "gram.y" /* yacc.c:1646 */ { switch ((yyvsp[0].pollarg).kw) { case 0: if ((yyval.loop).stmt) parse_error_locus(&(yylsp[0]), _("duplicate loop increment")); (yyval.loop).stmt = (yyvsp[0].pollarg).expr; break; case T_FOR: if ((yyval.loop).for_stmt) parse_error_locus(&(yylsp[0]), _("duplicate for statement")); (yyval.loop).for_stmt = (yyvsp[0].pollarg).expr; break; case T_WHILE: if ((yyval.loop).beg_while) parse_error_locus(&(yylsp[0]), _("duplicate while statement")); (yyval.loop).beg_while = (yyvsp[0].pollarg).expr; break; default: abort(); } } #line 3832 "gram.c" /* yacc.c:1646 */ break; case 141: #line 1641 "gram.y" /* yacc.c:1646 */ { (yyval.pollarg).kw = 0; (yyval.pollarg).expr = (yyvsp[0].stmtlist).head; } #line 3841 "gram.c" /* yacc.c:1646 */ break; case 142: #line 1646 "gram.y" /* yacc.c:1646 */ { (yyval.pollarg).kw = T_FOR; (yyval.pollarg).expr = (yyvsp[0].stmtlist).head; } #line 3850 "gram.c" /* yacc.c:1646 */ break; case 143: #line 1651 "gram.y" /* yacc.c:1646 */ { (yyval.pollarg).kw = T_WHILE; (yyval.pollarg).expr = (yyvsp[0].node); } #line 3859 "gram.c" /* yacc.c:1646 */ break; case 144: #line 1658 "gram.y" /* yacc.c:1646 */ { (yyval.node) = NULL; } #line 3867 "gram.c" /* yacc.c:1646 */ break; case 145: #line 1662 "gram.y" /* yacc.c:1646 */ { (yyval.node) = (yyvsp[0].node); } #line 3875 "gram.c" /* yacc.c:1646 */ break; case 146: #line 1668 "gram.y" /* yacc.c:1646 */ { if (!within_loop((yyvsp[0].literal))) { if ((yyvsp[0].literal)) parse_error_locus(&(yylsp[0]), _("no such loop: %s"), (yyvsp[0].literal)->text); parse_error_locus(&(yylsp[-1]), _("`break' used outside of `loop'")); YYERROR; } (yyval.node) = alloc_node(node_type_break, &(yylsp[-1])); (yyval.node)->v.literal = (yyvsp[0].literal); } #line 3893 "gram.c" /* yacc.c:1646 */ break; case 147: #line 1682 "gram.y" /* yacc.c:1646 */ { if (!within_loop((yyvsp[0].literal))) { if ((yyvsp[0].literal)) { parse_error_locus(&(yylsp[0]), _("no such loop: %s"), (yyvsp[0].literal)->text); parse_error_locus(&(yylsp[-1]), _("`next' used outside `loop'")); YYERROR; } else { parse_error_locus(&(yylsp[-1]), _("`next' is used outside `loop'; " "did you mean `pass'?")); YYERROR; } } else { (yyval.node) = alloc_node(node_type_next, &(yylsp[-1])); (yyval.node)->v.literal = (yyvsp[0].literal); } } #line 3918 "gram.c" /* yacc.c:1646 */ break; case 148: #line 1707 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_un, &(yylsp[-1])); (yyval.node)->v.un.opcode = unary_not; (yyval.node)->v.un.arg = cast_to(dtype_number, (yyvsp[0].node)); } #line 3928 "gram.c" /* yacc.c:1646 */ break; case 149: #line 1713 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1])); (yyval.node)->v.bin.opcode = bin_eq; (yyval.node)->v.bin.arg[0] = (yyvsp[-2].node); (yyval.node)->v.bin.arg[1] = cast_to(node_type((yyvsp[-2].node)), (yyvsp[0].node)); } #line 3939 "gram.c" /* yacc.c:1646 */ break; case 150: #line 1720 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1])); (yyval.node)->v.bin.opcode = bin_ne; (yyval.node)->v.bin.arg[0] = (yyvsp[-2].node); (yyval.node)->v.bin.arg[1] = cast_to(node_type((yyvsp[-2].node)), (yyvsp[0].node)); } #line 3950 "gram.c" /* yacc.c:1646 */ break; case 151: #line 1727 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1])); (yyval.node)->v.bin.opcode = bin_lt; (yyval.node)->v.bin.arg[0] = (yyvsp[-2].node); (yyval.node)->v.bin.arg[1] = cast_to(node_type((yyvsp[-2].node)), (yyvsp[0].node)); } #line 3961 "gram.c" /* yacc.c:1646 */ break; case 152: #line 1734 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1])); (yyval.node)->v.bin.opcode = bin_le; (yyval.node)->v.bin.arg[0] = (yyvsp[-2].node); (yyval.node)->v.bin.arg[1] = cast_to(node_type((yyvsp[-2].node)), (yyvsp[0].node)); } #line 3972 "gram.c" /* yacc.c:1646 */ break; case 153: #line 1741 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1])); (yyval.node)->v.bin.opcode = bin_gt; (yyval.node)->v.bin.arg[0] = (yyvsp[-2].node); (yyval.node)->v.bin.arg[1] = cast_to(node_type((yyvsp[-2].node)), (yyvsp[0].node)); } #line 3983 "gram.c" /* yacc.c:1646 */ break; case 154: #line 1748 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1])); (yyval.node)->v.bin.opcode = bin_ge; (yyval.node)->v.bin.arg[0] = (yyvsp[-2].node); (yyval.node)->v.bin.arg[1] = cast_to(node_type((yyvsp[-2].node)), (yyvsp[0].node)); } #line 3994 "gram.c" /* yacc.c:1646 */ break; case 155: #line 1755 "gram.y" /* yacc.c:1646 */ { NODE *p; (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1])); (yyval.node)->v.bin.opcode = bin_match; (yyval.node)->v.bin.qualifier = (yyvsp[-1].matchtype).qualifier; (yyval.node)->v.bin.arg[0] = cast_to(dtype_string, (yyvsp[-2].node)); (yyval.node)->v.bin.arg[1] = p = alloc_node(node_type_regcomp, &(yylsp[-1])); p->v.regcomp_data.expr = cast_to(dtype_string, (yyvsp[0].node)); p->v.regcomp_data.flags = regex_flags; p->v.regcomp_data.regind = -1; } #line 4012 "gram.c" /* yacc.c:1646 */ break; case 156: #line 1769 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1])); (yyval.node)->v.bin.opcode = bin_fnmatch; (yyval.node)->v.bin.qualifier = (yyvsp[-1].matchtype).qualifier; (yyval.node)->v.bin.arg[0] = cast_to(dtype_string, (yyvsp[-2].node)); (yyval.node)->v.bin.arg[1] = cast_to(dtype_string, (yyvsp[0].node)); } #line 4024 "gram.c" /* yacc.c:1646 */ break; case 157: #line 1777 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1])); (yyval.node)->v.bin.opcode = bin_or; (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node)); (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node)); } #line 4035 "gram.c" /* yacc.c:1646 */ break; case 158: #line 1784 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-1])); (yyval.node)->v.bin.opcode = bin_and; (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node)); (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node)); } #line 4046 "gram.c" /* yacc.c:1646 */ break; case 160: #line 1794 "gram.y" /* yacc.c:1646 */ { (yyval.node) = NULL; } #line 4054 "gram.c" /* yacc.c:1646 */ break; case 163: #line 1802 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2])); (yyval.node)->v.bin.opcode = bin_add; (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node)); (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node)); } #line 4065 "gram.c" /* yacc.c:1646 */ break; case 164: #line 1809 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_concat, &(yylsp[-1])); (yyval.node)->v.concat.arg[0] = cast_to(dtype_string, (yyvsp[-2].node)); (yyval.node)->v.concat.arg[1] = cast_to(dtype_string, (yyvsp[0].node)); } #line 4075 "gram.c" /* yacc.c:1646 */ break; case 165: #line 1815 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2])); (yyval.node)->v.bin.opcode = bin_sub; (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node)); (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node)); } #line 4086 "gram.c" /* yacc.c:1646 */ break; case 166: #line 1822 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2])); (yyval.node)->v.bin.opcode = bin_mul; (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node)); (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node)); } #line 4097 "gram.c" /* yacc.c:1646 */ break; case 167: #line 1829 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2])); (yyval.node)->v.bin.opcode = bin_div; (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node)); (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node)); } #line 4108 "gram.c" /* yacc.c:1646 */ break; case 168: #line 1836 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2])); (yyval.node)->v.bin.opcode = bin_mod; (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node)); (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node)); } #line 4119 "gram.c" /* yacc.c:1646 */ break; case 169: #line 1843 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2])); (yyval.node)->v.bin.opcode = bin_logand; (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node)); (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node)); } #line 4130 "gram.c" /* yacc.c:1646 */ break; case 170: #line 1850 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2])); (yyval.node)->v.bin.opcode = bin_logor; (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node)); (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node)); } #line 4141 "gram.c" /* yacc.c:1646 */ break; case 171: #line 1857 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2])); (yyval.node)->v.bin.opcode = bin_logxor; (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node)); (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node)); } #line 4152 "gram.c" /* yacc.c:1646 */ break; case 172: #line 1864 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2])); (yyval.node)->v.bin.opcode = bin_shl; (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node)); (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node)); } #line 4163 "gram.c" /* yacc.c:1646 */ break; case 173: #line 1871 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_bin, &(yylsp[-2])); (yyval.node)->v.bin.opcode = bin_shr; (yyval.node)->v.bin.arg[0] = cast_to(dtype_number, (yyvsp[-2].node)); (yyval.node)->v.bin.arg[1] = cast_to(dtype_number, (yyvsp[0].node)); } #line 4174 "gram.c" /* yacc.c:1646 */ break; case 174: #line 1880 "gram.y" /* yacc.c:1646 */ { if (node_type((yyvsp[0].node)) == dtype_unspecified) parse_error(_("unspecified value not ignored as it should be")); } #line 4183 "gram.c" /* yacc.c:1646 */ break; case 175: #line 1885 "gram.y" /* yacc.c:1646 */ { (yyval.node) = (yyvsp[-1].node); } #line 4191 "gram.c" /* yacc.c:1646 */ break; case 176: #line 1889 "gram.y" /* yacc.c:1646 */ { (yyval.node) = cast_to((yyvsp[-3].type), (yyvsp[-1].node)); } #line 4199 "gram.c" /* yacc.c:1646 */ break; case 178: #line 1894 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_un, &(yylsp[-1])); (yyval.node)->v.un.opcode = unary_minus; (yyval.node)->v.un.arg = cast_to(dtype_number, (yyvsp[0].node)); } #line 4209 "gram.c" /* yacc.c:1646 */ break; case 179: #line 1900 "gram.y" /* yacc.c:1646 */ { (yyval.node) = (yyvsp[0].node); } #line 4217 "gram.c" /* yacc.c:1646 */ break; case 180: #line 1904 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_un, &(yylsp[-1])); (yyval.node)->v.un.opcode = unary_lognot; (yyval.node)->v.un.arg = cast_to(dtype_number, (yyvsp[0].node)); } #line 4227 "gram.c" /* yacc.c:1646 */ break; case 181: #line 1912 "gram.y" /* yacc.c:1646 */ { (yyval.node) = create_node_symbol((yyvsp[0].literal), &(yylsp[0])); } #line 4235 "gram.c" /* yacc.c:1646 */ break; case 182: #line 1916 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_number, &(yylsp[0])); (yyval.node)->v.number = (yyvsp[0].number); } #line 4244 "gram.c" /* yacc.c:1646 */ break; case 183: #line 1921 "gram.y" /* yacc.c:1646 */ { (yyval.node) = create_node_backref((yyvsp[0].number), &(yylsp[0])); } #line 4252 "gram.c" /* yacc.c:1646 */ break; case 185: #line 1926 "gram.y" /* yacc.c:1646 */ { (yyval.node) = create_node_argcount(&(yylsp[0])); } #line 4260 "gram.c" /* yacc.c:1646 */ break; case 186: #line 1930 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_offset, &(yylsp[-1])); (yyval.node)->v.var_ref.variable = (yyvsp[0].var); (yyval.node)->v.var_ref.nframes = catch_nesting; } #line 4270 "gram.c" /* yacc.c:1646 */ break; case 187: #line 1936 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_vaptr, &(yylsp[-1])); (yyval.node)->v.node = (yyvsp[0].node); } #line 4279 "gram.c" /* yacc.c:1646 */ break; case 190: #line 1945 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_concat, &(yylsp[0])); (yyval.node)->v.concat.arg[0] = (yyvsp[-1].node); (yyval.node)->v.concat.arg[1] = (yyvsp[0].node); } #line 4289 "gram.c" /* yacc.c:1646 */ break; case 191: #line 1953 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_string, &(yylsp[0])); (yyval.node)->v.literal = (yyvsp[0].literal); } #line 4298 "gram.c" /* yacc.c:1646 */ break; case 193: #line 1961 "gram.y" /* yacc.c:1646 */ { (yyval.node) = create_node_variable((yyvsp[0].var), &(yylsp[0])); } #line 4306 "gram.c" /* yacc.c:1646 */ break; case 194: #line 1965 "gram.y" /* yacc.c:1646 */ { (yyval.node) = create_node_arg((yyvsp[0].number), &(yylsp[0])); } #line 4314 "gram.c" /* yacc.c:1646 */ break; case 195: #line 1969 "gram.y" /* yacc.c:1646 */ { if (outer_context == context_function) { if (func->varargs) { (yyval.node) = alloc_node(node_type_argx, &(yylsp[-3])); (yyval.node)->v.argx.nargs = PARMCOUNT() + FUNC_HIDDEN_ARGS(func); (yyval.node)->v.argx.node = (yyvsp[-1].node); } else { (yyval.node) = alloc_node(node_type_noop, &(yylsp[-3])); parse_error_locus(&(yylsp[-3]), _("$(expr) is allowed only " "in a function with " "variable number of " "arguments")); } } else { (yyval.node) = alloc_node(node_type_noop, &(yylsp[-3])); parse_error_locus(&(yylsp[-3]), _("$(expr) is allowed only " "in a function with " "variable number of " "arguments")); } } #line 4343 "gram.c" /* yacc.c:1646 */ break; case 197: #line 1997 "gram.y" /* yacc.c:1646 */ { (yyval.node) = (yyvsp[-1].node); } #line 4351 "gram.c" /* yacc.c:1646 */ break; case 198: #line 2003 "gram.y" /* yacc.c:1646 */ { if (check_builtin_usage((yyvsp[-3].builtin), &(yylsp[-3]))) YYERROR; if ((yyvsp[-1].arglist).count < (yyvsp[-3].builtin)->parmcount - (yyvsp[-3].builtin)->optcount) { parse_error_locus(&(yylsp[-3]), _("too few arguments in call to `%s'"), (yyvsp[-3].builtin)->name); YYERROR; } else if ((yyvsp[-1].arglist).count > (yyvsp[-3].builtin)->parmcount && !((yyvsp[-3].builtin)->flags & MFD_BUILTIN_VARIADIC)) { parse_error_locus(&(yylsp[-3]), _("too many arguments in call to `%s'"), (yyvsp[-3].builtin)->name); YYERROR; } else { (yyval.node) = alloc_node(node_type_builtin, &(yylsp[-3])); (yyval.node)->v.builtin.builtin = (yyvsp[-3].builtin); (yyval.node)->v.builtin.args = reverse(cast_arg_list((yyvsp[-1].arglist).head, (yyvsp[-3].builtin)->parmcount, (yyvsp[-3].builtin)->parmtype, (yyval.node)->v.builtin.builtin->flags & MFD_BUILTIN_NO_PROMOTE)); } } #line 4380 "gram.c" /* yacc.c:1646 */ break; case 199: #line 2028 "gram.y" /* yacc.c:1646 */ { if (check_builtin_usage((yyvsp[-2].builtin), &(yylsp[-2]))) YYERROR; if ((yyvsp[-2].builtin)->parmcount - (yyvsp[-2].builtin)->optcount) { parse_error_locus(&(yylsp[-2]), _("too few arguments in call to `%s'"), (yyvsp[-2].builtin)->name); YYERROR; } else { (yyval.node) = alloc_node(node_type_builtin, &(yylsp[-2])); (yyval.node)->v.builtin.builtin = (yyvsp[-2].builtin); (yyval.node)->v.builtin.args = NULL; } } #line 4399 "gram.c" /* yacc.c:1646 */ break; case 200: #line 2043 "gram.y" /* yacc.c:1646 */ { if (check_func_usage((yyvsp[-3].function), &(yylsp[-3]))) YYERROR; (yyval.node) = function_call((yyvsp[-3].function), (yyvsp[-1].arglist).count, (yyvsp[-1].arglist).head); if (!(yyval.node)) YYERROR; } #line 4411 "gram.c" /* yacc.c:1646 */ break; case 201: #line 2051 "gram.y" /* yacc.c:1646 */ { if (check_func_usage((yyvsp[-2].function), &(yylsp[-2]))) YYERROR; (yyval.node) = function_call((yyvsp[-2].function), 0, NULL); if (!(yyval.node)) YYERROR; } #line 4423 "gram.c" /* yacc.c:1646 */ break; case 202: #line 2061 "gram.y" /* yacc.c:1646 */ { (yyvsp[0].node)->next = NULL; (yyval.arglist).head = (yyval.arglist).tail = (yyvsp[0].node); (yyval.arglist).count = 1; } #line 4433 "gram.c" /* yacc.c:1646 */ break; case 203: #line 2067 "gram.y" /* yacc.c:1646 */ { (yyvsp[-2].arglist).tail->next = (yyvsp[0].node); (yyvsp[-2].arglist).tail = (yyvsp[0].node); (yyvsp[-2].arglist).count++; (yyval.arglist) = (yyvsp[-2].arglist); } #line 4444 "gram.c" /* yacc.c:1646 */ break; case 204: #line 2076 "gram.y" /* yacc.c:1646 */ { add_xref((yyvsp[0].var), &(yylsp[0])); } #line 4452 "gram.c" /* yacc.c:1646 */ break; case 205: #line 2080 "gram.y" /* yacc.c:1646 */ { YYERROR; } #line 4460 "gram.c" /* yacc.c:1646 */ break; case 206: #line 2086 "gram.y" /* yacc.c:1646 */ { if (outer_context == context_function) { func->exmask->all |= (yyval.node)->v.catch.exmask->all; bitmask_merge(&func->exmask->bm, &(yyval.node)->v.catch.exmask->bm); } } #line 4472 "gram.c" /* yacc.c:1646 */ break; case 207: #line 2094 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_try, &(yylsp[-1])); (yyval.node)->v.try.node = (yyvsp[-1].node); (yyval.node)->v.try.catch = (yyvsp[0].node); } #line 4482 "gram.c" /* yacc.c:1646 */ break; case 208: #line 2102 "gram.y" /* yacc.c:1646 */ { (yyval.node) = (yyvsp[-1].stmtlist).head; } #line 4490 "gram.c" /* yacc.c:1646 */ break; case 209: #line 2109 "gram.y" /* yacc.c:1646 */ { (yyval.tie_in) = inner_context; inner_context = context_catch; catch_nesting++; } #line 4498 "gram.c" /* yacc.c:1646 */ break; case 210: #line 2113 "gram.y" /* yacc.c:1646 */ { int i; struct valist *p; inner_context = (yyvsp[-2].tie_in); catch_nesting--; (yyval.node) = alloc_node(node_type_catch, &(yylsp[-5])); (yyval.node)->v.catch.exmask = exmask_create(); (yyval.node)->v.catch.context = outer_context;/*??*/ (yyval.node)->v.catch.exmask->all = (yyvsp[-4].catchlist).all; if (!(yyvsp[-4].catchlist).all) { for (i = 0, p = (yyvsp[-4].catchlist).valist; p; p = p->next, i++) { if (p->value.type != dtype_number) { parse_error_locus(&(yylsp[-5]), _("expected numeric value, but found `%s'"), p->value.v.literal->text); continue; } bitmask_set(&(yyval.node)->v.catch.exmask->bm, p->value.v.number); } } (yyval.node)->v.catch.node = (yyvsp[-1].stmtlist).head; } #line 4527 "gram.c" /* yacc.c:1646 */ break; case 211: #line 2140 "gram.y" /* yacc.c:1646 */ { (yyval.catchlist).all = 1; } #line 4535 "gram.c" /* yacc.c:1646 */ break; case 212: #line 2144 "gram.y" /* yacc.c:1646 */ { (yyval.catchlist).all = 0; (yyval.catchlist).valist = (yyvsp[0].valist_list).head; } #line 4544 "gram.c" /* yacc.c:1646 */ break; case 213: #line 2151 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_throw, &(yylsp[-2])); if ((yyvsp[-1].value).type != dtype_number) parse_error_locus(&(yylsp[-1]), _("exception code not a number")); else if ((yyvsp[-1].value).v.number > exception_count) parse_error_locus(&(yylsp[-1]), _("invalid exception number: %lu"), (yyvsp[-1].value).v.number); (yyval.node)->v.throw.code = (yyvsp[-1].value).v.number; (yyval.node)->v.throw.expr = cast_to(dtype_string, (yyvsp[0].node)); } #line 4562 "gram.c" /* yacc.c:1646 */ break; case 214: #line 2167 "gram.y" /* yacc.c:1646 */ { if (!func) parse_error_locus(&(yylsp[0]), _("`return' outside of a function")); else if (func->rettype != dtype_unspecified) parse_error_locus(&(yylsp[0]), _("`return' with no value, in function " "returning non-void")); (yyval.node) = alloc_node(node_type_return, &(yylsp[0])); (yyval.node)->v.node = NULL; } #line 4578 "gram.c" /* yacc.c:1646 */ break; case 215: #line 2179 "gram.y" /* yacc.c:1646 */ { if (!func) parse_error_locus(&(yylsp[-1]), _("`return' outside of a function")); else { (yyval.node) = alloc_node(node_type_return, &(yylsp[-1])); if (func->rettype == dtype_unspecified) { parse_error_locus(&(yylsp[-1]), _("`return' with a value, in function " "returning void")); (yyval.node)->v.node = NULL; } else (yyval.node)->v.node = cast_to(func->rettype, (yyvsp[0].node)); } } #line 4599 "gram.c" /* yacc.c:1646 */ break; case 216: #line 2202 "gram.y" /* yacc.c:1646 */ { NODE *sel, *np; NODE *head = NULL, *tail; struct function *fp; fp = function_lookup((yyvsp[-3].poll).client_addr ? "strictpoll" : "stdpoll"); if (!fp) { parse_error_locus(&(yylsp[-4]), _("`on poll' used without prior `require poll'")); YYERROR; } /* Build argument list */ if ((yyvsp[-3].poll).client_addr) { head = tail = (yyvsp[-3].poll).client_addr; tail = (yyvsp[-3].poll).email; if (!tail) { parse_error_locus(&(yylsp[-3]), _("recipient address not specified " "in `on poll' construct")); YYERROR; } tail->next = NULL; head->next = tail; } else head = tail = (yyvsp[-3].poll).email; if ((yyvsp[-3].poll).ehlo) np = (yyvsp[-3].poll).ehlo; else { /* FIXME: Pass NULL? */ np = alloc_node(node_type_variable, &(yylsp[-3])); np->v.var_ref.variable = variable_lookup("ehlo_domain"); np->v.var_ref.nframes = 0; } tail->next = np; tail = np; if ((yyvsp[-3].poll).mailfrom) np = (yyvsp[-3].poll).mailfrom; else { /* FIXME: Pass NULL? */ np = alloc_node(node_type_variable, &(yylsp[-3])); np->v.var_ref.variable = variable_lookup("mailfrom_address"); np->v.var_ref.nframes = 0; } tail->next = np; tail = np; sel = function_call(fp, nodelistlength(head), head); (yyval.node) = alloc_node(node_type_switch, &(yylsp[-4])); (yyval.node)->v.switch_stmt.node = sel; (yyval.node)->v.switch_stmt.cases = (yyvsp[-1].case_list).head; } #line 4662 "gram.c" /* yacc.c:1646 */ break; case 217: #line 2261 "gram.y" /* yacc.c:1646 */ { (yyval.node) = alloc_node(node_type_switch, &(yylsp[-4])); (yyval.node)->v.switch_stmt.node = (yyvsp[-3].node); (yyval.node)->v.switch_stmt.cases = (yyvsp[-1].case_list).head; } #line 4672 "gram.c" /* yacc.c:1646 */ break; case 218: #line 2269 "gram.y" /* yacc.c:1646 */ { tie_in_onblock(1); } #line 4680 "gram.c" /* yacc.c:1646 */ break; case 219: #line 2275 "gram.y" /* yacc.c:1646 */ { tie_in_onblock(0); } #line 4688 "gram.c" /* yacc.c:1646 */ break; case 220: #line 2281 "gram.y" /* yacc.c:1646 */ { struct pollarg arg; arg.kw = T_FOR; arg.expr = (yyvsp[0].node); memset(&(yyval.poll), 0, sizeof (yyval.poll)); set_poll_arg(&(yyval.poll), arg.kw, arg.expr); } #line 4701 "gram.c" /* yacc.c:1646 */ break; case 221: #line 2290 "gram.y" /* yacc.c:1646 */ { struct pollarg arg; arg.kw = T_FOR; arg.expr = (yyvsp[-1].node); set_poll_arg(&(yyvsp[0].poll), arg.kw, arg.expr); (yyval.poll) = (yyvsp[0].poll); } #line 4714 "gram.c" /* yacc.c:1646 */ break; case 222: #line 2299 "gram.y" /* yacc.c:1646 */ { (yyval.poll) = (yyvsp[0].poll); } #line 4722 "gram.c" /* yacc.c:1646 */ break; case 223: #line 2305 "gram.y" /* yacc.c:1646 */ { memset(&(yyval.poll), 0, sizeof (yyval.poll)); set_poll_arg(&(yyval.poll), (yyvsp[0].pollarg).kw, (yyvsp[0].pollarg).expr); } #line 4731 "gram.c" /* yacc.c:1646 */ break; case 224: #line 2310 "gram.y" /* yacc.c:1646 */ { set_poll_arg(&(yyvsp[-1].poll), (yyvsp[0].pollarg).kw, (yyvsp[0].pollarg).expr); (yyval.poll) = (yyvsp[-1].poll); } #line 4740 "gram.c" /* yacc.c:1646 */ break; case 225: #line 2317 "gram.y" /* yacc.c:1646 */ { (yyval.pollarg).kw = T_FOR; (yyval.pollarg).expr = (yyvsp[0].node); } #line 4749 "gram.c" /* yacc.c:1646 */ break; case 226: #line 2322 "gram.y" /* yacc.c:1646 */ { (yyval.pollarg).kw = T_HOST; (yyval.pollarg).expr = (yyvsp[0].node); } #line 4758 "gram.c" /* yacc.c:1646 */ break; case 227: #line 2327 "gram.y" /* yacc.c:1646 */ { (yyval.pollarg).kw = T_AS; (yyval.pollarg).expr = (yyvsp[0].node); } #line 4767 "gram.c" /* yacc.c:1646 */ break; case 228: #line 2332 "gram.y" /* yacc.c:1646 */ { (yyval.pollarg).kw = T_FROM; (yyval.pollarg).expr = (yyvsp[0].node); } #line 4776 "gram.c" /* yacc.c:1646 */ break; case 229: #line 2340 "gram.y" /* yacc.c:1646 */ { (yyval.case_list).head = (yyval.case_list).tail = (yyvsp[0].case_stmt); } #line 4784 "gram.c" /* yacc.c:1646 */ break; case 230: #line 2344 "gram.y" /* yacc.c:1646 */ { (yyvsp[-1].case_list).tail->next = (yyvsp[0].case_stmt); (yyvsp[-1].case_list).tail = (yyvsp[0].case_stmt); (yyval.case_list) = (yyvsp[-1].case_list); } #line 4794 "gram.c" /* yacc.c:1646 */ break; case 231: #line 2352 "gram.y" /* yacc.c:1646 */ { struct valist *p; for (p = (yyvsp[-2].valist_list).head; p; p = p->next) { if (p->value.type == dtype_string) { parse_error_locus(&(yylsp[-2]), _("invalid data type, " "expected number")); /* Try to continue */ p->value.type = dtype_number; p->value.v.number = 0; } } (yyval.case_stmt) = mu_alloc(sizeof *(yyval.case_stmt)); (yyval.case_stmt)->next = NULL; mu_locus_range_init (&(yyval.case_stmt)->locus); mu_locus_range_copy (&(yyval.case_stmt)->locus, &(yylsp[-3])); (yyval.case_stmt)->valist = (yyvsp[-2].valist_list).head; (yyval.case_stmt)->node = (yyvsp[0].stmtlist).head; } #line 4820 "gram.c" /* yacc.c:1646 */ break; #line 4824 "gram.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires that yytoken be updated with the new translation. We take the approach of translating immediately before every use of yytoken. One alternative is translating here after every semantic action, but that translation would be missed if the semantic action invokes YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an incorrect destructor might then be invoked immediately. In the case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; *++yylsp = yyloc; /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*--------------------------------------. | yyerrlab -- here on detecting error. | `--------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ yyssp, yytoken) { char const *yymsgp = YY_("syntax error"); int yysyntax_error_status; yysyntax_error_status = YYSYNTAX_ERROR; if (yysyntax_error_status == 0) yymsgp = yymsg; else if (yysyntax_error_status == 1) { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); if (!yymsg) { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; yysyntax_error_status = 2; } else { yysyntax_error_status = YYSYNTAX_ERROR; yymsgp = yymsg; } } yyerror (yymsgp); if (yysyntax_error_status == 2) goto yyexhaustedlab; } # undef YYSYNTAX_ERROR #endif } yyerror_range[1] = yylloc; if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval, &yylloc); yychar = YYEMPTY; } } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; yyerror_range[1] = yylsp[1-yylen]; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yyerror_range[1] = *yylsp; yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END yyerror_range[2] = yylloc; /* Using YYLLOC is tempting, but would change the location of the lookahead. YYLOC is available though. */ YYLLOC_DEFAULT (yyloc, yyerror_range, 2); *++yylsp = yyloc; /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEMPTY) { /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ yytoken = YYTRANSLATE (yychar); yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); } /* Do not reclaim the symbols of the rule whose action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp, yylsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif return yyresult; } #line 2375 "gram.y" /* yacc.c:1906 */ int yyerror(char const *s) { parse_error("%s", s); return 0; } struct stream_state { int mode; struct mu_locus_range loc; int sevmask; }; void stream_state_save(mu_stream_t str, struct stream_state *st) { mu_stream_ioctl(mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_GET_MODE, &st->mode); mu_locus_range_init(&st->loc); mu_stream_ioctl(mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_GET_LOCUS_RANGE, &st->loc); mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_GET_SEVERITY_MASK, &st->sevmask); } void stream_state_restore(mu_stream_t str, struct stream_state *st) { mu_stream_ioctl(mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_MODE, &st->mode); mu_stream_ioctl(mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_LOCUS_RANGE, &st->loc); mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_SEVERITY_MASK, &st->sevmask); mu_locus_range_deinit(&st->loc); } int parse_program(char *name, int ydebug) { int rc; struct stream_state st; int mode; stream_state_save(mu_strerr, &st); mode = st.mode | MU_LOGMODE_LOCUS | MU_LOGMODE_SEVERITY; mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_MODE, &mode); mode = MU_DEBUG_LEVEL_MASK (MU_DIAG_ERROR); mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, MU_IOCTL_LOGSTREAM_SET_SEVERITY_MASK, &mode); yydebug = ydebug; if (lex_new_source(name, 0)) return -1; outer_context = inner_context = context_none; catch_nesting = 0; code_immediate(NULL, ptr); /* Reserve 0 slot */ rc = yyparse() + error_count; stream_state_restore(mu_strerr, &st); return rc; } static void alloc_locus(struct mu_locus_range const *locus) { struct literal *lit; if (locus->beg.mu_file) { lit = string_alloc(locus->beg.mu_file, strlen(locus->beg.mu_file)); lit->flags |= SYM_REFERENCED; } if (!mu_locus_point_same_file(&locus->beg, &locus->end)) { lit = string_alloc(locus->end.mu_file, strlen(locus->end.mu_file)); lit->flags |= SYM_REFERENCED; } } NODE * alloc_node(enum node_type type, struct mu_locus_range const *locus) { NODE *node = malloc(sizeof(*node)); if (!node) { yyerror("Not enough memory"); abort(); } node->type = type; mu_locus_range_init (&node->locus); mu_locus_range_copy (&node->locus, locus); alloc_locus(locus); node->next = NULL; return node; } void free_node(NODE *node) { mu_locus_range_deinit(&node->locus); free(node); } void copy_node(NODE *dest, NODE *src) { dest->type = src->type; mu_locus_range_copy (&dest->locus, &src->locus); dest->v = src->v; } void free_subtree(NODE *node) { /*FIXME*/ } void free_parser_data() { /*FIXME*/ } /* Print parse tree */ static void print_node_list(NODE *node, int indent); static void print_node_list_reverse(NODE *node, int level); static void print_node(NODE *node, int indent); void print_stat(sfsistat stat); static int dbg_setreply(void *data, char *code, char *xcode, char *message); static void dbg_msgmod(void *data, struct msgmod_closure *clos); static void print_level(int level) { level *= 2; printf("%*.*s", level, level, ""); } static void print_bin_op(enum bin_opcode opcode) { char *p; switch (opcode) { case bin_and: p = "AND"; break; case bin_or: p = "OR"; break; case bin_eq: p = "EQ"; break; case bin_ne: p = "NE"; break; case bin_lt: p = "LT"; break; case bin_le: p = "LE"; break; case bin_gt: p = "GT"; break; case bin_ge: p = "GE"; break; case bin_match: p = "MATCH"; break; case bin_fnmatch: p = "FNMATCH"; break; case bin_add: p = "ADD"; break; case bin_sub: p = "SUB"; break; case bin_mul: p = "MUL"; break; case bin_div: p = "DIV"; break; case bin_mod: p = "MOD"; break; case bin_logand: p = "LOGAND"; break; case bin_logor: p = "LOGOR"; break; case bin_logxor: p = "LOGXOR"; break; case bin_shl: p = "SHL"; break; case bin_shr: p = "SHR"; break; default: p = "UNKNOWN_OP"; } printf("%s", p); } static void print_quoted_string(const char *str) { for (; *str; str++) { if (mu_isprint(*str)) putchar(*str); else { putchar('\\'); switch (*str) { case '\a': putchar('a'); break; case '\b': putchar('b'); break; case '\f': putchar('f'); break; case '\n': putchar('n'); break; case '\r': putchar('r'); break; case '\t': putchar('t'); break; default: printf("%03o", *str); } } } } struct node_drv { void (*print) (NODE *, int); void (*mark) (NODE *); void (*code) (NODE *, struct mu_locus_range const **); void (*optimize) (NODE *); }; static void traverse_tree(NODE *node); static void code_node(NODE *node); static void code_node(NODE *node); static void optimize_node(NODE *node); static void optimize(NODE *node); static void record_switch(struct switch_stmt *sw); #include "drivers.c" #include "node-tab.c" struct node_drv * find_node_drv(enum node_type type) { if (type >= NELEMS(nodetab)) { parse_error(_("INTERNAL ERROR at %s:%d, " "unexpected node type %d"), __FILE__, __LINE__, type); abort(); } return nodetab + type; } static void print_node(NODE *node, int level) { struct node_drv *nd = find_node_drv(node->type); if (nd->print) nd->print(node, level); } static void print_node_list(NODE *node, int level) { for (; node; node = node->next) print_node(node, level); } static void print_node_list_reverse(NODE *node, int level) { if (node) { print_node_list_reverse(node->next, level); print_node(node, level); } } int function_enumerator(void *sym, void *data) { int i; struct function *fsym = sym; struct function *f = (struct function *)symbol_resolve_alias(&fsym->sym); struct module *mod = data; if (f->sym.module != mod) return 0; printf("function %s (", f->sym.name); for (i = 0; i < f->parmcount; i++) { printf("%s", type_to_string(f->parmtype[i])); if (i < f->parmcount-1) putchar(','); } putchar(')'); if (f->rettype != dtype_unspecified) printf(" returns %s", type_to_string(f->rettype)); printf(":\n"); print_node_list(f->node, 0); printf("END function %s\n", f->sym.name); return 0; } void print_syntax_tree() { struct module **modv; size_t i, modc; enum smtp_state tag; printf("State handlers:\n"); printf("---------------\n"); for (tag = smtp_state_first; tag < smtp_state_count; tag++) { if (root_node[tag]) { printf("%s:\n", state_to_string(tag)); print_node_list(root_node[tag], 0); putchar('\n'); } } printf("User functions:\n"); printf("---------------\n"); collect_modules(&modv, &modc); for (i = 0; i < modc; i++) { size_t n; n = printf("Module %s (%s)\n", modv[i]->name, modv[i]->file); while (n--) putchar('-'); putchar('\n'); symtab_enumerate(MODULE_SYMTAB(modv[i], namespace_function), function_enumerator, modv[i]); putchar('\n'); } free(modv); } /* Cross-reference support */ struct collect_data { mu_opool_t pool; size_t count; }; static int variable_enumerator(void *item, void *data) { struct variable *var = item; struct collect_data *p = data; if (var->sym.flags & (SYM_VOLATILE | SYM_REFERENCED)) { mu_opool_append(p->pool, &var, sizeof var); p->count++; } return 0; } int print_locus(void *item, void *data) { struct mu_locus_range *loc = item; struct mu_locus_range **prev = data; int c; if (!*prev) { *prev = loc; printf("%s", loc->beg.mu_file); c = ':'; } else if (mu_locus_point_same_file (&(*prev)->beg, &loc->beg)) { *prev = loc; printf(", %s", loc->beg.mu_file); c = ':'; } else c = ','; printf("%c%u", c, loc->beg.mu_line); return 0; } void print_xref_var(struct variable *var) { struct mu_locus_range *prev = NULL; var = (struct variable *)symbol_resolve_alias(&var->sym); printf("%-32.32s %6s %lu ", var->sym.name, type_to_string(var->type), (unsigned long)var->off); mu_list_foreach(var->xref, print_locus, &prev); printf("\n"); } int vp_comp(const void *a, const void *b) { struct variable * const *va = a, * const *vb = b; return strcmp((*va)->sym.name, (*vb)->sym.name); } void print_xref() { struct collect_data cd; struct variable **vp; size_t i; mu_opool_create(&cd.pool, MU_OPOOL_ENOMEMABRT); cd.count = 0; symtab_enumerate(TOP_MODULE_SYMTAB(namespace_variable), variable_enumerator, &cd); printf("Cross-references:\n"); printf("-----------------\n"); vp = mu_opool_finish(cd.pool, NULL); qsort(vp, cd.count, sizeof *vp, vp_comp); for (i = 0; i < cd.count; i++, vp++) print_xref_var(*vp); mu_opool_destroy(&cd.pool); } static mu_list_t smtp_macro_list[gacopyz_stage_max]; static enum gacopyz_stage smtp_to_gacopyz_stage(enum smtp_state tag) { switch (tag) { case smtp_state_connect: return gacopyz_stage_conn; case smtp_state_helo: return gacopyz_stage_helo; case smtp_state_envfrom: return gacopyz_stage_mail; case smtp_state_envrcpt: return gacopyz_stage_rcpt; case smtp_state_data: case smtp_state_header: case smtp_state_body: return gacopyz_stage_data; case smtp_state_eoh: return gacopyz_stage_eoh; case smtp_state_eom: return gacopyz_stage_eom; default: break; } return gacopyz_stage_none; } static int compare_macro_names (const void *item, const void *data) { const char *elt; size_t elen; const char *arg; size_t alen; elt = item; elen = strlen (elt); if (elt[0] == '{') { elt++; elen -= 2; } arg = data; alen = strlen (arg); if (arg[0] == '{') { arg++; alen -= 2; } if (alen != elen) return 1; return memcmp (elt, arg, alen); } void register_macro(enum smtp_state state, const char *macro) { enum gacopyz_stage ind = smtp_to_gacopyz_stage(state); if (ind == gacopyz_stage_none) return; if (!smtp_macro_list[ind]) { mu_list_create(&smtp_macro_list[ind]); mu_list_set_comparator(smtp_macro_list[ind], compare_macro_names); } /* FIXME: MU: 2nd arg should be const? */ if (mu_list_locate(smtp_macro_list[ind], (void*) macro, NULL)) { char *cmacro; if (macro[1] == 0 || macro[0] == '{') cmacro = mu_strdup (macro); else { size_t mlen = strlen (macro); cmacro = mu_alloc (mlen + 3); cmacro[0] = '{'; memcpy (cmacro + 1, macro, mlen); cmacro[mlen + 1] = '}'; cmacro[mlen + 2] = 0; } mu_list_append(smtp_macro_list[ind], cmacro); } } static int print_macro(void *item, void *data) { int *p = data; if (*p) { printf(" "); *p = 0; } else printf(", "); printf("%s", (char*) item); return 0; } void print_used_macros() { enum gacopyz_stage i; for (i = 0; i < gacopyz_stage_max; i++) { if (smtp_macro_list[i]) { int n = 1; printf("%s", gacopyz_stage_name[i]); mu_list_foreach(smtp_macro_list[i], print_macro, &n); printf("\n"); } } } struct macro_acc { size_t size; char *buf; }; static int add_macro_size(void *item, void *data) { char *macro = (char*) item; struct macro_acc *mp = data; mp->size += strlen(macro) + 1; return 0; } static int concat_macro(void *item, void *data) { char *macro = (char*) item; struct macro_acc *mp = data; size_t len = strlen(macro); char *pbuf = mp->buf + mp->size; memcpy(pbuf, macro, len); pbuf[len++] = ' '; mp->size += len; return 0; } char * get_stage_macro_string(enum gacopyz_stage i) { struct macro_acc acc; size_t size; mu_list_t list = smtp_macro_list[i]; if (!list) return NULL; acc.size = 0; mu_list_foreach(list, add_macro_size, &acc); if (!acc.size) return NULL; size = acc.size; acc.size = 0; acc.buf = mu_alloc (size); mu_list_foreach(list, concat_macro, &acc); acc.buf[size-1] = 0; return acc.buf; } /* Code generation */ static void code_node(NODE *node) { if (!node) error_count++; else { static struct mu_locus_range const *old_locus; struct node_drv *nd = find_node_drv(node->type); if (nd->code) nd->code(node, &old_locus); } } static void traverse_tree(NODE *node) { for (; node; node = node->next) code_node(node); } static void optimize_node(NODE *node) { if (!node) error_count++; else { struct node_drv *nd = find_node_drv(node->type); if (nd->optimize) nd->optimize(node); } } static void optimize(NODE *node) { for (; node; node = node->next) optimize_node(node); } static int optimize_tree(NODE *node) { if (optimization_level) optimize(node); return error_count; } static struct switch_stmt *switch_root; static void record_switch(struct switch_stmt *sw) { sw->next = switch_root; switch_root = sw; } static struct exmask *exmask_root; struct exmask * exmask_create() { struct exmask *p = mu_alloc(sizeof(*p)); p->next = exmask_root; p->off = 0; p->all = 0; bitmask_init(&p->bm); exmask_root = p; return p; } static void mark_node(NODE *node) { if (!node) error_count++; else { struct node_drv *nd = find_node_drv(node->type); if (nd->mark) nd->mark(node); } } static void mark(NODE *node) { for (; node; node = node->next) mark_node(node); } static int codegen(prog_counter_t *pc, NODE *node, struct exmask *exmask, int finalize, size_t nautos) { int save_mask; if (error_count) return 1; *pc = code_get_counter(); jump_pc = 0; if (nautos) { code_op(opcode_stkalloc); code_immediate(nautos, uint); } save_mask = exmask && bitmask_nset(&exmask->bm); if (save_mask) { code_op(opcode_saveex); code_exmask(exmask); } traverse_tree(node); jump_fixup(jump_pc, code_get_counter()); if (save_mask) code_op(opcode_restex); if (finalize) code_op(opcode_nil); else code_op(opcode_return); return 0; } static void compile_tree(NODE *node) { struct node_drv *nd; struct mu_locus_range const *plocus; for (; node; node = node->next) { switch (node->type) { case node_type_progdecl: case node_type_funcdecl: nd = find_node_drv(node->type); if (!nd->code) abort(); nd->code(node, &plocus); break; default: parse_error_locus(&node->locus, _("INTERNAL ERROR at %s:%d, " "unexpected node type %d"), __FILE__, __LINE__, node->type); break; } } } enum regex_mode { regex_enable, regex_disable, regex_set }; static mf_stack_t regex_stack; void regex_push() { if (!regex_stack) regex_stack = mf_stack_create(sizeof regex_flags, 0); mf_stack_push(regex_stack, ®ex_flags); } void regex_pop() { if (!regex_stack || mf_stack_pop(regex_stack, ®ex_flags)) parse_error(_("nothing to pop")); } static void pragma_regex(int argc, char **argv, const char *text) { enum regex_mode mode = regex_set; int i = 1; if (strcmp(argv[i], "push") == 0) { regex_push(); i++; } else if (strcmp(argv[i], "pop") == 0) { regex_pop(); i++; } for (; i < argc; i++) { int bit; char *p = argv[i]; switch (p[0]) { case '+': mode = regex_enable; p++; break; case '-': mode = regex_disable; p++; break; case '=': mode = regex_set; p++; break; } if (strcmp (p, REG_EXTENDED_NAME) == 0) bit = REG_EXTENDED; else if (strcmp (p, REG_ICASE_NAME) == 0) bit = REG_ICASE; else if (strcmp (p, REG_NEWLINE_NAME) == 0) bit = REG_NEWLINE; else { parse_error(_("unknown regexp flag: %s"), p); return; } switch (mode) { case regex_disable: regex_flags &= ~bit; break; case regex_enable: regex_flags |= bit; break; case regex_set: regex_flags = bit; break; } } } static int strtosize(const char *text, size_t *psize) { unsigned long n; size_t size; char *p; n = strtoul(text, &p, 0); size = n; switch (*p) { case 't': case 'T': size *= 1024; case 'g': case 'G': size *= 1024; case 'm': case 'M': size *= 1024; case 'k': case 'K': size *= 1024; p++; if (*p && (*p == 'b' || *p == 'B')) p++; break; case 0: break; default: parse_error(_("invalid size suffix (near %s)"), p); return 1; } if (size < n) { parse_error(_("invalid size: numeric overflow occurred")); return 2; } *psize = size; return 0; } static void pragma_stacksize(int argc, char **argv, const char *text) { size_t size, incr = stack_expand_incr, max_size = stack_max_size; enum stack_expand_policy policy = stack_expand_policy; switch (argc) { case 4: if (strtosize(argv[3], &max_size)) return; case 3: if (strcmp(argv[2], "twice") == 0) policy = stack_expand_twice; else { policy = stack_expand_add; if (strtosize(argv[2], &incr)) return; } case 2: strtosize(argv[1], &size); } stack_size = size; stack_expand_incr = incr; stack_expand_policy = policy; stack_max_size = max_size; } void pragma_setup() { install_pragma("regex", 2, 0, pragma_regex); install_pragma("stacksize", 2, 4, pragma_stacksize); } /* Test run */ struct sfsistat_tab { char *name; sfsistat stat; } sfsistat_tab[] = { { "accept", SMFIS_ACCEPT }, { "continue", SMFIS_CONTINUE }, { "discard", SMFIS_DISCARD }, { "reject", SMFIS_REJECT }, { "tempfail", SMFIS_TEMPFAIL }, { NULL } }; const char * sfsistat_str(sfsistat stat) { struct sfsistat_tab *p; for (p = sfsistat_tab; p->name; p++) if (p->stat == stat) return p->name; return NULL; } void print_stat(sfsistat stat) { struct sfsistat_tab *p; for (p = sfsistat_tab; p->name; p++) if (p->stat == stat) { printf("%s", p->name); return; } printf("%d", stat); } const char * msgmod_opcode_str(enum msgmod_opcode opcode) { switch (opcode) { case header_add: return "ADD HEADER"; case header_replace: return "REPLACE HEADER"; case header_delete: return "DELETE HEADER"; case header_insert: return "INSERT HEADER"; case rcpt_add: return "ADD RECIPIENT"; case rcpt_delete: return "DELETE RECIPIENT"; case quarantine: return "QUARANTINE"; case body_repl: return "REPLACE BODY"; case body_repl_fd: return "REPLACE BODY FROM FILE"; case set_from: return "SET FROM"; } return "UNKNOWN HEADER COMMAND"; } static int dbg_setreply(void *data, char *code, char *xcode, char *message) { if (code) { printf("SET REPLY %s", code); if (xcode) printf(" %s", xcode); if (message) printf(" %s", message); printf("\n"); } return 0; } static void dbg_msgmod(void *data, struct msgmod_closure *clos) { if (!clos) printf("clearing msgmod list\n"); else printf("%s %s: %s %u\n", msgmod_opcode_str(clos->opcode), SP(clos->name), SP(clos->value), clos->idx); } static const char * dbg_dict_getsym (void *data, const char *str) { return dict_getsym ((mu_assoc_t)data, str); } void mailfromd_test(int argc, char **argv) { int i; mu_assoc_t dict = NULL; eval_environ_t env; char *p, *end; long n; sfsistat status; char *args[9] = {0,0,0,0,0,0,0,0,0}; dict_init(&dict); env = create_environment(NULL, dbg_dict_getsym, dbg_setreply, dbg_msgmod, dict); env_init(env); xeval(env, smtp_state_begin); env_init(env); for (i = 0; i < argc; i++) { if (p = strchr(argv[i], '=')) { char *ident = argv[i]; *p++ = 0; if (mu_isdigit(*ident) && *ident != 0 && ident[1] == 0) args[*ident - '0' - 1] = p; else dict_install(dict, argv[i], p); } } for (i = state_parms[test_state].cnt; i--; ) { switch (state_parms[test_state].types[i]) { case dtype_string: env_push_string(env, args[i] ? args[i] : ""); break; case dtype_number: if (args[i]) { n = strtol(args[i], &end, 0); if (*end) mu_error(_("$%d is not a number"), i+1); } else n = 0; env_push_number(env, n); break; default: abort(); } } test_message_data_init(env); env_make_frame(env); xeval(env, test_state); env_leave_frame(env, state_parms[test_state].cnt); env_final_gc(env); status = environment_get_status(env); env_init(env); xeval(env, smtp_state_end); printf("State %s: ", state_to_string(test_state)); print_stat(status); printf("\n"); destroy_environment(env); } void mailfromd_run(prog_counter_t entry_point, int argc, char **argv) { int rc, i; mu_assoc_t dict = NULL; eval_environ_t env; dict_init(&dict); env = create_environment(NULL, dbg_dict_getsym, dbg_setreply, dbg_msgmod, dict); env_init(env); test_message_data_init(env); env_push_number(env, 0); for (i = argc - 1; i >= 0; i--) env_push_string(env, argv[i]); env_push_number(env, argc); env_make_frame0(env); rc = eval_environment(env, entry_point); env_final_gc(env); rc = mf_c_val(env_get_reg(env), int); destroy_environment(env); exit(rc); } static struct tagtable { char *name; enum smtp_state tag; } tagtable[] = { { "none", smtp_state_none }, { "begin", smtp_state_begin }, { "connect", smtp_state_connect }, { "helo", smtp_state_helo }, { "envfrom", smtp_state_envfrom }, { "envrcpt", smtp_state_envrcpt }, { "data", smtp_state_data }, { "header", smtp_state_header }, { "eoh", smtp_state_eoh }, { "body", smtp_state_body }, { "eom", smtp_state_eom }, { "end", smtp_state_end }, }; enum smtp_state string_to_state(const char *name) { struct tagtable *p; for (p = tagtable; p < tagtable + sizeof tagtable/sizeof tagtable[0]; p++) if (strcasecmp (p->name, name) == 0) return p->tag; return smtp_state_none; } const char * state_to_string(enum smtp_state state) { if (state < sizeof tagtable/sizeof tagtable[0]) return tagtable[state].name; abort(); } static NODE * _reverse(NODE *list, NODE **root) { NODE *next; if (list->next == NULL) { *root = list; return list; } next = _reverse(list->next, root); next->next = list; list->next = NULL; return list; } NODE * reverse(NODE *in) { NODE *root; if (!in) return in; _reverse(in, &root); return root; } size_t nodelistlength(NODE *p) { size_t len = 0; for (; p; p = p->next) len++; return len; } static NODE * create_asgn_node(struct variable *var, NODE *expr, struct mu_locus_range const *loc) { NODE *node; data_type_t t = node_type(expr); if (t == dtype_unspecified) { parse_error(_("unspecified value not ignored as it should be")); return NULL; } node = alloc_node(node_type_asgn, loc); node->v.asgn.var = var; node->v.asgn.nframes = catch_nesting; node->v.asgn.node = cast_to(var->type, expr); return node; } NODE * function_call(struct function *function, size_t count, NODE *subtree) { NODE *np = NULL; if (count < function->parmcount - function->optcount) { parse_error(_("too few arguments in call to `%s'"), function->sym.name); } else if (count > function->parmcount && !function->varargs) { parse_error(_("too many arguments in call to `%s'"), function->sym.name); } else { np = alloc_node(node_type_call, &yylloc); np->v.call.func = function; np->v.call.args = reverse(cast_arg_list(subtree, function->parmcount, function->parmtype, 0)); } return np; } data_type_t node_type(NODE *node) { switch (node->type) { case node_type_string: case node_type_symbol: return dtype_string; case node_type_number: return dtype_number; case node_type_if: return dtype_unspecified; case node_type_bin: return dtype_number; case node_type_un: return dtype_number; case node_type_builtin: return node->v.builtin.builtin->rettype; case node_type_concat: return dtype_string; case node_type_variable: return node->v.var_ref.variable->type; case node_type_arg: return node->v.arg.data_type; case node_type_argx: return dtype_string; case node_type_call: return node->v.call.func->rettype; case node_type_return: if (node->v.node) return node_type(node->v.node); break; case node_type_backref: return dtype_string; case node_type_cast: return node->v.cast.data_type; case node_type_offset: return dtype_number; case node_type_vaptr: return dtype_number; case node_type_result: case node_type_header: case node_type_asgn: case node_type_regex: case node_type_regcomp: case node_type_catch: case node_type_try: case node_type_throw: case node_type_echo: case node_type_switch: case node_type_funcdecl: case node_type_progdecl: case node_type_noop: case node_type_next: case node_type_break: case node_type_loop: case max_node_type: break; } return dtype_unspecified; } NODE * cast_to(data_type_t type, NODE *node) { NODE *np; data_type_t ntype = node_type(node); switch (ntype) { case dtype_string: case dtype_number: if (type == ntype) return node; break; case dtype_pointer: if (type == ntype) return node; break; case dtype_unspecified: parse_error(_("cannot convert %s to %s"), type_to_string(ntype), type_to_string(type)); return NULL; default: abort(); } np = alloc_node(node_type_cast, &yylloc); np->v.cast.data_type = type; np->v.cast.node = node; node->next = NULL; return np; } NODE * cast_arg_list(NODE *args, size_t parmc, data_type_t *parmtype, int disable_prom) { NODE *head = NULL, *tail = NULL; while (args) { NODE *next = args->next; NODE *p; data_type_t type; if (parmc) { type = *parmtype++; parmc--; } else if (disable_prom) type = node_type(args); else type = dtype_string; p = cast_to(type, args); if (head) tail->next = p; else head = p; tail = p; args = next; } return head; } void add_xref(struct variable *var, struct mu_locus_range const *locus) { if (script_dump_xref) { /* FIXME: either change type to mu_locus_point, or change print_locus above */ struct mu_locus_range *elt = mu_zalloc(sizeof *elt); if (!var->xref) mu_list_create(&var->xref); mu_locus_range_copy(elt, locus); mu_list_append(var->xref, elt); } } struct variable * vardecl(const char *name, data_type_t type, storage_class_t sc, struct mu_locus_range const *loc) { struct variable *var; const struct constant *cptr; if (!loc) loc = &yylloc; if (type == dtype_unspecified) { parse_error(_("cannot define variable of unspecified type")); return NULL; } var = variable_install(name); if (var->type == dtype_unspecified) { /* the variable has just been added: go straight to initializing it */; } else if (sc != var->storage_class) { struct variable *vp; switch (sc) { case storage_extern: parse_error(_("INTERNAL ERROR at %s:%d, declaring %s %s"), __FILE__, __LINE__, storage_class_str(sc), name); abort(); case storage_auto: if (var->storage_class == storage_param) { parse_warning_locus(loc, _("automatic variable `%s' " "is shadowing a parameter"), var->sym.name); } else parse_warning_locus(loc, _("automatic variable `%s' " "is shadowing a global"), var->sym.name); unregister_auto(var); break; case storage_param: parse_warning_locus(loc, _("parameter `%s' is shadowing a " "global"), name); } /* Do the shadowing */ vp = variable_replace(var->sym.name, NULL); vp->shadowed = var; var = vp; } else { switch (sc) { case storage_extern: if (var->type != type) { parse_error_locus(loc, _("redeclaring `%s' as different " "data type"), name); parse_error_locus(&var->sym.locus, _("this is the location of the " "previous definition")); return NULL; } break; case storage_auto: if (var->type != type) { parse_error_locus(loc, _("redeclaring `%s' as different " "data type"), name); parse_error_locus(&var->sym.locus, _("this is the location of the " "previous definition")); return NULL; } else { parse_error_locus(loc, _("duplicate variable: %s"), name); return NULL; } break; case storage_param: parse_error_locus(loc, _("duplicate parameter: %s"), name); return NULL; } } /* FIXME: This is necessary because constants can be referred to the same way as variables. */ if (cptr = constant_lookup(name)) { parse_warning_locus(loc, _("variable name `%s' clashes with a constant name"), name); parse_warning_locus(&cptr->sym.locus, _("this is the location of the " "previous definition")); } var->type = type; var->storage_class = sc; switch (sc) { case storage_extern: add_xref(var, loc); break; case storage_auto: case storage_param: register_auto(var); } mu_locus_range_copy(&var->sym.locus, loc); return var; } static int cast_value(data_type_t type, struct value *value) { if (type != value->type) { char buf[NUMERIC_BUFSIZE_BOUND]; char *p; switch (type) { default: abort(); case dtype_string: snprintf(buf, sizeof buf, "%ld", value->v.number); value->v.literal = string_alloc(buf, strlen(buf)); break; case dtype_number: value->v.number = strtol(value->v.literal->text, &p, 10); if (*p) { parse_error(_("cannot convert `%s' to number"), value->v.literal->text); return 1; } break; } value->type = type; } return 0; } static struct variable * externdecl(const char *name, struct value *value, struct mu_locus_range const *loc) { struct variable *var = vardecl(name, value->type, storage_extern, loc); if (!var) return NULL; if (initialize_variable(var, value, loc)) return NULL; return var; } struct deferred_decl { struct deferred_decl *next; struct literal *name; struct value value; struct mu_locus_range locus; }; struct deferred_decl *deferred_decl; void defer_initialize_variable(const char *arg, const char *val, struct mu_locus_range const *ploc) { struct deferred_decl *p; struct literal *name = string_alloc(arg, strlen(arg)); for (p = deferred_decl; p; p = p->next) if (p->name == name) { parse_warning_locus(NULL, _("redefining variable %s"), name->text); p->value.type = dtype_string; p->value.v.literal = string_alloc(val, strlen(val)); mu_locus_range_copy (&p->locus, ploc); return; } p = mu_alloc(sizeof *p); p->name = name; p->value.type = dtype_string; p->value.v.literal = string_alloc(val, strlen(val)); mu_locus_range_init (&p->locus); mu_locus_range_copy (&p->locus, ploc); p->next = deferred_decl; deferred_decl = p; } static void apply_deferred_init() { struct deferred_decl *p; for (p = deferred_decl; p; p = p->next) { struct variable *var = variable_lookup(p->name->text); if (!var) { mu_error(_(": warning: " "no such variable: %s"), p->name->text); continue; } if (initialize_variable(var, &p->value, &p->locus)) parse_error_locus(&p->locus, _("error initialising variable %s: incompatible types"), p->name->text); } } struct declvar { struct declvar *next; struct mu_locus_range locus; struct variable *var; struct value val; }; static struct declvar *declvar; void set_poll_arg(struct poll_data *poll, int kw, NODE *expr) { switch (kw) { case T_FOR: poll->email = expr; break; case T_HOST: poll->client_addr = expr; break; case T_AS: poll->mailfrom = expr; break; case T_FROM: poll->ehlo = expr; break; default: abort(); } } int initialize_variable(struct variable *var, struct value *val, struct mu_locus_range const *locus) { struct declvar *dv; if (cast_value(var->type, val)) return 1; for (dv = declvar; dv; dv = dv->next) if (dv->var == var) { if (dv->locus.beg.mu_file) { parse_warning_locus(locus, _("variable `%s' already initialized"), var->sym.name); parse_warning_locus(&dv->locus, _("this is the location of the " "previous initialization")); } if (locus) mu_locus_range_copy (&dv->locus, locus); else mu_locus_range_deinit (&dv->locus); dv->val = *val; return 0; } dv = mu_alloc(sizeof *dv); dv->next = declvar; dv->var = var; mu_locus_range_init (&dv->locus); if (locus) mu_locus_range_copy (&dv->locus, locus); dv->val = *val; declvar = dv; var->sym.flags |= SYM_INITIALIZED; return 0; } void ensure_initialized_variable(const char *name, struct value *val) { struct declvar *dv; struct variable *var = variable_lookup(name); if (!var) { mu_error(_("INTERNAL ERROR at %s:%d: variable to be " "initialized is not declared"), __FILE__, __LINE__); abort(); } if (var->type != val->type) mu_error(_("INTERNAL ERROR at %s:%d: variable to be " "initialized has wrong type"), __FILE__, __LINE__); for (dv = declvar; dv; dv = dv->next) if (dv->var == var) return; dv = mu_alloc(sizeof *dv); mu_locus_range_init (&dv->locus); dv->var = var; dv->val = *val; dv->next = declvar; declvar = dv; } static int _ds_variable_count_fun(void *sym, void *data) { struct variable *var = sym; if ((var->sym.flags & (SYM_VOLATILE | SYM_REFERENCED)) && !(var->sym.flags & SYM_PASSTOGGLE)) { var->sym.flags |= SYM_PASSTOGGLE; variable_count++; if (var->type == dtype_string) dataseg_reloc_count++; if (var->sym.flags & SYM_PRECIOUS) precious_count++; } return 0; } static int _ds_variable_fill_fun(void *sym, void *data) { struct variable *var = sym; if (var->sym.flags & SYM_PASSTOGGLE) { var->sym.flags &= ~SYM_PASSTOGGLE; struct variable ***vtabptr = data; **vtabptr = var; ++*vtabptr; } return 0; } static int _ds_reloc_fun(void *sym, void *data) { struct variable *var = sym; size_t *pi = data; if ((var->sym.flags & (SYM_VOLATILE | SYM_REFERENCED)) && !(var->sym.flags & SYM_PASSTOGGLE) && var->type == dtype_string) { var->sym.flags |= SYM_PASSTOGGLE; dataseg_reloc[(*pi)++] = var->off; } return 0; } static int _ds_literal_count_fun(void *sym, void *data) { struct literal *lit = sym; size_t *offset = data; if (!(lit->flags & SYM_VOLATILE) && (lit->flags & SYM_REFERENCED)) { lit->off = *offset; *offset += B2STACK(strlen(lit->text) + 1); } return 0; } static int _ds_literal_copy_fun(void *sym, void *data) { struct literal *lit = sym; if (!(lit->flags & SYM_VOLATILE) && (lit->flags & SYM_REFERENCED)) strcpy((char*)(dataseg + lit->off), lit->text); return 0; } static int vtab_comp(const void *a, const void *b) { const struct variable *vp1 = *(const struct variable **)a; const struct variable *vp2 = *(const struct variable **)b; if ((vp1->sym.flags & SYM_PRECIOUS) && !(vp2->sym.flags & SYM_PRECIOUS)) return 1; else if ((vp2->sym.flags & SYM_PRECIOUS) && !(vp1->sym.flags & SYM_PRECIOUS)) return -1; return 0; } static int place_exc(const struct constant *cp, const struct literal *lit, void *data) { STKVAL *tab = data; tab[cp->value.v.number] = (STKVAL) lit->off; return 0; } static void dataseg_layout() { struct declvar *dv; size_t i; struct switch_stmt *sw; struct variable **vtab, **pvtab; struct exmask *exmask; /* Count used variables and estimate the number of relocations needed */ dataseg_reloc_count = 0; module_symtab_enumerate(namespace_variable, _ds_variable_count_fun, NULL); /* Fill variable pointer array and make sure precious variables occupy its bottom part */ vtab = mu_calloc(variable_count, sizeof(vtab[0])); pvtab = vtab; module_symtab_enumerate(namespace_variable, _ds_variable_fill_fun, &pvtab); qsort(vtab, variable_count, sizeof(vtab[0]), vtab_comp); /* Compute variable offsets. Offset 0 is reserved for NULL symbol */ for (i = 0; i < variable_count; i++) { vtab[i]->off = i + 1; if (vtab[i]->addrptr) *vtab[i]->addrptr = vtab[i]->off; } /* Free the array */ free(vtab); /* Mark literals used to initialize variables as referenced */ for (dv = declvar; dv; dv = dv->next) { if ((dv->var->sym.flags & (SYM_VOLATILE | SYM_REFERENCED)) && dv->var->type == dtype_string) { dv->val.v.literal->flags |= SYM_REFERENCED; } } datasize = variable_count + 1; dvarsize = datasize - precious_count; /* Count referenced literals and adjust the data size */ symtab_enumerate(stab_literal, _ds_literal_count_fun, &datasize); /* Account for switch translation tables */ for (sw = switch_root; sw; sw = sw->next) { sw->off = datasize; datasize += sw->tabsize; } /* Account for exception masks */ for (exmask = exmask_root; exmask; exmask = exmask->next) { exmask->off = datasize; if (exmask->all) { size_t i; for (i = 0; i < exception_count; i++) bitmask_set(&exmask->bm, i); } datasize += exmask->bm.bm_size + 1; } /* Account for exception name table */ datasize += exception_count; /* Allocate data segment and relocation table */ dataseg = mu_calloc(datasize, sizeof(STKVAL)); dataseg_reloc = mu_calloc(dataseg_reloc_count, sizeof *dataseg_reloc); /* Fill relocation table */ i = 0; module_symtab_enumerate(namespace_variable, _ds_reloc_fun, &i); /* Initialize variables */ for (dv = declvar; dv; dv = dv->next) { if (dv->var->sym.flags & (SYM_VOLATILE | SYM_REFERENCED)) { switch (dv->var->type) { case dtype_string: dataseg[dv->var->off] = (STKVAL) dv->val.v.literal->off; break; case dtype_number: dataseg[dv->var->off] = (STKVAL) dv->val.v.number; break; default: abort(); } } } /* Place literals */ symtab_enumerate(stab_literal, _ds_literal_copy_fun, NULL); /* Initialize exception masks */ for (exmask = exmask_root; exmask; exmask = exmask->next) { size_t i, off = exmask->off; dataseg[off++] = (STKVAL) exmask->bm.bm_size; for (i = 0; i < exmask->bm.bm_size; i++) dataseg[off++] = (STKVAL) exmask->bm.bm_bits[i++]; } /* Initialize exception name table */ enumerate_exceptions(place_exc, dataseg + EXTABIND); } static int _regex_compile_fun(void *sym, void *data) { struct literal *lit = sym; if (lit->regex) { struct sym_regex *rp; for (rp = lit->regex; rp; rp = rp->next) register_regex(rp); } return 0; } void regex_layout() { symtab_enumerate(stab_literal, _regex_compile_fun, NULL); finalize_regex(); } static struct variable *auto_list; static void register_auto(struct variable *var) { var->next = auto_list; auto_list = var; } static void unregister_auto(struct variable *var) { struct variable *p = auto_list, *prev = NULL; while (p) { struct variable *next = p->next; if (p == var) { if (prev) prev->next = next; else auto_list = next; p->next = NULL; return; } prev = p; p = next; } } /* FIXME: Redo shadowing via a separate table? */ static size_t forget_autos(size_t nparam, size_t auto_count, size_t hidden_arg) { size_t param_count = 0; struct variable *var = auto_list; while (var) { struct variable *next = var->next; switch (var->storage_class) { case storage_auto: var->off = auto_count++; break; case storage_param: var->off = nparam - param_count++; var->ord = var->off - (hidden_arg ? 1 : 0) - 1; break; default: abort(); } while (var->storage_class != storage_extern) { struct variable *shadowed = var->shadowed; if (!shadowed) { symtab_remove(TOP_MODULE_SYMTAB(namespace_variable), var->sym.name); break; } var->shadowed = NULL; var = variable_replace(var->sym.name, shadowed); } var = next; } auto_list = NULL; return auto_count; } const char * storage_class_str(storage_class_t sc) { switch (sc) { case storage_extern: return "extern"; case storage_auto: return "auto"; case storage_param: return "param"; } return "unknown?"; } const char * function_name() { switch (outer_context) { case context_function: return func->sym.name; case context_handler: return state_to_string(state_tag); default: return ""; } } NODE * declare_function(struct function *func, struct mu_locus_range const *loc, size_t nautos) { NODE *node = alloc_node(node_type_funcdecl, loc); node->v.funcdecl.func = func; node->v.funcdecl.auto_count = nautos; node->v.funcdecl.tree = func->node; return node; } NODE * create_node_variable(struct variable *var, struct mu_locus_range const *locus) { NODE *node = alloc_node(node_type_variable, locus); node->v.var_ref.variable = var; node->v.var_ref.nframes = catch_nesting; return node; } NODE * create_node_argcount(struct mu_locus_range const *locus) { NODE *node; if (outer_context == context_function) { if (func->optcount || func->varargs) { node = alloc_node(node_type_arg, locus); node->v.arg.data_type = dtype_number; node->v.arg.number = 1; } else { node = alloc_node(node_type_number, locus); node->v.number = parminfo[outer_context].parmcount(); } } else { node = alloc_node(node_type_number, locus); node->v.number = parminfo[outer_context].parmcount(); } return node; } NODE * create_node_arg(long num, struct mu_locus_range const *locus) { NODE *node; if (inner_context == context_function && func->varargs) ; else if (num > PARMCOUNT()) parse_error(_("argument number too high")); node = alloc_node(node_type_arg, locus); node->v.arg.data_type = PARMTYPE(num); node->v.arg.number = num; if (inner_context == context_function) node->v.arg.number += FUNC_HIDDEN_ARGS(func); return node; } NODE * create_node_symbol(struct literal *lit, struct mu_locus_range const *locus) { NODE *node; register_macro(state_tag, lit->text); node = alloc_node(node_type_symbol, locus); node->v.literal = lit; return node; } NODE * create_node_backref(long num, struct mu_locus_range const *locus) { NODE *node = alloc_node(node_type_backref, locus); node->v.number = num; return node; }