michael@0: /* A Bison parser, made by GNU Bison 2.7. */ michael@0: michael@0: /* Bison implementation for Yacc-like parsers in C michael@0: michael@0: Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. michael@0: michael@0: This program is free software: you can redistribute it and/or modify michael@0: it under the terms of the GNU General Public License as published by michael@0: the Free Software Foundation, either version 3 of the License, or michael@0: (at your option) any later version. michael@0: michael@0: This program is distributed in the hope that it will be useful, michael@0: but WITHOUT ANY WARRANTY; without even the implied warranty of michael@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the michael@0: GNU General Public License for more details. michael@0: michael@0: You should have received a copy of the GNU General Public License michael@0: along with this program. If not, see . */ michael@0: michael@0: /* As a special exception, you may create a larger work that contains michael@0: part or all of the Bison parser skeleton and distribute that work michael@0: under terms of your choice, so long as that work isn't itself a michael@0: parser generator using the skeleton or a modified version thereof michael@0: as a parser skeleton. Alternatively, if you modify or redistribute michael@0: the parser skeleton itself, you may (at your option) remove this michael@0: special exception, which will cause the skeleton and the resulting michael@0: Bison output files to be licensed under the GNU General Public michael@0: License without this special exception. michael@0: michael@0: This special exception was added by the Free Software Foundation in michael@0: version 2.2 of Bison. */ michael@0: michael@0: /* C LALR(1) parser skeleton written by Richard Stallman, by michael@0: simplifying the original so-called "semantic" parser. */ michael@0: michael@0: /* All symbols defined below should begin with yy or YY, to avoid michael@0: infringing on user name space. This should be done even for local michael@0: variables, as they might otherwise be expanded by user macros. michael@0: There are some unavoidable exceptions within include files to michael@0: define necessary library symbols; they are noted "INFRINGES ON michael@0: USER NAME SPACE" below. */ michael@0: michael@0: /* Identify Bison output. */ michael@0: #define YYBISON 1 michael@0: michael@0: /* Bison version. */ michael@0: #define YYBISON_VERSION "2.7" michael@0: michael@0: /* Skeleton name. */ michael@0: #define YYSKELETON_NAME "yacc.c" michael@0: michael@0: /* Pure parsers. */ michael@0: #define YYPURE 1 michael@0: michael@0: /* Push parsers. */ michael@0: #define YYPUSH 0 michael@0: michael@0: /* Pull parsers. */ michael@0: #define YYPULL 1 michael@0: michael@0: michael@0: /* Substitute the variable and function names. */ michael@0: #define yyparse ppparse michael@0: #define yylex pplex michael@0: #define yyerror pperror michael@0: #define yylval pplval michael@0: #define yychar ppchar michael@0: #define yydebug ppdebug michael@0: #define yynerrs ppnerrs michael@0: michael@0: /* Copy the first part of user declarations. */ michael@0: michael@0: michael@0: // michael@0: // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: // This file is auto-generated by generate_parser.sh. DO NOT EDIT! michael@0: michael@0: #if defined(__GNUC__) michael@0: // Triggered by the auto-generated pplval variable. michael@0: #if !defined(__clang__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) michael@0: #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" michael@0: #else michael@0: #pragma GCC diagnostic ignored "-Wuninitialized" michael@0: #endif michael@0: #elif defined(_MSC_VER) michael@0: #pragma warning(disable: 4065 4701) michael@0: #endif michael@0: michael@0: #include "ExpressionParser.h" michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #include "DiagnosticsBase.h" michael@0: #include "Lexer.h" michael@0: #include "Token.h" michael@0: michael@0: #if defined(_MSC_VER) michael@0: typedef __int64 YYSTYPE; michael@0: #else michael@0: #include michael@0: typedef intmax_t YYSTYPE; michael@0: #endif // _MSC_VER michael@0: #define YYENABLE_NLS 0 michael@0: #define YYLTYPE_IS_TRIVIAL 1 michael@0: #define YYSTYPE_IS_TRIVIAL 1 michael@0: #define YYSTYPE_IS_DECLARED 1 michael@0: michael@0: namespace { michael@0: struct Context michael@0: { michael@0: pp::Diagnostics* diagnostics; michael@0: pp::Lexer* lexer; michael@0: pp::Token* token; michael@0: int* result; michael@0: }; michael@0: } // namespace michael@0: michael@0: michael@0: static int yylex(YYSTYPE* lvalp, Context* context); michael@0: static void yyerror(Context* context, const char* reason); michael@0: michael@0: michael@0: michael@0: # ifndef YY_NULL michael@0: # if defined __cplusplus && 201103L <= __cplusplus michael@0: # define YY_NULL nullptr michael@0: # else michael@0: # define YY_NULL 0 michael@0: # endif michael@0: # endif michael@0: michael@0: /* Enabling verbose error messages. */ michael@0: #ifdef YYERROR_VERBOSE michael@0: # undef YYERROR_VERBOSE michael@0: # define YYERROR_VERBOSE 1 michael@0: #else michael@0: # define YYERROR_VERBOSE 0 michael@0: #endif michael@0: michael@0: michael@0: /* Enabling traces. */ michael@0: #ifndef YYDEBUG michael@0: # define YYDEBUG 0 michael@0: #endif michael@0: #if YYDEBUG michael@0: extern int ppdebug; michael@0: #endif michael@0: michael@0: /* Tokens. */ michael@0: #ifndef YYTOKENTYPE michael@0: # define YYTOKENTYPE michael@0: /* Put the tokens into the symbol table, so that GDB and other debuggers michael@0: know about them. */ michael@0: enum yytokentype { michael@0: TOK_CONST_INT = 258, michael@0: TOK_OP_OR = 259, michael@0: TOK_OP_AND = 260, michael@0: TOK_OP_NE = 261, michael@0: TOK_OP_EQ = 262, michael@0: TOK_OP_GE = 263, michael@0: TOK_OP_LE = 264, michael@0: TOK_OP_RIGHT = 265, michael@0: TOK_OP_LEFT = 266, michael@0: TOK_UNARY = 267 michael@0: }; michael@0: #endif michael@0: michael@0: michael@0: #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED michael@0: typedef int YYSTYPE; michael@0: # define YYSTYPE_IS_TRIVIAL 1 michael@0: # define yystype YYSTYPE /* obsolescent; will be withdrawn */ michael@0: # define YYSTYPE_IS_DECLARED 1 michael@0: #endif michael@0: michael@0: michael@0: #ifdef YYPARSE_PARAM michael@0: #if defined __STDC__ || defined __cplusplus michael@0: int ppparse (void *YYPARSE_PARAM); michael@0: #else michael@0: int ppparse (); michael@0: #endif michael@0: #else /* ! YYPARSE_PARAM */ michael@0: #if defined __STDC__ || defined __cplusplus michael@0: int ppparse (Context *context); michael@0: #else michael@0: int ppparse (); michael@0: #endif michael@0: #endif /* ! YYPARSE_PARAM */ michael@0: michael@0: michael@0: michael@0: /* Copy the second part of user declarations. */ michael@0: michael@0: michael@0: michael@0: #ifdef short michael@0: # undef short michael@0: #endif michael@0: michael@0: #ifdef YYTYPE_UINT8 michael@0: typedef YYTYPE_UINT8 yytype_uint8; michael@0: #else michael@0: typedef unsigned char yytype_uint8; michael@0: #endif michael@0: michael@0: #ifdef YYTYPE_INT8 michael@0: typedef YYTYPE_INT8 yytype_int8; michael@0: #elif (defined __STDC__ || defined __C99__FUNC__ \ michael@0: || defined __cplusplus || defined _MSC_VER) michael@0: typedef signed char yytype_int8; michael@0: #else michael@0: typedef short int yytype_int8; michael@0: #endif michael@0: michael@0: #ifdef YYTYPE_UINT16 michael@0: typedef YYTYPE_UINT16 yytype_uint16; michael@0: #else michael@0: typedef unsigned short int yytype_uint16; michael@0: #endif michael@0: michael@0: #ifdef YYTYPE_INT16 michael@0: typedef YYTYPE_INT16 yytype_int16; michael@0: #else michael@0: typedef short int yytype_int16; michael@0: #endif michael@0: michael@0: #ifndef YYSIZE_T michael@0: # ifdef __SIZE_TYPE__ michael@0: # define YYSIZE_T __SIZE_TYPE__ michael@0: # elif defined size_t michael@0: # define YYSIZE_T size_t michael@0: # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ michael@0: || defined __cplusplus || defined _MSC_VER) michael@0: # include /* INFRINGES ON USER NAME SPACE */ michael@0: # define YYSIZE_T size_t michael@0: # else michael@0: # define YYSIZE_T unsigned int michael@0: # endif michael@0: #endif michael@0: michael@0: #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) michael@0: michael@0: #ifndef YY_ michael@0: # if defined YYENABLE_NLS && YYENABLE_NLS michael@0: # if ENABLE_NLS michael@0: # include /* INFRINGES ON USER NAME SPACE */ michael@0: # define YY_(Msgid) dgettext ("bison-runtime", Msgid) michael@0: # endif michael@0: # endif michael@0: # ifndef YY_ michael@0: # define YY_(Msgid) Msgid michael@0: # endif michael@0: #endif michael@0: michael@0: /* Suppress unused-variable warnings by "using" E. */ michael@0: #if ! defined lint || defined __GNUC__ michael@0: # define YYUSE(E) ((void) (E)) michael@0: #else michael@0: # define YYUSE(E) /* empty */ michael@0: #endif michael@0: michael@0: /* Identity function, used to suppress warnings about constant conditions. */ michael@0: #ifndef lint michael@0: # define YYID(N) (N) michael@0: #else michael@0: #if (defined __STDC__ || defined __C99__FUNC__ \ michael@0: || defined __cplusplus || defined _MSC_VER) michael@0: static int michael@0: YYID (int yyi) michael@0: #else michael@0: static int michael@0: YYID (yyi) michael@0: int yyi; michael@0: #endif michael@0: { michael@0: return yyi; michael@0: } michael@0: #endif michael@0: michael@0: #if ! defined yyoverflow || YYERROR_VERBOSE michael@0: michael@0: /* The parser invokes alloca or malloc; define the necessary symbols. */ michael@0: michael@0: # ifdef YYSTACK_USE_ALLOCA michael@0: # if YYSTACK_USE_ALLOCA michael@0: # ifdef __GNUC__ michael@0: # define YYSTACK_ALLOC __builtin_alloca michael@0: # elif defined __BUILTIN_VA_ARG_INCR michael@0: # include /* INFRINGES ON USER NAME SPACE */ michael@0: # elif defined _AIX michael@0: # define YYSTACK_ALLOC __alloca michael@0: # elif defined _MSC_VER michael@0: # include /* INFRINGES ON USER NAME SPACE */ michael@0: # define alloca _alloca michael@0: # else michael@0: # define YYSTACK_ALLOC alloca michael@0: # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ michael@0: || defined __cplusplus || defined _MSC_VER) michael@0: # include /* INFRINGES ON USER NAME SPACE */ michael@0: /* Use EXIT_SUCCESS as a witness for stdlib.h. */ michael@0: # ifndef EXIT_SUCCESS michael@0: # define EXIT_SUCCESS 0 michael@0: # endif michael@0: # endif michael@0: # endif michael@0: # endif michael@0: # endif michael@0: michael@0: # ifdef YYSTACK_ALLOC michael@0: /* Pacify GCC's `empty if-body' warning. */ michael@0: # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) michael@0: # ifndef YYSTACK_ALLOC_MAXIMUM michael@0: /* The OS might guarantee only one guard page at the bottom of the stack, michael@0: and a page size can be as small as 4096 bytes. So we cannot safely michael@0: invoke alloca (N) if N exceeds 4096. Use a slightly smaller number michael@0: to allow for a few compiler-allocated temporary stack slots. */ michael@0: # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ michael@0: # endif michael@0: # else michael@0: # define YYSTACK_ALLOC YYMALLOC michael@0: # define YYSTACK_FREE YYFREE michael@0: # ifndef YYSTACK_ALLOC_MAXIMUM michael@0: # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM michael@0: # endif michael@0: # if (defined __cplusplus && ! defined EXIT_SUCCESS \ michael@0: && ! ((defined YYMALLOC || defined malloc) \ michael@0: && (defined YYFREE || defined free))) michael@0: # include /* INFRINGES ON USER NAME SPACE */ michael@0: # ifndef EXIT_SUCCESS michael@0: # define EXIT_SUCCESS 0 michael@0: # endif michael@0: # endif michael@0: # ifndef YYMALLOC michael@0: # define YYMALLOC malloc michael@0: # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ michael@0: || defined __cplusplus || defined _MSC_VER) michael@0: void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ michael@0: # endif michael@0: # endif michael@0: # ifndef YYFREE michael@0: # define YYFREE free michael@0: # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ michael@0: || defined __cplusplus || defined _MSC_VER) michael@0: void free (void *); /* INFRINGES ON USER NAME SPACE */ michael@0: # endif michael@0: # endif michael@0: # endif michael@0: #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ michael@0: michael@0: michael@0: #if (! defined yyoverflow \ michael@0: && (! defined __cplusplus \ michael@0: || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) michael@0: michael@0: /* A type that is properly aligned for any stack member. */ michael@0: union yyalloc michael@0: { michael@0: yytype_int16 yyss_alloc; michael@0: YYSTYPE yyvs_alloc; michael@0: }; michael@0: michael@0: /* The size of the maximum gap between one aligned stack and the next. */ michael@0: # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) michael@0: michael@0: /* The size of an array large to enough to hold all stacks, each with michael@0: N elements. */ michael@0: # define YYSTACK_BYTES(N) \ michael@0: ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ michael@0: + YYSTACK_GAP_MAXIMUM) michael@0: michael@0: # define YYCOPY_NEEDED 1 michael@0: michael@0: /* Relocate STACK from its old location to the new one. The michael@0: local variables YYSIZE and YYSTACKSIZE give the old and new number of michael@0: elements in the stack, and YYPTR gives the new location of the michael@0: stack. Advance YYPTR to a properly aligned location for the next michael@0: stack. */ michael@0: # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ michael@0: do \ michael@0: { \ michael@0: YYSIZE_T yynewbytes; \ michael@0: YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ michael@0: Stack = &yyptr->Stack_alloc; \ michael@0: yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ michael@0: yyptr += yynewbytes / sizeof (*yyptr); \ michael@0: } \ michael@0: while (YYID (0)) michael@0: michael@0: #endif michael@0: michael@0: #if defined YYCOPY_NEEDED && YYCOPY_NEEDED michael@0: /* Copy COUNT objects from SRC to DST. The source and destination do michael@0: not overlap. */ michael@0: # ifndef YYCOPY michael@0: # if defined __GNUC__ && 1 < __GNUC__ michael@0: # define YYCOPY(Dst, Src, Count) \ michael@0: __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) michael@0: # else michael@0: # define YYCOPY(Dst, Src, Count) \ michael@0: do \ michael@0: { \ michael@0: YYSIZE_T yyi; \ michael@0: for (yyi = 0; yyi < (Count); yyi++) \ michael@0: (Dst)[yyi] = (Src)[yyi]; \ michael@0: } \ michael@0: while (YYID (0)) michael@0: # endif michael@0: # endif michael@0: #endif /* !YYCOPY_NEEDED */ michael@0: michael@0: /* YYFINAL -- State number of the termination state. */ michael@0: #define YYFINAL 14 michael@0: /* YYLAST -- Last index in YYTABLE. */ michael@0: #define YYLAST 175 michael@0: michael@0: /* YYNTOKENS -- Number of terminals. */ michael@0: #define YYNTOKENS 27 michael@0: /* YYNNTS -- Number of nonterminals. */ michael@0: #define YYNNTS 3 michael@0: /* YYNRULES -- Number of rules. */ michael@0: #define YYNRULES 26 michael@0: /* YYNRULES -- Number of states. */ michael@0: #define YYNSTATES 52 michael@0: michael@0: /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ michael@0: #define YYUNDEFTOK 2 michael@0: #define YYMAXUTOK 267 michael@0: michael@0: #define YYTRANSLATE(YYX) \ michael@0: ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) michael@0: michael@0: /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ michael@0: static const yytype_uint8 yytranslate[] = michael@0: { michael@0: 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 23, 2, 2, 2, 21, 8, 2, michael@0: 25, 26, 19, 17, 2, 18, 2, 20, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 11, 2, 12, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 7, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 6, 2, 24, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, michael@0: 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, michael@0: 5, 9, 10, 13, 14, 15, 16, 22 michael@0: }; michael@0: michael@0: #if YYDEBUG michael@0: /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in michael@0: YYRHS. */ michael@0: static const yytype_uint8 yyprhs[] = michael@0: { michael@0: 0, 0, 3, 5, 7, 11, 15, 19, 23, 27, michael@0: 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, michael@0: 71, 75, 79, 82, 85, 88, 91 michael@0: }; michael@0: michael@0: /* YYRHS -- A `-1'-separated list of the rules' RHS. */ michael@0: static const yytype_int8 yyrhs[] = michael@0: { michael@0: 28, 0, -1, 29, -1, 3, -1, 29, 4, 29, michael@0: -1, 29, 5, 29, -1, 29, 6, 29, -1, 29, michael@0: 7, 29, -1, 29, 8, 29, -1, 29, 9, 29, michael@0: -1, 29, 10, 29, -1, 29, 13, 29, -1, 29, michael@0: 14, 29, -1, 29, 12, 29, -1, 29, 11, 29, michael@0: -1, 29, 15, 29, -1, 29, 16, 29, -1, 29, michael@0: 18, 29, -1, 29, 17, 29, -1, 29, 21, 29, michael@0: -1, 29, 20, 29, -1, 29, 19, 29, -1, 23, michael@0: 29, -1, 24, 29, -1, 18, 29, -1, 17, 29, michael@0: -1, 25, 29, 26, -1 michael@0: }; michael@0: michael@0: /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ michael@0: static const yytype_uint8 yyrline[] = michael@0: { michael@0: 0, 91, 91, 98, 99, 102, 105, 108, 111, 114, michael@0: 117, 120, 123, 126, 129, 132, 135, 138, 141, 144, michael@0: 157, 170, 173, 176, 179, 182, 185 michael@0: }; michael@0: #endif michael@0: michael@0: #if YYDEBUG || YYERROR_VERBOSE || 0 michael@0: /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. michael@0: First, the terminals, then, starting at YYNTOKENS, nonterminals. */ michael@0: static const char *const yytname[] = michael@0: { michael@0: "$end", "error", "$undefined", "TOK_CONST_INT", "TOK_OP_OR", michael@0: "TOK_OP_AND", "'|'", "'^'", "'&'", "TOK_OP_NE", "TOK_OP_EQ", "'<'", michael@0: "'>'", "TOK_OP_GE", "TOK_OP_LE", "TOK_OP_RIGHT", "TOK_OP_LEFT", "'+'", michael@0: "'-'", "'*'", "'/'", "'%'", "TOK_UNARY", "'!'", "'~'", "'('", "')'", michael@0: "$accept", "input", "expression", YY_NULL michael@0: }; michael@0: #endif michael@0: michael@0: # ifdef YYPRINT michael@0: /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to michael@0: token YYLEX-NUM. */ michael@0: static const yytype_uint16 yytoknum[] = michael@0: { michael@0: 0, 256, 257, 258, 259, 260, 124, 94, 38, 261, michael@0: 262, 60, 62, 263, 264, 265, 266, 43, 45, 42, michael@0: 47, 37, 267, 33, 126, 40, 41 michael@0: }; michael@0: # endif michael@0: michael@0: /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ michael@0: static const yytype_uint8 yyr1[] = michael@0: { michael@0: 0, 27, 28, 29, 29, 29, 29, 29, 29, 29, michael@0: 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, michael@0: 29, 29, 29, 29, 29, 29, 29 michael@0: }; michael@0: michael@0: /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ michael@0: static const yytype_uint8 yyr2[] = michael@0: { michael@0: 0, 2, 1, 1, 3, 3, 3, 3, 3, 3, michael@0: 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, michael@0: 3, 3, 2, 2, 2, 2, 3 michael@0: }; michael@0: michael@0: /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. michael@0: Performed when YYTABLE doesn't specify something else to do. Zero michael@0: means the default is an error. */ michael@0: static const yytype_uint8 yydefact[] = michael@0: { michael@0: 0, 3, 0, 0, 0, 0, 0, 0, 2, 25, michael@0: 24, 22, 23, 0, 1, 0, 0, 0, 0, 0, michael@0: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, michael@0: 0, 0, 0, 26, 4, 5, 6, 7, 8, 9, michael@0: 10, 14, 13, 11, 12, 15, 16, 18, 17, 21, michael@0: 20, 19 michael@0: }; michael@0: michael@0: /* YYDEFGOTO[NTERM-NUM]. */ michael@0: static const yytype_int8 yydefgoto[] = michael@0: { michael@0: -1, 7, 8 michael@0: }; michael@0: michael@0: /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing michael@0: STATE-NUM. */ michael@0: #define YYPACT_NINF -11 michael@0: static const yytype_int16 yypact[] = michael@0: { michael@0: 46, -11, 46, 46, 46, 46, 46, 12, 68, -11, michael@0: -11, -11, -11, 27, -11, 46, 46, 46, 46, 46, michael@0: 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, michael@0: 46, 46, 46, -11, 85, 101, 116, 130, 143, 154, michael@0: 154, -10, -10, -10, -10, 37, 37, 31, 31, -11, michael@0: -11, -11 michael@0: }; michael@0: michael@0: /* YYPGOTO[NTERM-NUM]. */ michael@0: static const yytype_int8 yypgoto[] = michael@0: { michael@0: -11, -11, -2 michael@0: }; michael@0: michael@0: /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If michael@0: positive, shift that token. If negative, reduce the rule which michael@0: number is the opposite. If YYTABLE_NINF, syntax error. */ michael@0: #define YYTABLE_NINF -1 michael@0: static const yytype_uint8 yytable[] = michael@0: { michael@0: 9, 10, 11, 12, 13, 26, 27, 28, 29, 30, michael@0: 31, 32, 14, 34, 35, 36, 37, 38, 39, 40, michael@0: 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, michael@0: 51, 15, 16, 17, 18, 19, 20, 21, 22, 23, michael@0: 24, 25, 26, 27, 28, 29, 30, 31, 32, 1, michael@0: 30, 31, 32, 33, 28, 29, 30, 31, 32, 0, michael@0: 0, 0, 0, 2, 3, 0, 0, 0, 0, 4, michael@0: 5, 6, 15, 16, 17, 18, 19, 20, 21, 22, michael@0: 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, michael@0: 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, michael@0: 26, 27, 28, 29, 30, 31, 32, 17, 18, 19, michael@0: 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, michael@0: 30, 31, 32, 18, 19, 20, 21, 22, 23, 24, michael@0: 25, 26, 27, 28, 29, 30, 31, 32, 19, 20, michael@0: 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, michael@0: 31, 32, 20, 21, 22, 23, 24, 25, 26, 27, michael@0: 28, 29, 30, 31, 32, 22, 23, 24, 25, 26, michael@0: 27, 28, 29, 30, 31, 32 michael@0: }; michael@0: michael@0: #define yypact_value_is_default(Yystate) \ michael@0: (!!((Yystate) == (-11))) michael@0: michael@0: #define yytable_value_is_error(Yytable_value) \ michael@0: YYID (0) michael@0: michael@0: static const yytype_int8 yycheck[] = michael@0: { michael@0: 2, 3, 4, 5, 6, 15, 16, 17, 18, 19, michael@0: 20, 21, 0, 15, 16, 17, 18, 19, 20, 21, michael@0: 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, michael@0: 32, 4, 5, 6, 7, 8, 9, 10, 11, 12, michael@0: 13, 14, 15, 16, 17, 18, 19, 20, 21, 3, michael@0: 19, 20, 21, 26, 17, 18, 19, 20, 21, -1, michael@0: -1, -1, -1, 17, 18, -1, -1, -1, -1, 23, michael@0: 24, 25, 4, 5, 6, 7, 8, 9, 10, 11, michael@0: 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, michael@0: 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, michael@0: 15, 16, 17, 18, 19, 20, 21, 6, 7, 8, michael@0: 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, michael@0: 19, 20, 21, 7, 8, 9, 10, 11, 12, 13, michael@0: 14, 15, 16, 17, 18, 19, 20, 21, 8, 9, michael@0: 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, michael@0: 20, 21, 9, 10, 11, 12, 13, 14, 15, 16, michael@0: 17, 18, 19, 20, 21, 11, 12, 13, 14, 15, michael@0: 16, 17, 18, 19, 20, 21 michael@0: }; michael@0: michael@0: /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing michael@0: symbol of state STATE-NUM. */ michael@0: static const yytype_uint8 yystos[] = michael@0: { michael@0: 0, 3, 17, 18, 23, 24, 25, 28, 29, 29, michael@0: 29, 29, 29, 29, 0, 4, 5, 6, 7, 8, michael@0: 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, michael@0: 19, 20, 21, 26, 29, 29, 29, 29, 29, 29, michael@0: 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, michael@0: 29, 29 michael@0: }; michael@0: michael@0: #define yyerrok (yyerrstatus = 0) michael@0: #define yyclearin (yychar = YYEMPTY) michael@0: #define YYEMPTY (-2) michael@0: #define YYEOF 0 michael@0: michael@0: #define YYACCEPT goto yyacceptlab michael@0: #define YYABORT goto yyabortlab michael@0: #define YYERROR goto yyerrorlab michael@0: michael@0: michael@0: /* Like YYERROR except do call yyerror. This remains here temporarily michael@0: to ease the transition to the new meaning of YYERROR, for GCC. michael@0: Once GCC version 2 has supplanted version 1, this can go. However, michael@0: YYFAIL appears to be in use. Nevertheless, it is formally deprecated michael@0: in Bison 2.4.2's NEWS entry, where a plan to phase it out is michael@0: discussed. */ michael@0: michael@0: #define YYFAIL goto yyerrlab michael@0: #if defined YYFAIL michael@0: /* This is here to suppress warnings from the GCC cpp's michael@0: -Wunused-macros. Normally we don't worry about that warning, but michael@0: some users do, and we want to make it easy for users to remove michael@0: YYFAIL uses, which will produce warnings from Bison 2.5. */ michael@0: #endif michael@0: michael@0: #define YYRECOVERING() (!!yyerrstatus) michael@0: michael@0: #define YYBACKUP(Token, Value) \ michael@0: do \ michael@0: if (yychar == YYEMPTY) \ michael@0: { \ michael@0: yychar = (Token); \ michael@0: yylval = (Value); \ michael@0: YYPOPSTACK (yylen); \ michael@0: yystate = *yyssp; \ michael@0: goto yybackup; \ michael@0: } \ michael@0: else \ michael@0: { \ michael@0: yyerror (context, YY_("syntax error: cannot back up")); \ michael@0: YYERROR; \ michael@0: } \ michael@0: while (YYID (0)) michael@0: michael@0: /* Error token number */ michael@0: #define YYTERROR 1 michael@0: #define YYERRCODE 256 michael@0: michael@0: michael@0: /* This macro is provided for backward compatibility. */ michael@0: #ifndef YY_LOCATION_PRINT michael@0: # define YY_LOCATION_PRINT(File, Loc) ((void) 0) michael@0: #endif michael@0: michael@0: michael@0: /* YYLEX -- calling `yylex' with the right arguments. */ michael@0: #ifdef YYLEX_PARAM michael@0: # define YYLEX yylex (&yylval, YYLEX_PARAM) michael@0: #else michael@0: # define YYLEX yylex (&yylval, context) michael@0: #endif michael@0: michael@0: /* Enable debugging if requested. */ michael@0: #if YYDEBUG michael@0: michael@0: # ifndef YYFPRINTF michael@0: # include /* INFRINGES ON USER NAME SPACE */ michael@0: # define YYFPRINTF fprintf michael@0: # endif michael@0: michael@0: # define YYDPRINTF(Args) \ michael@0: do { \ michael@0: if (yydebug) \ michael@0: YYFPRINTF Args; \ michael@0: } while (YYID (0)) michael@0: michael@0: # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ michael@0: do { \ michael@0: if (yydebug) \ michael@0: { \ michael@0: YYFPRINTF (stderr, "%s ", Title); \ michael@0: yy_symbol_print (stderr, \ michael@0: Type, Value, context); \ michael@0: YYFPRINTF (stderr, "\n"); \ michael@0: } \ michael@0: } while (YYID (0)) michael@0: michael@0: michael@0: /*--------------------------------. michael@0: | Print this symbol on YYOUTPUT. | michael@0: `--------------------------------*/ michael@0: michael@0: /*ARGSUSED*/ michael@0: #if (defined __STDC__ || defined __C99__FUNC__ \ michael@0: || defined __cplusplus || defined _MSC_VER) michael@0: static void michael@0: yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Context *context) michael@0: #else michael@0: static void michael@0: yy_symbol_value_print (yyoutput, yytype, yyvaluep, context) michael@0: FILE *yyoutput; michael@0: int yytype; michael@0: YYSTYPE const * const yyvaluep; michael@0: Context *context; michael@0: #endif michael@0: { michael@0: FILE *yyo = yyoutput; michael@0: YYUSE (yyo); michael@0: if (!yyvaluep) michael@0: return; michael@0: YYUSE (context); michael@0: # ifdef YYPRINT michael@0: if (yytype < YYNTOKENS) michael@0: YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); michael@0: # else michael@0: YYUSE (yyoutput); michael@0: # endif michael@0: switch (yytype) michael@0: { michael@0: default: michael@0: break; michael@0: } michael@0: } michael@0: michael@0: michael@0: /*--------------------------------. michael@0: | Print this symbol on YYOUTPUT. | michael@0: `--------------------------------*/ michael@0: michael@0: #if (defined __STDC__ || defined __C99__FUNC__ \ michael@0: || defined __cplusplus || defined _MSC_VER) michael@0: static void michael@0: yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Context *context) michael@0: #else michael@0: static void michael@0: yy_symbol_print (yyoutput, yytype, yyvaluep, context) michael@0: FILE *yyoutput; michael@0: int yytype; michael@0: YYSTYPE const * const yyvaluep; michael@0: Context *context; michael@0: #endif michael@0: { michael@0: if (yytype < YYNTOKENS) michael@0: YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); michael@0: else michael@0: YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); michael@0: michael@0: yy_symbol_value_print (yyoutput, yytype, yyvaluep, context); michael@0: YYFPRINTF (yyoutput, ")"); michael@0: } michael@0: michael@0: /*------------------------------------------------------------------. michael@0: | yy_stack_print -- Print the state stack from its BOTTOM up to its | michael@0: | TOP (included). | michael@0: `------------------------------------------------------------------*/ michael@0: michael@0: #if (defined __STDC__ || defined __C99__FUNC__ \ michael@0: || defined __cplusplus || defined _MSC_VER) michael@0: static void michael@0: yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) michael@0: #else michael@0: static void michael@0: yy_stack_print (yybottom, yytop) michael@0: yytype_int16 *yybottom; michael@0: yytype_int16 *yytop; michael@0: #endif michael@0: { michael@0: YYFPRINTF (stderr, "Stack now"); michael@0: for (; yybottom <= yytop; yybottom++) michael@0: { michael@0: int yybot = *yybottom; michael@0: YYFPRINTF (stderr, " %d", yybot); michael@0: } michael@0: YYFPRINTF (stderr, "\n"); michael@0: } michael@0: michael@0: # define YY_STACK_PRINT(Bottom, Top) \ michael@0: do { \ michael@0: if (yydebug) \ michael@0: yy_stack_print ((Bottom), (Top)); \ michael@0: } while (YYID (0)) michael@0: michael@0: michael@0: /*------------------------------------------------. michael@0: | Report that the YYRULE is going to be reduced. | michael@0: `------------------------------------------------*/ michael@0: michael@0: #if (defined __STDC__ || defined __C99__FUNC__ \ michael@0: || defined __cplusplus || defined _MSC_VER) michael@0: static void michael@0: yy_reduce_print (YYSTYPE *yyvsp, int yyrule, Context *context) michael@0: #else michael@0: static void michael@0: yy_reduce_print (yyvsp, yyrule, context) michael@0: YYSTYPE *yyvsp; michael@0: int yyrule; michael@0: Context *context; michael@0: #endif michael@0: { michael@0: int yynrhs = yyr2[yyrule]; michael@0: int yyi; michael@0: unsigned long int yylno = yyrline[yyrule]; michael@0: YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", michael@0: yyrule - 1, yylno); michael@0: /* The symbols being reduced. */ michael@0: for (yyi = 0; yyi < yynrhs; yyi++) michael@0: { michael@0: YYFPRINTF (stderr, " $%d = ", yyi + 1); michael@0: yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], michael@0: &(yyvsp[(yyi + 1) - (yynrhs)]) michael@0: , context); michael@0: YYFPRINTF (stderr, "\n"); michael@0: } michael@0: } michael@0: michael@0: # define YY_REDUCE_PRINT(Rule) \ michael@0: do { \ michael@0: if (yydebug) \ michael@0: yy_reduce_print (yyvsp, Rule, context); \ michael@0: } while (YYID (0)) michael@0: michael@0: /* Nonzero means print parse trace. It is left uninitialized so that michael@0: multiple parsers can coexist. */ michael@0: int yydebug; michael@0: #else /* !YYDEBUG */ michael@0: # define YYDPRINTF(Args) michael@0: # define YY_SYMBOL_PRINT(Title, Type, Value, Location) michael@0: # define YY_STACK_PRINT(Bottom, Top) michael@0: # define YY_REDUCE_PRINT(Rule) michael@0: #endif /* !YYDEBUG */ michael@0: michael@0: michael@0: /* YYINITDEPTH -- initial size of the parser's stacks. */ michael@0: #ifndef YYINITDEPTH michael@0: # define YYINITDEPTH 200 michael@0: #endif michael@0: michael@0: /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only michael@0: if the built-in stack extension method is used). michael@0: michael@0: Do not make this value too large; the results are undefined if michael@0: YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) michael@0: evaluated with infinite-precision integer arithmetic. */ michael@0: michael@0: #ifndef YYMAXDEPTH michael@0: # define YYMAXDEPTH 10000 michael@0: #endif michael@0: michael@0: michael@0: #if YYERROR_VERBOSE michael@0: michael@0: # ifndef yystrlen michael@0: # if defined __GLIBC__ && defined _STRING_H michael@0: # define yystrlen strlen michael@0: # else michael@0: /* Return the length of YYSTR. */ michael@0: #if (defined __STDC__ || defined __C99__FUNC__ \ michael@0: || defined __cplusplus || defined _MSC_VER) michael@0: static YYSIZE_T michael@0: yystrlen (const char *yystr) michael@0: #else michael@0: static YYSIZE_T michael@0: yystrlen (yystr) michael@0: const char *yystr; michael@0: #endif michael@0: { michael@0: YYSIZE_T yylen; michael@0: for (yylen = 0; yystr[yylen]; yylen++) michael@0: continue; michael@0: return yylen; michael@0: } michael@0: # endif michael@0: # endif michael@0: michael@0: # ifndef yystpcpy michael@0: # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE michael@0: # define yystpcpy stpcpy michael@0: # else michael@0: /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in michael@0: YYDEST. */ michael@0: #if (defined __STDC__ || defined __C99__FUNC__ \ michael@0: || defined __cplusplus || defined _MSC_VER) michael@0: static char * michael@0: yystpcpy (char *yydest, const char *yysrc) michael@0: #else michael@0: static char * michael@0: yystpcpy (yydest, yysrc) michael@0: char *yydest; michael@0: const char *yysrc; michael@0: #endif michael@0: { michael@0: char *yyd = yydest; michael@0: const char *yys = yysrc; michael@0: michael@0: while ((*yyd++ = *yys++) != '\0') michael@0: continue; michael@0: michael@0: return yyd - 1; michael@0: } michael@0: # endif michael@0: # endif michael@0: michael@0: # ifndef yytnamerr michael@0: /* Copy to YYRES the contents of YYSTR after stripping away unnecessary michael@0: quotes and backslashes, so that it's suitable for yyerror. The michael@0: heuristic is that double-quoting is unnecessary unless the string michael@0: contains an apostrophe, a comma, or backslash (other than michael@0: backslash-backslash). YYSTR is taken from yytname. If YYRES is michael@0: null, do not copy; instead, return the length of what the result michael@0: would have been. */ michael@0: static YYSIZE_T michael@0: yytnamerr (char *yyres, const char *yystr) michael@0: { michael@0: if (*yystr == '"') michael@0: { michael@0: YYSIZE_T yyn = 0; michael@0: char const *yyp = yystr; michael@0: michael@0: for (;;) michael@0: switch (*++yyp) michael@0: { michael@0: case '\'': michael@0: case ',': michael@0: goto do_not_strip_quotes; michael@0: michael@0: case '\\': michael@0: if (*++yyp != '\\') michael@0: goto do_not_strip_quotes; michael@0: /* Fall through. */ michael@0: default: michael@0: if (yyres) michael@0: yyres[yyn] = *yyp; michael@0: yyn++; michael@0: break; michael@0: michael@0: case '"': michael@0: if (yyres) michael@0: yyres[yyn] = '\0'; michael@0: return yyn; michael@0: } michael@0: do_not_strip_quotes: ; michael@0: } michael@0: michael@0: if (! yyres) michael@0: return yystrlen (yystr); michael@0: michael@0: return yystpcpy (yyres, yystr) - yyres; michael@0: } michael@0: # endif michael@0: michael@0: /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message michael@0: about the unexpected token YYTOKEN for the state stack whose top is michael@0: YYSSP. michael@0: michael@0: Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is michael@0: not large enough to hold the message. In that case, also set michael@0: *YYMSG_ALLOC to the required number of bytes. Return 2 if the michael@0: required number of bytes is too large to store. */ michael@0: static int michael@0: yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, michael@0: yytype_int16 *yyssp, int yytoken) michael@0: { michael@0: YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); michael@0: YYSIZE_T yysize = yysize0; michael@0: enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; michael@0: /* Internationalized format string. */ michael@0: const char *yyformat = YY_NULL; michael@0: /* Arguments of yyformat. */ michael@0: char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; michael@0: /* Number of reported tokens (one for the "unexpected", one per michael@0: "expected"). */ michael@0: int yycount = 0; michael@0: michael@0: /* There are many possibilities here to consider: michael@0: - Assume YYFAIL is not used. It's too flawed to consider. See michael@0: michael@0: for details. YYERROR is fine as it does not invoke this michael@0: function. michael@0: - If this state is a consistent state with a default action, then michael@0: the only way this function was invoked is if the default action michael@0: is an error action. In that case, don't check for expected michael@0: tokens because there are none. michael@0: - The only way there can be no lookahead present (in yychar) is if michael@0: this state is a consistent state with a default action. Thus, michael@0: detecting the absence of a lookahead is sufficient to determine michael@0: that there is no unexpected or expected token to report. In that michael@0: case, just report a simple "syntax error". michael@0: - Don't assume there isn't a lookahead just because this state is a michael@0: consistent state with a default action. There might have been a michael@0: previous inconsistent state, consistent state with a non-default michael@0: action, or user semantic action that manipulated yychar. michael@0: - Of course, the expected token list depends on states to have michael@0: correct lookahead information, and it depends on the parser not michael@0: to perform extra reductions after fetching a lookahead from the michael@0: scanner and before detecting a syntax error. Thus, state merging michael@0: (from LALR or IELR) and default reductions corrupt the expected michael@0: token list. However, the list is correct for canonical LR with michael@0: one exception: it will still contain any token that will not be michael@0: accepted due to an error action in a later state. michael@0: */ michael@0: if (yytoken != YYEMPTY) michael@0: { michael@0: int yyn = yypact[*yyssp]; michael@0: yyarg[yycount++] = yytname[yytoken]; michael@0: if (!yypact_value_is_default (yyn)) michael@0: { michael@0: /* Start YYX at -YYN if negative to avoid negative indexes in michael@0: YYCHECK. In other words, skip the first -YYN actions for michael@0: this state because they are default actions. */ michael@0: int yyxbegin = yyn < 0 ? -yyn : 0; michael@0: /* Stay within bounds of both yycheck and yytname. */ michael@0: int yychecklim = YYLAST - yyn + 1; michael@0: int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; michael@0: int yyx; michael@0: michael@0: for (yyx = yyxbegin; yyx < yyxend; ++yyx) michael@0: if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR michael@0: && !yytable_value_is_error (yytable[yyx + yyn])) michael@0: { michael@0: if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) michael@0: { michael@0: yycount = 1; michael@0: yysize = yysize0; michael@0: break; michael@0: } michael@0: yyarg[yycount++] = yytname[yyx]; michael@0: { michael@0: YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); michael@0: if (! (yysize <= yysize1 michael@0: && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) michael@0: return 2; michael@0: yysize = yysize1; michael@0: } michael@0: } michael@0: } michael@0: } michael@0: michael@0: switch (yycount) michael@0: { michael@0: # define YYCASE_(N, S) \ michael@0: case N: \ michael@0: yyformat = S; \ michael@0: break michael@0: YYCASE_(0, YY_("syntax error")); michael@0: YYCASE_(1, YY_("syntax error, unexpected %s")); michael@0: YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); michael@0: YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); michael@0: YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); michael@0: YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); michael@0: # undef YYCASE_ michael@0: } michael@0: michael@0: { michael@0: YYSIZE_T yysize1 = yysize + yystrlen (yyformat); michael@0: if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) michael@0: return 2; michael@0: yysize = yysize1; michael@0: } michael@0: michael@0: if (*yymsg_alloc < yysize) michael@0: { michael@0: *yymsg_alloc = 2 * yysize; michael@0: if (! (yysize <= *yymsg_alloc michael@0: && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) michael@0: *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; michael@0: return 1; michael@0: } michael@0: michael@0: /* Avoid sprintf, as that infringes on the user's name space. michael@0: Don't have undefined behavior even if the translation michael@0: produced a string with the wrong number of "%s"s. */ michael@0: { michael@0: char *yyp = *yymsg; michael@0: int yyi = 0; michael@0: while ((*yyp = *yyformat) != '\0') michael@0: if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) michael@0: { michael@0: yyp += yytnamerr (yyp, yyarg[yyi++]); michael@0: yyformat += 2; michael@0: } michael@0: else michael@0: { michael@0: yyp++; michael@0: yyformat++; michael@0: } michael@0: } michael@0: return 0; michael@0: } michael@0: #endif /* YYERROR_VERBOSE */ michael@0: michael@0: /*-----------------------------------------------. michael@0: | Release the memory associated to this symbol. | michael@0: `-----------------------------------------------*/ michael@0: michael@0: /*ARGSUSED*/ michael@0: #if (defined __STDC__ || defined __C99__FUNC__ \ michael@0: || defined __cplusplus || defined _MSC_VER) michael@0: static void michael@0: yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Context *context) michael@0: #else michael@0: static void michael@0: yydestruct (yymsg, yytype, yyvaluep, context) michael@0: const char *yymsg; michael@0: int yytype; michael@0: YYSTYPE *yyvaluep; michael@0: Context *context; michael@0: #endif michael@0: { michael@0: YYUSE (yyvaluep); michael@0: YYUSE (context); michael@0: michael@0: if (!yymsg) michael@0: yymsg = "Deleting"; michael@0: YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); michael@0: michael@0: switch (yytype) michael@0: { michael@0: michael@0: default: michael@0: break; michael@0: } michael@0: } michael@0: michael@0: michael@0: michael@0: michael@0: /*----------. michael@0: | yyparse. | michael@0: `----------*/ michael@0: michael@0: #ifdef YYPARSE_PARAM michael@0: #if (defined __STDC__ || defined __C99__FUNC__ \ michael@0: || defined __cplusplus || defined _MSC_VER) michael@0: int michael@0: yyparse (void *YYPARSE_PARAM) michael@0: #else michael@0: int michael@0: yyparse (YYPARSE_PARAM) michael@0: void *YYPARSE_PARAM; michael@0: #endif michael@0: #else /* ! YYPARSE_PARAM */ michael@0: #if (defined __STDC__ || defined __C99__FUNC__ \ michael@0: || defined __cplusplus || defined _MSC_VER) michael@0: int michael@0: yyparse (Context *context) michael@0: #else michael@0: int michael@0: yyparse (context) michael@0: Context *context; michael@0: #endif michael@0: #endif michael@0: { michael@0: /* The lookahead symbol. */ michael@0: int yychar; michael@0: michael@0: michael@0: #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ michael@0: /* Suppress an incorrect diagnostic about yylval being uninitialized. */ michael@0: # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ michael@0: _Pragma ("GCC diagnostic push") \ michael@0: _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ michael@0: _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") michael@0: # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ michael@0: _Pragma ("GCC diagnostic pop") michael@0: #else michael@0: /* Default value used for initialization, for pacifying older GCCs michael@0: or non-GCC compilers. */ michael@0: static YYSTYPE yyval_default; michael@0: # define YY_INITIAL_VALUE(Value) = Value michael@0: #endif michael@0: #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN michael@0: # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN michael@0: # define YY_IGNORE_MAYBE_UNINITIALIZED_END michael@0: #endif michael@0: #ifndef YY_INITIAL_VALUE michael@0: # define YY_INITIAL_VALUE(Value) /* Nothing. */ michael@0: #endif michael@0: michael@0: /* The semantic value of the lookahead symbol. */ michael@0: YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); michael@0: michael@0: /* Number of syntax errors so far. */ michael@0: int yynerrs; michael@0: michael@0: int yystate; michael@0: /* Number of tokens to shift before error messages enabled. */ michael@0: int yyerrstatus; michael@0: michael@0: /* The stacks and their tools: michael@0: `yyss': related to states. michael@0: `yyvs': related to semantic values. michael@0: michael@0: Refer to the stacks through separate pointers, to allow yyoverflow michael@0: to reallocate them elsewhere. */ michael@0: michael@0: /* The state stack. */ michael@0: yytype_int16 yyssa[YYINITDEPTH]; michael@0: yytype_int16 *yyss; michael@0: yytype_int16 *yyssp; michael@0: michael@0: /* The semantic value stack. */ michael@0: YYSTYPE yyvsa[YYINITDEPTH]; michael@0: YYSTYPE *yyvs; michael@0: YYSTYPE *yyvsp; michael@0: michael@0: YYSIZE_T yystacksize; michael@0: michael@0: int yyn; michael@0: int yyresult; michael@0: /* Lookahead token as an internal (translated) token number. */ michael@0: int yytoken = 0; michael@0: /* The variables used to return semantic value and location from the michael@0: action routines. */ michael@0: YYSTYPE yyval; michael@0: michael@0: #if YYERROR_VERBOSE michael@0: /* Buffer for error messages, and its allocated size. */ michael@0: char yymsgbuf[128]; michael@0: char *yymsg = yymsgbuf; michael@0: YYSIZE_T yymsg_alloc = sizeof yymsgbuf; michael@0: #endif michael@0: michael@0: #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) michael@0: michael@0: /* The number of symbols on the RHS of the reduced rule. michael@0: Keep to zero when no symbol should be popped. */ michael@0: int yylen = 0; michael@0: michael@0: yyssp = yyss = yyssa; michael@0: yyvsp = yyvs = yyvsa; michael@0: yystacksize = YYINITDEPTH; michael@0: michael@0: YYDPRINTF ((stderr, "Starting parse\n")); michael@0: michael@0: yystate = 0; michael@0: yyerrstatus = 0; michael@0: yynerrs = 0; michael@0: yychar = YYEMPTY; /* Cause a token to be read. */ michael@0: goto yysetstate; michael@0: michael@0: /*------------------------------------------------------------. michael@0: | yynewstate -- Push a new state, which is found in yystate. | michael@0: `------------------------------------------------------------*/ michael@0: yynewstate: michael@0: /* In all cases, when you get here, the value and location stacks michael@0: have just been pushed. So pushing a state here evens the stacks. */ michael@0: yyssp++; michael@0: michael@0: yysetstate: michael@0: *yyssp = yystate; michael@0: michael@0: if (yyss + yystacksize - 1 <= yyssp) michael@0: { michael@0: /* Get the current used size of the three stacks, in elements. */ michael@0: YYSIZE_T yysize = yyssp - yyss + 1; michael@0: michael@0: #ifdef yyoverflow michael@0: { michael@0: /* Give user a chance to reallocate the stack. Use copies of michael@0: these so that the &'s don't force the real ones into michael@0: memory. */ michael@0: YYSTYPE *yyvs1 = yyvs; michael@0: yytype_int16 *yyss1 = yyss; michael@0: michael@0: /* Each stack pointer address is followed by the size of the michael@0: data in use in that stack, in bytes. This used to be a michael@0: conditional around just the two extra args, but that might michael@0: be undefined if yyoverflow is a macro. */ michael@0: yyoverflow (YY_("memory exhausted"), michael@0: &yyss1, yysize * sizeof (*yyssp), michael@0: &yyvs1, yysize * sizeof (*yyvsp), michael@0: &yystacksize); michael@0: michael@0: yyss = yyss1; michael@0: yyvs = yyvs1; michael@0: } michael@0: #else /* no yyoverflow */ michael@0: # ifndef YYSTACK_RELOCATE michael@0: goto yyexhaustedlab; michael@0: # else michael@0: /* Extend the stack our own way. */ michael@0: if (YYMAXDEPTH <= yystacksize) michael@0: goto yyexhaustedlab; michael@0: yystacksize *= 2; michael@0: if (YYMAXDEPTH < yystacksize) michael@0: yystacksize = YYMAXDEPTH; michael@0: michael@0: { michael@0: yytype_int16 *yyss1 = yyss; michael@0: union yyalloc *yyptr = michael@0: (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); michael@0: if (! yyptr) michael@0: goto yyexhaustedlab; michael@0: YYSTACK_RELOCATE (yyss_alloc, yyss); michael@0: YYSTACK_RELOCATE (yyvs_alloc, yyvs); michael@0: # undef YYSTACK_RELOCATE michael@0: if (yyss1 != yyssa) michael@0: YYSTACK_FREE (yyss1); michael@0: } michael@0: # endif michael@0: #endif /* no yyoverflow */ michael@0: michael@0: yyssp = yyss + yysize - 1; michael@0: yyvsp = yyvs + yysize - 1; michael@0: michael@0: YYDPRINTF ((stderr, "Stack size increased to %lu\n", michael@0: (unsigned long int) yystacksize)); michael@0: michael@0: if (yyss + yystacksize - 1 <= yyssp) michael@0: YYABORT; michael@0: } michael@0: michael@0: YYDPRINTF ((stderr, "Entering state %d\n", yystate)); michael@0: michael@0: if (yystate == YYFINAL) michael@0: YYACCEPT; michael@0: michael@0: goto yybackup; michael@0: michael@0: /*-----------. michael@0: | yybackup. | michael@0: `-----------*/ michael@0: yybackup: michael@0: michael@0: /* Do appropriate processing given the current state. Read a michael@0: lookahead token if we need one and don't already have one. */ michael@0: michael@0: /* First try to decide what to do without reference to lookahead token. */ michael@0: yyn = yypact[yystate]; michael@0: if (yypact_value_is_default (yyn)) michael@0: goto yydefault; michael@0: michael@0: /* Not known => get a lookahead token if don't already have one. */ michael@0: michael@0: /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ michael@0: if (yychar == YYEMPTY) michael@0: { michael@0: YYDPRINTF ((stderr, "Reading a token: ")); michael@0: yychar = YYLEX; michael@0: } michael@0: michael@0: if (yychar <= YYEOF) michael@0: { michael@0: yychar = yytoken = YYEOF; michael@0: YYDPRINTF ((stderr, "Now at end of input.\n")); michael@0: } michael@0: else michael@0: { michael@0: yytoken = YYTRANSLATE (yychar); michael@0: YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); michael@0: } michael@0: michael@0: /* If the proper action on seeing token YYTOKEN is to reduce or to michael@0: detect an error, take that action. */ michael@0: yyn += yytoken; michael@0: if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) michael@0: goto yydefault; michael@0: yyn = yytable[yyn]; michael@0: if (yyn <= 0) michael@0: { michael@0: if (yytable_value_is_error (yyn)) michael@0: goto yyerrlab; michael@0: yyn = -yyn; michael@0: goto yyreduce; michael@0: } michael@0: michael@0: /* Count tokens shifted since error; after three, turn off error michael@0: status. */ michael@0: if (yyerrstatus) michael@0: yyerrstatus--; michael@0: michael@0: /* Shift the lookahead token. */ michael@0: YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); michael@0: michael@0: /* Discard the shifted token. */ michael@0: yychar = YYEMPTY; michael@0: michael@0: yystate = yyn; michael@0: YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN michael@0: *++yyvsp = yylval; michael@0: YY_IGNORE_MAYBE_UNINITIALIZED_END michael@0: michael@0: goto yynewstate; michael@0: michael@0: michael@0: /*-----------------------------------------------------------. michael@0: | yydefault -- do the default action for the current state. | michael@0: `-----------------------------------------------------------*/ michael@0: yydefault: michael@0: yyn = yydefact[yystate]; michael@0: if (yyn == 0) michael@0: goto yyerrlab; michael@0: goto yyreduce; michael@0: michael@0: michael@0: /*-----------------------------. michael@0: | yyreduce -- Do a reduction. | michael@0: `-----------------------------*/ michael@0: yyreduce: michael@0: /* yyn is the number of a rule to reduce with. */ michael@0: yylen = yyr2[yyn]; michael@0: michael@0: /* If YYLEN is nonzero, implement the default value of the action: michael@0: `$$ = $1'. michael@0: michael@0: Otherwise, the following line sets YYVAL to garbage. michael@0: This behavior is undocumented and Bison michael@0: users should not rely upon it. Assigning to YYVAL michael@0: unconditionally makes the parser a bit smaller, and it avoids a michael@0: GCC warning that YYVAL may be used uninitialized. */ michael@0: yyval = yyvsp[1-yylen]; michael@0: michael@0: michael@0: YY_REDUCE_PRINT (yyn); michael@0: switch (yyn) michael@0: { michael@0: case 2: michael@0: michael@0: { michael@0: *(context->result) = static_cast((yyvsp[(1) - (1)])); michael@0: YYACCEPT; michael@0: } michael@0: break; michael@0: michael@0: case 4: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(1) - (3)]) || (yyvsp[(3) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: case 5: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(1) - (3)]) && (yyvsp[(3) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: case 6: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(1) - (3)]) | (yyvsp[(3) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: case 7: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(1) - (3)]) ^ (yyvsp[(3) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: case 8: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(1) - (3)]) & (yyvsp[(3) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: case 9: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(1) - (3)]) != (yyvsp[(3) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: case 10: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(1) - (3)]) == (yyvsp[(3) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: case 11: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(1) - (3)]) >= (yyvsp[(3) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: case 12: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(1) - (3)]) <= (yyvsp[(3) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: case 13: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(1) - (3)]) > (yyvsp[(3) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: case 14: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(1) - (3)]) < (yyvsp[(3) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: case 15: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(1) - (3)]) >> (yyvsp[(3) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: case 16: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(1) - (3)]) << (yyvsp[(3) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: case 17: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(1) - (3)]) - (yyvsp[(3) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: case 18: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(1) - (3)]) + (yyvsp[(3) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: case 19: michael@0: michael@0: { michael@0: if ((yyvsp[(3) - (3)]) == 0) { michael@0: std::ostringstream stream; michael@0: stream << (yyvsp[(1) - (3)]) << " % " << (yyvsp[(3) - (3)]); michael@0: std::string text = stream.str(); michael@0: context->diagnostics->report(pp::Diagnostics::DIVISION_BY_ZERO, michael@0: context->token->location, michael@0: text.c_str()); michael@0: YYABORT; michael@0: } else { michael@0: (yyval) = (yyvsp[(1) - (3)]) % (yyvsp[(3) - (3)]); michael@0: } michael@0: } michael@0: break; michael@0: michael@0: case 20: michael@0: michael@0: { michael@0: if ((yyvsp[(3) - (3)]) == 0) { michael@0: std::ostringstream stream; michael@0: stream << (yyvsp[(1) - (3)]) << " / " << (yyvsp[(3) - (3)]); michael@0: std::string text = stream.str(); michael@0: context->diagnostics->report(pp::Diagnostics::DIVISION_BY_ZERO, michael@0: context->token->location, michael@0: text.c_str()); michael@0: YYABORT; michael@0: } else { michael@0: (yyval) = (yyvsp[(1) - (3)]) / (yyvsp[(3) - (3)]); michael@0: } michael@0: } michael@0: break; michael@0: michael@0: case 21: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(1) - (3)]) * (yyvsp[(3) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: case 22: michael@0: michael@0: { michael@0: (yyval) = ! (yyvsp[(2) - (2)]); michael@0: } michael@0: break; michael@0: michael@0: case 23: michael@0: michael@0: { michael@0: (yyval) = ~ (yyvsp[(2) - (2)]); michael@0: } michael@0: break; michael@0: michael@0: case 24: michael@0: michael@0: { michael@0: (yyval) = - (yyvsp[(2) - (2)]); michael@0: } michael@0: break; michael@0: michael@0: case 25: michael@0: michael@0: { michael@0: (yyval) = + (yyvsp[(2) - (2)]); michael@0: } michael@0: break; michael@0: michael@0: case 26: michael@0: michael@0: { michael@0: (yyval) = (yyvsp[(2) - (3)]); michael@0: } michael@0: break; michael@0: michael@0: michael@0: michael@0: default: break; michael@0: } michael@0: /* User semantic actions sometimes alter yychar, and that requires michael@0: that yytoken be updated with the new translation. We take the michael@0: approach of translating immediately before every use of yytoken. michael@0: One alternative is translating here after every semantic action, michael@0: but that translation would be missed if the semantic action invokes michael@0: YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or michael@0: if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an michael@0: incorrect destructor might then be invoked immediately. In the michael@0: case of YYERROR or YYBACKUP, subsequent parser actions might lead michael@0: to an incorrect destructor call or verbose syntax error message michael@0: before the lookahead is translated. */ michael@0: YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); michael@0: michael@0: YYPOPSTACK (yylen); michael@0: yylen = 0; michael@0: YY_STACK_PRINT (yyss, yyssp); michael@0: michael@0: *++yyvsp = yyval; michael@0: michael@0: /* Now `shift' the result of the reduction. Determine what state michael@0: that goes to, based on the state we popped back to and the rule michael@0: number reduced by. */ michael@0: michael@0: yyn = yyr1[yyn]; michael@0: michael@0: yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; michael@0: if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) michael@0: yystate = yytable[yystate]; michael@0: else michael@0: yystate = yydefgoto[yyn - YYNTOKENS]; michael@0: michael@0: goto yynewstate; michael@0: michael@0: michael@0: /*------------------------------------. michael@0: | yyerrlab -- here on detecting error | michael@0: `------------------------------------*/ michael@0: yyerrlab: michael@0: /* Make sure we have latest lookahead translation. See comments at michael@0: user semantic actions for why this is necessary. */ michael@0: yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); michael@0: michael@0: /* If not already recovering from an error, report this error. */ michael@0: if (!yyerrstatus) michael@0: { michael@0: ++yynerrs; michael@0: #if ! YYERROR_VERBOSE michael@0: yyerror (context, YY_("syntax error")); michael@0: #else michael@0: # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ michael@0: yyssp, yytoken) michael@0: { michael@0: char const *yymsgp = YY_("syntax error"); michael@0: int yysyntax_error_status; michael@0: yysyntax_error_status = YYSYNTAX_ERROR; michael@0: if (yysyntax_error_status == 0) michael@0: yymsgp = yymsg; michael@0: else if (yysyntax_error_status == 1) michael@0: { michael@0: if (yymsg != yymsgbuf) michael@0: YYSTACK_FREE (yymsg); michael@0: yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); michael@0: if (!yymsg) michael@0: { michael@0: yymsg = yymsgbuf; michael@0: yymsg_alloc = sizeof yymsgbuf; michael@0: yysyntax_error_status = 2; michael@0: } michael@0: else michael@0: { michael@0: yysyntax_error_status = YYSYNTAX_ERROR; michael@0: yymsgp = yymsg; michael@0: } michael@0: } michael@0: yyerror (context, yymsgp); michael@0: if (yysyntax_error_status == 2) michael@0: goto yyexhaustedlab; michael@0: } michael@0: # undef YYSYNTAX_ERROR michael@0: #endif michael@0: } michael@0: michael@0: michael@0: michael@0: if (yyerrstatus == 3) michael@0: { michael@0: /* If just tried and failed to reuse lookahead token after an michael@0: error, discard it. */ michael@0: michael@0: if (yychar <= YYEOF) michael@0: { michael@0: /* Return failure if at end of input. */ michael@0: if (yychar == YYEOF) michael@0: YYABORT; michael@0: } michael@0: else michael@0: { michael@0: yydestruct ("Error: discarding", michael@0: yytoken, &yylval, context); michael@0: yychar = YYEMPTY; michael@0: } michael@0: } michael@0: michael@0: /* Else will try to reuse lookahead token after shifting the error michael@0: token. */ michael@0: goto yyerrlab1; michael@0: michael@0: michael@0: /*---------------------------------------------------. michael@0: | yyerrorlab -- error raised explicitly by YYERROR. | michael@0: `---------------------------------------------------*/ michael@0: yyerrorlab: michael@0: michael@0: /* Pacify compilers like GCC when the user code never invokes michael@0: YYERROR and the label yyerrorlab therefore never appears in user michael@0: code. */ michael@0: if (/*CONSTCOND*/ 0) michael@0: goto yyerrorlab; michael@0: michael@0: /* Do not reclaim the symbols of the rule which action triggered michael@0: this YYERROR. */ michael@0: YYPOPSTACK (yylen); michael@0: yylen = 0; michael@0: YY_STACK_PRINT (yyss, yyssp); michael@0: yystate = *yyssp; michael@0: goto yyerrlab1; michael@0: michael@0: michael@0: /*-------------------------------------------------------------. michael@0: | yyerrlab1 -- common code for both syntax error and YYERROR. | michael@0: `-------------------------------------------------------------*/ michael@0: yyerrlab1: michael@0: yyerrstatus = 3; /* Each real token shifted decrements this. */ michael@0: michael@0: for (;;) michael@0: { michael@0: yyn = yypact[yystate]; michael@0: if (!yypact_value_is_default (yyn)) michael@0: { michael@0: yyn += YYTERROR; michael@0: if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) michael@0: { michael@0: yyn = yytable[yyn]; michael@0: if (0 < yyn) michael@0: break; michael@0: } michael@0: } michael@0: michael@0: /* Pop the current state because it cannot handle the error token. */ michael@0: if (yyssp == yyss) michael@0: YYABORT; michael@0: michael@0: michael@0: yydestruct ("Error: popping", michael@0: yystos[yystate], yyvsp, context); michael@0: YYPOPSTACK (1); michael@0: yystate = *yyssp; michael@0: YY_STACK_PRINT (yyss, yyssp); michael@0: } michael@0: michael@0: YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN michael@0: *++yyvsp = yylval; michael@0: YY_IGNORE_MAYBE_UNINITIALIZED_END michael@0: michael@0: michael@0: /* Shift the error token. */ michael@0: YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); michael@0: michael@0: yystate = yyn; michael@0: goto yynewstate; michael@0: michael@0: michael@0: /*-------------------------------------. michael@0: | yyacceptlab -- YYACCEPT comes here. | michael@0: `-------------------------------------*/ michael@0: yyacceptlab: michael@0: yyresult = 0; michael@0: goto yyreturn; michael@0: michael@0: /*-----------------------------------. michael@0: | yyabortlab -- YYABORT comes here. | michael@0: `-----------------------------------*/ michael@0: yyabortlab: michael@0: yyresult = 1; michael@0: goto yyreturn; michael@0: michael@0: #if !defined yyoverflow || YYERROR_VERBOSE michael@0: /*-------------------------------------------------. michael@0: | yyexhaustedlab -- memory exhaustion comes here. | michael@0: `-------------------------------------------------*/ michael@0: yyexhaustedlab: michael@0: yyerror (context, YY_("memory exhausted")); michael@0: yyresult = 2; michael@0: /* Fall through. */ michael@0: #endif michael@0: michael@0: yyreturn: michael@0: if (yychar != YYEMPTY) michael@0: { michael@0: /* Make sure we have latest lookahead translation. See comments at michael@0: user semantic actions for why this is necessary. */ michael@0: yytoken = YYTRANSLATE (yychar); michael@0: yydestruct ("Cleanup: discarding lookahead", michael@0: yytoken, &yylval, context); michael@0: } michael@0: /* Do not reclaim the symbols of the rule which action triggered michael@0: this YYABORT or YYACCEPT. */ michael@0: YYPOPSTACK (yylen); michael@0: YY_STACK_PRINT (yyss, yyssp); michael@0: while (yyssp != yyss) michael@0: { michael@0: yydestruct ("Cleanup: popping", michael@0: yystos[*yyssp], yyvsp, context); michael@0: YYPOPSTACK (1); michael@0: } michael@0: #ifndef yyoverflow michael@0: if (yyss != yyssa) michael@0: YYSTACK_FREE (yyss); michael@0: #endif michael@0: #if YYERROR_VERBOSE michael@0: if (yymsg != yymsgbuf) michael@0: YYSTACK_FREE (yymsg); michael@0: #endif michael@0: /* Make sure YYID is used. */ michael@0: return YYID (yyresult); michael@0: } michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: int yylex(YYSTYPE* lvalp, Context* context) michael@0: { michael@0: int type = 0; michael@0: michael@0: pp::Token* token = context->token; michael@0: switch (token->type) michael@0: { michael@0: case pp::Token::CONST_INT: michael@0: { michael@0: unsigned int val = 0; michael@0: if (!token->uValue(&val)) michael@0: { michael@0: context->diagnostics->report(pp::Diagnostics::INTEGER_OVERFLOW, michael@0: token->location, token->text); michael@0: } michael@0: *lvalp = static_cast(val); michael@0: type = TOK_CONST_INT; michael@0: break; michael@0: } michael@0: case pp::Token::OP_OR: type = TOK_OP_OR; break; michael@0: case pp::Token::OP_AND: type = TOK_OP_AND; break; michael@0: case pp::Token::OP_NE: type = TOK_OP_NE; break; michael@0: case pp::Token::OP_EQ: type = TOK_OP_EQ; break; michael@0: case pp::Token::OP_GE: type = TOK_OP_GE; break; michael@0: case pp::Token::OP_LE: type = TOK_OP_LE; break; michael@0: case pp::Token::OP_RIGHT: type = TOK_OP_RIGHT; break; michael@0: case pp::Token::OP_LEFT: type = TOK_OP_LEFT; break; michael@0: case '|': type = '|'; break; michael@0: case '^': type = '^'; break; michael@0: case '&': type = '&'; break; michael@0: case '>': type = '>'; break; michael@0: case '<': type = '<'; break; michael@0: case '-': type = '-'; break; michael@0: case '+': type = '+'; break; michael@0: case '%': type = '%'; break; michael@0: case '/': type = '/'; break; michael@0: case '*': type = '*'; break; michael@0: case '!': type = '!'; break; michael@0: case '~': type = '~'; break; michael@0: case '(': type = '('; break; michael@0: case ')': type = ')'; break; michael@0: michael@0: default: break; michael@0: } michael@0: michael@0: // Advance to the next token if the current one is valid. michael@0: if (type != 0) context->lexer->lex(token); michael@0: michael@0: return type; michael@0: } michael@0: michael@0: void yyerror(Context* context, const char* reason) michael@0: { michael@0: context->diagnostics->report(pp::Diagnostics::INVALID_EXPRESSION, michael@0: context->token->location, michael@0: reason); michael@0: } michael@0: michael@0: namespace pp { michael@0: michael@0: ExpressionParser::ExpressionParser(Lexer* lexer, Diagnostics* diagnostics) : michael@0: mLexer(lexer), michael@0: mDiagnostics(diagnostics) michael@0: { michael@0: } michael@0: michael@0: bool ExpressionParser::parse(Token* token, int* result) michael@0: { michael@0: Context context; michael@0: context.diagnostics = mDiagnostics; michael@0: context.lexer = mLexer; michael@0: context.token = token; michael@0: context.result = result; michael@0: int ret = yyparse(&context); michael@0: switch (ret) michael@0: { michael@0: case 0: michael@0: case 1: michael@0: break; michael@0: michael@0: case 2: michael@0: mDiagnostics->report(Diagnostics::OUT_OF_MEMORY, token->location, ""); michael@0: break; michael@0: michael@0: default: michael@0: assert(false); michael@0: mDiagnostics->report(Diagnostics::INTERNAL_ERROR, token->location, ""); michael@0: break; michael@0: } michael@0: michael@0: return ret == 0; michael@0: } michael@0: michael@0: } // namespace pp