gfx/angle/src/compiler/preprocessor/ExpressionParser.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/angle/src/compiler/preprocessor/ExpressionParser.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,1981 @@
     1.4 +/* A Bison parser, made by GNU Bison 2.7.  */
     1.5 +
     1.6 +/* Bison implementation for Yacc-like parsers in C
     1.7 +   
     1.8 +      Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
     1.9 +   
    1.10 +   This program is free software: you can redistribute it and/or modify
    1.11 +   it under the terms of the GNU General Public License as published by
    1.12 +   the Free Software Foundation, either version 3 of the License, or
    1.13 +   (at your option) any later version.
    1.14 +   
    1.15 +   This program is distributed in the hope that it will be useful,
    1.16 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.17 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.18 +   GNU General Public License for more details.
    1.19 +   
    1.20 +   You should have received a copy of the GNU General Public License
    1.21 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1.22 +
    1.23 +/* As a special exception, you may create a larger work that contains
    1.24 +   part or all of the Bison parser skeleton and distribute that work
    1.25 +   under terms of your choice, so long as that work isn't itself a
    1.26 +   parser generator using the skeleton or a modified version thereof
    1.27 +   as a parser skeleton.  Alternatively, if you modify or redistribute
    1.28 +   the parser skeleton itself, you may (at your option) remove this
    1.29 +   special exception, which will cause the skeleton and the resulting
    1.30 +   Bison output files to be licensed under the GNU General Public
    1.31 +   License without this special exception.
    1.32 +   
    1.33 +   This special exception was added by the Free Software Foundation in
    1.34 +   version 2.2 of Bison.  */
    1.35 +
    1.36 +/* C LALR(1) parser skeleton written by Richard Stallman, by
    1.37 +   simplifying the original so-called "semantic" parser.  */
    1.38 +
    1.39 +/* All symbols defined below should begin with yy or YY, to avoid
    1.40 +   infringing on user name space.  This should be done even for local
    1.41 +   variables, as they might otherwise be expanded by user macros.
    1.42 +   There are some unavoidable exceptions within include files to
    1.43 +   define necessary library symbols; they are noted "INFRINGES ON
    1.44 +   USER NAME SPACE" below.  */
    1.45 +
    1.46 +/* Identify Bison output.  */
    1.47 +#define YYBISON 1
    1.48 +
    1.49 +/* Bison version.  */
    1.50 +#define YYBISON_VERSION "2.7"
    1.51 +
    1.52 +/* Skeleton name.  */
    1.53 +#define YYSKELETON_NAME "yacc.c"
    1.54 +
    1.55 +/* Pure parsers.  */
    1.56 +#define YYPURE 1
    1.57 +
    1.58 +/* Push parsers.  */
    1.59 +#define YYPUSH 0
    1.60 +
    1.61 +/* Pull parsers.  */
    1.62 +#define YYPULL 1
    1.63 +
    1.64 +
    1.65 +/* Substitute the variable and function names.  */
    1.66 +#define yyparse         ppparse
    1.67 +#define yylex           pplex
    1.68 +#define yyerror         pperror
    1.69 +#define yylval          pplval
    1.70 +#define yychar          ppchar
    1.71 +#define yydebug         ppdebug
    1.72 +#define yynerrs         ppnerrs
    1.73 +
    1.74 +/* Copy the first part of user declarations.  */
    1.75 +
    1.76 +
    1.77 +//
    1.78 +// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
    1.79 +// Use of this source code is governed by a BSD-style license that can be
    1.80 +// found in the LICENSE file.
    1.81 +//
    1.82 +
    1.83 +// This file is auto-generated by generate_parser.sh. DO NOT EDIT!
    1.84 +
    1.85 +#if defined(__GNUC__)
    1.86 +// Triggered by the auto-generated pplval variable.
    1.87 +#if !defined(__clang__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
    1.88 +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
    1.89 +#else
    1.90 +#pragma GCC diagnostic ignored "-Wuninitialized"
    1.91 +#endif
    1.92 +#elif defined(_MSC_VER)
    1.93 +#pragma warning(disable: 4065 4701)
    1.94 +#endif
    1.95 +
    1.96 +#include "ExpressionParser.h"
    1.97 +
    1.98 +#include <cassert>
    1.99 +#include <sstream>
   1.100 +
   1.101 +#include "DiagnosticsBase.h"
   1.102 +#include "Lexer.h"
   1.103 +#include "Token.h"
   1.104 +
   1.105 +#if defined(_MSC_VER)
   1.106 +typedef __int64 YYSTYPE;
   1.107 +#else
   1.108 +#include <stdint.h>
   1.109 +typedef intmax_t YYSTYPE;
   1.110 +#endif  // _MSC_VER
   1.111 +#define YYENABLE_NLS 0
   1.112 +#define YYLTYPE_IS_TRIVIAL 1
   1.113 +#define YYSTYPE_IS_TRIVIAL 1
   1.114 +#define YYSTYPE_IS_DECLARED 1
   1.115 +
   1.116 +namespace {
   1.117 +struct Context
   1.118 +{
   1.119 +    pp::Diagnostics* diagnostics;
   1.120 +    pp::Lexer* lexer;
   1.121 +    pp::Token* token;
   1.122 +    int* result;
   1.123 +};
   1.124 +}  // namespace
   1.125 +
   1.126 +
   1.127 +static int yylex(YYSTYPE* lvalp, Context* context);
   1.128 +static void yyerror(Context* context, const char* reason);
   1.129 +
   1.130 +
   1.131 +
   1.132 +# ifndef YY_NULL
   1.133 +#  if defined __cplusplus && 201103L <= __cplusplus
   1.134 +#   define YY_NULL nullptr
   1.135 +#  else
   1.136 +#   define YY_NULL 0
   1.137 +#  endif
   1.138 +# endif
   1.139 +
   1.140 +/* Enabling verbose error messages.  */
   1.141 +#ifdef YYERROR_VERBOSE
   1.142 +# undef YYERROR_VERBOSE
   1.143 +# define YYERROR_VERBOSE 1
   1.144 +#else
   1.145 +# define YYERROR_VERBOSE 0
   1.146 +#endif
   1.147 +
   1.148 +
   1.149 +/* Enabling traces.  */
   1.150 +#ifndef YYDEBUG
   1.151 +# define YYDEBUG 0
   1.152 +#endif
   1.153 +#if YYDEBUG
   1.154 +extern int ppdebug;
   1.155 +#endif
   1.156 +
   1.157 +/* Tokens.  */
   1.158 +#ifndef YYTOKENTYPE
   1.159 +# define YYTOKENTYPE
   1.160 +   /* Put the tokens into the symbol table, so that GDB and other debuggers
   1.161 +      know about them.  */
   1.162 +   enum yytokentype {
   1.163 +     TOK_CONST_INT = 258,
   1.164 +     TOK_OP_OR = 259,
   1.165 +     TOK_OP_AND = 260,
   1.166 +     TOK_OP_NE = 261,
   1.167 +     TOK_OP_EQ = 262,
   1.168 +     TOK_OP_GE = 263,
   1.169 +     TOK_OP_LE = 264,
   1.170 +     TOK_OP_RIGHT = 265,
   1.171 +     TOK_OP_LEFT = 266,
   1.172 +     TOK_UNARY = 267
   1.173 +   };
   1.174 +#endif
   1.175 +
   1.176 +
   1.177 +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
   1.178 +typedef int YYSTYPE;
   1.179 +# define YYSTYPE_IS_TRIVIAL 1
   1.180 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */
   1.181 +# define YYSTYPE_IS_DECLARED 1
   1.182 +#endif
   1.183 +
   1.184 +
   1.185 +#ifdef YYPARSE_PARAM
   1.186 +#if defined __STDC__ || defined __cplusplus
   1.187 +int ppparse (void *YYPARSE_PARAM);
   1.188 +#else
   1.189 +int ppparse ();
   1.190 +#endif
   1.191 +#else /* ! YYPARSE_PARAM */
   1.192 +#if defined __STDC__ || defined __cplusplus
   1.193 +int ppparse (Context *context);
   1.194 +#else
   1.195 +int ppparse ();
   1.196 +#endif
   1.197 +#endif /* ! YYPARSE_PARAM */
   1.198 +
   1.199 +
   1.200 +
   1.201 +/* Copy the second part of user declarations.  */
   1.202 +
   1.203 +
   1.204 +
   1.205 +#ifdef short
   1.206 +# undef short
   1.207 +#endif
   1.208 +
   1.209 +#ifdef YYTYPE_UINT8
   1.210 +typedef YYTYPE_UINT8 yytype_uint8;
   1.211 +#else
   1.212 +typedef unsigned char yytype_uint8;
   1.213 +#endif
   1.214 +
   1.215 +#ifdef YYTYPE_INT8
   1.216 +typedef YYTYPE_INT8 yytype_int8;
   1.217 +#elif (defined __STDC__ || defined __C99__FUNC__ \
   1.218 +     || defined __cplusplus || defined _MSC_VER)
   1.219 +typedef signed char yytype_int8;
   1.220 +#else
   1.221 +typedef short int yytype_int8;
   1.222 +#endif
   1.223 +
   1.224 +#ifdef YYTYPE_UINT16
   1.225 +typedef YYTYPE_UINT16 yytype_uint16;
   1.226 +#else
   1.227 +typedef unsigned short int yytype_uint16;
   1.228 +#endif
   1.229 +
   1.230 +#ifdef YYTYPE_INT16
   1.231 +typedef YYTYPE_INT16 yytype_int16;
   1.232 +#else
   1.233 +typedef short int yytype_int16;
   1.234 +#endif
   1.235 +
   1.236 +#ifndef YYSIZE_T
   1.237 +# ifdef __SIZE_TYPE__
   1.238 +#  define YYSIZE_T __SIZE_TYPE__
   1.239 +# elif defined size_t
   1.240 +#  define YYSIZE_T size_t
   1.241 +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
   1.242 +     || defined __cplusplus || defined _MSC_VER)
   1.243 +#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
   1.244 +#  define YYSIZE_T size_t
   1.245 +# else
   1.246 +#  define YYSIZE_T unsigned int
   1.247 +# endif
   1.248 +#endif
   1.249 +
   1.250 +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
   1.251 +
   1.252 +#ifndef YY_
   1.253 +# if defined YYENABLE_NLS && YYENABLE_NLS
   1.254 +#  if ENABLE_NLS
   1.255 +#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
   1.256 +#   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
   1.257 +#  endif
   1.258 +# endif
   1.259 +# ifndef YY_
   1.260 +#  define YY_(Msgid) Msgid
   1.261 +# endif
   1.262 +#endif
   1.263 +
   1.264 +/* Suppress unused-variable warnings by "using" E.  */
   1.265 +#if ! defined lint || defined __GNUC__
   1.266 +# define YYUSE(E) ((void) (E))
   1.267 +#else
   1.268 +# define YYUSE(E) /* empty */
   1.269 +#endif
   1.270 +
   1.271 +/* Identity function, used to suppress warnings about constant conditions.  */
   1.272 +#ifndef lint
   1.273 +# define YYID(N) (N)
   1.274 +#else
   1.275 +#if (defined __STDC__ || defined __C99__FUNC__ \
   1.276 +     || defined __cplusplus || defined _MSC_VER)
   1.277 +static int
   1.278 +YYID (int yyi)
   1.279 +#else
   1.280 +static int
   1.281 +YYID (yyi)
   1.282 +    int yyi;
   1.283 +#endif
   1.284 +{
   1.285 +  return yyi;
   1.286 +}
   1.287 +#endif
   1.288 +
   1.289 +#if ! defined yyoverflow || YYERROR_VERBOSE
   1.290 +
   1.291 +/* The parser invokes alloca or malloc; define the necessary symbols.  */
   1.292 +
   1.293 +# ifdef YYSTACK_USE_ALLOCA
   1.294 +#  if YYSTACK_USE_ALLOCA
   1.295 +#   ifdef __GNUC__
   1.296 +#    define YYSTACK_ALLOC __builtin_alloca
   1.297 +#   elif defined __BUILTIN_VA_ARG_INCR
   1.298 +#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
   1.299 +#   elif defined _AIX
   1.300 +#    define YYSTACK_ALLOC __alloca
   1.301 +#   elif defined _MSC_VER
   1.302 +#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
   1.303 +#    define alloca _alloca
   1.304 +#   else
   1.305 +#    define YYSTACK_ALLOC alloca
   1.306 +#    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
   1.307 +     || defined __cplusplus || defined _MSC_VER)
   1.308 +#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
   1.309 +      /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
   1.310 +#     ifndef EXIT_SUCCESS
   1.311 +#      define EXIT_SUCCESS 0
   1.312 +#     endif
   1.313 +#    endif
   1.314 +#   endif
   1.315 +#  endif
   1.316 +# endif
   1.317 +
   1.318 +# ifdef YYSTACK_ALLOC
   1.319 +   /* Pacify GCC's `empty if-body' warning.  */
   1.320 +#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
   1.321 +#  ifndef YYSTACK_ALLOC_MAXIMUM
   1.322 +    /* The OS might guarantee only one guard page at the bottom of the stack,
   1.323 +       and a page size can be as small as 4096 bytes.  So we cannot safely
   1.324 +       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
   1.325 +       to allow for a few compiler-allocated temporary stack slots.  */
   1.326 +#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
   1.327 +#  endif
   1.328 +# else
   1.329 +#  define YYSTACK_ALLOC YYMALLOC
   1.330 +#  define YYSTACK_FREE YYFREE
   1.331 +#  ifndef YYSTACK_ALLOC_MAXIMUM
   1.332 +#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
   1.333 +#  endif
   1.334 +#  if (defined __cplusplus && ! defined EXIT_SUCCESS \
   1.335 +       && ! ((defined YYMALLOC || defined malloc) \
   1.336 +	     && (defined YYFREE || defined free)))
   1.337 +#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
   1.338 +#   ifndef EXIT_SUCCESS
   1.339 +#    define EXIT_SUCCESS 0
   1.340 +#   endif
   1.341 +#  endif
   1.342 +#  ifndef YYMALLOC
   1.343 +#   define YYMALLOC malloc
   1.344 +#   if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
   1.345 +     || defined __cplusplus || defined _MSC_VER)
   1.346 +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
   1.347 +#   endif
   1.348 +#  endif
   1.349 +#  ifndef YYFREE
   1.350 +#   define YYFREE free
   1.351 +#   if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
   1.352 +     || defined __cplusplus || defined _MSC_VER)
   1.353 +void free (void *); /* INFRINGES ON USER NAME SPACE */
   1.354 +#   endif
   1.355 +#  endif
   1.356 +# endif
   1.357 +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
   1.358 +
   1.359 +
   1.360 +#if (! defined yyoverflow \
   1.361 +     && (! defined __cplusplus \
   1.362 +	 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
   1.363 +
   1.364 +/* A type that is properly aligned for any stack member.  */
   1.365 +union yyalloc
   1.366 +{
   1.367 +  yytype_int16 yyss_alloc;
   1.368 +  YYSTYPE yyvs_alloc;
   1.369 +};
   1.370 +
   1.371 +/* The size of the maximum gap between one aligned stack and the next.  */
   1.372 +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
   1.373 +
   1.374 +/* The size of an array large to enough to hold all stacks, each with
   1.375 +   N elements.  */
   1.376 +# define YYSTACK_BYTES(N) \
   1.377 +     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
   1.378 +      + YYSTACK_GAP_MAXIMUM)
   1.379 +
   1.380 +# define YYCOPY_NEEDED 1
   1.381 +
   1.382 +/* Relocate STACK from its old location to the new one.  The
   1.383 +   local variables YYSIZE and YYSTACKSIZE give the old and new number of
   1.384 +   elements in the stack, and YYPTR gives the new location of the
   1.385 +   stack.  Advance YYPTR to a properly aligned location for the next
   1.386 +   stack.  */
   1.387 +# define YYSTACK_RELOCATE(Stack_alloc, Stack)				\
   1.388 +    do									\
   1.389 +      {									\
   1.390 +	YYSIZE_T yynewbytes;						\
   1.391 +	YYCOPY (&yyptr->Stack_alloc, Stack, yysize);			\
   1.392 +	Stack = &yyptr->Stack_alloc;					\
   1.393 +	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
   1.394 +	yyptr += yynewbytes / sizeof (*yyptr);				\
   1.395 +      }									\
   1.396 +    while (YYID (0))
   1.397 +
   1.398 +#endif
   1.399 +
   1.400 +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
   1.401 +/* Copy COUNT objects from SRC to DST.  The source and destination do
   1.402 +   not overlap.  */
   1.403 +# ifndef YYCOPY
   1.404 +#  if defined __GNUC__ && 1 < __GNUC__
   1.405 +#   define YYCOPY(Dst, Src, Count) \
   1.406 +      __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
   1.407 +#  else
   1.408 +#   define YYCOPY(Dst, Src, Count)              \
   1.409 +      do                                        \
   1.410 +        {                                       \
   1.411 +          YYSIZE_T yyi;                         \
   1.412 +          for (yyi = 0; yyi < (Count); yyi++)   \
   1.413 +            (Dst)[yyi] = (Src)[yyi];            \
   1.414 +        }                                       \
   1.415 +      while (YYID (0))
   1.416 +#  endif
   1.417 +# endif
   1.418 +#endif /* !YYCOPY_NEEDED */
   1.419 +
   1.420 +/* YYFINAL -- State number of the termination state.  */
   1.421 +#define YYFINAL  14
   1.422 +/* YYLAST -- Last index in YYTABLE.  */
   1.423 +#define YYLAST   175
   1.424 +
   1.425 +/* YYNTOKENS -- Number of terminals.  */
   1.426 +#define YYNTOKENS  27
   1.427 +/* YYNNTS -- Number of nonterminals.  */
   1.428 +#define YYNNTS  3
   1.429 +/* YYNRULES -- Number of rules.  */
   1.430 +#define YYNRULES  26
   1.431 +/* YYNRULES -- Number of states.  */
   1.432 +#define YYNSTATES  52
   1.433 +
   1.434 +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
   1.435 +#define YYUNDEFTOK  2
   1.436 +#define YYMAXUTOK   267
   1.437 +
   1.438 +#define YYTRANSLATE(YYX)						\
   1.439 +  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
   1.440 +
   1.441 +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
   1.442 +static const yytype_uint8 yytranslate[] =
   1.443 +{
   1.444 +       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.445 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.446 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.447 +       2,     2,     2,    23,     2,     2,     2,    21,     8,     2,
   1.448 +      25,    26,    19,    17,     2,    18,     2,    20,     2,     2,
   1.449 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.450 +      11,     2,    12,     2,     2,     2,     2,     2,     2,     2,
   1.451 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.452 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.453 +       2,     2,     2,     2,     7,     2,     2,     2,     2,     2,
   1.454 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.455 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.456 +       2,     2,     2,     2,     6,     2,    24,     2,     2,     2,
   1.457 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.458 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.459 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.460 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.461 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.462 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.463 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.464 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.465 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.466 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.467 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.468 +       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
   1.469 +       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
   1.470 +       5,     9,    10,    13,    14,    15,    16,    22
   1.471 +};
   1.472 +
   1.473 +#if YYDEBUG
   1.474 +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
   1.475 +   YYRHS.  */
   1.476 +static const yytype_uint8 yyprhs[] =
   1.477 +{
   1.478 +       0,     0,     3,     5,     7,    11,    15,    19,    23,    27,
   1.479 +      31,    35,    39,    43,    47,    51,    55,    59,    63,    67,
   1.480 +      71,    75,    79,    82,    85,    88,    91
   1.481 +};
   1.482 +
   1.483 +/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
   1.484 +static const yytype_int8 yyrhs[] =
   1.485 +{
   1.486 +      28,     0,    -1,    29,    -1,     3,    -1,    29,     4,    29,
   1.487 +      -1,    29,     5,    29,    -1,    29,     6,    29,    -1,    29,
   1.488 +       7,    29,    -1,    29,     8,    29,    -1,    29,     9,    29,
   1.489 +      -1,    29,    10,    29,    -1,    29,    13,    29,    -1,    29,
   1.490 +      14,    29,    -1,    29,    12,    29,    -1,    29,    11,    29,
   1.491 +      -1,    29,    15,    29,    -1,    29,    16,    29,    -1,    29,
   1.492 +      18,    29,    -1,    29,    17,    29,    -1,    29,    21,    29,
   1.493 +      -1,    29,    20,    29,    -1,    29,    19,    29,    -1,    23,
   1.494 +      29,    -1,    24,    29,    -1,    18,    29,    -1,    17,    29,
   1.495 +      -1,    25,    29,    26,    -1
   1.496 +};
   1.497 +
   1.498 +/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
   1.499 +static const yytype_uint8 yyrline[] =
   1.500 +{
   1.501 +       0,    91,    91,    98,    99,   102,   105,   108,   111,   114,
   1.502 +     117,   120,   123,   126,   129,   132,   135,   138,   141,   144,
   1.503 +     157,   170,   173,   176,   179,   182,   185
   1.504 +};
   1.505 +#endif
   1.506 +
   1.507 +#if YYDEBUG || YYERROR_VERBOSE || 0
   1.508 +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
   1.509 +   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
   1.510 +static const char *const yytname[] =
   1.511 +{
   1.512 +  "$end", "error", "$undefined", "TOK_CONST_INT", "TOK_OP_OR",
   1.513 +  "TOK_OP_AND", "'|'", "'^'", "'&'", "TOK_OP_NE", "TOK_OP_EQ", "'<'",
   1.514 +  "'>'", "TOK_OP_GE", "TOK_OP_LE", "TOK_OP_RIGHT", "TOK_OP_LEFT", "'+'",
   1.515 +  "'-'", "'*'", "'/'", "'%'", "TOK_UNARY", "'!'", "'~'", "'('", "')'",
   1.516 +  "$accept", "input", "expression", YY_NULL
   1.517 +};
   1.518 +#endif
   1.519 +
   1.520 +# ifdef YYPRINT
   1.521 +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
   1.522 +   token YYLEX-NUM.  */
   1.523 +static const yytype_uint16 yytoknum[] =
   1.524 +{
   1.525 +       0,   256,   257,   258,   259,   260,   124,    94,    38,   261,
   1.526 +     262,    60,    62,   263,   264,   265,   266,    43,    45,    42,
   1.527 +      47,    37,   267,    33,   126,    40,    41
   1.528 +};
   1.529 +# endif
   1.530 +
   1.531 +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
   1.532 +static const yytype_uint8 yyr1[] =
   1.533 +{
   1.534 +       0,    27,    28,    29,    29,    29,    29,    29,    29,    29,
   1.535 +      29,    29,    29,    29,    29,    29,    29,    29,    29,    29,
   1.536 +      29,    29,    29,    29,    29,    29,    29
   1.537 +};
   1.538 +
   1.539 +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
   1.540 +static const yytype_uint8 yyr2[] =
   1.541 +{
   1.542 +       0,     2,     1,     1,     3,     3,     3,     3,     3,     3,
   1.543 +       3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
   1.544 +       3,     3,     2,     2,     2,     2,     3
   1.545 +};
   1.546 +
   1.547 +/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
   1.548 +   Performed when YYTABLE doesn't specify something else to do.  Zero
   1.549 +   means the default is an error.  */
   1.550 +static const yytype_uint8 yydefact[] =
   1.551 +{
   1.552 +       0,     3,     0,     0,     0,     0,     0,     0,     2,    25,
   1.553 +      24,    22,    23,     0,     1,     0,     0,     0,     0,     0,
   1.554 +       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
   1.555 +       0,     0,     0,    26,     4,     5,     6,     7,     8,     9,
   1.556 +      10,    14,    13,    11,    12,    15,    16,    18,    17,    21,
   1.557 +      20,    19
   1.558 +};
   1.559 +
   1.560 +/* YYDEFGOTO[NTERM-NUM].  */
   1.561 +static const yytype_int8 yydefgoto[] =
   1.562 +{
   1.563 +      -1,     7,     8
   1.564 +};
   1.565 +
   1.566 +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
   1.567 +   STATE-NUM.  */
   1.568 +#define YYPACT_NINF -11
   1.569 +static const yytype_int16 yypact[] =
   1.570 +{
   1.571 +      46,   -11,    46,    46,    46,    46,    46,    12,    68,   -11,
   1.572 +     -11,   -11,   -11,    27,   -11,    46,    46,    46,    46,    46,
   1.573 +      46,    46,    46,    46,    46,    46,    46,    46,    46,    46,
   1.574 +      46,    46,    46,   -11,    85,   101,   116,   130,   143,   154,
   1.575 +     154,   -10,   -10,   -10,   -10,    37,    37,    31,    31,   -11,
   1.576 +     -11,   -11
   1.577 +};
   1.578 +
   1.579 +/* YYPGOTO[NTERM-NUM].  */
   1.580 +static const yytype_int8 yypgoto[] =
   1.581 +{
   1.582 +     -11,   -11,    -2
   1.583 +};
   1.584 +
   1.585 +/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
   1.586 +   positive, shift that token.  If negative, reduce the rule which
   1.587 +   number is the opposite.  If YYTABLE_NINF, syntax error.  */
   1.588 +#define YYTABLE_NINF -1
   1.589 +static const yytype_uint8 yytable[] =
   1.590 +{
   1.591 +       9,    10,    11,    12,    13,    26,    27,    28,    29,    30,
   1.592 +      31,    32,    14,    34,    35,    36,    37,    38,    39,    40,
   1.593 +      41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
   1.594 +      51,    15,    16,    17,    18,    19,    20,    21,    22,    23,
   1.595 +      24,    25,    26,    27,    28,    29,    30,    31,    32,     1,
   1.596 +      30,    31,    32,    33,    28,    29,    30,    31,    32,     0,
   1.597 +       0,     0,     0,     2,     3,     0,     0,     0,     0,     4,
   1.598 +       5,     6,    15,    16,    17,    18,    19,    20,    21,    22,
   1.599 +      23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
   1.600 +      16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
   1.601 +      26,    27,    28,    29,    30,    31,    32,    17,    18,    19,
   1.602 +      20,    21,    22,    23,    24,    25,    26,    27,    28,    29,
   1.603 +      30,    31,    32,    18,    19,    20,    21,    22,    23,    24,
   1.604 +      25,    26,    27,    28,    29,    30,    31,    32,    19,    20,
   1.605 +      21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
   1.606 +      31,    32,    20,    21,    22,    23,    24,    25,    26,    27,
   1.607 +      28,    29,    30,    31,    32,    22,    23,    24,    25,    26,
   1.608 +      27,    28,    29,    30,    31,    32
   1.609 +};
   1.610 +
   1.611 +#define yypact_value_is_default(Yystate) \
   1.612 +  (!!((Yystate) == (-11)))
   1.613 +
   1.614 +#define yytable_value_is_error(Yytable_value) \
   1.615 +  YYID (0)
   1.616 +
   1.617 +static const yytype_int8 yycheck[] =
   1.618 +{
   1.619 +       2,     3,     4,     5,     6,    15,    16,    17,    18,    19,
   1.620 +      20,    21,     0,    15,    16,    17,    18,    19,    20,    21,
   1.621 +      22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
   1.622 +      32,     4,     5,     6,     7,     8,     9,    10,    11,    12,
   1.623 +      13,    14,    15,    16,    17,    18,    19,    20,    21,     3,
   1.624 +      19,    20,    21,    26,    17,    18,    19,    20,    21,    -1,
   1.625 +      -1,    -1,    -1,    17,    18,    -1,    -1,    -1,    -1,    23,
   1.626 +      24,    25,     4,     5,     6,     7,     8,     9,    10,    11,
   1.627 +      12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
   1.628 +       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
   1.629 +      15,    16,    17,    18,    19,    20,    21,     6,     7,     8,
   1.630 +       9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
   1.631 +      19,    20,    21,     7,     8,     9,    10,    11,    12,    13,
   1.632 +      14,    15,    16,    17,    18,    19,    20,    21,     8,     9,
   1.633 +      10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
   1.634 +      20,    21,     9,    10,    11,    12,    13,    14,    15,    16,
   1.635 +      17,    18,    19,    20,    21,    11,    12,    13,    14,    15,
   1.636 +      16,    17,    18,    19,    20,    21
   1.637 +};
   1.638 +
   1.639 +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
   1.640 +   symbol of state STATE-NUM.  */
   1.641 +static const yytype_uint8 yystos[] =
   1.642 +{
   1.643 +       0,     3,    17,    18,    23,    24,    25,    28,    29,    29,
   1.644 +      29,    29,    29,    29,     0,     4,     5,     6,     7,     8,
   1.645 +       9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
   1.646 +      19,    20,    21,    26,    29,    29,    29,    29,    29,    29,
   1.647 +      29,    29,    29,    29,    29,    29,    29,    29,    29,    29,
   1.648 +      29,    29
   1.649 +};
   1.650 +
   1.651 +#define yyerrok		(yyerrstatus = 0)
   1.652 +#define yyclearin	(yychar = YYEMPTY)
   1.653 +#define YYEMPTY		(-2)
   1.654 +#define YYEOF		0
   1.655 +
   1.656 +#define YYACCEPT	goto yyacceptlab
   1.657 +#define YYABORT		goto yyabortlab
   1.658 +#define YYERROR		goto yyerrorlab
   1.659 +
   1.660 +
   1.661 +/* Like YYERROR except do call yyerror.  This remains here temporarily
   1.662 +   to ease the transition to the new meaning of YYERROR, for GCC.
   1.663 +   Once GCC version 2 has supplanted version 1, this can go.  However,
   1.664 +   YYFAIL appears to be in use.  Nevertheless, it is formally deprecated
   1.665 +   in Bison 2.4.2's NEWS entry, where a plan to phase it out is
   1.666 +   discussed.  */
   1.667 +
   1.668 +#define YYFAIL		goto yyerrlab
   1.669 +#if defined YYFAIL
   1.670 +  /* This is here to suppress warnings from the GCC cpp's
   1.671 +     -Wunused-macros.  Normally we don't worry about that warning, but
   1.672 +     some users do, and we want to make it easy for users to remove
   1.673 +     YYFAIL uses, which will produce warnings from Bison 2.5.  */
   1.674 +#endif
   1.675 +
   1.676 +#define YYRECOVERING()  (!!yyerrstatus)
   1.677 +
   1.678 +#define YYBACKUP(Token, Value)                                  \
   1.679 +do                                                              \
   1.680 +  if (yychar == YYEMPTY)                                        \
   1.681 +    {                                                           \
   1.682 +      yychar = (Token);                                         \
   1.683 +      yylval = (Value);                                         \
   1.684 +      YYPOPSTACK (yylen);                                       \
   1.685 +      yystate = *yyssp;                                         \
   1.686 +      goto yybackup;                                            \
   1.687 +    }                                                           \
   1.688 +  else                                                          \
   1.689 +    {                                                           \
   1.690 +      yyerror (context, YY_("syntax error: cannot back up")); \
   1.691 +      YYERROR;							\
   1.692 +    }								\
   1.693 +while (YYID (0))
   1.694 +
   1.695 +/* Error token number */
   1.696 +#define YYTERROR	1
   1.697 +#define YYERRCODE	256
   1.698 +
   1.699 +
   1.700 +/* This macro is provided for backward compatibility. */
   1.701 +#ifndef YY_LOCATION_PRINT
   1.702 +# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
   1.703 +#endif
   1.704 +
   1.705 +
   1.706 +/* YYLEX -- calling `yylex' with the right arguments.  */
   1.707 +#ifdef YYLEX_PARAM
   1.708 +# define YYLEX yylex (&yylval, YYLEX_PARAM)
   1.709 +#else
   1.710 +# define YYLEX yylex (&yylval, context)
   1.711 +#endif
   1.712 +
   1.713 +/* Enable debugging if requested.  */
   1.714 +#if YYDEBUG
   1.715 +
   1.716 +# ifndef YYFPRINTF
   1.717 +#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
   1.718 +#  define YYFPRINTF fprintf
   1.719 +# endif
   1.720 +
   1.721 +# define YYDPRINTF(Args)			\
   1.722 +do {						\
   1.723 +  if (yydebug)					\
   1.724 +    YYFPRINTF Args;				\
   1.725 +} while (YYID (0))
   1.726 +
   1.727 +# define YY_SYMBOL_PRINT(Title, Type, Value, Location)			  \
   1.728 +do {									  \
   1.729 +  if (yydebug)								  \
   1.730 +    {									  \
   1.731 +      YYFPRINTF (stderr, "%s ", Title);					  \
   1.732 +      yy_symbol_print (stderr,						  \
   1.733 +		  Type, Value, context); \
   1.734 +      YYFPRINTF (stderr, "\n");						  \
   1.735 +    }									  \
   1.736 +} while (YYID (0))
   1.737 +
   1.738 +
   1.739 +/*--------------------------------.
   1.740 +| Print this symbol on YYOUTPUT.  |
   1.741 +`--------------------------------*/
   1.742 +
   1.743 +/*ARGSUSED*/
   1.744 +#if (defined __STDC__ || defined __C99__FUNC__ \
   1.745 +     || defined __cplusplus || defined _MSC_VER)
   1.746 +static void
   1.747 +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Context *context)
   1.748 +#else
   1.749 +static void
   1.750 +yy_symbol_value_print (yyoutput, yytype, yyvaluep, context)
   1.751 +    FILE *yyoutput;
   1.752 +    int yytype;
   1.753 +    YYSTYPE const * const yyvaluep;
   1.754 +    Context *context;
   1.755 +#endif
   1.756 +{
   1.757 +  FILE *yyo = yyoutput;
   1.758 +  YYUSE (yyo);
   1.759 +  if (!yyvaluep)
   1.760 +    return;
   1.761 +  YYUSE (context);
   1.762 +# ifdef YYPRINT
   1.763 +  if (yytype < YYNTOKENS)
   1.764 +    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
   1.765 +# else
   1.766 +  YYUSE (yyoutput);
   1.767 +# endif
   1.768 +  switch (yytype)
   1.769 +    {
   1.770 +      default:
   1.771 +        break;
   1.772 +    }
   1.773 +}
   1.774 +
   1.775 +
   1.776 +/*--------------------------------.
   1.777 +| Print this symbol on YYOUTPUT.  |
   1.778 +`--------------------------------*/
   1.779 +
   1.780 +#if (defined __STDC__ || defined __C99__FUNC__ \
   1.781 +     || defined __cplusplus || defined _MSC_VER)
   1.782 +static void
   1.783 +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, Context *context)
   1.784 +#else
   1.785 +static void
   1.786 +yy_symbol_print (yyoutput, yytype, yyvaluep, context)
   1.787 +    FILE *yyoutput;
   1.788 +    int yytype;
   1.789 +    YYSTYPE const * const yyvaluep;
   1.790 +    Context *context;
   1.791 +#endif
   1.792 +{
   1.793 +  if (yytype < YYNTOKENS)
   1.794 +    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
   1.795 +  else
   1.796 +    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
   1.797 +
   1.798 +  yy_symbol_value_print (yyoutput, yytype, yyvaluep, context);
   1.799 +  YYFPRINTF (yyoutput, ")");
   1.800 +}
   1.801 +
   1.802 +/*------------------------------------------------------------------.
   1.803 +| yy_stack_print -- Print the state stack from its BOTTOM up to its |
   1.804 +| TOP (included).                                                   |
   1.805 +`------------------------------------------------------------------*/
   1.806 +
   1.807 +#if (defined __STDC__ || defined __C99__FUNC__ \
   1.808 +     || defined __cplusplus || defined _MSC_VER)
   1.809 +static void
   1.810 +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
   1.811 +#else
   1.812 +static void
   1.813 +yy_stack_print (yybottom, yytop)
   1.814 +    yytype_int16 *yybottom;
   1.815 +    yytype_int16 *yytop;
   1.816 +#endif
   1.817 +{
   1.818 +  YYFPRINTF (stderr, "Stack now");
   1.819 +  for (; yybottom <= yytop; yybottom++)
   1.820 +    {
   1.821 +      int yybot = *yybottom;
   1.822 +      YYFPRINTF (stderr, " %d", yybot);
   1.823 +    }
   1.824 +  YYFPRINTF (stderr, "\n");
   1.825 +}
   1.826 +
   1.827 +# define YY_STACK_PRINT(Bottom, Top)				\
   1.828 +do {								\
   1.829 +  if (yydebug)							\
   1.830 +    yy_stack_print ((Bottom), (Top));				\
   1.831 +} while (YYID (0))
   1.832 +
   1.833 +
   1.834 +/*------------------------------------------------.
   1.835 +| Report that the YYRULE is going to be reduced.  |
   1.836 +`------------------------------------------------*/
   1.837 +
   1.838 +#if (defined __STDC__ || defined __C99__FUNC__ \
   1.839 +     || defined __cplusplus || defined _MSC_VER)
   1.840 +static void
   1.841 +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, Context *context)
   1.842 +#else
   1.843 +static void
   1.844 +yy_reduce_print (yyvsp, yyrule, context)
   1.845 +    YYSTYPE *yyvsp;
   1.846 +    int yyrule;
   1.847 +    Context *context;
   1.848 +#endif
   1.849 +{
   1.850 +  int yynrhs = yyr2[yyrule];
   1.851 +  int yyi;
   1.852 +  unsigned long int yylno = yyrline[yyrule];
   1.853 +  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
   1.854 +	     yyrule - 1, yylno);
   1.855 +  /* The symbols being reduced.  */
   1.856 +  for (yyi = 0; yyi < yynrhs; yyi++)
   1.857 +    {
   1.858 +      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
   1.859 +      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
   1.860 +		       &(yyvsp[(yyi + 1) - (yynrhs)])
   1.861 +		       		       , context);
   1.862 +      YYFPRINTF (stderr, "\n");
   1.863 +    }
   1.864 +}
   1.865 +
   1.866 +# define YY_REDUCE_PRINT(Rule)		\
   1.867 +do {					\
   1.868 +  if (yydebug)				\
   1.869 +    yy_reduce_print (yyvsp, Rule, context); \
   1.870 +} while (YYID (0))
   1.871 +
   1.872 +/* Nonzero means print parse trace.  It is left uninitialized so that
   1.873 +   multiple parsers can coexist.  */
   1.874 +int yydebug;
   1.875 +#else /* !YYDEBUG */
   1.876 +# define YYDPRINTF(Args)
   1.877 +# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
   1.878 +# define YY_STACK_PRINT(Bottom, Top)
   1.879 +# define YY_REDUCE_PRINT(Rule)
   1.880 +#endif /* !YYDEBUG */
   1.881 +
   1.882 +
   1.883 +/* YYINITDEPTH -- initial size of the parser's stacks.  */
   1.884 +#ifndef	YYINITDEPTH
   1.885 +# define YYINITDEPTH 200
   1.886 +#endif
   1.887 +
   1.888 +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
   1.889 +   if the built-in stack extension method is used).
   1.890 +
   1.891 +   Do not make this value too large; the results are undefined if
   1.892 +   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
   1.893 +   evaluated with infinite-precision integer arithmetic.  */
   1.894 +
   1.895 +#ifndef YYMAXDEPTH
   1.896 +# define YYMAXDEPTH 10000
   1.897 +#endif
   1.898 +
   1.899 +
   1.900 +#if YYERROR_VERBOSE
   1.901 +
   1.902 +# ifndef yystrlen
   1.903 +#  if defined __GLIBC__ && defined _STRING_H
   1.904 +#   define yystrlen strlen
   1.905 +#  else
   1.906 +/* Return the length of YYSTR.  */
   1.907 +#if (defined __STDC__ || defined __C99__FUNC__ \
   1.908 +     || defined __cplusplus || defined _MSC_VER)
   1.909 +static YYSIZE_T
   1.910 +yystrlen (const char *yystr)
   1.911 +#else
   1.912 +static YYSIZE_T
   1.913 +yystrlen (yystr)
   1.914 +    const char *yystr;
   1.915 +#endif
   1.916 +{
   1.917 +  YYSIZE_T yylen;
   1.918 +  for (yylen = 0; yystr[yylen]; yylen++)
   1.919 +    continue;
   1.920 +  return yylen;
   1.921 +}
   1.922 +#  endif
   1.923 +# endif
   1.924 +
   1.925 +# ifndef yystpcpy
   1.926 +#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
   1.927 +#   define yystpcpy stpcpy
   1.928 +#  else
   1.929 +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
   1.930 +   YYDEST.  */
   1.931 +#if (defined __STDC__ || defined __C99__FUNC__ \
   1.932 +     || defined __cplusplus || defined _MSC_VER)
   1.933 +static char *
   1.934 +yystpcpy (char *yydest, const char *yysrc)
   1.935 +#else
   1.936 +static char *
   1.937 +yystpcpy (yydest, yysrc)
   1.938 +    char *yydest;
   1.939 +    const char *yysrc;
   1.940 +#endif
   1.941 +{
   1.942 +  char *yyd = yydest;
   1.943 +  const char *yys = yysrc;
   1.944 +
   1.945 +  while ((*yyd++ = *yys++) != '\0')
   1.946 +    continue;
   1.947 +
   1.948 +  return yyd - 1;
   1.949 +}
   1.950 +#  endif
   1.951 +# endif
   1.952 +
   1.953 +# ifndef yytnamerr
   1.954 +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
   1.955 +   quotes and backslashes, so that it's suitable for yyerror.  The
   1.956 +   heuristic is that double-quoting is unnecessary unless the string
   1.957 +   contains an apostrophe, a comma, or backslash (other than
   1.958 +   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
   1.959 +   null, do not copy; instead, return the length of what the result
   1.960 +   would have been.  */
   1.961 +static YYSIZE_T
   1.962 +yytnamerr (char *yyres, const char *yystr)
   1.963 +{
   1.964 +  if (*yystr == '"')
   1.965 +    {
   1.966 +      YYSIZE_T yyn = 0;
   1.967 +      char const *yyp = yystr;
   1.968 +
   1.969 +      for (;;)
   1.970 +	switch (*++yyp)
   1.971 +	  {
   1.972 +	  case '\'':
   1.973 +	  case ',':
   1.974 +	    goto do_not_strip_quotes;
   1.975 +
   1.976 +	  case '\\':
   1.977 +	    if (*++yyp != '\\')
   1.978 +	      goto do_not_strip_quotes;
   1.979 +	    /* Fall through.  */
   1.980 +	  default:
   1.981 +	    if (yyres)
   1.982 +	      yyres[yyn] = *yyp;
   1.983 +	    yyn++;
   1.984 +	    break;
   1.985 +
   1.986 +	  case '"':
   1.987 +	    if (yyres)
   1.988 +	      yyres[yyn] = '\0';
   1.989 +	    return yyn;
   1.990 +	  }
   1.991 +    do_not_strip_quotes: ;
   1.992 +    }
   1.993 +
   1.994 +  if (! yyres)
   1.995 +    return yystrlen (yystr);
   1.996 +
   1.997 +  return yystpcpy (yyres, yystr) - yyres;
   1.998 +}
   1.999 +# endif
  1.1000 +
  1.1001 +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
  1.1002 +   about the unexpected token YYTOKEN for the state stack whose top is
  1.1003 +   YYSSP.
  1.1004 +
  1.1005 +   Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
  1.1006 +   not large enough to hold the message.  In that case, also set
  1.1007 +   *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
  1.1008 +   required number of bytes is too large to store.  */
  1.1009 +static int
  1.1010 +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
  1.1011 +                yytype_int16 *yyssp, int yytoken)
  1.1012 +{
  1.1013 +  YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
  1.1014 +  YYSIZE_T yysize = yysize0;
  1.1015 +  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
  1.1016 +  /* Internationalized format string. */
  1.1017 +  const char *yyformat = YY_NULL;
  1.1018 +  /* Arguments of yyformat. */
  1.1019 +  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
  1.1020 +  /* Number of reported tokens (one for the "unexpected", one per
  1.1021 +     "expected"). */
  1.1022 +  int yycount = 0;
  1.1023 +
  1.1024 +  /* There are many possibilities here to consider:
  1.1025 +     - Assume YYFAIL is not used.  It's too flawed to consider.  See
  1.1026 +       <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
  1.1027 +       for details.  YYERROR is fine as it does not invoke this
  1.1028 +       function.
  1.1029 +     - If this state is a consistent state with a default action, then
  1.1030 +       the only way this function was invoked is if the default action
  1.1031 +       is an error action.  In that case, don't check for expected
  1.1032 +       tokens because there are none.
  1.1033 +     - The only way there can be no lookahead present (in yychar) is if
  1.1034 +       this state is a consistent state with a default action.  Thus,
  1.1035 +       detecting the absence of a lookahead is sufficient to determine
  1.1036 +       that there is no unexpected or expected token to report.  In that
  1.1037 +       case, just report a simple "syntax error".
  1.1038 +     - Don't assume there isn't a lookahead just because this state is a
  1.1039 +       consistent state with a default action.  There might have been a
  1.1040 +       previous inconsistent state, consistent state with a non-default
  1.1041 +       action, or user semantic action that manipulated yychar.
  1.1042 +     - Of course, the expected token list depends on states to have
  1.1043 +       correct lookahead information, and it depends on the parser not
  1.1044 +       to perform extra reductions after fetching a lookahead from the
  1.1045 +       scanner and before detecting a syntax error.  Thus, state merging
  1.1046 +       (from LALR or IELR) and default reductions corrupt the expected
  1.1047 +       token list.  However, the list is correct for canonical LR with
  1.1048 +       one exception: it will still contain any token that will not be
  1.1049 +       accepted due to an error action in a later state.
  1.1050 +  */
  1.1051 +  if (yytoken != YYEMPTY)
  1.1052 +    {
  1.1053 +      int yyn = yypact[*yyssp];
  1.1054 +      yyarg[yycount++] = yytname[yytoken];
  1.1055 +      if (!yypact_value_is_default (yyn))
  1.1056 +        {
  1.1057 +          /* Start YYX at -YYN if negative to avoid negative indexes in
  1.1058 +             YYCHECK.  In other words, skip the first -YYN actions for
  1.1059 +             this state because they are default actions.  */
  1.1060 +          int yyxbegin = yyn < 0 ? -yyn : 0;
  1.1061 +          /* Stay within bounds of both yycheck and yytname.  */
  1.1062 +          int yychecklim = YYLAST - yyn + 1;
  1.1063 +          int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
  1.1064 +          int yyx;
  1.1065 +
  1.1066 +          for (yyx = yyxbegin; yyx < yyxend; ++yyx)
  1.1067 +            if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
  1.1068 +                && !yytable_value_is_error (yytable[yyx + yyn]))
  1.1069 +              {
  1.1070 +                if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
  1.1071 +                  {
  1.1072 +                    yycount = 1;
  1.1073 +                    yysize = yysize0;
  1.1074 +                    break;
  1.1075 +                  }
  1.1076 +                yyarg[yycount++] = yytname[yyx];
  1.1077 +                {
  1.1078 +                  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
  1.1079 +                  if (! (yysize <= yysize1
  1.1080 +                         && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
  1.1081 +                    return 2;
  1.1082 +                  yysize = yysize1;
  1.1083 +                }
  1.1084 +              }
  1.1085 +        }
  1.1086 +    }
  1.1087 +
  1.1088 +  switch (yycount)
  1.1089 +    {
  1.1090 +# define YYCASE_(N, S)                      \
  1.1091 +      case N:                               \
  1.1092 +        yyformat = S;                       \
  1.1093 +      break
  1.1094 +      YYCASE_(0, YY_("syntax error"));
  1.1095 +      YYCASE_(1, YY_("syntax error, unexpected %s"));
  1.1096 +      YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
  1.1097 +      YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
  1.1098 +      YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
  1.1099 +      YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
  1.1100 +# undef YYCASE_
  1.1101 +    }
  1.1102 +
  1.1103 +  {
  1.1104 +    YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
  1.1105 +    if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
  1.1106 +      return 2;
  1.1107 +    yysize = yysize1;
  1.1108 +  }
  1.1109 +
  1.1110 +  if (*yymsg_alloc < yysize)
  1.1111 +    {
  1.1112 +      *yymsg_alloc = 2 * yysize;
  1.1113 +      if (! (yysize <= *yymsg_alloc
  1.1114 +             && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
  1.1115 +        *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
  1.1116 +      return 1;
  1.1117 +    }
  1.1118 +
  1.1119 +  /* Avoid sprintf, as that infringes on the user's name space.
  1.1120 +     Don't have undefined behavior even if the translation
  1.1121 +     produced a string with the wrong number of "%s"s.  */
  1.1122 +  {
  1.1123 +    char *yyp = *yymsg;
  1.1124 +    int yyi = 0;
  1.1125 +    while ((*yyp = *yyformat) != '\0')
  1.1126 +      if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
  1.1127 +        {
  1.1128 +          yyp += yytnamerr (yyp, yyarg[yyi++]);
  1.1129 +          yyformat += 2;
  1.1130 +        }
  1.1131 +      else
  1.1132 +        {
  1.1133 +          yyp++;
  1.1134 +          yyformat++;
  1.1135 +        }
  1.1136 +  }
  1.1137 +  return 0;
  1.1138 +}
  1.1139 +#endif /* YYERROR_VERBOSE */
  1.1140 +
  1.1141 +/*-----------------------------------------------.
  1.1142 +| Release the memory associated to this symbol.  |
  1.1143 +`-----------------------------------------------*/
  1.1144 +
  1.1145 +/*ARGSUSED*/
  1.1146 +#if (defined __STDC__ || defined __C99__FUNC__ \
  1.1147 +     || defined __cplusplus || defined _MSC_VER)
  1.1148 +static void
  1.1149 +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, Context *context)
  1.1150 +#else
  1.1151 +static void
  1.1152 +yydestruct (yymsg, yytype, yyvaluep, context)
  1.1153 +    const char *yymsg;
  1.1154 +    int yytype;
  1.1155 +    YYSTYPE *yyvaluep;
  1.1156 +    Context *context;
  1.1157 +#endif
  1.1158 +{
  1.1159 +  YYUSE (yyvaluep);
  1.1160 +  YYUSE (context);
  1.1161 +
  1.1162 +  if (!yymsg)
  1.1163 +    yymsg = "Deleting";
  1.1164 +  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
  1.1165 +
  1.1166 +  switch (yytype)
  1.1167 +    {
  1.1168 +
  1.1169 +      default:
  1.1170 +        break;
  1.1171 +    }
  1.1172 +}
  1.1173 +
  1.1174 +
  1.1175 +
  1.1176 +
  1.1177 +/*----------.
  1.1178 +| yyparse.  |
  1.1179 +`----------*/
  1.1180 +
  1.1181 +#ifdef YYPARSE_PARAM
  1.1182 +#if (defined __STDC__ || defined __C99__FUNC__ \
  1.1183 +     || defined __cplusplus || defined _MSC_VER)
  1.1184 +int
  1.1185 +yyparse (void *YYPARSE_PARAM)
  1.1186 +#else
  1.1187 +int
  1.1188 +yyparse (YYPARSE_PARAM)
  1.1189 +    void *YYPARSE_PARAM;
  1.1190 +#endif
  1.1191 +#else /* ! YYPARSE_PARAM */
  1.1192 +#if (defined __STDC__ || defined __C99__FUNC__ \
  1.1193 +     || defined __cplusplus || defined _MSC_VER)
  1.1194 +int
  1.1195 +yyparse (Context *context)
  1.1196 +#else
  1.1197 +int
  1.1198 +yyparse (context)
  1.1199 +    Context *context;
  1.1200 +#endif
  1.1201 +#endif
  1.1202 +{
  1.1203 +/* The lookahead symbol.  */
  1.1204 +int yychar;
  1.1205 +
  1.1206 +
  1.1207 +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
  1.1208 +/* Suppress an incorrect diagnostic about yylval being uninitialized.  */
  1.1209 +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
  1.1210 +    _Pragma ("GCC diagnostic push") \
  1.1211 +    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
  1.1212 +    _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
  1.1213 +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
  1.1214 +    _Pragma ("GCC diagnostic pop")
  1.1215 +#else
  1.1216 +/* Default value used for initialization, for pacifying older GCCs
  1.1217 +   or non-GCC compilers.  */
  1.1218 +static YYSTYPE yyval_default;
  1.1219 +# define YY_INITIAL_VALUE(Value) = Value
  1.1220 +#endif
  1.1221 +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1.1222 +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1.1223 +# define YY_IGNORE_MAYBE_UNINITIALIZED_END
  1.1224 +#endif
  1.1225 +#ifndef YY_INITIAL_VALUE
  1.1226 +# define YY_INITIAL_VALUE(Value) /* Nothing. */
  1.1227 +#endif
  1.1228 +
  1.1229 +/* The semantic value of the lookahead symbol.  */
  1.1230 +YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
  1.1231 +
  1.1232 +    /* Number of syntax errors so far.  */
  1.1233 +    int yynerrs;
  1.1234 +
  1.1235 +    int yystate;
  1.1236 +    /* Number of tokens to shift before error messages enabled.  */
  1.1237 +    int yyerrstatus;
  1.1238 +
  1.1239 +    /* The stacks and their tools:
  1.1240 +       `yyss': related to states.
  1.1241 +       `yyvs': related to semantic values.
  1.1242 +
  1.1243 +       Refer to the stacks through separate pointers, to allow yyoverflow
  1.1244 +       to reallocate them elsewhere.  */
  1.1245 +
  1.1246 +    /* The state stack.  */
  1.1247 +    yytype_int16 yyssa[YYINITDEPTH];
  1.1248 +    yytype_int16 *yyss;
  1.1249 +    yytype_int16 *yyssp;
  1.1250 +
  1.1251 +    /* The semantic value stack.  */
  1.1252 +    YYSTYPE yyvsa[YYINITDEPTH];
  1.1253 +    YYSTYPE *yyvs;
  1.1254 +    YYSTYPE *yyvsp;
  1.1255 +
  1.1256 +    YYSIZE_T yystacksize;
  1.1257 +
  1.1258 +  int yyn;
  1.1259 +  int yyresult;
  1.1260 +  /* Lookahead token as an internal (translated) token number.  */
  1.1261 +  int yytoken = 0;
  1.1262 +  /* The variables used to return semantic value and location from the
  1.1263 +     action routines.  */
  1.1264 +  YYSTYPE yyval;
  1.1265 +
  1.1266 +#if YYERROR_VERBOSE
  1.1267 +  /* Buffer for error messages, and its allocated size.  */
  1.1268 +  char yymsgbuf[128];
  1.1269 +  char *yymsg = yymsgbuf;
  1.1270 +  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
  1.1271 +#endif
  1.1272 +
  1.1273 +#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
  1.1274 +
  1.1275 +  /* The number of symbols on the RHS of the reduced rule.
  1.1276 +     Keep to zero when no symbol should be popped.  */
  1.1277 +  int yylen = 0;
  1.1278 +
  1.1279 +  yyssp = yyss = yyssa;
  1.1280 +  yyvsp = yyvs = yyvsa;
  1.1281 +  yystacksize = YYINITDEPTH;
  1.1282 +
  1.1283 +  YYDPRINTF ((stderr, "Starting parse\n"));
  1.1284 +
  1.1285 +  yystate = 0;
  1.1286 +  yyerrstatus = 0;
  1.1287 +  yynerrs = 0;
  1.1288 +  yychar = YYEMPTY; /* Cause a token to be read.  */
  1.1289 +  goto yysetstate;
  1.1290 +
  1.1291 +/*------------------------------------------------------------.
  1.1292 +| yynewstate -- Push a new state, which is found in yystate.  |
  1.1293 +`------------------------------------------------------------*/
  1.1294 + yynewstate:
  1.1295 +  /* In all cases, when you get here, the value and location stacks
  1.1296 +     have just been pushed.  So pushing a state here evens the stacks.  */
  1.1297 +  yyssp++;
  1.1298 +
  1.1299 + yysetstate:
  1.1300 +  *yyssp = yystate;
  1.1301 +
  1.1302 +  if (yyss + yystacksize - 1 <= yyssp)
  1.1303 +    {
  1.1304 +      /* Get the current used size of the three stacks, in elements.  */
  1.1305 +      YYSIZE_T yysize = yyssp - yyss + 1;
  1.1306 +
  1.1307 +#ifdef yyoverflow
  1.1308 +      {
  1.1309 +	/* Give user a chance to reallocate the stack.  Use copies of
  1.1310 +	   these so that the &'s don't force the real ones into
  1.1311 +	   memory.  */
  1.1312 +	YYSTYPE *yyvs1 = yyvs;
  1.1313 +	yytype_int16 *yyss1 = yyss;
  1.1314 +
  1.1315 +	/* Each stack pointer address is followed by the size of the
  1.1316 +	   data in use in that stack, in bytes.  This used to be a
  1.1317 +	   conditional around just the two extra args, but that might
  1.1318 +	   be undefined if yyoverflow is a macro.  */
  1.1319 +	yyoverflow (YY_("memory exhausted"),
  1.1320 +		    &yyss1, yysize * sizeof (*yyssp),
  1.1321 +		    &yyvs1, yysize * sizeof (*yyvsp),
  1.1322 +		    &yystacksize);
  1.1323 +
  1.1324 +	yyss = yyss1;
  1.1325 +	yyvs = yyvs1;
  1.1326 +      }
  1.1327 +#else /* no yyoverflow */
  1.1328 +# ifndef YYSTACK_RELOCATE
  1.1329 +      goto yyexhaustedlab;
  1.1330 +# else
  1.1331 +      /* Extend the stack our own way.  */
  1.1332 +      if (YYMAXDEPTH <= yystacksize)
  1.1333 +	goto yyexhaustedlab;
  1.1334 +      yystacksize *= 2;
  1.1335 +      if (YYMAXDEPTH < yystacksize)
  1.1336 +	yystacksize = YYMAXDEPTH;
  1.1337 +
  1.1338 +      {
  1.1339 +	yytype_int16 *yyss1 = yyss;
  1.1340 +	union yyalloc *yyptr =
  1.1341 +	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
  1.1342 +	if (! yyptr)
  1.1343 +	  goto yyexhaustedlab;
  1.1344 +	YYSTACK_RELOCATE (yyss_alloc, yyss);
  1.1345 +	YYSTACK_RELOCATE (yyvs_alloc, yyvs);
  1.1346 +#  undef YYSTACK_RELOCATE
  1.1347 +	if (yyss1 != yyssa)
  1.1348 +	  YYSTACK_FREE (yyss1);
  1.1349 +      }
  1.1350 +# endif
  1.1351 +#endif /* no yyoverflow */
  1.1352 +
  1.1353 +      yyssp = yyss + yysize - 1;
  1.1354 +      yyvsp = yyvs + yysize - 1;
  1.1355 +
  1.1356 +      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
  1.1357 +		  (unsigned long int) yystacksize));
  1.1358 +
  1.1359 +      if (yyss + yystacksize - 1 <= yyssp)
  1.1360 +	YYABORT;
  1.1361 +    }
  1.1362 +
  1.1363 +  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
  1.1364 +
  1.1365 +  if (yystate == YYFINAL)
  1.1366 +    YYACCEPT;
  1.1367 +
  1.1368 +  goto yybackup;
  1.1369 +
  1.1370 +/*-----------.
  1.1371 +| yybackup.  |
  1.1372 +`-----------*/
  1.1373 +yybackup:
  1.1374 +
  1.1375 +  /* Do appropriate processing given the current state.  Read a
  1.1376 +     lookahead token if we need one and don't already have one.  */
  1.1377 +
  1.1378 +  /* First try to decide what to do without reference to lookahead token.  */
  1.1379 +  yyn = yypact[yystate];
  1.1380 +  if (yypact_value_is_default (yyn))
  1.1381 +    goto yydefault;
  1.1382 +
  1.1383 +  /* Not known => get a lookahead token if don't already have one.  */
  1.1384 +
  1.1385 +  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
  1.1386 +  if (yychar == YYEMPTY)
  1.1387 +    {
  1.1388 +      YYDPRINTF ((stderr, "Reading a token: "));
  1.1389 +      yychar = YYLEX;
  1.1390 +    }
  1.1391 +
  1.1392 +  if (yychar <= YYEOF)
  1.1393 +    {
  1.1394 +      yychar = yytoken = YYEOF;
  1.1395 +      YYDPRINTF ((stderr, "Now at end of input.\n"));
  1.1396 +    }
  1.1397 +  else
  1.1398 +    {
  1.1399 +      yytoken = YYTRANSLATE (yychar);
  1.1400 +      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
  1.1401 +    }
  1.1402 +
  1.1403 +  /* If the proper action on seeing token YYTOKEN is to reduce or to
  1.1404 +     detect an error, take that action.  */
  1.1405 +  yyn += yytoken;
  1.1406 +  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
  1.1407 +    goto yydefault;
  1.1408 +  yyn = yytable[yyn];
  1.1409 +  if (yyn <= 0)
  1.1410 +    {
  1.1411 +      if (yytable_value_is_error (yyn))
  1.1412 +        goto yyerrlab;
  1.1413 +      yyn = -yyn;
  1.1414 +      goto yyreduce;
  1.1415 +    }
  1.1416 +
  1.1417 +  /* Count tokens shifted since error; after three, turn off error
  1.1418 +     status.  */
  1.1419 +  if (yyerrstatus)
  1.1420 +    yyerrstatus--;
  1.1421 +
  1.1422 +  /* Shift the lookahead token.  */
  1.1423 +  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
  1.1424 +
  1.1425 +  /* Discard the shifted token.  */
  1.1426 +  yychar = YYEMPTY;
  1.1427 +
  1.1428 +  yystate = yyn;
  1.1429 +  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1.1430 +  *++yyvsp = yylval;
  1.1431 +  YY_IGNORE_MAYBE_UNINITIALIZED_END
  1.1432 +
  1.1433 +  goto yynewstate;
  1.1434 +
  1.1435 +
  1.1436 +/*-----------------------------------------------------------.
  1.1437 +| yydefault -- do the default action for the current state.  |
  1.1438 +`-----------------------------------------------------------*/
  1.1439 +yydefault:
  1.1440 +  yyn = yydefact[yystate];
  1.1441 +  if (yyn == 0)
  1.1442 +    goto yyerrlab;
  1.1443 +  goto yyreduce;
  1.1444 +
  1.1445 +
  1.1446 +/*-----------------------------.
  1.1447 +| yyreduce -- Do a reduction.  |
  1.1448 +`-----------------------------*/
  1.1449 +yyreduce:
  1.1450 +  /* yyn is the number of a rule to reduce with.  */
  1.1451 +  yylen = yyr2[yyn];
  1.1452 +
  1.1453 +  /* If YYLEN is nonzero, implement the default value of the action:
  1.1454 +     `$$ = $1'.
  1.1455 +
  1.1456 +     Otherwise, the following line sets YYVAL to garbage.
  1.1457 +     This behavior is undocumented and Bison
  1.1458 +     users should not rely upon it.  Assigning to YYVAL
  1.1459 +     unconditionally makes the parser a bit smaller, and it avoids a
  1.1460 +     GCC warning that YYVAL may be used uninitialized.  */
  1.1461 +  yyval = yyvsp[1-yylen];
  1.1462 +
  1.1463 +
  1.1464 +  YY_REDUCE_PRINT (yyn);
  1.1465 +  switch (yyn)
  1.1466 +    {
  1.1467 +        case 2:
  1.1468 +
  1.1469 +    {
  1.1470 +        *(context->result) = static_cast<int>((yyvsp[(1) - (1)]));
  1.1471 +        YYACCEPT;
  1.1472 +    }
  1.1473 +    break;
  1.1474 +
  1.1475 +  case 4:
  1.1476 +
  1.1477 +    {
  1.1478 +        (yyval) = (yyvsp[(1) - (3)]) || (yyvsp[(3) - (3)]);
  1.1479 +    }
  1.1480 +    break;
  1.1481 +
  1.1482 +  case 5:
  1.1483 +
  1.1484 +    {
  1.1485 +        (yyval) = (yyvsp[(1) - (3)]) && (yyvsp[(3) - (3)]);
  1.1486 +    }
  1.1487 +    break;
  1.1488 +
  1.1489 +  case 6:
  1.1490 +
  1.1491 +    {
  1.1492 +        (yyval) = (yyvsp[(1) - (3)]) | (yyvsp[(3) - (3)]);
  1.1493 +    }
  1.1494 +    break;
  1.1495 +
  1.1496 +  case 7:
  1.1497 +
  1.1498 +    {
  1.1499 +        (yyval) = (yyvsp[(1) - (3)]) ^ (yyvsp[(3) - (3)]);
  1.1500 +    }
  1.1501 +    break;
  1.1502 +
  1.1503 +  case 8:
  1.1504 +
  1.1505 +    {
  1.1506 +        (yyval) = (yyvsp[(1) - (3)]) & (yyvsp[(3) - (3)]);
  1.1507 +    }
  1.1508 +    break;
  1.1509 +
  1.1510 +  case 9:
  1.1511 +
  1.1512 +    {
  1.1513 +        (yyval) = (yyvsp[(1) - (3)]) != (yyvsp[(3) - (3)]);
  1.1514 +    }
  1.1515 +    break;
  1.1516 +
  1.1517 +  case 10:
  1.1518 +
  1.1519 +    {
  1.1520 +        (yyval) = (yyvsp[(1) - (3)]) == (yyvsp[(3) - (3)]);
  1.1521 +    }
  1.1522 +    break;
  1.1523 +
  1.1524 +  case 11:
  1.1525 +
  1.1526 +    {
  1.1527 +        (yyval) = (yyvsp[(1) - (3)]) >= (yyvsp[(3) - (3)]);
  1.1528 +    }
  1.1529 +    break;
  1.1530 +
  1.1531 +  case 12:
  1.1532 +
  1.1533 +    {
  1.1534 +        (yyval) = (yyvsp[(1) - (3)]) <= (yyvsp[(3) - (3)]);
  1.1535 +    }
  1.1536 +    break;
  1.1537 +
  1.1538 +  case 13:
  1.1539 +
  1.1540 +    {
  1.1541 +        (yyval) = (yyvsp[(1) - (3)]) > (yyvsp[(3) - (3)]);
  1.1542 +    }
  1.1543 +    break;
  1.1544 +
  1.1545 +  case 14:
  1.1546 +
  1.1547 +    {
  1.1548 +        (yyval) = (yyvsp[(1) - (3)]) < (yyvsp[(3) - (3)]);
  1.1549 +    }
  1.1550 +    break;
  1.1551 +
  1.1552 +  case 15:
  1.1553 +
  1.1554 +    {
  1.1555 +        (yyval) = (yyvsp[(1) - (3)]) >> (yyvsp[(3) - (3)]);
  1.1556 +    }
  1.1557 +    break;
  1.1558 +
  1.1559 +  case 16:
  1.1560 +
  1.1561 +    {
  1.1562 +        (yyval) = (yyvsp[(1) - (3)]) << (yyvsp[(3) - (3)]);
  1.1563 +    }
  1.1564 +    break;
  1.1565 +
  1.1566 +  case 17:
  1.1567 +
  1.1568 +    {
  1.1569 +        (yyval) = (yyvsp[(1) - (3)]) - (yyvsp[(3) - (3)]);
  1.1570 +    }
  1.1571 +    break;
  1.1572 +
  1.1573 +  case 18:
  1.1574 +
  1.1575 +    {
  1.1576 +        (yyval) = (yyvsp[(1) - (3)]) + (yyvsp[(3) - (3)]);
  1.1577 +    }
  1.1578 +    break;
  1.1579 +
  1.1580 +  case 19:
  1.1581 +
  1.1582 +    {
  1.1583 +        if ((yyvsp[(3) - (3)]) == 0) {
  1.1584 +            std::ostringstream stream;
  1.1585 +            stream << (yyvsp[(1) - (3)]) << " % " << (yyvsp[(3) - (3)]);
  1.1586 +            std::string text = stream.str();
  1.1587 +            context->diagnostics->report(pp::Diagnostics::DIVISION_BY_ZERO,
  1.1588 +                                         context->token->location,
  1.1589 +                                         text.c_str());
  1.1590 +            YYABORT;
  1.1591 +        } else {
  1.1592 +            (yyval) = (yyvsp[(1) - (3)]) % (yyvsp[(3) - (3)]);
  1.1593 +        }
  1.1594 +    }
  1.1595 +    break;
  1.1596 +
  1.1597 +  case 20:
  1.1598 +
  1.1599 +    {
  1.1600 +        if ((yyvsp[(3) - (3)]) == 0) {
  1.1601 +            std::ostringstream stream;
  1.1602 +            stream << (yyvsp[(1) - (3)]) << " / " << (yyvsp[(3) - (3)]);
  1.1603 +            std::string text = stream.str();
  1.1604 +            context->diagnostics->report(pp::Diagnostics::DIVISION_BY_ZERO,
  1.1605 +                                         context->token->location,
  1.1606 +                                         text.c_str());
  1.1607 +            YYABORT;
  1.1608 +        } else {
  1.1609 +            (yyval) = (yyvsp[(1) - (3)]) / (yyvsp[(3) - (3)]);
  1.1610 +        }
  1.1611 +    }
  1.1612 +    break;
  1.1613 +
  1.1614 +  case 21:
  1.1615 +
  1.1616 +    {
  1.1617 +        (yyval) = (yyvsp[(1) - (3)]) * (yyvsp[(3) - (3)]);
  1.1618 +    }
  1.1619 +    break;
  1.1620 +
  1.1621 +  case 22:
  1.1622 +
  1.1623 +    {
  1.1624 +        (yyval) = ! (yyvsp[(2) - (2)]);
  1.1625 +    }
  1.1626 +    break;
  1.1627 +
  1.1628 +  case 23:
  1.1629 +
  1.1630 +    {
  1.1631 +        (yyval) = ~ (yyvsp[(2) - (2)]);
  1.1632 +    }
  1.1633 +    break;
  1.1634 +
  1.1635 +  case 24:
  1.1636 +
  1.1637 +    {
  1.1638 +        (yyval) = - (yyvsp[(2) - (2)]);
  1.1639 +    }
  1.1640 +    break;
  1.1641 +
  1.1642 +  case 25:
  1.1643 +
  1.1644 +    {
  1.1645 +        (yyval) = + (yyvsp[(2) - (2)]);
  1.1646 +    }
  1.1647 +    break;
  1.1648 +
  1.1649 +  case 26:
  1.1650 +
  1.1651 +    {
  1.1652 +        (yyval) = (yyvsp[(2) - (3)]);
  1.1653 +    }
  1.1654 +    break;
  1.1655 +
  1.1656 +
  1.1657 +
  1.1658 +      default: break;
  1.1659 +    }
  1.1660 +  /* User semantic actions sometimes alter yychar, and that requires
  1.1661 +     that yytoken be updated with the new translation.  We take the
  1.1662 +     approach of translating immediately before every use of yytoken.
  1.1663 +     One alternative is translating here after every semantic action,
  1.1664 +     but that translation would be missed if the semantic action invokes
  1.1665 +     YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
  1.1666 +     if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
  1.1667 +     incorrect destructor might then be invoked immediately.  In the
  1.1668 +     case of YYERROR or YYBACKUP, subsequent parser actions might lead
  1.1669 +     to an incorrect destructor call or verbose syntax error message
  1.1670 +     before the lookahead is translated.  */
  1.1671 +  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
  1.1672 +
  1.1673 +  YYPOPSTACK (yylen);
  1.1674 +  yylen = 0;
  1.1675 +  YY_STACK_PRINT (yyss, yyssp);
  1.1676 +
  1.1677 +  *++yyvsp = yyval;
  1.1678 +
  1.1679 +  /* Now `shift' the result of the reduction.  Determine what state
  1.1680 +     that goes to, based on the state we popped back to and the rule
  1.1681 +     number reduced by.  */
  1.1682 +
  1.1683 +  yyn = yyr1[yyn];
  1.1684 +
  1.1685 +  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
  1.1686 +  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1.1687 +    yystate = yytable[yystate];
  1.1688 +  else
  1.1689 +    yystate = yydefgoto[yyn - YYNTOKENS];
  1.1690 +
  1.1691 +  goto yynewstate;
  1.1692 +
  1.1693 +
  1.1694 +/*------------------------------------.
  1.1695 +| yyerrlab -- here on detecting error |
  1.1696 +`------------------------------------*/
  1.1697 +yyerrlab:
  1.1698 +  /* Make sure we have latest lookahead translation.  See comments at
  1.1699 +     user semantic actions for why this is necessary.  */
  1.1700 +  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
  1.1701 +
  1.1702 +  /* If not already recovering from an error, report this error.  */
  1.1703 +  if (!yyerrstatus)
  1.1704 +    {
  1.1705 +      ++yynerrs;
  1.1706 +#if ! YYERROR_VERBOSE
  1.1707 +      yyerror (context, YY_("syntax error"));
  1.1708 +#else
  1.1709 +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
  1.1710 +                                        yyssp, yytoken)
  1.1711 +      {
  1.1712 +        char const *yymsgp = YY_("syntax error");
  1.1713 +        int yysyntax_error_status;
  1.1714 +        yysyntax_error_status = YYSYNTAX_ERROR;
  1.1715 +        if (yysyntax_error_status == 0)
  1.1716 +          yymsgp = yymsg;
  1.1717 +        else if (yysyntax_error_status == 1)
  1.1718 +          {
  1.1719 +            if (yymsg != yymsgbuf)
  1.1720 +              YYSTACK_FREE (yymsg);
  1.1721 +            yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
  1.1722 +            if (!yymsg)
  1.1723 +              {
  1.1724 +                yymsg = yymsgbuf;
  1.1725 +                yymsg_alloc = sizeof yymsgbuf;
  1.1726 +                yysyntax_error_status = 2;
  1.1727 +              }
  1.1728 +            else
  1.1729 +              {
  1.1730 +                yysyntax_error_status = YYSYNTAX_ERROR;
  1.1731 +                yymsgp = yymsg;
  1.1732 +              }
  1.1733 +          }
  1.1734 +        yyerror (context, yymsgp);
  1.1735 +        if (yysyntax_error_status == 2)
  1.1736 +          goto yyexhaustedlab;
  1.1737 +      }
  1.1738 +# undef YYSYNTAX_ERROR
  1.1739 +#endif
  1.1740 +    }
  1.1741 +
  1.1742 +
  1.1743 +
  1.1744 +  if (yyerrstatus == 3)
  1.1745 +    {
  1.1746 +      /* If just tried and failed to reuse lookahead token after an
  1.1747 +	 error, discard it.  */
  1.1748 +
  1.1749 +      if (yychar <= YYEOF)
  1.1750 +	{
  1.1751 +	  /* Return failure if at end of input.  */
  1.1752 +	  if (yychar == YYEOF)
  1.1753 +	    YYABORT;
  1.1754 +	}
  1.1755 +      else
  1.1756 +	{
  1.1757 +	  yydestruct ("Error: discarding",
  1.1758 +		      yytoken, &yylval, context);
  1.1759 +	  yychar = YYEMPTY;
  1.1760 +	}
  1.1761 +    }
  1.1762 +
  1.1763 +  /* Else will try to reuse lookahead token after shifting the error
  1.1764 +     token.  */
  1.1765 +  goto yyerrlab1;
  1.1766 +
  1.1767 +
  1.1768 +/*---------------------------------------------------.
  1.1769 +| yyerrorlab -- error raised explicitly by YYERROR.  |
  1.1770 +`---------------------------------------------------*/
  1.1771 +yyerrorlab:
  1.1772 +
  1.1773 +  /* Pacify compilers like GCC when the user code never invokes
  1.1774 +     YYERROR and the label yyerrorlab therefore never appears in user
  1.1775 +     code.  */
  1.1776 +  if (/*CONSTCOND*/ 0)
  1.1777 +     goto yyerrorlab;
  1.1778 +
  1.1779 +  /* Do not reclaim the symbols of the rule which action triggered
  1.1780 +     this YYERROR.  */
  1.1781 +  YYPOPSTACK (yylen);
  1.1782 +  yylen = 0;
  1.1783 +  YY_STACK_PRINT (yyss, yyssp);
  1.1784 +  yystate = *yyssp;
  1.1785 +  goto yyerrlab1;
  1.1786 +
  1.1787 +
  1.1788 +/*-------------------------------------------------------------.
  1.1789 +| yyerrlab1 -- common code for both syntax error and YYERROR.  |
  1.1790 +`-------------------------------------------------------------*/
  1.1791 +yyerrlab1:
  1.1792 +  yyerrstatus = 3;	/* Each real token shifted decrements this.  */
  1.1793 +
  1.1794 +  for (;;)
  1.1795 +    {
  1.1796 +      yyn = yypact[yystate];
  1.1797 +      if (!yypact_value_is_default (yyn))
  1.1798 +	{
  1.1799 +	  yyn += YYTERROR;
  1.1800 +	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
  1.1801 +	    {
  1.1802 +	      yyn = yytable[yyn];
  1.1803 +	      if (0 < yyn)
  1.1804 +		break;
  1.1805 +	    }
  1.1806 +	}
  1.1807 +
  1.1808 +      /* Pop the current state because it cannot handle the error token.  */
  1.1809 +      if (yyssp == yyss)
  1.1810 +	YYABORT;
  1.1811 +
  1.1812 +
  1.1813 +      yydestruct ("Error: popping",
  1.1814 +		  yystos[yystate], yyvsp, context);
  1.1815 +      YYPOPSTACK (1);
  1.1816 +      yystate = *yyssp;
  1.1817 +      YY_STACK_PRINT (yyss, yyssp);
  1.1818 +    }
  1.1819 +
  1.1820 +  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  1.1821 +  *++yyvsp = yylval;
  1.1822 +  YY_IGNORE_MAYBE_UNINITIALIZED_END
  1.1823 +
  1.1824 +
  1.1825 +  /* Shift the error token.  */
  1.1826 +  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
  1.1827 +
  1.1828 +  yystate = yyn;
  1.1829 +  goto yynewstate;
  1.1830 +
  1.1831 +
  1.1832 +/*-------------------------------------.
  1.1833 +| yyacceptlab -- YYACCEPT comes here.  |
  1.1834 +`-------------------------------------*/
  1.1835 +yyacceptlab:
  1.1836 +  yyresult = 0;
  1.1837 +  goto yyreturn;
  1.1838 +
  1.1839 +/*-----------------------------------.
  1.1840 +| yyabortlab -- YYABORT comes here.  |
  1.1841 +`-----------------------------------*/
  1.1842 +yyabortlab:
  1.1843 +  yyresult = 1;
  1.1844 +  goto yyreturn;
  1.1845 +
  1.1846 +#if !defined yyoverflow || YYERROR_VERBOSE
  1.1847 +/*-------------------------------------------------.
  1.1848 +| yyexhaustedlab -- memory exhaustion comes here.  |
  1.1849 +`-------------------------------------------------*/
  1.1850 +yyexhaustedlab:
  1.1851 +  yyerror (context, YY_("memory exhausted"));
  1.1852 +  yyresult = 2;
  1.1853 +  /* Fall through.  */
  1.1854 +#endif
  1.1855 +
  1.1856 +yyreturn:
  1.1857 +  if (yychar != YYEMPTY)
  1.1858 +    {
  1.1859 +      /* Make sure we have latest lookahead translation.  See comments at
  1.1860 +         user semantic actions for why this is necessary.  */
  1.1861 +      yytoken = YYTRANSLATE (yychar);
  1.1862 +      yydestruct ("Cleanup: discarding lookahead",
  1.1863 +                  yytoken, &yylval, context);
  1.1864 +    }
  1.1865 +  /* Do not reclaim the symbols of the rule which action triggered
  1.1866 +     this YYABORT or YYACCEPT.  */
  1.1867 +  YYPOPSTACK (yylen);
  1.1868 +  YY_STACK_PRINT (yyss, yyssp);
  1.1869 +  while (yyssp != yyss)
  1.1870 +    {
  1.1871 +      yydestruct ("Cleanup: popping",
  1.1872 +		  yystos[*yyssp], yyvsp, context);
  1.1873 +      YYPOPSTACK (1);
  1.1874 +    }
  1.1875 +#ifndef yyoverflow
  1.1876 +  if (yyss != yyssa)
  1.1877 +    YYSTACK_FREE (yyss);
  1.1878 +#endif
  1.1879 +#if YYERROR_VERBOSE
  1.1880 +  if (yymsg != yymsgbuf)
  1.1881 +    YYSTACK_FREE (yymsg);
  1.1882 +#endif
  1.1883 +  /* Make sure YYID is used.  */
  1.1884 +  return YYID (yyresult);
  1.1885 +}
  1.1886 +
  1.1887 +
  1.1888 +
  1.1889 +
  1.1890 +
  1.1891 +int yylex(YYSTYPE* lvalp, Context* context)
  1.1892 +{
  1.1893 +    int type = 0;
  1.1894 +
  1.1895 +    pp::Token* token = context->token;
  1.1896 +    switch (token->type)
  1.1897 +    {
  1.1898 +      case pp::Token::CONST_INT:
  1.1899 +      {
  1.1900 +        unsigned int val = 0;
  1.1901 +        if (!token->uValue(&val))
  1.1902 +        {
  1.1903 +            context->diagnostics->report(pp::Diagnostics::INTEGER_OVERFLOW,
  1.1904 +                                         token->location, token->text);
  1.1905 +        }
  1.1906 +        *lvalp = static_cast<YYSTYPE>(val);
  1.1907 +        type = TOK_CONST_INT;
  1.1908 +        break;
  1.1909 +      }
  1.1910 +      case pp::Token::OP_OR: type = TOK_OP_OR; break;
  1.1911 +      case pp::Token::OP_AND: type = TOK_OP_AND; break;
  1.1912 +      case pp::Token::OP_NE: type = TOK_OP_NE; break;
  1.1913 +      case pp::Token::OP_EQ: type = TOK_OP_EQ; break;
  1.1914 +      case pp::Token::OP_GE: type = TOK_OP_GE; break;
  1.1915 +      case pp::Token::OP_LE: type = TOK_OP_LE; break;
  1.1916 +      case pp::Token::OP_RIGHT: type = TOK_OP_RIGHT; break;
  1.1917 +      case pp::Token::OP_LEFT: type = TOK_OP_LEFT; break;
  1.1918 +      case '|': type = '|'; break;
  1.1919 +      case '^': type = '^'; break;
  1.1920 +      case '&': type = '&'; break;
  1.1921 +      case '>': type = '>'; break;
  1.1922 +      case '<': type = '<'; break;
  1.1923 +      case '-': type = '-'; break;
  1.1924 +      case '+': type = '+'; break;
  1.1925 +      case '%': type = '%'; break;
  1.1926 +      case '/': type = '/'; break;
  1.1927 +      case '*': type = '*'; break;
  1.1928 +      case '!': type = '!'; break;
  1.1929 +      case '~': type = '~'; break;
  1.1930 +      case '(': type = '('; break;
  1.1931 +      case ')': type = ')'; break;
  1.1932 +
  1.1933 +      default: break;
  1.1934 +    }
  1.1935 +
  1.1936 +    // Advance to the next token if the current one is valid.
  1.1937 +    if (type != 0) context->lexer->lex(token);
  1.1938 +
  1.1939 +    return type;
  1.1940 +}
  1.1941 +
  1.1942 +void yyerror(Context* context, const char* reason)
  1.1943 +{
  1.1944 +    context->diagnostics->report(pp::Diagnostics::INVALID_EXPRESSION,
  1.1945 +                                 context->token->location,
  1.1946 +                                 reason);
  1.1947 +}
  1.1948 +
  1.1949 +namespace pp {
  1.1950 +
  1.1951 +ExpressionParser::ExpressionParser(Lexer* lexer, Diagnostics* diagnostics) :
  1.1952 +    mLexer(lexer),
  1.1953 +    mDiagnostics(diagnostics)
  1.1954 +{
  1.1955 +}
  1.1956 +
  1.1957 +bool ExpressionParser::parse(Token* token, int* result)
  1.1958 +{
  1.1959 +    Context context;
  1.1960 +    context.diagnostics = mDiagnostics;
  1.1961 +    context.lexer = mLexer;
  1.1962 +    context.token = token;
  1.1963 +    context.result = result;
  1.1964 +    int ret = yyparse(&context);
  1.1965 +    switch (ret)
  1.1966 +    {
  1.1967 +      case 0:
  1.1968 +      case 1:
  1.1969 +        break;
  1.1970 +
  1.1971 +      case 2:
  1.1972 +        mDiagnostics->report(Diagnostics::OUT_OF_MEMORY, token->location, "");
  1.1973 +        break;
  1.1974 +
  1.1975 +      default:
  1.1976 +        assert(false);
  1.1977 +        mDiagnostics->report(Diagnostics::INTERNAL_ERROR, token->location, "");
  1.1978 +        break;
  1.1979 +    }
  1.1980 +
  1.1981 +    return ret == 0;
  1.1982 +}
  1.1983 +
  1.1984 +}  // namespace pp

mercurial