src/vParser.cpp

Go to the documentation of this file.
00001 /* A Bison parser, made by GNU Bison 2.3.  */
00002 
00003 /* Skeleton implementation for Bison's Yacc-like parsers in C
00004 
00005    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
00006    Free Software Foundation, Inc.
00007 
00008    This program is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; either version 2, or (at your option)
00011    any later version.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021    Boston, MA 02110-1301, USA.  */
00022 
00023 /* As a special exception, you may create a larger work that contains
00024    part or all of the Bison parser skeleton and distribute that work
00025    under terms of your choice, so long as that work isn't itself a
00026    parser generator using the skeleton or a modified version thereof
00027    as a parser skeleton.  Alternatively, if you modify or redistribute
00028    the parser skeleton itself, you may (at your option) remove this
00029    special exception, which will cause the skeleton and the resulting
00030    Bison output files to be licensed under the GNU General Public
00031    License without this special exception.
00032 
00033    This special exception was added by the Free Software Foundation in
00034    version 2.2 of Bison.  */
00035 
00036 /* C LALR(1) parser skeleton written by Richard Stallman, by
00037    simplifying the original so-called "semantic" parser.  */
00038 
00039 /* All symbols defined below should begin with yy or YY, to avoid
00040    infringing on user name space.  This should be done even for local
00041    variables, as they might otherwise be expanded by user macros.
00042    There are some unavoidable exceptions within include files to
00043    define necessary library symbols; they are noted "INFRINGES ON
00044    USER NAME SPACE" below.  */
00045 
00046 /* Identify Bison output.  */
00047 #define YYBISON 1
00048 
00049 /* Bison version.  */
00050 #define YYBISON_VERSION "2.3"
00051 
00052 /* Skeleton name.  */
00053 #define YYSKELETON_NAME "yacc.c"
00054 
00055 /* Pure parsers.  */
00056 #define YYPURE 0
00057 
00058 /* Using locations.  */
00059 #define YYLSP_NEEDED 0
00060 
00061 
00062 
00063 /* Tokens.  */
00064 #ifndef YYTOKENTYPE
00065 # define YYTOKENTYPE
00066 /* Put the tokens into the symbol table, so that GDB and other debuggers
00067    know about them.  */
00068 enum yytokentype {
00069     tINTEGER = 258,
00070     tSTRING = 259,
00071     tID = 260,
00072     tNE = 261,
00073     tEQ = 262,
00074     tGT = 263,
00075     tLT = 264,
00076     tGE = 265,
00077     tLE = 266,
00078     tCOMPARE = 267,
00079     tUNARYMINUS = 268
00080 };
00081 #endif
00082 /* Tokens.  */
00083 #define tINTEGER 258
00084 #define tSTRING 259
00085 #define tID 260
00086 #define tNE 261
00087 #define tEQ 262
00088 #define tGT 263
00089 #define tLT 264
00090 #define tGE 265
00091 #define tLE 266
00092 #define tCOMPARE 267
00093 #define tUNARYMINUS 268
00094 
00095 
00096 
00097 
00098 /* Copy the first part of user declarations.  */
00099 #line 3 "vParser.ypp"
00100 
00101 // With at BISON 2.1 and GCC 3.3, the generated .cpp file fails to compile.
00102 // Solution for z-man: upgrade to BISON 2.2.
00103 // Users of the tarball shouldn't be affected by this.
00104 
00105         #include <stdlib.h>     // Works around a bug in BISON 2.1 non-pedantic
00106         #define YYINCLUDED_STDLIB_H // tell Bison we did that
00107 
00108         #include <vector>
00109 
00110         #include "tError.h"
00111         #include "values/vCore.h"
00112         #include "values/veComparison.h"
00113         #include "values/veMath.h"
00114         #include "values/vRegistry.h"
00115         #include "values/vParser.h"
00116         #include "tString.h"
00117 
00118 int yylex(void);
00119 void yyerror(char const *s);
00120 
00121 using namespace vValue;
00122 
00123 Expr::Base *rv;
00124 
00125 
00126 /* Enabling traces.  */
00127 #ifndef YYDEBUG
00128 # define YYDEBUG 0
00129 #endif
00130 
00131 /* Enabling verbose error messages.  */
00132 #ifdef YYERROR_VERBOSE
00133 # undef YYERROR_VERBOSE
00134 # define YYERROR_VERBOSE 1
00135 #else
00136 # define YYERROR_VERBOSE 0
00137 #endif
00138 
00139 /* Enabling the token table.  */
00140 #ifndef YYTOKEN_TABLE
00141 # define YYTOKEN_TABLE 0
00142 #endif
00143 
00144 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
00145 typedef union YYSTYPE
00146 #line 30 "vParser.ypp"
00147 {
00148     int integer;
00149     tString *string;
00150     Expr::Base *expr;
00151     Type::arglist *arglist;
00152 }
00153 /* Line 187 of yacc.c.  */
00154 #line 155 "vParser.cpp"
00155 YYSTYPE;
00156 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
00157 # define YYSTYPE_IS_DECLARED 1
00158 # define YYSTYPE_IS_TRIVIAL 1
00159 #endif
00160 
00161 
00162 
00163 /* Copy the second part of user declarations.  */
00164 
00165 
00166 /* Line 216 of yacc.c.  */
00167 #line 168 "vParser.cpp"
00168 
00169 #ifdef short
00170 # undef short
00171 #endif
00172 
00173 #ifdef YYTYPE_UINT8
00174 typedef YYTYPE_UINT8 yytype_uint8;
00175 #else
00176 typedef unsigned char yytype_uint8;
00177 #endif
00178 
00179 #ifdef YYTYPE_INT8
00180 typedef YYTYPE_INT8 yytype_int8;
00181 #elif (defined __STDC__ || defined __C99__FUNC__ \
00182      || defined __cplusplus || defined _MSC_VER)
00183 typedef signed char yytype_int8;
00184 #else
00185 typedef short int yytype_int8;
00186 #endif
00187 
00188 #ifdef YYTYPE_UINT16
00189 typedef YYTYPE_UINT16 yytype_uint16;
00190 #else
00191 typedef unsigned short int yytype_uint16;
00192 #endif
00193 
00194 #ifdef YYTYPE_INT16
00195 typedef YYTYPE_INT16 yytype_int16;
00196 #else
00197 typedef short int yytype_int16;
00198 #endif
00199 
00200 #ifndef YYSIZE_T
00201 # ifdef __SIZE_TYPE__
00202 #  define YYSIZE_T __SIZE_TYPE__
00203 # elif defined size_t
00204 #  define YYSIZE_T size_t
00205 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
00206      || defined __cplusplus || defined _MSC_VER)
00207 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
00208 #  define YYSIZE_T size_t
00209 # else
00210 #  define YYSIZE_T unsigned int
00211 # endif
00212 #endif
00213 
00214 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
00215 
00216 #ifndef YY_
00217 # if YYENABLE_NLS
00218 #  if ENABLE_NLS
00219 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
00220 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
00221 #  endif
00222 # endif
00223 # ifndef YY_
00224 #  define YY_(msgid) msgid
00225 # endif
00226 #endif
00227 
00228 /* Suppress unused-variable warnings by "using" E.  */
00229 #if ! defined lint || defined __GNUC__
00230 # define YYUSE(e) ((void) (e))
00231 #else
00232 # define YYUSE(e) /* empty */
00233 #endif
00234 
00235 /* Identity function, used to suppress warnings about constant conditions.  */
00236 #ifndef lint
00237 # define YYID(n) (n)
00238 #else
00239 #if (defined __STDC__ || defined __C99__FUNC__ \
00240      || defined __cplusplus || defined _MSC_VER)
00241 static int
00242 YYID (int i)
00243 #else
00244 static int
00245 YYID (i)
00246 int i;
00247 #endif
00248 {
00249     return i;
00250 }
00251 #endif
00252 
00253 #if ! defined yyoverflow || YYERROR_VERBOSE
00254 
00255 /* The parser invokes alloca or malloc; define the necessary symbols.  */
00256 
00257 # ifdef YYSTACK_USE_ALLOCA
00258 #  if YYSTACK_USE_ALLOCA
00259 #   ifdef __GNUC__
00260 #    define YYSTACK_ALLOC __builtin_alloca
00261 #   elif defined __BUILTIN_VA_ARG_INCR
00262 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
00263 #   elif defined _AIX
00264 #    define YYSTACK_ALLOC __alloca
00265 #   elif defined _MSC_VER
00266 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
00267 #    define alloca _alloca
00268 #   else
00269 #    define YYSTACK_ALLOC alloca
00270 #    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
00271      || defined __cplusplus || defined _MSC_VER)
00272 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
00273 #     ifndef _STDLIB_H
00274 #      define _STDLIB_H 1
00275 #     endif
00276 #    endif
00277 #   endif
00278 #  endif
00279 # endif
00280 
00281 # ifdef YYSTACK_ALLOC
00282 /* Pacify GCC's `empty if-body' warning.  */
00283 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
00284 #  ifndef YYSTACK_ALLOC_MAXIMUM
00285 /* The OS might guarantee only one guard page at the bottom of the stack,
00286    and a page size can be as small as 4096 bytes.  So we cannot safely
00287    invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
00288    to allow for a few compiler-allocated temporary stack slots.  */
00289 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
00290 #  endif
00291 # else
00292 #  define YYSTACK_ALLOC YYMALLOC
00293 #  define YYSTACK_FREE YYFREE
00294 #  ifndef YYSTACK_ALLOC_MAXIMUM
00295 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
00296 #  endif
00297 #  if (defined __cplusplus && ! defined _STDLIB_H \
00298        && ! ((defined YYMALLOC || defined malloc) \
00299              && (defined YYFREE || defined free)))
00300 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
00301 #   ifndef _STDLIB_H
00302 #    define _STDLIB_H 1
00303 #   endif
00304 #  endif
00305 #  ifndef YYMALLOC
00306 #   define YYMALLOC malloc
00307 #   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
00308      || defined __cplusplus || defined _MSC_VER)
00309 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
00310 #   endif
00311 #  endif
00312 #  ifndef YYFREE
00313 #   define YYFREE free
00314 #   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
00315      || defined __cplusplus || defined _MSC_VER)
00316 void free (void *); /* INFRINGES ON USER NAME SPACE */
00317 #   endif
00318 #  endif
00319 # endif
00320 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
00321 
00322 
00323 #if (! defined yyoverflow \
00324      && (! defined __cplusplus \
00325          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
00326 
00327 /* A type that is properly aligned for any stack member.  */
00328 union yyalloc
00329 {
00330     yytype_int16 yyss;
00331     YYSTYPE yyvs;
00332 };
00333 
00334 /* The size of the maximum gap between one aligned stack and the next.  */
00335 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
00336 
00337 /* The size of an array large to enough to hold all stacks, each with
00338    N elements.  */
00339 # define YYSTACK_BYTES(N) \
00340      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
00341       + YYSTACK_GAP_MAXIMUM)
00342 
00343 /* Copy COUNT objects from FROM to TO.  The source and destination do
00344    not overlap.  */
00345 # ifndef YYCOPY
00346 #  if defined __GNUC__ && 1 < __GNUC__
00347 #   define YYCOPY(To, From, Count) \
00348       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
00349 #  else
00350 #   define YYCOPY(To, From, Count)              \
00351       do                                        \
00352         {                                       \
00353           YYSIZE_T yyi;                         \
00354           for (yyi = 0; yyi < (Count); yyi++)   \
00355             (To)[yyi] = (From)[yyi];            \
00356         }                                       \
00357       while (YYID (0))
00358 #  endif
00359 # endif
00360 
00361 /* Relocate STACK from its old location to the new one.  The
00362    local variables YYSIZE and YYSTACKSIZE give the old and new number of
00363    elements in the stack, and YYPTR gives the new location of the
00364    stack.  Advance YYPTR to a properly aligned location for the next
00365    stack.  */
00366 # define YYSTACK_RELOCATE(Stack)                                        \
00367     do                                                                  \
00368       {                                                                 \
00369         YYSIZE_T yynewbytes;                                            \
00370         YYCOPY (&yyptr->Stack, Stack, yysize);                          \
00371         Stack = &yyptr->Stack;                                          \
00372         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
00373         yyptr += yynewbytes / sizeof (*yyptr);                          \
00374       }                                                                 \
00375     while (YYID (0))
00376 
00377 #endif
00378 
00379 /* YYFINAL -- State number of the termination state.  */
00380 #define YYFINAL  12
00381 /* YYLAST -- Last index in YYTABLE.  */
00382 #define YYLAST   38
00383 
00384 /* YYNTOKENS -- Number of terminals.  */
00385 #define YYNTOKENS  22
00386 /* YYNNTS -- Number of nonterminals.  */
00387 #define YYNNTS  5
00388 /* YYNRULES -- Number of rules.  */
00389 #define YYNRULES  17
00390 /* YYNRULES -- Number of states.  */
00391 #define YYNSTATES  31
00392 
00393 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
00394 #define YYUNDEFTOK  2
00395 #define YYMAXUTOK   268
00396 
00397 #define YYTRANSLATE(YYX)                                                \
00398   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
00399 
00400 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
00401 static const yytype_uint8 yytranslate[] =
00402     {
00403         0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00404         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00405         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00406         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00407         19,    20,     8,     6,    21,     7,    18,     9,     2,     2,
00408         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00409         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00410         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00411         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00412         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00413         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00414         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00415         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00416         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00417         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00418         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00419         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00420         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00421         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00422         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00423         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00424         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00425         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00426         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00427         2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00428         2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
00429         5,    10,    11,    12,    13,    14,    15,    16,    17
00430     };
00431 
00432 #if YYDEBUG
00433 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
00434    YYRHS.  */
00435 static const yytype_uint8 yyprhs[] =
00436     {
00437         0,     0,     3,     5,     7,     9,    11,    15,    19,    23,
00438         27,    31,    34,    38,    43,    47,    48,    50
00439     };
00440 
00441 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
00442 static const yytype_int8 yyrhs[] =
00443     {
00444         23,     0,    -1,    24,    -1,     3,    -1,     4,    -1,    25,
00445         -1,    24,     6,    24,    -1,    24,     7,    24,    -1,    24,
00446         8,    24,    -1,    24,     9,    24,    -1,    24,    16,    24,
00447         -1,     7,    24,    -1,    19,    24,    20,    -1,     5,    19,
00448         26,    20,    -1,    25,    18,    25,    -1,    -1,    24,    -1,
00449         26,    21,    24,    -1
00450     };
00451 
00452 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
00453 static const yytype_uint8 yyrline[] =
00454     {
00455         0,    55,    55,    81,    86,    91,    92,    96,   100,   104,
00456         108,   112,   117,   125,   133,   137,   140,   145
00457     };
00458 #endif
00459 
00460 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
00461 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
00462    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
00463 static const char *const yytname[] =
00464     {
00465         "$end", "error", "$undefined", "tINTEGER", "tSTRING", "tID", "'+'",
00466         "'-'", "'*'", "'/'", "tNE", "tEQ", "tGT", "tLT", "tGE", "tLE",
00467         "tCOMPARE", "tUNARYMINUS", "'.'", "'('", "')'", "','", "$accept",
00468         "input", "expr", "function", "arglist", 0
00469     };
00470 #endif
00471 
00472 # ifdef YYPRINT
00473 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
00474    token YYLEX-NUM.  */
00475 static const yytype_uint16 yytoknum[] =
00476     {
00477         0,   256,   257,   258,   259,   260,    43,    45,    42,    47,
00478         261,   262,   263,   264,   265,   266,   267,   268,    46,    40,
00479         41,    44
00480     };
00481 # endif
00482 
00483 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
00484 static const yytype_uint8 yyr1[] =
00485     {
00486         0,    22,    23,    24,    24,    24,    24,    24,    24,    24,
00487         24,    24,    24,    25,    25,    26,    26,    26
00488     };
00489 
00490 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
00491 static const yytype_uint8 yyr2[] =
00492     {
00493         0,     2,     1,     1,     1,     1,     3,     3,     3,     3,
00494         3,     2,     3,     4,     3,     0,     1,     3
00495     };
00496 
00497 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
00498    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
00499    means the default is an error.  */
00500 static const yytype_uint8 yydefact[] =
00501     {
00502         0,     3,     4,     0,     0,     0,     0,     2,     5,    15,
00503         11,     0,     1,     0,     0,     0,     0,     0,     0,    16,
00504         0,    12,     6,     7,     8,     9,    10,    14,    13,     0,
00505         17
00506     };
00507 
00508 /* YYDEFGOTO[NTERM-NUM].  */
00509 static const yytype_int8 yydefgoto[] =
00510     {
00511         -1,     6,     7,     8,    20
00512     };
00513 
00514 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
00515    STATE-NUM.  */
00516 #define YYPACT_NINF -14
00517 static const yytype_int8 yypact[] =
00518     {
00519         -1,   -14,   -14,     4,    -1,    -1,    30,    13,    14,    -1,
00520         -14,     8,   -14,    -1,    -1,    -1,    -1,    -1,    26,    13,
00521         -13,   -14,    18,    18,    17,    17,   -14,    19,   -14,    -1,
00522         13
00523     };
00524 
00525 /* YYPGOTO[NTERM-NUM].  */
00526 static const yytype_int8 yypgoto[] =
00527     {
00528         -14,   -14,    -4,    20,   -14
00529     };
00530 
00531 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
00532    positive, shift that token.  If negative, reduce the rule which
00533    number is the opposite.  If zero, do what YYDEFACT says.
00534    If YYTABLE_NINF, syntax error.  */
00535 #define YYTABLE_NINF -1
00536 static const yytype_int8 yytable[] =
00537     {
00538         10,    11,     1,     2,     3,    19,     4,    28,    29,    22,
00539         23,    24,    25,    26,    13,    14,    15,    16,     5,    13,
00540         14,    15,    16,     9,    17,    30,    15,    16,    21,    17,
00541         12,     3,    18,    17,    17,     0,     0,    -1,    27
00542     };
00543 
00544 static const yytype_int8 yycheck[] =
00545     {
00546         4,     5,     3,     4,     5,     9,     7,    20,    21,    13,
00547         14,    15,    16,    17,     6,     7,     8,     9,    19,     6,
00548         7,     8,     9,    19,    16,    29,     8,     9,    20,    16,
00549         0,     5,    18,    16,    16,    -1,    -1,    18,    18
00550     };
00551 
00552 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
00553    symbol of state STATE-NUM.  */
00554 static const yytype_uint8 yystos[] =
00555     {
00556         0,     3,     4,     5,     7,    19,    23,    24,    25,    19,
00557         24,    24,     0,     6,     7,     8,     9,    16,    18,    24,
00558         26,    20,    24,    24,    24,    24,    24,    25,    20,    21,
00559         24
00560     };
00561 
00562 #define yyerrok         (yyerrstatus = 0)
00563 #define yyclearin       (yychar = YYEMPTY)
00564 #define YYEMPTY         (-2)
00565 #define YYEOF           0
00566 
00567 #define YYACCEPT        goto yyacceptlab
00568 #define YYABORT         goto yyabortlab
00569 #define YYERROR         goto yyerrorlab
00570 
00571 
00572 /* Like YYERROR except do call yyerror.  This remains here temporarily
00573    to ease the transition to the new meaning of YYERROR, for GCC.
00574    Once GCC version 2 has supplanted version 1, this can go.  */
00575 
00576 #define YYFAIL          goto yyerrlab
00577 
00578 #define YYRECOVERING()  (!!yyerrstatus)
00579 
00580 #define YYBACKUP(Token, Value)                                  \
00581 do                                                              \
00582   if (yychar == YYEMPTY && yylen == 1)                          \
00583     {                                                           \
00584       yychar = (Token);                                         \
00585       yylval = (Value);                                         \
00586       yytoken = YYTRANSLATE (yychar);                           \
00587       YYPOPSTACK (1);                                           \
00588       goto yybackup;                                            \
00589     }                                                           \
00590   else                                                          \
00591     {                                                           \
00592       yyerror (YY_("syntax error: cannot back up")); \
00593       YYERROR;                                                  \
00594     }                                                           \
00595 while (YYID (0))
00596 
00597 
00598 #define YYTERROR        1
00599 #define YYERRCODE       256
00600 
00601 
00602 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
00603    If N is 0, then set CURRENT to the empty location which ends
00604    the previous symbol: RHS[0] (always defined).  */
00605 
00606 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
00607 #ifndef YYLLOC_DEFAULT
00608 # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
00609     do                                                                  \
00610       if (YYID (N))                                                    \
00611         {                                                               \
00612           (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
00613           (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
00614           (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
00615           (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
00616         }                                                               \
00617       else                                                              \
00618         {                                                               \
00619           (Current).first_line   = (Current).last_line   =              \
00620             YYRHSLOC (Rhs, 0).last_line;                                \
00621           (Current).first_column = (Current).last_column =              \
00622             YYRHSLOC (Rhs, 0).last_column;                              \
00623         }                                                               \
00624     while (YYID (0))
00625 #endif
00626 
00627 
00628 /* YY_LOCATION_PRINT -- Print the location on the stream.
00629    This macro was not mandated originally: define only if we know
00630    we won't break user code: when these are the locations we know.  */
00631 
00632 #ifndef YY_LOCATION_PRINT
00633 # if YYLTYPE_IS_TRIVIAL
00634 #  define YY_LOCATION_PRINT(File, Loc)                  \
00635      fprintf (File, "%d.%d-%d.%d",                      \
00636               (Loc).first_line, (Loc).first_column,     \
00637               (Loc).last_line,  (Loc).last_column)
00638 # else
00639 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
00640 # endif
00641 #endif
00642 
00643 
00644 /* YYLEX -- calling `yylex' with the right arguments.  */
00645 
00646 #ifdef YYLEX_PARAM
00647 # define YYLEX yylex (YYLEX_PARAM)
00648 #else
00649 # define YYLEX yylex ()
00650 #endif
00651 
00652 /* Enable debugging if requested.  */
00653 #if YYDEBUG
00654 
00655 # ifndef YYFPRINTF
00656 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
00657 #  define YYFPRINTF fprintf
00658 # endif
00659 
00660 # define YYDPRINTF(Args)                        \
00661 do {                                            \
00662   if (yydebug)                                  \
00663     YYFPRINTF Args;                             \
00664 } while (YYID (0))
00665 
00666 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
00667 do {                                                                      \
00668   if (yydebug)                                                            \
00669     {                                                                     \
00670       YYFPRINTF (stderr, "%s ", Title);                                   \
00671       yy_symbol_print (stderr,                                            \
00672                   Type, Value); \
00673       YYFPRINTF (stderr, "\n");                                           \
00674     }                                                                     \
00675 } while (YYID (0))
00676 
00677 
00678 /*--------------------------------.
00679 | Print this symbol on YYOUTPUT.  |
00680 `--------------------------------*/
00681 
00682 /*ARGSUSED*/
00683 #if (defined __STDC__ || defined __C99__FUNC__ \
00684      || defined __cplusplus || defined _MSC_VER)
00685 static void
00686 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
00687 #else
00688 static void
00689 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
00690 FILE *yyoutput;
00691 int yytype;
00692 YYSTYPE const * const yyvaluep;
00693 #endif
00694 {
00695     if (!yyvaluep)
00696         return;
00697 # ifdef YYPRINT
00698     if (yytype < YYNTOKENS)
00699         YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
00700 # else
00701     YYUSE (yyoutput);
00702 # endif
00703     switch (yytype)
00704     {
00705     default:
00706         break;
00707     }
00708 }
00709 
00710 
00711 /*--------------------------------.
00712 | Print this symbol on YYOUTPUT.  |
00713 `--------------------------------*/
00714 
00715 #if (defined __STDC__ || defined __C99__FUNC__ \
00716      || defined __cplusplus || defined _MSC_VER)
00717 static void
00718 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
00719 #else
00720 static void
00721 yy_symbol_print (yyoutput, yytype, yyvaluep)
00722 FILE *yyoutput;
00723 int yytype;
00724 YYSTYPE const * const yyvaluep;
00725 #endif
00726 {
00727     if (yytype < YYNTOKENS)
00728         YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
00729     else
00730         YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
00731 
00732     yy_symbol_value_print (yyoutput, yytype, yyvaluep);
00733     YYFPRINTF (yyoutput, ")");
00734 }
00735 
00736 /*------------------------------------------------------------------.
00737 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
00738 | TOP (included).                                                   |
00739 `------------------------------------------------------------------*/
00740 
00741 #if (defined __STDC__ || defined __C99__FUNC__ \
00742      || defined __cplusplus || defined _MSC_VER)
00743 static void
00744 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
00745 #else
00746 static void
00747 yy_stack_print (bottom, top)
00748 yytype_int16 *bottom;
00749 yytype_int16 *top;
00750 #endif
00751 {
00752     YYFPRINTF (stderr, "Stack now");
00753     for (; bottom <= top; ++bottom)
00754         YYFPRINTF (stderr, " %d", *bottom);
00755     YYFPRINTF (stderr, "\n");
00756 }
00757 
00758 # define YY_STACK_PRINT(Bottom, Top)                            \
00759 do {                                                            \
00760   if (yydebug)                                                  \
00761     yy_stack_print ((Bottom), (Top));                           \
00762 } while (YYID (0))
00763 
00764 
00765 /*------------------------------------------------.
00766 | Report that the YYRULE is going to be reduced.  |
00767 `------------------------------------------------*/
00768 
00769 #if (defined __STDC__ || defined __C99__FUNC__ \
00770      || defined __cplusplus || defined _MSC_VER)
00771 static void
00772 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
00773 #else
00774 static void
00775 yy_reduce_print (yyvsp, yyrule)
00776 YYSTYPE *yyvsp;
00777 int yyrule;
00778 #endif
00779 {
00780     int yynrhs = yyr2[yyrule];
00781     int yyi;
00782     unsigned long int yylno = yyrline[yyrule];
00783     YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
00784                yyrule - 1, yylno);
00785     /* The symbols being reduced.  */
00786     for (yyi = 0; yyi < yynrhs; yyi++)
00787     {
00788         fprintf (stderr, "   $%d = ", yyi + 1);
00789         yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
00790                          &(yyvsp[(yyi + 1) - (yynrhs)])
00791                         );
00792         fprintf (stderr, "\n");
00793     }
00794 }
00795 
00796 # define YY_REDUCE_PRINT(Rule)          \
00797 do {                                    \
00798   if (yydebug)                          \
00799     yy_reduce_print (yyvsp, Rule); \
00800 } while (YYID (0))
00801 
00802 /* Nonzero means print parse trace.  It is left uninitialized so that
00803    multiple parsers can coexist.  */
00804 int yydebug;
00805 #else /* !YYDEBUG */
00806 # define YYDPRINTF(Args)
00807 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
00808 # define YY_STACK_PRINT(Bottom, Top)
00809 # define YY_REDUCE_PRINT(Rule)
00810 #endif /* !YYDEBUG */
00811 
00812 
00813 /* YYINITDEPTH -- initial size of the parser's stacks.  */
00814 #ifndef YYINITDEPTH
00815 # define YYINITDEPTH 200
00816 #endif
00817 
00818 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
00819    if the built-in stack extension method is used).
00820 
00821    Do not make this value too large; the results are undefined if
00822    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
00823    evaluated with infinite-precision integer arithmetic.  */
00824 
00825 #ifndef YYMAXDEPTH
00826 # define YYMAXDEPTH 10000
00827 #endif
00828 
00829 
00830 
00831 #if YYERROR_VERBOSE
00832 
00833 # ifndef yystrlen
00834 #  if defined __GLIBC__ && defined _STRING_H
00835 #   define yystrlen strlen
00836 #  else
00837 /* Return the length of YYSTR.  */
00838 #if (defined __STDC__ || defined __C99__FUNC__ \
00839      || defined __cplusplus || defined _MSC_VER)
00840 static YYSIZE_T
00841 yystrlen (const char *yystr)
00842 #else
00843 static YYSIZE_T
00844 yystrlen (yystr)
00845 const char *yystr;
00846 #endif
00847 {
00848     YYSIZE_T yylen;
00849     for (yylen = 0; yystr[yylen]; yylen++)
00850         continue;
00851     return yylen;
00852 }
00853 #  endif
00854 # endif
00855 
00856 # ifndef yystpcpy
00857 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
00858 #   define yystpcpy stpcpy
00859 #  else
00860 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
00861 YYDEST.  */
00862 #if (defined __STDC__ || defined __C99__FUNC__ \
00863      || defined __cplusplus || defined _MSC_VER)
00864 static char *
00865 yystpcpy (char *yydest, const char *yysrc)
00866 #else
00867 static char *
00868 yystpcpy (yydest, yysrc)
00869 char *yydest;
00870 const char *yysrc;
00871 #endif
00872 {
00873     char *yyd = yydest;
00874     const char *yys = yysrc;
00875 
00876     while ((*yyd++ = *yys++) != '\0')
00877         continue;
00878 
00879     return yyd - 1;
00880 }
00881 #  endif
00882 # endif
00883 
00884 # ifndef yytnamerr
00885 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
00886    quotes and backslashes, so that it's suitable for yyerror.  The
00887    heuristic is that double-quoting is unnecessary unless the string
00888    contains an apostrophe, a comma, or backslash (other than
00889    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
00890    null, do not copy; instead, return the length of what the result
00891    would have been.  */
00892 static YYSIZE_T
00893 yytnamerr (char *yyres, const char *yystr)
00894 {
00895     if (*yystr == '"')
00896     {
00897         YYSIZE_T yyn = 0;
00898         char const *yyp = yystr;
00899 
00900         for (;;)
00901             switch (*++yyp)
00902             {
00903             case '\'':
00904             case ',':
00905                 goto do_not_strip_quotes;
00906 
00907             case '\\':
00908                 if (*++yyp != '\\')
00909                     goto do_not_strip_quotes;
00910                 /* Fall through.  */
00911             default:
00912                 if (yyres)
00913                     yyres[yyn] = *yyp;
00914                 yyn++;
00915                 break;
00916 
00917             case '"':
00918                 if (yyres)
00919                     yyres[yyn] = '\0';
00920                 return yyn;
00921             }
00922 do_not_strip_quotes: ;
00923     }
00924 
00925     if (! yyres)
00926         return yystrlen (yystr);
00927 
00928     return yystpcpy (yyres, yystr) - yyres;
00929 }
00930 # endif
00931 
00932 /* Copy into YYRESULT an error message about the unexpected token
00933    YYCHAR while in state YYSTATE.  Return the number of bytes copied,
00934    including the terminating null byte.  If YYRESULT is null, do not
00935    copy anything; just return the number of bytes that would be
00936    copied.  As a special case, return 0 if an ordinary "syntax error"
00937    message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
00938    size calculation.  */
00939 static YYSIZE_T
00940 yysyntax_error (char *yyresult, int yystate, int yychar)
00941 {
00942     int yyn = yypact[yystate];
00943 
00944     if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
00945         return 0;
00946     else
00947     {
00948         int yytype = YYTRANSLATE (yychar);
00949         YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
00950         YYSIZE_T yysize = yysize0;
00951         YYSIZE_T yysize1;
00952         int yysize_overflow = 0;
00953         enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
00954         char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
00955         int yyx;
00956 
00957 # if 0
00958         /* This is so xgettext sees the translatable formats that are
00959         constructed on the fly.  */
00960         YY_("syntax error, unexpected %s");
00961         YY_("syntax error, unexpected %s, expecting %s");
00962         YY_("syntax error, unexpected %s, expecting %s or %s");
00963         YY_("syntax error, unexpected %s, expecting %s or %s or %s");
00964         YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
00965 # endif
00966         char *yyfmt;
00967         char const *yyf;
00968         static char const yyunexpected[] = "syntax error, unexpected %s";
00969         static char const yyexpecting[] = ", expecting %s";
00970         static char const yyor[] = " or %s";
00971         char yyformat[sizeof yyunexpected
00972                       + sizeof yyexpecting - 1
00973                       + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
00974                          * (sizeof yyor - 1))];
00975         char const *yyprefix = yyexpecting;
00976 
00977         /* Start YYX at -YYN if negative to avoid negative indexes in
00978         YYCHECK.  */
00979         int yyxbegin = yyn < 0 ? -yyn : 0;
00980 
00981         /* Stay within bounds of both yycheck and yytname.  */
00982         int yychecklim = YYLAST - yyn + 1;
00983         int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
00984         int yycount = 1;
00985 
00986         yyarg[0] = yytname[yytype];
00987         yyfmt = yystpcpy (yyformat, yyunexpected);
00988 
00989         for (yyx = yyxbegin; yyx < yyxend; ++yyx)
00990             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
00991             {
00992                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
00993                 {
00994                     yycount = 1;
00995                     yysize = yysize0;
00996                     yyformat[sizeof yyunexpected - 1] = '\0';
00997                     break;
00998                 }
00999                 yyarg[yycount++] = yytname[yyx];
01000                 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
01001                 yysize_overflow |= (yysize1 < yysize);
01002                 yysize = yysize1;
01003                 yyfmt = yystpcpy (yyfmt, yyprefix);
01004                 yyprefix = yyor;
01005             }
01006 
01007         yyf = YY_(yyformat);
01008         yysize1 = yysize + yystrlen (yyf);
01009         yysize_overflow |= (yysize1 < yysize);
01010         yysize = yysize1;
01011 
01012         if (yysize_overflow)
01013             return YYSIZE_MAXIMUM;
01014 
01015         if (yyresult)
01016         {
01017             /* Avoid sprintf, as that infringes on the user's name space.
01018                Don't have undefined behavior even if the translation
01019                produced a string with the wrong number of "%s"s.  */
01020             char *yyp = yyresult;
01021             int yyi = 0;
01022             while ((*yyp = *yyf) != '\0')
01023             {
01024                 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
01025                 {
01026                     yyp += yytnamerr (yyp, yyarg[yyi++]);
01027                     yyf += 2;
01028                 }
01029                 else
01030                 {
01031                     yyp++;
01032                     yyf++;
01033                 }
01034             }
01035         }
01036         return yysize;
01037     }
01038 }
01039 #endif /* YYERROR_VERBOSE */
01040 
01041 
01042 /*-----------------------------------------------.
01043 | Release the memory associated to this symbol.  |
01044 `-----------------------------------------------*/
01045 
01046 /*ARGSUSED*/
01047 #if (defined __STDC__ || defined __C99__FUNC__ \
01048      || defined __cplusplus || defined _MSC_VER)
01049 static void
01050 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
01051 #else
01052 static void
01053 yydestruct (yymsg, yytype, yyvaluep)
01054 const char *yymsg;
01055 int yytype;
01056 YYSTYPE *yyvaluep;
01057 #endif
01058 {
01059     YYUSE (yyvaluep);
01060 
01061     if (!yymsg)
01062         yymsg = "Deleting";
01063     YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
01064 
01065     switch (yytype)
01066     {
01067     case 4: /* "tSTRING" */
01068 #line 37 "vParser.ypp"
01069         {
01070             delete (yyvaluep->string);
01071         };
01072 #line 1073 "vParser.cpp"
01073         break;
01074     case 5: /* "tID" */
01075 #line 37 "vParser.ypp"
01076         {
01077             delete (yyvaluep->string);
01078         };
01079 #line 1080 "vParser.cpp"
01080         break;
01081     case 24: /* "expr" */
01082 #line 37 "vParser.ypp"
01083         {
01084             delete (yyvaluep->expr);
01085         };
01086 #line 1087 "vParser.cpp"
01087         break;
01088     case 25: /* "function" */
01089 #line 37 "vParser.ypp"
01090         {
01091             delete (yyvaluep->expr);
01092         };
01093 #line 1094 "vParser.cpp"
01094         break;
01095 
01096     default:
01097         break;
01098     }
01099 }
01100 
01101 
01102 /* Prevent warnings from -Wmissing-prototypes.  */
01103 
01104 #ifdef YYPARSE_PARAM
01105 #if defined __STDC__ || defined __cplusplus
01106 int yyparse (void *YYPARSE_PARAM);
01107 #else
01108 int yyparse ();
01109 #endif
01110 #else /* ! YYPARSE_PARAM */
01111 #if defined __STDC__ || defined __cplusplus
01112 int yyparse (void);
01113 #else
01114 int yyparse ();
01115 #endif
01116 #endif /* ! YYPARSE_PARAM */
01117 
01118 
01119 
01120 /* The look-ahead symbol.  */
01121 int yychar;
01122 
01123 /* The semantic value of the look-ahead symbol.  */
01124 YYSTYPE yylval;
01125 
01126 /* Number of syntax errors so far.  */
01127 int yynerrs;
01128 
01129 
01130 
01131 /*----------.
01132 | yyparse.  |
01133 `----------*/
01134 
01135 #ifdef YYPARSE_PARAM
01136 #if (defined __STDC__ || defined __C99__FUNC__ \
01137      || defined __cplusplus || defined _MSC_VER)
01138 int
01139 yyparse (void *YYPARSE_PARAM)
01140 #else
01141 int
01142 yyparse (YYPARSE_PARAM)
01143 void *YYPARSE_PARAM;
01144 #endif
01145 #else /* ! YYPARSE_PARAM */
01146 #if (defined __STDC__ || defined __C99__FUNC__ \
01147      || defined __cplusplus || defined _MSC_VER)
01148 int
01149 yyparse (void)
01150 #else
01151 int
01152 yyparse ()
01153 
01154 #endif
01155 #endif
01156 {
01157 
01158     int yystate;
01159     int yyn;
01160     int yyresult;
01161     /* Number of tokens to shift before error messages enabled.  */
01162     int yyerrstatus;
01163     /* Look-ahead token as an internal (translated) token number.  */
01164     int yytoken = 0;
01165 #if YYERROR_VERBOSE
01166     /* Buffer for error messages, and its allocated size.  */
01167     char yymsgbuf[128];
01168     char *yymsg = yymsgbuf;
01169     YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
01170 #endif
01171 
01172     /* Three stacks and their tools:
01173        `yyss': related to states,
01174        `yyvs': related to semantic values,
01175        `yyls': related to locations.
01176 
01177        Refer to the stacks thru separate pointers, to allow yyoverflow
01178        to reallocate them elsewhere.  */
01179 
01180     /* The state stack.  */
01181     yytype_int16 yyssa[YYINITDEPTH];
01182     yytype_int16 *yyss = yyssa;
01183     yytype_int16 *yyssp;
01184 
01185     /* The semantic value stack.  */
01186     YYSTYPE yyvsa[YYINITDEPTH];
01187     YYSTYPE *yyvs = yyvsa;
01188     YYSTYPE *yyvsp;
01189 
01190 
01191 
01192 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
01193 
01194     YYSIZE_T yystacksize = YYINITDEPTH;
01195 
01196     /* The variables used to return semantic value and location from the
01197        action routines.  */
01198     YYSTYPE yyval;
01199 
01200 
01201     /* The number of symbols on the RHS of the reduced rule.
01202        Keep to zero when no symbol should be popped.  */
01203     int yylen = 0;
01204 
01205     YYDPRINTF ((stderr, "Starting parse\n"));
01206 
01207     yystate = 0;
01208     yyerrstatus = 0;
01209     yynerrs = 0;
01210     yychar = YYEMPTY;           /* Cause a token to be read.  */
01211 
01212     /* Initialize stack pointers.
01213        Waste one element of value and location stack
01214        so that they stay on the same level as the state stack.
01215        The wasted elements are never initialized.  */
01216 
01217     yyssp = yyss;
01218     yyvsp = yyvs;
01219 
01220     goto yysetstate;
01221 
01222     /*------------------------------------------------------------.
01223     | yynewstate -- Push a new state, which is found in yystate.  |
01224     `------------------------------------------------------------*/
01225 yynewstate:
01226     /* In all cases, when you get here, the value and location stacks
01227        have just been pushed.  So pushing a state here evens the stacks.  */
01228     yyssp++;
01229 
01230 yysetstate:
01231     *yyssp = yystate;
01232 
01233     if (yyss + yystacksize - 1 <= yyssp)
01234     {
01235         /* Get the current used size of the three stacks, in elements.  */
01236         YYSIZE_T yysize = yyssp - yyss + 1;
01237 
01238 #ifdef yyoverflow
01239         {
01240             /* Give user a chance to reallocate the stack.  Use copies of
01241                these so that the &'s don't force the real ones into
01242                memory.  */
01243             YYSTYPE *yyvs1 = yyvs;
01244             yytype_int16 *yyss1 = yyss;
01245 
01246 
01247             /* Each stack pointer address is followed by the size of the
01248                data in use in that stack, in bytes.  This used to be a
01249                conditional around just the two extra args, but that might
01250                be undefined if yyoverflow is a macro.  */
01251             yyoverflow (YY_("memory exhausted"),
01252                         &yyss1, yysize * sizeof (*yyssp),
01253                         &yyvs1, yysize * sizeof (*yyvsp),
01254 
01255                         &yystacksize);
01256 
01257             yyss = yyss1;
01258             yyvs = yyvs1;
01259         }
01260 #else /* no yyoverflow */
01261 # ifndef YYSTACK_RELOCATE
01262         goto yyexhaustedlab;
01263 # else
01264         /* Extend the stack our own way.  */
01265         if (YYMAXDEPTH <= yystacksize)
01266             goto yyexhaustedlab;
01267         yystacksize *= 2;
01268         if (YYMAXDEPTH < yystacksize)
01269             yystacksize = YYMAXDEPTH;
01270 
01271         {
01272             yytype_int16 *yyss1 = yyss;
01273             union yyalloc *yyptr =
01274                             (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
01275             if (! yyptr)
01276                 goto yyexhaustedlab;
01277             YYSTACK_RELOCATE (yyss);
01278             YYSTACK_RELOCATE (yyvs);
01279 
01280 #  undef YYSTACK_RELOCATE
01281             if (yyss1 != yyssa)
01282                 YYSTACK_FREE (yyss1);
01283         }
01284 # endif
01285 #endif /* no yyoverflow */
01286 
01287         yyssp = yyss + yysize - 1;
01288         yyvsp = yyvs + yysize - 1;
01289 
01290 
01291         YYDPRINTF ((stderr, "Stack size increased to %lu\n",
01292                     (unsigned long int) yystacksize));
01293 
01294         if (yyss + yystacksize - 1 <= yyssp)
01295             YYABORT;
01296     }
01297 
01298     YYDPRINTF ((stderr, "Entering state %d\n", yystate));
01299 
01300     goto yybackup;
01301 
01302     /*-----------.
01303     | yybackup.  |
01304     `-----------*/
01305 yybackup:
01306 
01307     /* Do appropriate processing given the current state.  Read a
01308        look-ahead token if we need one and don't already have one.  */
01309 
01310     /* First try to decide what to do without reference to look-ahead token.  */
01311     yyn = yypact[yystate];
01312     if (yyn == YYPACT_NINF)
01313         goto yydefault;
01314 
01315     /* Not known => get a look-ahead token if don't already have one.  */
01316 
01317     /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
01318     if (yychar == YYEMPTY)
01319     {
01320         YYDPRINTF ((stderr, "Reading a token: "));
01321         yychar = YYLEX;
01322     }
01323 
01324     if (yychar <= YYEOF)
01325     {
01326         yychar = yytoken = YYEOF;
01327         YYDPRINTF ((stderr, "Now at end of input.\n"));
01328     }
01329     else
01330     {
01331         yytoken = YYTRANSLATE (yychar);
01332         YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
01333     }
01334 
01335     /* If the proper action on seeing token YYTOKEN is to reduce or to
01336        detect an error, take that action.  */
01337     yyn += yytoken;
01338     if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
01339         goto yydefault;
01340     yyn = yytable[yyn];
01341     if (yyn <= 0)
01342     {
01343         if (yyn == 0 || yyn == YYTABLE_NINF)
01344             goto yyerrlab;
01345         yyn = -yyn;
01346         goto yyreduce;
01347     }
01348 
01349     if (yyn == YYFINAL)
01350         YYACCEPT;
01351 
01352     /* Count tokens shifted since error; after three, turn off error
01353        status.  */
01354     if (yyerrstatus)
01355         yyerrstatus--;
01356 
01357     /* Shift the look-ahead token.  */
01358     YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
01359 
01360     /* Discard the shifted token unless it is eof.  */
01361     if (yychar != YYEOF)
01362         yychar = YYEMPTY;
01363 
01364     yystate = yyn;
01365     *++yyvsp = yylval;
01366 
01367     goto yynewstate;
01368 
01369 
01370     /*-----------------------------------------------------------.
01371     | yydefault -- do the default action for the current state.  |
01372     `-----------------------------------------------------------*/
01373 yydefault:
01374     yyn = yydefact[yystate];
01375     if (yyn == 0)
01376         goto yyerrlab;
01377     goto yyreduce;
01378 
01379 
01380     /*-----------------------------.
01381     | yyreduce -- Do a reduction.  |
01382     `-----------------------------*/
01383 yyreduce:
01384     /* yyn is the number of a rule to reduce with.  */
01385     yylen = yyr2[yyn];
01386 
01387     /* If YYLEN is nonzero, implement the default value of the action:
01388        `$$ = $1'.
01389 
01390        Otherwise, the following line sets YYVAL to garbage.
01391        This behavior is undocumented and Bison
01392        users should not rely upon it.  Assigning to YYVAL
01393        unconditionally makes the parser a bit smaller, and it avoids a
01394        GCC warning that YYVAL may be used uninitialized.  */
01395     yyval = yyvsp[1-yylen];
01396 
01397 
01398     YY_REDUCE_PRINT (yyn);
01399     switch (yyn)
01400     {
01401     case 2:
01402 #line 56 "vParser.ypp"
01403         {
01404             rv = (yyvsp[(1) - (1)].expr);
01405         }
01406         break;
01407 
01408     case 3:
01409 #line 82 "vParser.ypp"
01410         {
01411             (yyval.expr) = new Expr::Int((yyvsp[(1) - (1)].integer));
01412         }
01413         break;
01414 
01415     case 4:
01416 #line 87 "vParser.ypp"
01417         {
01418             (yyval.expr) = new Expr::String(*(yyvsp[(1) - (1)].string));
01419             delete (yyvsp[(1) - (1)].string);
01420         }
01421         break;
01422 
01423     case 6:
01424 #line 93 "vParser.ypp"
01425         {
01426             (yyval.expr) = new Expr::Math::Add(BasePtr((yyvsp[(1) - (3)].expr)), BasePtr((yyvsp[(3) - (3)].expr)));
01427         }
01428         break;
01429 
01430     case 7:
01431 #line 97 "vParser.ypp"
01432         {
01433             (yyval.expr) = new Expr::Math::Subtract(BasePtr((yyvsp[(1) - (3)].expr)), BasePtr((yyvsp[(3) - (3)].expr)));
01434         }
01435         break;
01436 
01437     case 8:
01438 #line 101 "vParser.ypp"
01439         {
01440             (yyval.expr) = new Expr::Math::Multiply(BasePtr((yyvsp[(1) - (3)].expr)), BasePtr((yyvsp[(3) - (3)].expr)));
01441         }
01442         break;
01443 
01444     case 9:
01445 #line 105 "vParser.ypp"
01446         {
01447             (yyval.expr) = new Expr::Math::Divide(BasePtr((yyvsp[(1) - (3)].expr)), BasePtr((yyvsp[(3) - (3)].expr)));
01448         }
01449         break;
01450 
01451     case 10:
01452 #line 109 "vParser.ypp"
01453         {
01454             (yyval.expr) = new Expr::Comparison::Compare(BasePtr((yyvsp[(1) - (3)].expr)), BasePtr((yyvsp[(3) - (3)].expr)));
01455         }
01456         break;
01457 
01458     case 11:
01459 #line 113 "vParser.ypp"
01460         {
01461             static BasePtr zero(new Expr::Int(0));
01462             (yyval.expr) = new Expr::Math::Subtract(zero, BasePtr((yyvsp[(2) - (2)].expr)));
01463         }
01464         break;
01465 
01466     case 12:
01467 #line 118 "vParser.ypp"
01468         {
01469             (yyval.expr) = (yyvsp[(2) - (3)].expr);
01470         }
01471         break;
01472 
01473     case 13:
01474 #line 126 "vParser.ypp"
01475         {
01476             std::vector<tString> flags;
01477             flags.push_back(tString("func"));
01478             (yyval.expr) = Registry::Registry::theRegistry().create(flags, *(yyvsp[(1) - (4)].string), *(yyvsp[(3) - (4)].arglist));
01479             delete (yyvsp[(1) - (4)].string);
01480             delete (yyvsp[(3) - (4)].arglist);
01481         }
01482         break;
01483 
01484     case 15:
01485 #line 137 "vParser.ypp"
01486         {
01487             (yyval.arglist) = new arglist();
01488         }
01489         break;
01490 
01491     case 16:
01492 #line 141 "vParser.ypp"
01493         {
01494             (yyval.arglist) = new arglist();
01495             (yyval.arglist)->push_back(BasePtr((yyvsp[(1) - (1)].expr)));
01496         }
01497         break;
01498 
01499     case 17:
01500 #line 146 "vParser.ypp"
01501         {
01502             (yyval.arglist) = (yyvsp[(1) - (3)].arglist);
01503             (yyval.arglist)->push_back(BasePtr((yyvsp[(3) - (3)].expr)));
01504         }
01505         break;
01506 
01507 
01508         /* Line 1267 of yacc.c.  */
01509 #line 1510 "vParser.cpp"
01510     default: break;
01511     }
01512     YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
01513 
01514     YYPOPSTACK (yylen);
01515     yylen = 0;
01516     YY_STACK_PRINT (yyss, yyssp);
01517 
01518     *++yyvsp = yyval;
01519 
01520 
01521     /* Now `shift' the result of the reduction.  Determine what state
01522        that goes to, based on the state we popped back to and the rule
01523        number reduced by.  */
01524 
01525     yyn = yyr1[yyn];
01526 
01527     yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
01528     if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
01529         yystate = yytable[yystate];
01530     else
01531         yystate = yydefgoto[yyn - YYNTOKENS];
01532 
01533     goto yynewstate;
01534 
01535 
01536     /*------------------------------------.
01537     | yyerrlab -- here on detecting error |
01538     `------------------------------------*/
01539 yyerrlab:
01540     /* If not already recovering from an error, report this error.  */
01541     if (!yyerrstatus)
01542     {
01543         ++yynerrs;
01544 #if ! YYERROR_VERBOSE
01545         yyerror (YY_("syntax error"));
01546 #else
01547         {
01548             YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
01549             if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
01550             {
01551                 YYSIZE_T yyalloc = 2 * yysize;
01552                 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
01553                     yyalloc = YYSTACK_ALLOC_MAXIMUM;
01554                 if (yymsg != yymsgbuf)
01555                     YYSTACK_FREE (yymsg);
01556                 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
01557                 if (yymsg)
01558                     yymsg_alloc = yyalloc;
01559                 else
01560                 {
01561                     yymsg = yymsgbuf;
01562                     yymsg_alloc = sizeof yymsgbuf;
01563                 }
01564             }
01565 
01566             if (0 < yysize && yysize <= yymsg_alloc)
01567             {
01568                 (void) yysyntax_error (yymsg, yystate, yychar);
01569                 yyerror (yymsg);
01570             }
01571             else
01572             {
01573                 yyerror (YY_("syntax error"));
01574                 if (yysize != 0)
01575                     goto yyexhaustedlab;
01576             }
01577         }
01578 #endif
01579     }
01580 
01581 
01582 
01583     if (yyerrstatus == 3)
01584     {
01585         /* If just tried and failed to reuse look-ahead token after an
01586         error, discard it.  */
01587 
01588         if (yychar <= YYEOF)
01589         {
01590             /* Return failure if at end of input.  */
01591             if (yychar == YYEOF)
01592                 YYABORT;
01593         }
01594         else
01595         {
01596             yydestruct ("Error: discarding",
01597                         yytoken, &yylval);
01598             yychar = YYEMPTY;
01599         }
01600     }
01601 
01602     /* Else will try to reuse look-ahead token after shifting the error
01603        token.  */
01604     goto yyerrlab1;
01605 
01606 
01607     /*---------------------------------------------------.
01608     | yyerrorlab -- error raised explicitly by YYERROR.  |
01609     `---------------------------------------------------*/
01610 yyerrorlab:
01611 
01612     /* Pacify compilers like GCC when the user code never invokes
01613        YYERROR and the label yyerrorlab therefore never appears in user
01614        code.  */
01615     if (/*CONSTCOND*/ 0)
01616         goto yyerrorlab;
01617 
01618     /* Do not reclaim the symbols of the rule which action triggered
01619        this YYERROR.  */
01620     YYPOPSTACK (yylen);
01621     yylen = 0;
01622     YY_STACK_PRINT (yyss, yyssp);
01623     yystate = *yyssp;
01624     goto yyerrlab1;
01625 
01626 
01627     /*-------------------------------------------------------------.
01628     | yyerrlab1 -- common code for both syntax error and YYERROR.  |
01629     `-------------------------------------------------------------*/
01630 yyerrlab1:
01631     yyerrstatus = 3;    /* Each real token shifted decrements this.  */
01632 
01633     for (;;)
01634     {
01635         yyn = yypact[yystate];
01636         if (yyn != YYPACT_NINF)
01637         {
01638             yyn += YYTERROR;
01639             if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
01640             {
01641                 yyn = yytable[yyn];
01642                 if (0 < yyn)
01643                     break;
01644             }
01645         }
01646 
01647         /* Pop the current state because it cannot handle the error token.  */
01648         if (yyssp == yyss)
01649             YYABORT;
01650 
01651 
01652         yydestruct ("Error: popping",
01653                     yystos[yystate], yyvsp);
01654         YYPOPSTACK (1);
01655         yystate = *yyssp;
01656         YY_STACK_PRINT (yyss, yyssp);
01657     }
01658 
01659     if (yyn == YYFINAL)
01660         YYACCEPT;
01661 
01662     *++yyvsp = yylval;
01663 
01664 
01665     /* Shift the error token.  */
01666     YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
01667 
01668     yystate = yyn;
01669     goto yynewstate;
01670 
01671 
01672     /*-------------------------------------.
01673     | yyacceptlab -- YYACCEPT comes here.  |
01674     `-------------------------------------*/
01675 yyacceptlab:
01676     yyresult = 0;
01677     goto yyreturn;
01678 
01679     /*-----------------------------------.
01680     | yyabortlab -- YYABORT comes here.  |
01681     `-----------------------------------*/
01682 yyabortlab:
01683     yyresult = 1;
01684     goto yyreturn;
01685 
01686 #ifndef yyoverflow
01687     /*-------------------------------------------------.
01688     | yyexhaustedlab -- memory exhaustion comes here.  |
01689     `-------------------------------------------------*/
01690 yyexhaustedlab:
01691     yyerror (YY_("memory exhausted"));
01692     yyresult = 2;
01693     /* Fall through.  */
01694 #endif
01695 
01696 yyreturn:
01697             if (yychar != YYEOF && yychar != YYEMPTY)
01698                 yydestruct ("Cleanup: discarding lookahead",
01699                             yytoken, &yylval);
01700     /* Do not reclaim the symbols of the rule which action triggered
01701        this YYABORT or YYACCEPT.  */
01702     YYPOPSTACK (yylen);
01703     YY_STACK_PRINT (yyss, yyssp);
01704     while (yyssp != yyss)
01705     {
01706         yydestruct ("Cleanup: popping",
01707                     yystos[*yyssp], yyvsp);
01708         YYPOPSTACK (1);
01709     }
01710 #ifndef yyoverflow
01711     if (yyss != yyssa)
01712         YYSTACK_FREE (yyss);
01713 #endif
01714 #if YYERROR_VERBOSE
01715     if (yymsg != yymsgbuf)
01716         YYSTACK_FREE (yymsg);
01717 #endif
01718     /* Make sure YYID is used.  */
01719     return YYID (yyresult);
01720 }
01721 
01722 
01723 #line 151 "vParser.ypp"
01724 
01725 
01726 #if tCodeParser_STANDALONE
01727 int
01728 main(void)
01729 {
01730     return yyparse();
01731 }
01732 
01733 #define lex_getc        getchar
01734 #define lex_ungetc(c)   ungetc(c, stdin)
01735 #else
01736 tString in;
01737 int pos, buffer;
01738 
01739 Expr::Base *
01740 vValue::Parser::parse(tString s)
01741 {
01742     pos = 0;
01743     buffer = -1;
01744     in = s;
01745     if (!yyparse())
01746         return rv;
01747     return NULL;
01748 }
01749 
01750 int
01751 lex_getc(void)
01752 {
01753     if (buffer != -1)
01754     {
01755         int r = buffer;
01756         buffer = -1;
01757         return r;
01758     }
01759 
01760     if ((unsigned int)pos >= in.size())
01761         return EOF;
01762     return in[pos++];
01763 }
01764 
01765 static void
01766 lex_ungetc(int c)
01767 {
01768     assert(buffer == -1);
01769     buffer = c;
01770 }
01771 #endif
01772 
01773 void
01774 yyerror(const char *s)
01775 {
01776     //puts(s);
01777     //exit(1);
01778     tString msg("vValue parse error: ");
01779     msg << s;
01780     tERR_ERROR(msg);
01781 }
01782 
01783 static bool
01784 follow(int expect)
01785 {
01786     int c = lex_getc();
01787 
01788     if (c == expect)
01789         return true;
01790     lex_ungetc(c);
01791     return false;
01792 }
01793 
01794 int
01795 yylex(void)
01796 {
01797     int c;
01798 
01799     /* Skip white space.  */
01800     while (isspace(c = lex_getc()))
01801 #ifdef tCodeParser_STANDALONE
01802         if (c == '\n')
01803             return c;
01804 #endif
01805     ;
01806 
01807     if (c == EOF)
01808         return 0;
01809 
01810     if (isdigit(c))
01811     {
01812         int n = 0;
01813 
01814         for ( ; isdigit(c); c = lex_getc())
01815             n = (n * 10) + (c - '0');
01816         lex_ungetc(c);
01817         yylval.integer = n;
01818         return tINTEGER;
01819     }
01820 
01821     if (isalpha(c))
01822     {
01823         tString *s = new tString;
01824         for ( ; isalnum(c); c = lex_getc())
01825             *s += (char)c;
01826         lex_ungetc(c);
01827         yylval.string = s;
01828         return tID;
01829     }
01830 
01831     if (c == '"')
01832     {
01833         tString *s = new tString;
01834         while ('"' != (c = lex_getc()))
01835         {
01836             switch (c) {
01837             case EOF:
01838                 yyerror("Missing quote! wtf?");
01839                 break;
01840             case '\\':
01841                 // Supported only to escape another backslash or quote
01842                 // in the future, this should handle \n and co
01843                 c = lex_getc();
01844                 break;
01845             }
01846             (*s) += (char)c;
01847         }
01848         yylval.string = s;
01849         return tSTRING;
01850     }
01851 
01852     switch (c) {
01853     case '<':
01854         if (follow('='))
01855         {
01856             if (follow('>'))
01857                 return tCOMPARE;
01858             else
01859                 return tLE;
01860         }
01861         break;
01862     }
01863 
01864     return c;
01865 }
01866 

Generated on Sat Mar 15 22:56:14 2008 for Armagetron Advanced by  doxygen 1.5.4