1 /* A Bison parser, made by GNU Bison 2.3. */
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
23 /* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
39 /* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
46 /* Identify Bison output. */
50 #define YYBISON_VERSION "2.3"
53 #define YYSKELETON_NAME "yacc.c"
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
66 /* Put the tokens into the symbol table, so that GDB and other debuggers
80 /* Copy the first part of user declarations. */
83 #include <stdio.h> /* for printf() */
84 #include <stdlib.h> /* for strtod() */
86 #include <math.h> /* for pow() */
88 #define YYSTYPE double
91 void yyerror(const char *);
96 /* Enabling traces. */
101 /* Enabling verbose error messages. */
102 #ifdef YYERROR_VERBOSE
103 # undef YYERROR_VERBOSE
104 # define YYERROR_VERBOSE 1
106 # define YYERROR_VERBOSE 0
109 /* Enabling the token table. */
110 #ifndef YYTOKEN_TABLE
111 # define YYTOKEN_TABLE 0
114 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
116 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
117 # define YYSTYPE_IS_DECLARED 1
118 # define YYSTYPE_IS_TRIVIAL 1
123 /* Copy the second part of user declarations. */
126 /* Line 216 of yacc.c. */
134 typedef YYTYPE_UINT8 yytype_uint8
;
136 typedef unsigned char yytype_uint8
;
140 typedef YYTYPE_INT8 yytype_int8
;
141 #elif (defined __STDC__ || defined __C99__FUNC__ \
142 || defined __cplusplus || defined _MSC_VER)
143 typedef signed char yytype_int8
;
145 typedef short int yytype_int8
;
149 typedef YYTYPE_UINT16 yytype_uint16
;
151 typedef unsigned short int yytype_uint16
;
155 typedef YYTYPE_INT16 yytype_int16
;
157 typedef short int yytype_int16
;
161 # ifdef __SIZE_TYPE__
162 # define YYSIZE_T __SIZE_TYPE__
163 # elif defined size_t
164 # define YYSIZE_T size_t
165 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
166 || defined __cplusplus || defined _MSC_VER)
167 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
168 # define YYSIZE_T size_t
170 # define YYSIZE_T unsigned int
174 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
179 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
180 # define YY_(msgid) dgettext ("bison-runtime", msgid)
184 # define YY_(msgid) msgid
188 /* Suppress unused-variable warnings by "using" E. */
189 #if ! defined lint || defined __GNUC__
190 # define YYUSE(e) ((void) (e))
192 # define YYUSE(e) /* empty */
195 /* Identity function, used to suppress warnings about constant conditions. */
199 #if (defined __STDC__ || defined __C99__FUNC__ \
200 || defined __cplusplus || defined _MSC_VER)
213 #if ! defined yyoverflow || YYERROR_VERBOSE
215 /* The parser invokes alloca or malloc; define the necessary symbols. */
217 # ifdef YYSTACK_USE_ALLOCA
218 # if YYSTACK_USE_ALLOCA
220 # define YYSTACK_ALLOC __builtin_alloca
221 # elif defined __BUILTIN_VA_ARG_INCR
222 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
224 # define YYSTACK_ALLOC __alloca
225 # elif defined _MSC_VER
226 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
227 # define alloca _alloca
229 # define YYSTACK_ALLOC alloca
230 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
231 || defined __cplusplus || defined _MSC_VER)
232 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
241 # ifdef YYSTACK_ALLOC
242 /* Pacify GCC's `empty if-body' warning. */
243 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
244 # ifndef YYSTACK_ALLOC_MAXIMUM
245 /* The OS might guarantee only one guard page at the bottom of the stack,
246 and a page size can be as small as 4096 bytes. So we cannot safely
247 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
248 to allow for a few compiler-allocated temporary stack slots. */
249 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
252 # define YYSTACK_ALLOC YYMALLOC
253 # define YYSTACK_FREE YYFREE
254 # ifndef YYSTACK_ALLOC_MAXIMUM
255 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
257 # if (defined __cplusplus && ! defined _STDLIB_H \
258 && ! ((defined YYMALLOC || defined malloc) \
259 && (defined YYFREE || defined free)))
260 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
266 # define YYMALLOC malloc
267 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
268 || defined __cplusplus || defined _MSC_VER)
269 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
274 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
275 || defined __cplusplus || defined _MSC_VER)
276 void free (void *); /* INFRINGES ON USER NAME SPACE */
280 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
283 #if (! defined yyoverflow \
284 && (! defined __cplusplus \
285 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
287 /* A type that is properly aligned for any stack member. */
294 /* The size of the maximum gap between one aligned stack and the next. */
295 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
297 /* The size of an array large to enough to hold all stacks, each with
299 # define YYSTACK_BYTES(N) \
300 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
301 + YYSTACK_GAP_MAXIMUM)
303 /* Copy COUNT objects from FROM to TO. The source and destination do
306 # if defined __GNUC__ && 1 < __GNUC__
307 # define YYCOPY(To, From, Count) \
308 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
310 # define YYCOPY(To, From, Count) \
314 for (yyi = 0; yyi < (Count); yyi++) \
315 (To)[yyi] = (From)[yyi]; \
321 /* Relocate STACK from its old location to the new one. The
322 local variables YYSIZE and YYSTACKSIZE give the old and new number of
323 elements in the stack, and YYPTR gives the new location of the
324 stack. Advance YYPTR to a properly aligned location for the next
326 # define YYSTACK_RELOCATE(Stack) \
329 YYSIZE_T yynewbytes; \
330 YYCOPY (&yyptr->Stack, Stack, yysize); \
331 Stack = &yyptr->Stack; \
332 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
333 yyptr += yynewbytes / sizeof (*yyptr); \
339 /* YYFINAL -- State number of the termination state. */
341 /* YYLAST -- Last index in YYTABLE. */
344 /* YYNTOKENS -- Number of terminals. */
346 /* YYNNTS -- Number of nonterminals. */
348 /* YYNRULES -- Number of rules. */
350 /* YYNRULES -- Number of states. */
353 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
355 #define YYMAXUTOK 259
357 #define YYTRANSLATE(YYX) \
358 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
360 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
361 static const yytype_uint8 yytranslate
[] =
363 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
364 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
365 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
366 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
367 10, 11, 6, 5, 2, 4, 2, 7, 2, 2,
368 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
369 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
370 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
371 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
372 2, 2, 2, 2, 9, 2, 2, 2, 2, 2,
373 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
374 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
375 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
376 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
377 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
378 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
379 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
380 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
381 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
382 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
383 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
384 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
385 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
386 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
387 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
388 2, 2, 2, 2, 2, 2, 1, 2, 3, 8
392 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
394 static const yytype_uint8 yyprhs
[] =
396 0, 0, 3, 5, 7, 11, 15, 19, 23, 26,
400 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
401 static const yytype_int8 yyrhs
[] =
403 13, 0, -1, 14, -1, 3, -1, 14, 5, 14,
404 -1, 14, 4, 14, -1, 14, 6, 14, -1, 14,
405 7, 14, -1, 4, 14, -1, 14, 9, 14, -1,
409 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
410 static const yytype_uint8 yyrline
[] =
412 0, 23, 23, 26, 27, 28, 29, 30, 31, 32,
417 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
418 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
419 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
420 static const char *const yytname
[] =
422 "$end", "error", "$undefined", "NUM", "'-'", "'+'", "'*'", "'/'", "NEG",
423 "'^'", "'('", "')'", "$accept", "line", "exp", 0
428 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
430 static const yytype_uint16 yytoknum
[] =
432 0, 256, 257, 258, 45, 43, 42, 47, 259, 94,
437 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
438 static const yytype_uint8 yyr1
[] =
440 0, 12, 13, 14, 14, 14, 14, 14, 14, 14,
444 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
445 static const yytype_uint8 yyr2
[] =
447 0, 2, 1, 1, 3, 3, 3, 3, 2, 3,
451 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
452 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
453 means the default is an error. */
454 static const yytype_uint8 yydefact
[] =
456 0, 3, 0, 0, 0, 2, 8, 0, 1, 0,
457 0, 0, 0, 0, 10, 5, 4, 6, 7, 9
460 /* YYDEFGOTO[NTERM-NUM]. */
461 static const yytype_int8 yydefgoto
[] =
466 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
468 #define YYPACT_NINF -5
469 static const yytype_int8 yypact
[] =
471 17, -5, 17, 17, 4, 19, -3, 8, -5, 17,
472 17, 17, 17, 17, -5, -4, -4, -3, -3, -3
475 /* YYPGOTO[NTERM-NUM]. */
476 static const yytype_int8 yypgoto
[] =
481 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
482 positive, shift that token. If negative, reduce the rule which
483 number is the opposite. If zero, do what YYDEFACT says.
484 If YYTABLE_NINF, syntax error. */
485 #define YYTABLE_NINF -1
486 static const yytype_uint8 yytable
[] =
488 6, 7, 11, 12, 8, 13, 13, 15, 16, 17,
489 18, 19, 9, 10, 11, 12, 0, 13, 0, 14,
490 1, 2, 0, 9, 10, 11, 12, 3, 13
493 static const yytype_int8 yycheck
[] =
495 2, 3, 6, 7, 0, 9, 9, 9, 10, 11,
496 12, 13, 4, 5, 6, 7, -1, 9, -1, 11,
497 3, 4, -1, 4, 5, 6, 7, 10, 9
500 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
501 symbol of state STATE-NUM. */
502 static const yytype_uint8 yystos
[] =
504 0, 3, 4, 10, 13, 14, 14, 14, 0, 4,
505 5, 6, 7, 9, 11, 14, 14, 14, 14, 14
508 #define yyerrok (yyerrstatus = 0)
509 #define yyclearin (yychar = YYEMPTY)
513 #define YYACCEPT goto yyacceptlab
514 #define YYABORT goto yyabortlab
515 #define YYERROR goto yyerrorlab
518 /* Like YYERROR except do call yyerror. This remains here temporarily
519 to ease the transition to the new meaning of YYERROR, for GCC.
520 Once GCC version 2 has supplanted version 1, this can go. */
522 #define YYFAIL goto yyerrlab
524 #define YYRECOVERING() (!!yyerrstatus)
526 #define YYBACKUP(Token, Value) \
528 if (yychar == YYEMPTY && yylen == 1) \
532 yytoken = YYTRANSLATE (yychar); \
538 yyerror (YY_("syntax error: cannot back up")); \
545 #define YYERRCODE 256
548 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
549 If N is 0, then set CURRENT to the empty location which ends
550 the previous symbol: RHS[0] (always defined). */
552 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
553 #ifndef YYLLOC_DEFAULT
554 # define YYLLOC_DEFAULT(Current, Rhs, N) \
558 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
559 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
560 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
561 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
565 (Current).first_line = (Current).last_line = \
566 YYRHSLOC (Rhs, 0).last_line; \
567 (Current).first_column = (Current).last_column = \
568 YYRHSLOC (Rhs, 0).last_column; \
574 /* YY_LOCATION_PRINT -- Print the location on the stream.
575 This macro was not mandated originally: define only if we know
576 we won't break user code: when these are the locations we know. */
578 #ifndef YY_LOCATION_PRINT
579 # if YYLTYPE_IS_TRIVIAL
580 # define YY_LOCATION_PRINT(File, Loc) \
581 fprintf (File, "%d.%d-%d.%d", \
582 (Loc).first_line, (Loc).first_column, \
583 (Loc).last_line, (Loc).last_column)
585 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
590 /* YYLEX -- calling `yylex' with the right arguments. */
593 # define YYLEX yylex (YYLEX_PARAM)
595 # define YYLEX yylex ()
598 /* Enable debugging if requested. */
602 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
603 # define YYFPRINTF fprintf
606 # define YYDPRINTF(Args) \
612 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
616 YYFPRINTF (stderr, "%s ", Title); \
617 yy_symbol_print (stderr, \
619 YYFPRINTF (stderr, "\n"); \
624 /*--------------------------------.
625 | Print this symbol on YYOUTPUT. |
626 `--------------------------------*/
629 #if (defined __STDC__ || defined __C99__FUNC__ \
630 || defined __cplusplus || defined _MSC_VER)
632 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
)
635 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
)
638 YYSTYPE
const * const yyvaluep
;
644 if (yytype
< YYNTOKENS
)
645 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
657 /*--------------------------------.
658 | Print this symbol on YYOUTPUT. |
659 `--------------------------------*/
661 #if (defined __STDC__ || defined __C99__FUNC__ \
662 || defined __cplusplus || defined _MSC_VER)
664 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
)
667 yy_symbol_print (yyoutput
, yytype
, yyvaluep
)
670 YYSTYPE
const * const yyvaluep
;
673 if (yytype
< YYNTOKENS
)
674 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
676 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
678 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
);
679 YYFPRINTF (yyoutput
, ")");
682 /*------------------------------------------------------------------.
683 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
685 `------------------------------------------------------------------*/
687 #if (defined __STDC__ || defined __C99__FUNC__ \
688 || defined __cplusplus || defined _MSC_VER)
690 yy_stack_print (yytype_int16
*bottom
, yytype_int16
*top
)
693 yy_stack_print (bottom
, top
)
694 yytype_int16
*bottom
;
698 YYFPRINTF (stderr
, "Stack now");
699 for (; bottom
<= top
; ++bottom
)
700 YYFPRINTF (stderr
, " %d", *bottom
);
701 YYFPRINTF (stderr
, "\n");
704 # define YY_STACK_PRINT(Bottom, Top) \
707 yy_stack_print ((Bottom), (Top)); \
711 /*------------------------------------------------.
712 | Report that the YYRULE is going to be reduced. |
713 `------------------------------------------------*/
715 #if (defined __STDC__ || defined __C99__FUNC__ \
716 || defined __cplusplus || defined _MSC_VER)
718 yy_reduce_print (YYSTYPE
*yyvsp
, int yyrule
)
721 yy_reduce_print (yyvsp
, yyrule
)
726 int yynrhs
= yyr2
[yyrule
];
728 unsigned long int yylno
= yyrline
[yyrule
];
729 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
731 /* The symbols being reduced. */
732 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
734 fprintf (stderr
, " $%d = ", yyi
+ 1);
735 yy_symbol_print (stderr
, yyrhs
[yyprhs
[yyrule
] + yyi
],
736 &(yyvsp
[(yyi
+ 1) - (yynrhs
)])
738 fprintf (stderr
, "\n");
742 # define YY_REDUCE_PRINT(Rule) \
745 yy_reduce_print (yyvsp, Rule); \
748 /* Nonzero means print parse trace. It is left uninitialized so that
749 multiple parsers can coexist. */
752 # define YYDPRINTF(Args)
753 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
754 # define YY_STACK_PRINT(Bottom, Top)
755 # define YY_REDUCE_PRINT(Rule)
756 #endif /* !YYDEBUG */
759 /* YYINITDEPTH -- initial size of the parser's stacks. */
761 # define YYINITDEPTH 200
764 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
765 if the built-in stack extension method is used).
767 Do not make this value too large; the results are undefined if
768 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
769 evaluated with infinite-precision integer arithmetic. */
772 # define YYMAXDEPTH 10000
780 # if defined __GLIBC__ && defined _STRING_H
781 # define yystrlen strlen
783 /* Return the length of YYSTR. */
784 #if (defined __STDC__ || defined __C99__FUNC__ \
785 || defined __cplusplus || defined _MSC_VER)
787 yystrlen (const char *yystr
)
795 for (yylen
= 0; yystr
[yylen
]; yylen
++)
803 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
804 # define yystpcpy stpcpy
806 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
808 #if (defined __STDC__ || defined __C99__FUNC__ \
809 || defined __cplusplus || defined _MSC_VER)
811 yystpcpy (char *yydest
, const char *yysrc
)
814 yystpcpy (yydest
, yysrc
)
820 const char *yys
= yysrc
;
822 while ((*yyd
++ = *yys
++) != '\0')
831 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
832 quotes and backslashes, so that it's suitable for yyerror. The
833 heuristic is that double-quoting is unnecessary unless the string
834 contains an apostrophe, a comma, or backslash (other than
835 backslash-backslash). YYSTR is taken from yytname. If YYRES is
836 null, do not copy; instead, return the length of what the result
839 yytnamerr (char *yyres
, const char *yystr
)
844 char const *yyp
= yystr
;
851 goto do_not_strip_quotes
;
855 goto do_not_strip_quotes
;
868 do_not_strip_quotes
: ;
872 return yystrlen (yystr
);
874 return yystpcpy (yyres
, yystr
) - yyres
;
878 /* Copy into YYRESULT an error message about the unexpected token
879 YYCHAR while in state YYSTATE. Return the number of bytes copied,
880 including the terminating null byte. If YYRESULT is null, do not
881 copy anything; just return the number of bytes that would be
882 copied. As a special case, return 0 if an ordinary "syntax error"
883 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
886 yysyntax_error (char *yyresult
, int yystate
, int yychar
)
888 int yyn
= yypact
[yystate
];
890 if (! (YYPACT_NINF
< yyn
&& yyn
<= YYLAST
))
894 int yytype
= YYTRANSLATE (yychar
);
895 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytype
]);
896 YYSIZE_T yysize
= yysize0
;
898 int yysize_overflow
= 0;
899 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
900 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
904 /* This is so xgettext sees the translatable formats that are
905 constructed on the fly. */
906 YY_("syntax error, unexpected %s");
907 YY_("syntax error, unexpected %s, expecting %s");
908 YY_("syntax error, unexpected %s, expecting %s or %s");
909 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
910 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
914 static char const yyunexpected
[] = "syntax error, unexpected %s";
915 static char const yyexpecting
[] = ", expecting %s";
916 static char const yyor
[] = " or %s";
917 char yyformat
[sizeof yyunexpected
918 + sizeof yyexpecting
- 1
919 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
920 * (sizeof yyor
- 1))];
921 char const *yyprefix
= yyexpecting
;
923 /* Start YYX at -YYN if negative to avoid negative indexes in
925 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
927 /* Stay within bounds of both yycheck and yytname. */
928 int yychecklim
= YYLAST
- yyn
+ 1;
929 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
932 yyarg
[0] = yytname
[yytype
];
933 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
935 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
936 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
938 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
942 yyformat
[sizeof yyunexpected
- 1] = '\0';
945 yyarg
[yycount
++] = yytname
[yyx
];
946 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
947 yysize_overflow
|= (yysize1
< yysize
);
949 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
954 yysize1
= yysize
+ yystrlen (yyf
);
955 yysize_overflow
|= (yysize1
< yysize
);
959 return YYSIZE_MAXIMUM
;
963 /* Avoid sprintf, as that infringes on the user's name space.
964 Don't have undefined behavior even if the translation
965 produced a string with the wrong number of "%s"s. */
966 char *yyp
= yyresult
;
968 while ((*yyp
= *yyf
) != '\0')
970 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
972 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
985 #endif /* YYERROR_VERBOSE */
988 /*-----------------------------------------------.
989 | Release the memory associated to this symbol. |
990 `-----------------------------------------------*/
993 #if (defined __STDC__ || defined __C99__FUNC__ \
994 || defined __cplusplus || defined _MSC_VER)
996 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
)
999 yydestruct (yymsg
, yytype
, yyvaluep
)
1009 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1020 /* Prevent warnings from -Wmissing-prototypes. */
1022 #ifdef YYPARSE_PARAM
1023 #if defined __STDC__ || defined __cplusplus
1024 int yyparse (void *YYPARSE_PARAM
);
1028 #else /* ! YYPARSE_PARAM */
1029 #if defined __STDC__ || defined __cplusplus
1034 #endif /* ! YYPARSE_PARAM */
1038 /* The look-ahead symbol. */
1041 /* The semantic value of the look-ahead symbol. */
1044 /* Number of syntax errors so far. */
1053 #ifdef YYPARSE_PARAM
1054 #if (defined __STDC__ || defined __C99__FUNC__ \
1055 || defined __cplusplus || defined _MSC_VER)
1057 yyparse (void *YYPARSE_PARAM
)
1060 yyparse (YYPARSE_PARAM
)
1061 void *YYPARSE_PARAM
;
1063 #else /* ! YYPARSE_PARAM */
1064 #if (defined __STDC__ || defined __C99__FUNC__ \
1065 || defined __cplusplus || defined _MSC_VER)
1079 /* Number of tokens to shift before error messages enabled. */
1081 /* Look-ahead token as an internal (translated) token number. */
1084 /* Buffer for error messages, and its allocated size. */
1086 char *yymsg
= yymsgbuf
;
1087 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1090 /* Three stacks and their tools:
1091 `yyss': related to states,
1092 `yyvs': related to semantic values,
1093 `yyls': related to locations.
1095 Refer to the stacks thru separate pointers, to allow yyoverflow
1096 to reallocate them elsewhere. */
1098 /* The state stack. */
1099 yytype_int16 yyssa
[YYINITDEPTH
];
1100 yytype_int16
*yyss
= yyssa
;
1101 yytype_int16
*yyssp
;
1103 /* The semantic value stack. */
1104 YYSTYPE yyvsa
[YYINITDEPTH
];
1105 YYSTYPE
*yyvs
= yyvsa
;
1110 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1112 YYSIZE_T yystacksize
= YYINITDEPTH
;
1114 /* The variables used to return semantic value and location from the
1119 /* The number of symbols on the RHS of the reduced rule.
1120 Keep to zero when no symbol should be popped. */
1123 YYDPRINTF ((stderr
, "Starting parse\n"));
1128 yychar
= YYEMPTY
; /* Cause a token to be read. */
1130 /* Initialize stack pointers.
1131 Waste one element of value and location stack
1132 so that they stay on the same level as the state stack.
1133 The wasted elements are never initialized. */
1140 /*------------------------------------------------------------.
1141 | yynewstate -- Push a new state, which is found in yystate. |
1142 `------------------------------------------------------------*/
1144 /* In all cases, when you get here, the value and location stacks
1145 have just been pushed. So pushing a state here evens the stacks. */
1151 if (yyss
+ yystacksize
- 1 <= yyssp
)
1153 /* Get the current used size of the three stacks, in elements. */
1154 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1158 /* Give user a chance to reallocate the stack. Use copies of
1159 these so that the &'s don't force the real ones into
1161 YYSTYPE
*yyvs1
= yyvs
;
1162 yytype_int16
*yyss1
= yyss
;
1165 /* Each stack pointer address is followed by the size of the
1166 data in use in that stack, in bytes. This used to be a
1167 conditional around just the two extra args, but that might
1168 be undefined if yyoverflow is a macro. */
1169 yyoverflow (YY_("memory exhausted"),
1170 &yyss1
, yysize
* sizeof (*yyssp
),
1171 &yyvs1
, yysize
* sizeof (*yyvsp
),
1178 #else /* no yyoverflow */
1179 # ifndef YYSTACK_RELOCATE
1180 goto yyexhaustedlab
;
1182 /* Extend the stack our own way. */
1183 if (YYMAXDEPTH
<= yystacksize
)
1184 goto yyexhaustedlab
;
1186 if (YYMAXDEPTH
< yystacksize
)
1187 yystacksize
= YYMAXDEPTH
;
1190 yytype_int16
*yyss1
= yyss
;
1191 union yyalloc
*yyptr
=
1192 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1194 goto yyexhaustedlab
;
1195 YYSTACK_RELOCATE (yyss
);
1196 YYSTACK_RELOCATE (yyvs
);
1198 # undef YYSTACK_RELOCATE
1200 YYSTACK_FREE (yyss1
);
1203 #endif /* no yyoverflow */
1205 yyssp
= yyss
+ yysize
- 1;
1206 yyvsp
= yyvs
+ yysize
- 1;
1209 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1210 (unsigned long int) yystacksize
));
1212 if (yyss
+ yystacksize
- 1 <= yyssp
)
1216 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1225 /* Do appropriate processing given the current state. Read a
1226 look-ahead token if we need one and don't already have one. */
1228 /* First try to decide what to do without reference to look-ahead token. */
1229 yyn
= yypact
[yystate
];
1230 if (yyn
== YYPACT_NINF
)
1233 /* Not known => get a look-ahead token if don't already have one. */
1235 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1236 if (yychar
== YYEMPTY
)
1238 YYDPRINTF ((stderr
, "Reading a token: "));
1242 if (yychar
<= YYEOF
)
1244 yychar
= yytoken
= YYEOF
;
1245 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1249 yytoken
= YYTRANSLATE (yychar
);
1250 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1253 /* If the proper action on seeing token YYTOKEN is to reduce or to
1254 detect an error, take that action. */
1256 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1261 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1270 /* Count tokens shifted since error; after three, turn off error
1275 /* Shift the look-ahead token. */
1276 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1278 /* Discard the shifted token unless it is eof. */
1279 if (yychar
!= YYEOF
)
1288 /*-----------------------------------------------------------.
1289 | yydefault -- do the default action for the current state. |
1290 `-----------------------------------------------------------*/
1292 yyn
= yydefact
[yystate
];
1298 /*-----------------------------.
1299 | yyreduce -- Do a reduction. |
1300 `-----------------------------*/
1302 /* yyn is the number of a rule to reduce with. */
1305 /* If YYLEN is nonzero, implement the default value of the action:
1308 Otherwise, the following line sets YYVAL to garbage.
1309 This behavior is undocumented and Bison
1310 users should not rely upon it. Assigning to YYVAL
1311 unconditionally makes the parser a bit smaller, and it avoids a
1312 GCC warning that YYVAL may be used uninitialized. */
1313 yyval
= yyvsp
[1-yylen
];
1316 YY_REDUCE_PRINT (yyn
);
1321 { yyreturn
= (yyvsp
[(1) - (1)]); ;}
1326 { (yyval
) = (yyvsp
[(1) - (1)]); ;}
1331 { (yyval
) = (yyvsp
[(1) - (3)]) + (yyvsp
[(3) - (3)]); ;}
1336 { (yyval
) = (yyvsp
[(1) - (3)]) - (yyvsp
[(3) - (3)]); ;}
1341 { (yyval
) = (yyvsp
[(1) - (3)]) * (yyvsp
[(3) - (3)]); ;}
1346 { (yyval
) = (yyvsp
[(1) - (3)]) / (yyvsp
[(3) - (3)]); ;}
1351 { (yyval
) = -(yyvsp
[(2) - (2)]); ;}
1356 { (yyval
) = pow((yyvsp
[(1) - (3)]), (yyvsp
[(3) - (3)])); ;}
1361 { (yyval
) = (yyvsp
[(2) - (3)]); ;}
1365 /* Line 1267 of yacc.c. */
1369 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
1373 YY_STACK_PRINT (yyss
, yyssp
);
1378 /* Now `shift' the result of the reduction. Determine what state
1379 that goes to, based on the state we popped back to and the rule
1380 number reduced by. */
1384 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1385 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1386 yystate
= yytable
[yystate
];
1388 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1393 /*------------------------------------.
1394 | yyerrlab -- here on detecting error |
1395 `------------------------------------*/
1397 /* If not already recovering from an error, report this error. */
1401 #if ! YYERROR_VERBOSE
1402 yyerror (YY_("syntax error"));
1405 YYSIZE_T yysize
= yysyntax_error (0, yystate
, yychar
);
1406 if (yymsg_alloc
< yysize
&& yymsg_alloc
< YYSTACK_ALLOC_MAXIMUM
)
1408 YYSIZE_T yyalloc
= 2 * yysize
;
1409 if (! (yysize
<= yyalloc
&& yyalloc
<= YYSTACK_ALLOC_MAXIMUM
))
1410 yyalloc
= YYSTACK_ALLOC_MAXIMUM
;
1411 if (yymsg
!= yymsgbuf
)
1412 YYSTACK_FREE (yymsg
);
1413 yymsg
= (char *) YYSTACK_ALLOC (yyalloc
);
1415 yymsg_alloc
= yyalloc
;
1419 yymsg_alloc
= sizeof yymsgbuf
;
1423 if (0 < yysize
&& yysize
<= yymsg_alloc
)
1425 (void) yysyntax_error (yymsg
, yystate
, yychar
);
1430 yyerror (YY_("syntax error"));
1432 goto yyexhaustedlab
;
1440 if (yyerrstatus
== 3)
1442 /* If just tried and failed to reuse look-ahead token after an
1443 error, discard it. */
1445 if (yychar
<= YYEOF
)
1447 /* Return failure if at end of input. */
1448 if (yychar
== YYEOF
)
1453 yydestruct ("Error: discarding",
1459 /* Else will try to reuse look-ahead token after shifting the error
1464 /*---------------------------------------------------.
1465 | yyerrorlab -- error raised explicitly by YYERROR. |
1466 `---------------------------------------------------*/
1469 /* Pacify compilers like GCC when the user code never invokes
1470 YYERROR and the label yyerrorlab therefore never appears in user
1472 if (/*CONSTCOND*/ 0)
1475 /* Do not reclaim the symbols of the rule which action triggered
1479 YY_STACK_PRINT (yyss
, yyssp
);
1484 /*-------------------------------------------------------------.
1485 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1486 `-------------------------------------------------------------*/
1488 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1492 yyn
= yypact
[yystate
];
1493 if (yyn
!= YYPACT_NINF
)
1496 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1504 /* Pop the current state because it cannot handle the error token. */
1509 yydestruct ("Error: popping",
1510 yystos
[yystate
], yyvsp
);
1513 YY_STACK_PRINT (yyss
, yyssp
);
1522 /* Shift the error token. */
1523 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
1529 /*-------------------------------------.
1530 | yyacceptlab -- YYACCEPT comes here. |
1531 `-------------------------------------*/
1536 /*-----------------------------------.
1537 | yyabortlab -- YYABORT comes here. |
1538 `-----------------------------------*/
1544 /*-------------------------------------------------.
1545 | yyexhaustedlab -- memory exhaustion comes here. |
1546 `-------------------------------------------------*/
1548 yyerror (YY_("memory exhausted"));
1554 if (yychar
!= YYEOF
&& yychar
!= YYEMPTY
)
1555 yydestruct ("Cleanup: discarding lookahead",
1557 /* Do not reclaim the symbols of the rule which action triggered
1558 this YYABORT or YYACCEPT. */
1560 YY_STACK_PRINT (yyss
, yyssp
);
1561 while (yyssp
!= yyss
)
1563 yydestruct ("Cleanup: popping",
1564 yystos
[*yyssp
], yyvsp
);
1569 YYSTACK_FREE (yyss
);
1572 if (yymsg
!= yymsgbuf
)
1573 YYSTACK_FREE (yymsg
);
1575 /* Make sure YYID is used. */
1576 return YYID (yyresult
);
1583 /*#define EXPRESSION_VERBOSE*/
1585 static const char *yydata
;
1587 int parse_expression(const char *data
, double *d
) {
1590 #ifdef EXPRESSION_VERBOSE
1591 printf("%s = ", data
);
1595 #ifdef EXPRESSION_VERBOSE
1596 printf(" [NULL]\n");
1605 #ifdef EXPRESSION_VERBOSE
1606 printf("%f\n", yyreturn
);
1615 while(isspace(*yydata
)) yydata
++;
1617 if(!*yydata
) return 0;
1619 if(isdigit(*yydata
) || *yydata
== '.') {
1620 yylval
= strtod(yydata
, &p
);
1621 if(p
== yydata
) return 0;
1624 while(isspace(*yydata
)) yydata
++;
1632 void yyerror(const char *s
) {
1633 fprintf(stderr
, "%s: \"%s\"\n", s
, yydata
);