STYLE: Nightly Date Stamp
[cmake.git] / Source / cmExprParser.cxx
blob86ee6319ac2ad71f3aaff44c7ab34ae0fc182454
1 /* A Bison parser, made by GNU Bison 1.875d. */
3 /* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984,
4 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
26 /* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
29 /* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
36 /* turn off some warning as this is generated code */
37 #if defined(_MSC_VER)
38 # pragma warning ( disable : 4702 ) /* unreachable code */
39 #endif
41 /* Identify Bison output. */
42 #define YYBISON 1
44 /* Skeleton name. */
45 #define YYSKELETON_NAME "yacc.c"
47 /* Pure parsers. */
48 #define YYPURE 1
50 /* Using locations. */
51 #define YYLSP_NEEDED 0
53 /* If NAME_PREFIX is specified substitute the variables and functions
54 names. */
55 #define yyparse cmExpr_yyparse
56 #define yylex cmExpr_yylex
57 #define yyerror cmExpr_yyerror
58 #define yylval cmExpr_yylval
59 #define yychar cmExpr_yychar
60 #define yydebug cmExpr_yydebug
61 #define yynerrs cmExpr_yynerrs
64 /* Tokens. */
65 #ifndef YYTOKENTYPE
66 # define YYTOKENTYPE
67 /* Put the tokens into the symbol table, so that GDB and other debuggers
68 know about them. */
69 enum yytokentype {
70 exp_PLUS = 258,
71 exp_MINUS = 259,
72 exp_TIMES = 260,
73 exp_DIVIDE = 261,
74 exp_MOD = 262,
75 exp_SHIFTLEFT = 263,
76 exp_SHIFTRIGHT = 264,
77 exp_OPENPARENT = 265,
78 exp_CLOSEPARENT = 266,
79 exp_OR = 267,
80 exp_AND = 268,
81 exp_XOR = 269,
82 exp_NOT = 270,
83 exp_NUMBER = 271
85 #endif
86 #define exp_PLUS 258
87 #define exp_MINUS 259
88 #define exp_TIMES 260
89 #define exp_DIVIDE 261
90 #define exp_MOD 262
91 #define exp_SHIFTLEFT 263
92 #define exp_SHIFTRIGHT 264
93 #define exp_OPENPARENT 265
94 #define exp_CLOSEPARENT 266
95 #define exp_OR 267
96 #define exp_AND 268
97 #define exp_XOR 269
98 #define exp_NOT 270
99 #define exp_NUMBER 271
104 /* Copy the first part of user declarations. */
107 /*=========================================================================
109 Program: CMake - Cross-Platform Makefile Generator
110 Module: $RCSfile: cmExprParser.cxx,v $
111 Language: C++
112 Date: $Date: 2007-03-05 15:36:06 $
113 Version: $Revision: 1.6 $
115 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
116 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
118 This software is distributed WITHOUT ANY WARRANTY; without even
119 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
120 PURPOSE. See the above copyright notices for more information.
122 =========================================================================*/
125 This file must be translated to C and modified to build everywhere.
127 Run bison like this:
129 bison --yacc --name-prefix=cmExpr_yy --defines=cmExprParserTokens.h
130 -ocmExprParser.cxx cmExprParser.y
132 Modify cmExprParser.cxx:
133 - remove TABs
134 - add __HP_aCC to the #if test for yyerrorlab warning suppression
138 /* Configure the parser to use a lexer object. */
139 #define YYPARSE_PARAM yyscanner
140 #define YYLEX_PARAM yyscanner
141 #define YYERROR_VERBOSE 1
142 #define cmExpr_yyerror(x) \
143 cmExprError(yyscanner, x)
144 #define yyGetParser (cmExpr_yyget_extra(yyscanner))
146 /*-------------------------------------------------------------------------*/
147 #include "cmExprParserHelper.h" /* Interface to parser object. */
148 #include "cmExprLexer.h" /* Interface to lexer object. */
149 #include "cmExprParserTokens.h" /* Need YYSTYPE for YY_DECL. */
151 #include <math.h>
153 /* Forward declare the lexer entry point. */
154 YY_DECL;
156 /* Internal utility functions. */
157 static void cmExprError(yyscan_t yyscanner, const char* message);
159 #define YYDEBUG 1
160 //#define YYMAXDEPTH 100000
161 //#define YYINITDEPTH 10000
164 /* Disable some warnings in the generated code. */
165 #ifdef __BORLANDC__
166 # pragma warn -8004 /* Variable assigned a value that is not used. */
167 # pragma warn -8008 /* condition always returns true */
168 # pragma warn -8060 /* possibly incorrect assignment */
169 # pragma warn -8066 /* unreachable code */
170 #endif
171 #ifdef _MSC_VER
172 # pragma warning (disable: 4102) /* Unused goto label. */
173 # pragma warning (disable: 4065) /* Switch statement contains default but
174 no case. */
175 #endif
178 /* Enabling traces. */
179 #ifndef YYDEBUG
180 # define YYDEBUG 0
181 #endif
183 /* Enabling verbose error messages. */
184 #ifdef YYERROR_VERBOSE
185 # undef YYERROR_VERBOSE
186 # define YYERROR_VERBOSE 1
187 #else
188 # define YYERROR_VERBOSE 0
189 #endif
191 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
192 typedef int YYSTYPE;
193 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
194 # define YYSTYPE_IS_DECLARED 1
195 # define YYSTYPE_IS_TRIVIAL 1
196 #endif
200 /* Copy the second part of user declarations. */
203 /* Line 214 of yacc.c. */
206 #if ! defined (yyoverflow) || YYERROR_VERBOSE
208 # ifndef YYFREE
209 # define YYFREE free
210 # endif
211 # ifndef YYMALLOC
212 # define YYMALLOC malloc
213 # endif
215 /* The parser invokes alloca or malloc; define the necessary symbols. */
217 # ifdef YYSTACK_USE_ALLOCA
218 # if YYSTACK_USE_ALLOCA
219 # define YYSTACK_ALLOC alloca
220 # endif
221 # else
222 # if defined (alloca) || defined (_ALLOCA_H)
223 # define YYSTACK_ALLOC alloca
224 # else
225 # ifdef __GNUC__
226 # define YYSTACK_ALLOC __builtin_alloca
227 # endif
228 # endif
229 # endif
231 # ifdef YYSTACK_ALLOC
232 /* Pacify GCC's `empty if-body' warning. */
233 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
234 # else
235 # if defined (__STDC__) || defined (__cplusplus)
236 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
237 # define YYSIZE_T size_t
238 # endif
239 # define YYSTACK_ALLOC YYMALLOC
240 # define YYSTACK_FREE YYFREE
241 # endif
242 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
245 #if (! defined (yyoverflow) \
246 && (! defined (__cplusplus) \
247 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
249 /* A type that is properly aligned for any stack member. */
250 union yyalloc
252 short int yyss;
253 YYSTYPE yyvs;
256 /* The size of the maximum gap between one aligned stack and the next. */
257 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
259 /* The size of an array large to enough to hold all stacks, each with
260 N elements. */
261 # define YYSTACK_BYTES(N) \
262 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
263 + YYSTACK_GAP_MAXIMUM)
265 /* Copy COUNT objects from FROM to TO. The source and destination do
266 not overlap. */
267 # ifndef YYCOPY
268 # if defined (__GNUC__) && 1 < __GNUC__
269 # define YYCOPY(To, From, Count) \
270 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
271 # else
272 # define YYCOPY(To, From, Count) \
273 do \
275 register YYSIZE_T yyi; \
276 for (yyi = 0; yyi < (Count); yyi++) \
277 (To)[yyi] = (From)[yyi]; \
279 while (0)
280 # endif
281 # endif
283 /* Relocate STACK from its old location to the new one. The
284 local variables YYSIZE and YYSTACKSIZE give the old and new number of
285 elements in the stack, and YYPTR gives the new location of the
286 stack. Advance YYPTR to a properly aligned location for the next
287 stack. */
288 # define YYSTACK_RELOCATE(Stack) \
289 do \
291 YYSIZE_T yynewbytes; \
292 YYCOPY (&yyptr->Stack, Stack, yysize); \
293 Stack = &yyptr->Stack; \
294 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
295 yyptr += yynewbytes / sizeof (*yyptr); \
297 while (0)
299 #endif
301 #if defined (__STDC__) || defined (__cplusplus)
302 typedef signed char yysigned_char;
303 #else
304 typedef short int yysigned_char;
305 #endif
307 /* YYFINAL -- State number of the termination state. */
308 #define YYFINAL 12
309 /* YYLAST -- Last index in YYTABLE. */
310 #define YYLAST 25
312 /* YYNTOKENS -- Number of terminals. */
313 #define YYNTOKENS 17
314 /* YYNNTS -- Number of nonterminals. */
315 #define YYNNTS 9
316 /* YYNRULES -- Number of rules. */
317 #define YYNRULES 20
318 /* YYNRULES -- Number of states. */
319 #define YYNSTATES 34
321 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
322 #define YYUNDEFTOK 2
323 #define YYMAXUTOK 271
325 #define YYTRANSLATE(YYX) \
326 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
328 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
329 static const unsigned char yytranslate[] =
331 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
332 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
333 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
334 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
335 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
336 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
337 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
338 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
339 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
340 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
341 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
342 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
343 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
344 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
345 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
346 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
347 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
348 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
349 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
350 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
351 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
352 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
353 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
354 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
355 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
356 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
357 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
358 15, 16
361 #if YYDEBUG
362 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
363 YYRHS. */
364 static const unsigned char yyprhs[] =
366 0, 0, 3, 5, 7, 11, 13, 17, 19, 23,
367 25, 29, 33, 35, 39, 43, 45, 49, 53, 57,
371 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
372 static const yysigned_char yyrhs[] =
374 18, 0, -1, 19, -1, 20, -1, 19, 12, 20,
375 -1, 21, -1, 20, 14, 21, -1, 22, -1, 21,
376 13, 22, -1, 23, -1, 22, 8, 23, -1, 22,
377 9, 23, -1, 24, -1, 23, 3, 24, -1, 23,
378 4, 24, -1, 25, -1, 24, 5, 25, -1, 24,
379 6, 25, -1, 24, 7, 25, -1, 16, -1, 10,
380 19, 11, -1
383 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
384 static const unsigned char yyrline[] =
386 0, 94, 94, 100, 103, 107, 110, 114, 117, 121,
387 124, 127, 132, 135, 138, 142, 145, 148, 151, 155,
390 #endif
392 #if YYDEBUG || YYERROR_VERBOSE
393 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
394 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
395 static const char *const yytname[] =
397 "$end", "error", "$undefined", "exp_PLUS", "exp_MINUS", "exp_TIMES",
398 "exp_DIVIDE", "exp_MOD", "exp_SHIFTLEFT", "exp_SHIFTRIGHT",
399 "exp_OPENPARENT", "exp_CLOSEPARENT", "exp_OR", "exp_AND", "exp_XOR",
400 "exp_NOT", "exp_NUMBER", "$accept", "Start", "exp", "bitwiseor",
401 "bitwisexor", "bitwiseand", "shift", "term", "factor", 0
403 #endif
405 # ifdef YYPRINT
406 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
407 token YYLEX-NUM. */
408 static const unsigned short int yytoknum[] =
410 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
411 265, 266, 267, 268, 269, 270, 271
413 # endif
415 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
416 static const unsigned char yyr1[] =
418 0, 17, 18, 19, 19, 20, 20, 21, 21, 22,
419 22, 22, 23, 23, 23, 24, 24, 24, 24, 25,
423 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
424 static const unsigned char yyr2[] =
426 0, 2, 1, 1, 3, 1, 3, 1, 3, 1,
427 3, 3, 1, 3, 3, 1, 3, 3, 3, 1,
431 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
432 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
433 means the default is an error. */
434 static const unsigned char yydefact[] =
436 0, 0, 19, 0, 2, 3, 5, 7, 9, 12,
437 15, 0, 1, 0, 0, 0, 0, 0, 0, 0,
438 0, 0, 0, 20, 4, 6, 8, 10, 11, 13,
439 14, 16, 17, 18
442 /* YYDEFGOTO[NTERM-NUM]. */
443 static const yysigned_char yydefgoto[] =
445 -1, 3, 4, 5, 6, 7, 8, 9, 10
448 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
449 STATE-NUM. */
450 #define YYPACT_NINF -14
451 static const yysigned_char yypact[] =
453 -10, -10, -14, 18, 7, 6, 8, 2, 1, -4,
454 -14, 3, -14, -10, -10, -10, -10, -10, -10, -10,
455 -10, -10, -10, -14, 6, 8, 2, 1, 1, -4,
456 -4, -14, -14, -14
459 /* YYPGOTO[NTERM-NUM]. */
460 static const yysigned_char yypgoto[] =
462 -14, -14, 21, 10, 11, 9, 0, -6, -13
465 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
466 positive, shift that token. If negative, reduce the rule which
467 number is the opposite. If zero, do what YYDEFACT says.
468 If YYTABLE_NINF, syntax error. */
469 #define YYTABLE_NINF -1
470 static const unsigned char yytable[] =
472 1, 20, 21, 22, 18, 19, 2, 31, 32, 33,
473 16, 17, 29, 30, 23, 13, 27, 28, 12, 13,
474 14, 15, 11, 24, 26, 25
477 static const unsigned char yycheck[] =
479 10, 5, 6, 7, 3, 4, 16, 20, 21, 22,
480 8, 9, 18, 19, 11, 12, 16, 17, 0, 12,
481 14, 13, 1, 13, 15, 14
484 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
485 symbol of state STATE-NUM. */
486 static const unsigned char yystos[] =
488 0, 10, 16, 18, 19, 20, 21, 22, 23, 24,
489 25, 19, 0, 12, 14, 13, 8, 9, 3, 4,
490 5, 6, 7, 11, 20, 21, 22, 23, 23, 24,
491 24, 25, 25, 25
494 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
495 # define YYSIZE_T __SIZE_TYPE__
496 #endif
497 #if ! defined (YYSIZE_T) && defined (size_t)
498 # define YYSIZE_T size_t
499 #endif
500 #if ! defined (YYSIZE_T)
501 # if defined (__STDC__) || defined (__cplusplus)
502 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
503 # define YYSIZE_T size_t
504 # endif
505 #endif
506 #if ! defined (YYSIZE_T)
507 # define YYSIZE_T unsigned int
508 #endif
510 #define yyerrok (yyerrstatus = 0)
511 #define yyclearin (yychar = YYEMPTY)
512 #define YYEMPTY (-2)
513 #define YYEOF 0
515 #define YYACCEPT goto yyacceptlab
516 #define YYABORT goto yyabortlab
517 #define YYERROR goto yyerrorlab
520 /* Like YYERROR except do call yyerror. This remains here temporarily
521 to ease the transition to the new meaning of YYERROR, for GCC.
522 Once GCC version 2 has supplanted version 1, this can go. */
524 #define YYFAIL goto yyerrlab
526 #define YYRECOVERING() (!!yyerrstatus)
528 #define YYBACKUP(Token, Value) \
529 do \
530 if (yychar == YYEMPTY && yylen == 1) \
532 yychar = (Token); \
533 yylval = (Value); \
534 yytoken = YYTRANSLATE (yychar); \
535 YYPOPSTACK; \
536 goto yybackup; \
538 else \
540 yyerror ("syntax error: cannot back up");\
541 YYERROR; \
543 while (0)
545 #define YYTERROR 1
546 #define YYERRCODE 256
548 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
549 are run). */
551 #ifndef YYLLOC_DEFAULT
552 # define YYLLOC_DEFAULT(Current, Rhs, N) \
553 ((Current).first_line = (Rhs)[1].first_line, \
554 (Current).first_column = (Rhs)[1].first_column, \
555 (Current).last_line = (Rhs)[N].last_line, \
556 (Current).last_column = (Rhs)[N].last_column)
557 #endif
559 /* YYLEX -- calling `yylex' with the right arguments. */
561 #ifdef YYLEX_PARAM
562 # define YYLEX yylex (&yylval, YYLEX_PARAM)
563 #else
564 # define YYLEX yylex (&yylval)
565 #endif
567 /* Enable debugging if requested. */
568 #if YYDEBUG
570 # ifndef YYFPRINTF
571 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
572 # define YYFPRINTF fprintf
573 # endif
575 # define YYDPRINTF(Args) \
576 do { \
577 if (yydebug) \
578 YYFPRINTF Args; \
579 } while (0)
581 # define YYDSYMPRINT(Args) \
582 do { \
583 if (yydebug) \
584 yysymprint Args; \
585 } while (0)
587 # define YYDSYMPRINTF(Title, Token, Value, Location) \
588 do { \
589 if (yydebug) \
591 YYFPRINTF (stderr, "%s ", Title); \
592 yysymprint (stderr, \
593 Token, Value); \
594 YYFPRINTF (stderr, "\n"); \
596 } while (0)
598 /*------------------------------------------------------------------.
599 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
600 | TOP (included). |
601 `------------------------------------------------------------------*/
603 #if defined (__STDC__) || defined (__cplusplus)
604 static void
605 yy_stack_print (short int *bottom, short int *top)
606 #else
607 static void
608 yy_stack_print (bottom, top)
609 short int *bottom;
610 short int *top;
611 #endif
613 YYFPRINTF (stderr, "Stack now");
614 for (/* Nothing. */; bottom <= top; ++bottom)
615 YYFPRINTF (stderr, " %d", *bottom);
616 YYFPRINTF (stderr, "\n");
619 # define YY_STACK_PRINT(Bottom, Top) \
620 do { \
621 if (yydebug) \
622 yy_stack_print ((Bottom), (Top)); \
623 } while (0)
626 /*------------------------------------------------.
627 | Report that the YYRULE is going to be reduced. |
628 `------------------------------------------------*/
630 #if defined (__STDC__) || defined (__cplusplus)
631 static void
632 yy_reduce_print (int yyrule)
633 #else
634 static void
635 yy_reduce_print (yyrule)
636 int yyrule;
637 #endif
639 int yyi;
640 unsigned int yylno = yyrline[yyrule];
641 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
642 yyrule - 1, yylno);
643 /* Print the symbols being reduced, and their result. */
644 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
645 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
646 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
649 # define YY_REDUCE_PRINT(Rule) \
650 do { \
651 if (yydebug) \
652 yy_reduce_print (Rule); \
653 } while (0)
655 /* Nonzero means print parse trace. It is left uninitialized so that
656 multiple parsers can coexist. */
657 int yydebug;
658 #else /* !YYDEBUG */
659 # define YYDPRINTF(Args)
660 # define YYDSYMPRINT(Args)
661 # define YYDSYMPRINTF(Title, Token, Value, Location)
662 # define YY_STACK_PRINT(Bottom, Top)
663 # define YY_REDUCE_PRINT(Rule)
664 #endif /* !YYDEBUG */
667 /* YYINITDEPTH -- initial size of the parser's stacks. */
668 #ifndef YYINITDEPTH
669 # define YYINITDEPTH 200
670 #endif
672 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
673 if the built-in stack extension method is used).
675 Do not make this value too large; the results are undefined if
676 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
677 evaluated with infinite-precision integer arithmetic. */
679 #if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
680 # undef YYMAXDEPTH
681 #endif
683 #ifndef YYMAXDEPTH
684 # define YYMAXDEPTH 10000
685 #endif
689 #if YYERROR_VERBOSE
691 # ifndef yystrlen
692 # if defined (__GLIBC__) && defined (_STRING_H)
693 # define yystrlen strlen
694 # else
695 /* Return the length of YYSTR. */
696 static YYSIZE_T
697 # if defined (__STDC__) || defined (__cplusplus)
698 yystrlen (const char *yystr)
699 # else
700 yystrlen (yystr)
701 const char *yystr;
702 # endif
704 register const char *yys = yystr;
706 while (*yys++ != '\0')
707 continue;
709 return yys - yystr - 1;
711 # endif
712 # endif
714 # ifndef yystpcpy
715 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
716 # define yystpcpy stpcpy
717 # else
718 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
719 YYDEST. */
720 static char *
721 # if defined (__STDC__) || defined (__cplusplus)
722 yystpcpy (char *yydest, const char *yysrc)
723 # else
724 yystpcpy (yydest, yysrc)
725 char *yydest;
726 const char *yysrc;
727 # endif
729 register char *yyd = yydest;
730 register const char *yys = yysrc;
732 while ((*yyd++ = *yys++) != '\0')
733 continue;
735 return yyd - 1;
737 # endif
738 # endif
740 #endif /* !YYERROR_VERBOSE */
744 #if YYDEBUG
745 /*--------------------------------.
746 | Print this symbol on YYOUTPUT. |
747 `--------------------------------*/
749 #if defined (__STDC__) || defined (__cplusplus)
750 static void
751 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
752 #else
753 static void
754 yysymprint (yyoutput, yytype, yyvaluep)
755 FILE *yyoutput;
756 int yytype;
757 YYSTYPE *yyvaluep;
758 #endif
760 /* Pacify ``unused variable'' warnings. */
761 (void) yyvaluep;
763 if (yytype < YYNTOKENS)
765 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
766 # ifdef YYPRINT
767 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
768 # endif
770 else
771 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
773 switch (yytype)
775 default:
776 break;
778 YYFPRINTF (yyoutput, ")");
781 #endif /* ! YYDEBUG */
782 /*-----------------------------------------------.
783 | Release the memory associated to this symbol. |
784 `-----------------------------------------------*/
786 #if defined (__STDC__) || defined (__cplusplus)
787 static void
788 yydestruct (int yytype, YYSTYPE *yyvaluep)
789 #else
790 static void
791 yydestruct (yytype, yyvaluep)
792 int yytype;
793 YYSTYPE *yyvaluep;
794 #endif
796 /* Pacify ``unused variable'' warnings. */
797 (void) yyvaluep;
799 switch (yytype)
802 default:
803 break;
808 /* Prevent warnings from -Wmissing-prototypes. */
810 #ifdef YYPARSE_PARAM
811 # if defined (__STDC__) || defined (__cplusplus)
812 int yyparse (void *YYPARSE_PARAM);
813 # else
814 int yyparse ();
815 # endif
816 #else /* ! YYPARSE_PARAM */
817 #if defined (__STDC__) || defined (__cplusplus)
818 int yyparse (void);
819 #else
820 int yyparse ();
821 #endif
822 #endif /* ! YYPARSE_PARAM */
829 /*----------.
830 | yyparse. |
831 `----------*/
833 #ifdef YYPARSE_PARAM
834 # if defined (__STDC__) || defined (__cplusplus)
835 int yyparse (void *YYPARSE_PARAM)
836 # else
837 int yyparse (YYPARSE_PARAM)
838 void *YYPARSE_PARAM;
839 # endif
840 #else /* ! YYPARSE_PARAM */
841 #if defined (__STDC__) || defined (__cplusplus)
843 yyparse (void)
844 #else
846 yyparse ()
848 #endif
849 #endif
851 /* The lookahead symbol. */
852 int yychar;
854 /* The semantic value of the lookahead symbol. */
855 YYSTYPE yylval;
857 /* Number of syntax errors so far. */
858 int yynerrs;
860 register int yystate;
861 register int yyn;
862 int yyresult;
863 /* Number of tokens to shift before error messages enabled. */
864 int yyerrstatus;
865 /* Lookahead token as an internal (translated) token number. */
866 int yytoken = 0;
868 /* Three stacks and their tools:
869 `yyss': related to states,
870 `yyvs': related to semantic values,
871 `yyls': related to locations.
873 Refer to the stacks thru separate pointers, to allow yyoverflow
874 to reallocate them elsewhere. */
876 /* The state stack. */
877 short int yyssa[YYINITDEPTH];
878 short int *yyss = yyssa;
879 register short int *yyssp;
881 /* The semantic value stack. */
882 YYSTYPE yyvsa[YYINITDEPTH];
883 YYSTYPE *yyvs = yyvsa;
884 register YYSTYPE *yyvsp;
888 #define YYPOPSTACK (yyvsp--, yyssp--)
890 YYSIZE_T yystacksize = YYINITDEPTH;
892 /* The variables used to return semantic value and location from the
893 action routines. */
894 YYSTYPE yyval;
897 /* When reducing, the number of symbols on the RHS of the reduced
898 rule. */
899 int yylen;
901 YYDPRINTF ((stderr, "Starting parse\n"));
903 yystate = 0;
904 yyerrstatus = 0;
905 yynerrs = 0;
906 yychar = YYEMPTY; /* Cause a token to be read. */
908 /* Initialize stack pointers.
909 Waste one element of value and location stack
910 so that they stay on the same level as the state stack.
911 The wasted elements are never initialized. */
913 yyssp = yyss;
914 yyvsp = yyvs;
917 goto yysetstate;
919 /*------------------------------------------------------------.
920 | yynewstate -- Push a new state, which is found in yystate. |
921 `------------------------------------------------------------*/
922 yynewstate:
923 /* In all cases, when you get here, the value and location stacks
924 have just been pushed. so pushing a state here evens the stacks.
926 yyssp++;
928 yysetstate:
929 *yyssp = yystate;
931 if (yyss + yystacksize - 1 <= yyssp)
933 /* Get the current used size of the three stacks, in elements. */
934 YYSIZE_T yysize = yyssp - yyss + 1;
936 #ifdef yyoverflow
938 /* Give user a chance to reallocate the stack. Use copies of
939 these so that the &'s don't force the real ones into
940 memory. */
941 YYSTYPE *yyvs1 = yyvs;
942 short int *yyss1 = yyss;
945 /* Each stack pointer address is followed by the size of the
946 data in use in that stack, in bytes. This used to be a
947 conditional around just the two extra args, but that might
948 be undefined if yyoverflow is a macro. */
949 yyoverflow ("parser stack overflow",
950 &yyss1, yysize * sizeof (*yyssp),
951 &yyvs1, yysize * sizeof (*yyvsp),
953 &yystacksize);
955 yyss = yyss1;
956 yyvs = yyvs1;
958 #else /* no yyoverflow */
959 # ifndef YYSTACK_RELOCATE
960 goto yyoverflowlab;
961 # else
962 /* Extend the stack our own way. */
963 if (YYMAXDEPTH <= yystacksize)
964 goto yyoverflowlab;
965 yystacksize *= 2;
966 if (YYMAXDEPTH < yystacksize)
967 yystacksize = YYMAXDEPTH;
970 short int *yyss1 = yyss;
971 union yyalloc *yyptr =
972 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
973 if (! yyptr)
974 goto yyoverflowlab;
975 YYSTACK_RELOCATE (yyss);
976 YYSTACK_RELOCATE (yyvs);
978 # undef YYSTACK_RELOCATE
979 if (yyss1 != yyssa)
980 YYSTACK_FREE (yyss1);
982 # endif
983 #endif /* no yyoverflow */
985 yyssp = yyss + yysize - 1;
986 yyvsp = yyvs + yysize - 1;
989 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
990 (unsigned long int) yystacksize));
992 if (yyss + yystacksize - 1 <= yyssp)
993 YYABORT;
996 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
998 goto yybackup;
1000 /*-----------.
1001 | yybackup. |
1002 `-----------*/
1003 yybackup:
1005 /* Do appropriate processing given the current state. */
1006 /* Read a lookahead token if we need one and don't already have one. */
1007 /* yyresume: */
1009 /* First try to decide what to do without reference to lookahead token. */
1011 yyn = yypact[yystate];
1012 if (yyn == YYPACT_NINF)
1013 goto yydefault;
1015 /* Not known => get a lookahead token if don't already have one. */
1017 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1018 if (yychar == YYEMPTY)
1020 YYDPRINTF ((stderr, "Reading a token: "));
1021 yychar = YYLEX;
1024 if (yychar <= YYEOF)
1026 yychar = yytoken = YYEOF;
1027 YYDPRINTF ((stderr, "Now at end of input.\n"));
1029 else
1031 yytoken = YYTRANSLATE (yychar);
1032 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1035 /* If the proper action on seeing token YYTOKEN is to reduce or to
1036 detect an error, take that action. */
1037 yyn += yytoken;
1038 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1039 goto yydefault;
1040 yyn = yytable[yyn];
1041 if (yyn <= 0)
1043 if (yyn == 0 || yyn == YYTABLE_NINF)
1044 goto yyerrlab;
1045 yyn = -yyn;
1046 goto yyreduce;
1049 if (yyn == YYFINAL)
1050 YYACCEPT;
1052 /* Shift the lookahead token. */
1053 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1055 /* Discard the token being shifted unless it is eof. */
1056 if (yychar != YYEOF)
1057 yychar = YYEMPTY;
1059 *++yyvsp = yylval;
1062 /* Count tokens shifted since error; after three, turn off error
1063 status. */
1064 if (yyerrstatus)
1065 yyerrstatus--;
1067 yystate = yyn;
1068 goto yynewstate;
1071 /*-----------------------------------------------------------.
1072 | yydefault -- do the default action for the current state. |
1073 `-----------------------------------------------------------*/
1074 yydefault:
1075 yyn = yydefact[yystate];
1076 if (yyn == 0)
1077 goto yyerrlab;
1078 goto yyreduce;
1081 /*-----------------------------.
1082 | yyreduce -- Do a reduction. |
1083 `-----------------------------*/
1084 yyreduce:
1085 /* yyn is the number of a rule to reduce with. */
1086 yylen = yyr2[yyn];
1088 /* If YYLEN is nonzero, implement the default value of the action:
1089 `$$ = $1'.
1091 Otherwise, the following line sets YYVAL to garbage.
1092 This behavior is undocumented and Bison
1093 users should not rely upon it. Assigning to YYVAL
1094 unconditionally makes the parser a bit smaller, and it avoids a
1095 GCC warning that YYVAL may be used uninitialized. */
1096 yyval = yyvsp[1-yylen];
1099 YY_REDUCE_PRINT (yyn);
1100 switch (yyn)
1102 case 2:
1105 yyGetParser->SetResult(yyvsp[0].Number);
1107 break;
1109 case 3:
1111 {yyval.Number = yyvsp[0].Number;}
1112 break;
1114 case 4:
1116 {yyval.Number = yyvsp[-2].Number | yyvsp[0].Number;}
1117 break;
1119 case 5:
1121 {yyval.Number = yyvsp[0].Number;}
1122 break;
1124 case 6:
1126 {yyval.Number = yyvsp[-2].Number ^ yyvsp[0].Number;}
1127 break;
1129 case 7:
1131 {yyval.Number = yyvsp[0].Number;}
1132 break;
1134 case 8:
1136 {yyval.Number = yyvsp[-2].Number & yyvsp[0].Number;}
1137 break;
1139 case 9:
1141 {yyval.Number = yyvsp[0].Number;}
1142 break;
1144 case 10:
1146 {yyval.Number = yyvsp[-2].Number << yyvsp[0].Number;}
1147 break;
1149 case 11:
1151 {yyval.Number = yyvsp[-2].Number >> yyvsp[0].Number;}
1152 break;
1154 case 12:
1156 {yyval.Number = yyvsp[0].Number;}
1157 break;
1159 case 13:
1161 {yyval.Number = yyvsp[-2].Number + yyvsp[0].Number;}
1162 break;
1164 case 14:
1166 {yyval.Number = yyvsp[-2].Number - yyvsp[0].Number;}
1167 break;
1169 case 15:
1171 {yyval.Number = yyvsp[0].Number;}
1172 break;
1174 case 16:
1176 {yyval.Number = yyvsp[-2].Number * yyvsp[0].Number;}
1177 break;
1179 case 17:
1181 {yyval.Number = yyvsp[-2].Number / yyvsp[0].Number;}
1182 break;
1184 case 18:
1186 {yyval.Number = yyvsp[-2].Number % yyvsp[0].Number;}
1187 break;
1189 case 19:
1191 {yyval.Number = yyvsp[0].Number;}
1192 break;
1194 case 20:
1196 {yyval.Number = yyvsp[-1].Number;}
1197 break;
1202 /* Line 1010 of yacc.c. */
1205 yyvsp -= yylen;
1206 yyssp -= yylen;
1209 YY_STACK_PRINT (yyss, yyssp);
1211 *++yyvsp = yyval;
1214 /* Now `shift' the result of the reduction. Determine what state
1215 that goes to, based on the state we popped back to and the rule
1216 number reduced by. */
1218 yyn = yyr1[yyn];
1220 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1221 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1222 yystate = yytable[yystate];
1223 else
1224 yystate = yydefgoto[yyn - YYNTOKENS];
1226 goto yynewstate;
1229 /*------------------------------------.
1230 | yyerrlab -- here on detecting error |
1231 `------------------------------------*/
1232 yyerrlab:
1233 /* If not already recovering from an error, report this error. */
1234 if (!yyerrstatus)
1236 ++yynerrs;
1237 #if YYERROR_VERBOSE
1238 yyn = yypact[yystate];
1240 if (YYPACT_NINF < yyn && yyn < YYLAST)
1242 YYSIZE_T yysize = 0;
1243 int yytype = YYTRANSLATE (yychar);
1244 const char* yyprefix;
1245 char *yymsg;
1246 int yyx;
1248 /* Start YYX at -YYN if negative to avoid negative indexes in
1249 YYCHECK. */
1250 int yyxbegin = yyn < 0 ? -yyn : 0;
1252 /* Stay within bounds of both yycheck and yytname. */
1253 int yychecklim = YYLAST - yyn;
1254 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1255 int yycount = 0;
1257 yyprefix = ", expecting ";
1258 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1259 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1261 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
1262 yycount += 1;
1263 if (yycount == 5)
1265 yysize = 0;
1266 break;
1269 yysize += (sizeof ("syntax error, unexpected ")
1270 + yystrlen (yytname[yytype]));
1271 yymsg = (char *) YYSTACK_ALLOC (yysize);
1272 if (yymsg != 0)
1274 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1275 yyp = yystpcpy (yyp, yytname[yytype]);
1277 if (yycount < 5)
1279 yyprefix = ", expecting ";
1280 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1281 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1283 yyp = yystpcpy (yyp, yyprefix);
1284 yyp = yystpcpy (yyp, yytname[yyx]);
1285 yyprefix = " or ";
1288 yyerror (yymsg);
1289 YYSTACK_FREE (yymsg);
1291 else
1292 yyerror ("syntax error; also virtual memory exhausted");
1294 else
1295 #endif /* YYERROR_VERBOSE */
1296 yyerror ("syntax error");
1301 if (yyerrstatus == 3)
1303 /* If just tried and failed to reuse lookahead token after an
1304 error, discard it. */
1306 if (yychar <= YYEOF)
1308 /* If at end of input, pop the error token,
1309 then the rest of the stack, then return failure. */
1310 if (yychar == YYEOF)
1311 for (;;)
1313 YYPOPSTACK;
1314 if (yyssp == yyss)
1315 YYABORT;
1316 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1317 yydestruct (yystos[*yyssp], yyvsp);
1320 else
1322 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
1323 yydestruct (yytoken, &yylval);
1324 yychar = YYEMPTY;
1329 /* Else will try to reuse lookahead token after shifting the error
1330 token. */
1331 goto yyerrlab1;
1334 /*---------------------------------------------------.
1335 | yyerrorlab -- error raised explicitly by YYERROR. |
1336 `---------------------------------------------------*/
1337 yyerrorlab:
1339 #if defined( __GNUC__ ) || defined(__HP_aCC)
1340 /* Pacify GCC when the user code never invokes YYERROR and the label
1341 yyerrorlab therefore never appears in user code. */
1342 if (0)
1343 goto yyerrorlab;
1344 #endif
1346 yyvsp -= yylen;
1347 yyssp -= yylen;
1348 yystate = *yyssp;
1349 goto yyerrlab1;
1352 /*-------------------------------------------------------------.
1353 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1354 `-------------------------------------------------------------*/
1355 yyerrlab1:
1356 yyerrstatus = 3; /* Each real token shifted decrements this. */
1358 for (;;)
1360 yyn = yypact[yystate];
1361 if (yyn != YYPACT_NINF)
1363 yyn += YYTERROR;
1364 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1366 yyn = yytable[yyn];
1367 if (0 < yyn)
1368 break;
1372 /* Pop the current state because it cannot handle the error token. */
1373 if (yyssp == yyss)
1374 YYABORT;
1376 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1377 yydestruct (yystos[yystate], yyvsp);
1378 YYPOPSTACK;
1379 yystate = *yyssp;
1380 YY_STACK_PRINT (yyss, yyssp);
1383 if (yyn == YYFINAL)
1384 YYACCEPT;
1386 YYDPRINTF ((stderr, "Shifting error token, "));
1388 *++yyvsp = yylval;
1391 yystate = yyn;
1392 goto yynewstate;
1395 /*-------------------------------------.
1396 | yyacceptlab -- YYACCEPT comes here. |
1397 `-------------------------------------*/
1398 yyacceptlab:
1399 yyresult = 0;
1400 goto yyreturn;
1402 /*-----------------------------------.
1403 | yyabortlab -- YYABORT comes here. |
1404 `-----------------------------------*/
1405 yyabortlab:
1406 yyresult = 1;
1407 goto yyreturn;
1409 #ifndef yyoverflow
1410 /*----------------------------------------------.
1411 | yyoverflowlab -- parser overflow comes here. |
1412 `----------------------------------------------*/
1413 yyoverflowlab:
1414 yyerror ("parser stack overflow");
1415 yyresult = 2;
1416 /* Fall through. */
1417 #endif
1419 yyreturn:
1420 #ifndef yyoverflow
1421 if (yyss != yyssa)
1422 YYSTACK_FREE (yyss);
1423 #endif
1424 return yyresult;
1430 /* End of grammar */
1432 /*--------------------------------------------------------------------------*/
1433 void cmExprError(yyscan_t yyscanner, const char* message)
1435 yyGetParser->Error(message);