possible fix to bug 5333
[lyx.git] / intl / plural.c
blob9ce0beb436e71ffc288fa11859ec053113425d61
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)
11 any later version.
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. */
47 #define YYBISON 1
49 /* Bison version. */
50 #define YYBISON_VERSION "2.3"
52 /* Skeleton name. */
53 #define YYSKELETON_NAME "yacc.c"
55 /* Pure parsers. */
56 #define YYPURE 1
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
61 /* Substitute the variable and function names. */
62 #define yyparse __gettextparse
63 #define yylex __gettextlex
64 #define yyerror __gettexterror
65 #define yylval __gettextlval
66 #define yychar __gettextchar
67 #define yydebug __gettextdebug
68 #define yynerrs __gettextnerrs
71 /* Tokens. */
72 #ifndef YYTOKENTYPE
73 # define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
77 EQUOP2 = 258,
78 CMPOP2 = 259,
79 ADDOP2 = 260,
80 MULOP2 = 261,
81 NUMBER = 262
83 #endif
84 /* Tokens. */
85 #define EQUOP2 258
86 #define CMPOP2 259
87 #define ADDOP2 260
88 #define MULOP2 261
89 #define NUMBER 262
94 /* Copy the first part of user declarations. */
95 #line 1 "../../lyx-devel/intl/plural.y"
97 /* Expression parsing for plural form selection.
98 Copyright (C) 2000-2001, 2003, 2005 Free Software Foundation, Inc.
99 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
101 This program is free software; you can redistribute it and/or modify it
102 under the terms of the GNU Library General Public License as published
103 by the Free Software Foundation; either version 2, or (at your option)
104 any later version.
106 This program is distributed in the hope that it will be useful,
107 but WITHOUT ANY WARRANTY; without even the implied warranty of
108 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
109 Library General Public License for more details.
111 You should have received a copy of the GNU Library General Public
112 License along with this program; if not, write to the Free Software
113 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
114 USA. */
116 /* For bison < 2.0, the bison generated parser uses alloca. AIX 3 forces us
117 to put this declaration at the beginning of the file. The declaration in
118 bison's skeleton file comes too late. This must come before <config.h>
119 because <config.h> may include arbitrary system headers.
120 This can go away once the AM_INTL_SUBDIR macro requires bison >= 2.0. */
121 #if defined _AIX && !defined __GNUC__
122 #pragma alloca
123 #endif
125 #ifdef HAVE_CONFIG_H
126 # include <config.h>
127 #endif
129 #include <stddef.h>
130 #include <stdlib.h>
131 #include <string.h>
132 #include "plural-exp.h"
134 /* The main function generated by the parser is called __gettextparse,
135 but we want it to be called PLURAL_PARSE. */
136 #ifndef _LIBC
137 # define __gettextparse PLURAL_PARSE
138 #endif
140 #define YYLEX_PARAM &((struct parse_args *) arg)->cp
141 #define YYPARSE_PARAM arg
144 /* Enabling traces. */
145 #ifndef YYDEBUG
146 # define YYDEBUG 0
147 #endif
149 /* Enabling verbose error messages. */
150 #ifdef YYERROR_VERBOSE
151 # undef YYERROR_VERBOSE
152 # define YYERROR_VERBOSE 1
153 #else
154 # define YYERROR_VERBOSE 0
155 #endif
157 /* Enabling the token table. */
158 #ifndef YYTOKEN_TABLE
159 # define YYTOKEN_TABLE 0
160 #endif
162 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
163 typedef union YYSTYPE
164 #line 51 "../../lyx-devel/intl/plural.y"
166 unsigned long int num;
167 enum operator op;
168 struct expression *exp;
170 /* Line 187 of yacc.c. */
171 #line 172 "../../lyx-devel/intl/plural.c"
172 YYSTYPE;
173 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
174 # define YYSTYPE_IS_DECLARED 1
175 # define YYSTYPE_IS_TRIVIAL 1
176 #endif
180 /* Copy the second part of user declarations. */
181 #line 57 "../../lyx-devel/intl/plural.y"
183 /* Prototypes for local functions. */
184 static int yylex (YYSTYPE *lval, const char **pexp);
185 static void yyerror (const char *str);
187 /* Allocation of expressions. */
189 static struct expression *
190 new_exp (int nargs, enum operator op, struct expression * const *args)
192 int i;
193 struct expression *newp;
195 /* If any of the argument could not be malloc'ed, just return NULL. */
196 for (i = nargs - 1; i >= 0; i--)
197 if (args[i] == NULL)
198 goto fail;
200 /* Allocate a new expression. */
201 newp = (struct expression *) malloc (sizeof (*newp));
202 if (newp != NULL)
204 newp->nargs = nargs;
205 newp->operation = op;
206 for (i = nargs - 1; i >= 0; i--)
207 newp->val.args[i] = args[i];
208 return newp;
211 fail:
212 for (i = nargs - 1; i >= 0; i--)
213 FREE_EXPRESSION (args[i]);
215 return NULL;
218 static inline struct expression *
219 new_exp_0 (enum operator op)
221 return new_exp (0, op, NULL);
224 static inline struct expression *
225 new_exp_1 (enum operator op, struct expression *right)
227 struct expression *args[1];
229 args[0] = right;
230 return new_exp (1, op, args);
233 static struct expression *
234 new_exp_2 (enum operator op, struct expression *left, struct expression *right)
236 struct expression *args[2];
238 args[0] = left;
239 args[1] = right;
240 return new_exp (2, op, args);
243 static inline struct expression *
244 new_exp_3 (enum operator op, struct expression *bexp,
245 struct expression *tbranch, struct expression *fbranch)
247 struct expression *args[3];
249 args[0] = bexp;
250 args[1] = tbranch;
251 args[2] = fbranch;
252 return new_exp (3, op, args);
257 /* Line 216 of yacc.c. */
258 #line 259 "../../lyx-devel/intl/plural.c"
260 #ifdef short
261 # undef short
262 #endif
264 #ifdef YYTYPE_UINT8
265 typedef YYTYPE_UINT8 yytype_uint8;
266 #else
267 typedef unsigned char yytype_uint8;
268 #endif
270 #ifdef YYTYPE_INT8
271 typedef YYTYPE_INT8 yytype_int8;
272 #elif (defined __STDC__ || defined __C99__FUNC__ \
273 || defined __cplusplus || defined _MSC_VER)
274 typedef signed char yytype_int8;
275 #else
276 typedef short int yytype_int8;
277 #endif
279 #ifdef YYTYPE_UINT16
280 typedef YYTYPE_UINT16 yytype_uint16;
281 #else
282 typedef unsigned short int yytype_uint16;
283 #endif
285 #ifdef YYTYPE_INT16
286 typedef YYTYPE_INT16 yytype_int16;
287 #else
288 typedef short int yytype_int16;
289 #endif
291 #ifndef YYSIZE_T
292 # ifdef __SIZE_TYPE__
293 # define YYSIZE_T __SIZE_TYPE__
294 # elif defined size_t
295 # define YYSIZE_T size_t
296 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
297 || defined __cplusplus || defined _MSC_VER)
298 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
299 # define YYSIZE_T size_t
300 # else
301 # define YYSIZE_T unsigned int
302 # endif
303 #endif
305 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
307 #ifndef YY_
308 # if YYENABLE_NLS
309 # if ENABLE_NLS
310 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
311 # define YY_(msgid) dgettext ("bison-runtime", msgid)
312 # endif
313 # endif
314 # ifndef YY_
315 # define YY_(msgid) msgid
316 # endif
317 #endif
319 /* Suppress unused-variable warnings by "using" E. */
320 #if ! defined lint || defined __GNUC__
321 # define YYUSE(e) ((void) (e))
322 #else
323 # define YYUSE(e) /* empty */
324 #endif
326 /* Identity function, used to suppress warnings about constant conditions. */
327 #ifndef lint
328 # define YYID(n) (n)
329 #else
330 #if (defined __STDC__ || defined __C99__FUNC__ \
331 || defined __cplusplus || defined _MSC_VER)
332 static int
333 YYID (int i)
334 #else
335 static int
336 YYID (i)
337 int i;
338 #endif
340 return i;
342 #endif
344 #if ! defined yyoverflow || YYERROR_VERBOSE
346 /* The parser invokes alloca or malloc; define the necessary symbols. */
348 # ifdef YYSTACK_USE_ALLOCA
349 # if YYSTACK_USE_ALLOCA
350 # ifdef __GNUC__
351 # define YYSTACK_ALLOC __builtin_alloca
352 # elif defined __BUILTIN_VA_ARG_INCR
353 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
354 # elif defined _AIX
355 # define YYSTACK_ALLOC __alloca
356 # elif defined _MSC_VER
357 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
358 # define alloca _alloca
359 # else
360 # define YYSTACK_ALLOC alloca
361 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
362 || defined __cplusplus || defined _MSC_VER)
363 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
364 # ifndef _STDLIB_H
365 # define _STDLIB_H 1
366 # endif
367 # endif
368 # endif
369 # endif
370 # endif
372 # ifdef YYSTACK_ALLOC
373 /* Pacify GCC's `empty if-body' warning. */
374 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
375 # ifndef YYSTACK_ALLOC_MAXIMUM
376 /* The OS might guarantee only one guard page at the bottom of the stack,
377 and a page size can be as small as 4096 bytes. So we cannot safely
378 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
379 to allow for a few compiler-allocated temporary stack slots. */
380 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
381 # endif
382 # else
383 # define YYSTACK_ALLOC YYMALLOC
384 # define YYSTACK_FREE YYFREE
385 # ifndef YYSTACK_ALLOC_MAXIMUM
386 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
387 # endif
388 # if (defined __cplusplus && ! defined _STDLIB_H \
389 && ! ((defined YYMALLOC || defined malloc) \
390 && (defined YYFREE || defined free)))
391 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
392 # ifndef _STDLIB_H
393 # define _STDLIB_H 1
394 # endif
395 # endif
396 # ifndef YYMALLOC
397 # define YYMALLOC malloc
398 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
399 || defined __cplusplus || defined _MSC_VER)
400 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
401 # endif
402 # endif
403 # ifndef YYFREE
404 # define YYFREE free
405 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
406 || defined __cplusplus || defined _MSC_VER)
407 void free (void *); /* INFRINGES ON USER NAME SPACE */
408 # endif
409 # endif
410 # endif
411 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
414 #if (! defined yyoverflow \
415 && (! defined __cplusplus \
416 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
418 /* A type that is properly aligned for any stack member. */
419 union yyalloc
421 yytype_int16 yyss;
422 YYSTYPE yyvs;
425 /* The size of the maximum gap between one aligned stack and the next. */
426 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
428 /* The size of an array large to enough to hold all stacks, each with
429 N elements. */
430 # define YYSTACK_BYTES(N) \
431 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
432 + YYSTACK_GAP_MAXIMUM)
434 /* Copy COUNT objects from FROM to TO. The source and destination do
435 not overlap. */
436 # ifndef YYCOPY
437 # if defined __GNUC__ && 1 < __GNUC__
438 # define YYCOPY(To, From, Count) \
439 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
440 # else
441 # define YYCOPY(To, From, Count) \
442 do \
444 YYSIZE_T yyi; \
445 for (yyi = 0; yyi < (Count); yyi++) \
446 (To)[yyi] = (From)[yyi]; \
448 while (YYID (0))
449 # endif
450 # endif
452 /* Relocate STACK from its old location to the new one. The
453 local variables YYSIZE and YYSTACKSIZE give the old and new number of
454 elements in the stack, and YYPTR gives the new location of the
455 stack. Advance YYPTR to a properly aligned location for the next
456 stack. */
457 # define YYSTACK_RELOCATE(Stack) \
458 do \
460 YYSIZE_T yynewbytes; \
461 YYCOPY (&yyptr->Stack, Stack, yysize); \
462 Stack = &yyptr->Stack; \
463 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
464 yyptr += yynewbytes / sizeof (*yyptr); \
466 while (YYID (0))
468 #endif
470 /* YYFINAL -- State number of the termination state. */
471 #define YYFINAL 9
472 /* YYLAST -- Last index in YYTABLE. */
473 #define YYLAST 54
475 /* YYNTOKENS -- Number of terminals. */
476 #define YYNTOKENS 16
477 /* YYNNTS -- Number of nonterminals. */
478 #define YYNNTS 3
479 /* YYNRULES -- Number of rules. */
480 #define YYNRULES 13
481 /* YYNRULES -- Number of states. */
482 #define YYNSTATES 27
484 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
485 #define YYUNDEFTOK 2
486 #define YYMAXUTOK 262
488 #define YYTRANSLATE(YYX) \
489 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
491 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
492 static const yytype_uint8 yytranslate[] =
494 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
495 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
496 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
497 2, 2, 2, 10, 2, 2, 2, 2, 5, 2,
498 14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
499 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
500 2, 2, 2, 3, 2, 2, 2, 2, 2, 2,
501 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
502 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
503 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
504 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
505 13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
506 2, 2, 2, 2, 4, 2, 2, 2, 2, 2,
507 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
508 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
509 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
510 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
511 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
512 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
513 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
514 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
515 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
516 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
518 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
519 2, 2, 2, 2, 2, 2, 1, 2, 6, 7,
520 8, 9, 11
523 #if YYDEBUG
524 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
525 YYRHS. */
526 static const yytype_uint8 yyprhs[] =
528 0, 0, 3, 5, 11, 15, 19, 23, 27, 31,
529 35, 38, 40, 42
532 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
533 static const yytype_int8 yyrhs[] =
535 17, 0, -1, 18, -1, 18, 3, 18, 12, 18,
536 -1, 18, 4, 18, -1, 18, 5, 18, -1, 18,
537 6, 18, -1, 18, 7, 18, -1, 18, 8, 18,
538 -1, 18, 9, 18, -1, 10, 18, -1, 13, -1,
539 11, -1, 14, 18, 15, -1
542 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
543 static const yytype_uint8 yyrline[] =
545 0, 152, 152, 160, 164, 168, 172, 176, 180, 184,
546 188, 192, 196, 201
548 #endif
550 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
551 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
552 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
553 static const char *const yytname[] =
555 "$end", "error", "$undefined", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
556 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
557 "$accept", "start", "exp", 0
559 #endif
561 # ifdef YYPRINT
562 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
563 token YYLEX-NUM. */
564 static const yytype_uint16 yytoknum[] =
566 0, 256, 257, 63, 124, 38, 258, 259, 260, 261,
567 33, 262, 58, 110, 40, 41
569 # endif
571 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
572 static const yytype_uint8 yyr1[] =
574 0, 16, 17, 18, 18, 18, 18, 18, 18, 18,
575 18, 18, 18, 18
578 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
579 static const yytype_uint8 yyr2[] =
581 0, 2, 1, 5, 3, 3, 3, 3, 3, 3,
582 2, 1, 1, 3
585 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
586 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
587 means the default is an error. */
588 static const yytype_uint8 yydefact[] =
590 0, 0, 12, 11, 0, 0, 2, 10, 0, 1,
591 0, 0, 0, 0, 0, 0, 0, 13, 0, 4,
592 5, 6, 7, 8, 9, 0, 3
595 /* YYDEFGOTO[NTERM-NUM]. */
596 static const yytype_int8 yydefgoto[] =
598 -1, 5, 6
601 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
602 STATE-NUM. */
603 #define YYPACT_NINF -10
604 static const yytype_int8 yypact[] =
606 -9, -9, -10, -10, -9, 8, 36, -10, 13, -10,
607 -9, -9, -9, -9, -9, -9, -9, -10, 26, 41,
608 45, 18, -2, 14, -10, -9, 36
611 /* YYPGOTO[NTERM-NUM]. */
612 static const yytype_int8 yypgoto[] =
614 -10, -10, -1
617 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
618 positive, shift that token. If negative, reduce the rule which
619 number is the opposite. If zero, do what YYDEFACT says.
620 If YYTABLE_NINF, syntax error. */
621 #define YYTABLE_NINF -1
622 static const yytype_uint8 yytable[] =
624 7, 1, 2, 8, 3, 4, 15, 16, 9, 18,
625 19, 20, 21, 22, 23, 24, 10, 11, 12, 13,
626 14, 15, 16, 16, 26, 14, 15, 16, 17, 10,
627 11, 12, 13, 14, 15, 16, 0, 0, 25, 10,
628 11, 12, 13, 14, 15, 16, 12, 13, 14, 15,
629 16, 13, 14, 15, 16
632 static const yytype_int8 yycheck[] =
634 1, 10, 11, 4, 13, 14, 8, 9, 0, 10,
635 11, 12, 13, 14, 15, 16, 3, 4, 5, 6,
636 7, 8, 9, 9, 25, 7, 8, 9, 15, 3,
637 4, 5, 6, 7, 8, 9, -1, -1, 12, 3,
638 4, 5, 6, 7, 8, 9, 5, 6, 7, 8,
639 9, 6, 7, 8, 9
642 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
643 symbol of state STATE-NUM. */
644 static const yytype_uint8 yystos[] =
646 0, 10, 11, 13, 14, 17, 18, 18, 18, 0,
647 3, 4, 5, 6, 7, 8, 9, 15, 18, 18,
648 18, 18, 18, 18, 18, 12, 18
651 #define yyerrok (yyerrstatus = 0)
652 #define yyclearin (yychar = YYEMPTY)
653 #define YYEMPTY (-2)
654 #define YYEOF 0
656 #define YYACCEPT goto yyacceptlab
657 #define YYABORT goto yyabortlab
658 #define YYERROR goto yyerrorlab
661 /* Like YYERROR except do call yyerror. This remains here temporarily
662 to ease the transition to the new meaning of YYERROR, for GCC.
663 Once GCC version 2 has supplanted version 1, this can go. */
665 #define YYFAIL goto yyerrlab
667 #define YYRECOVERING() (!!yyerrstatus)
669 #define YYBACKUP(Token, Value) \
670 do \
671 if (yychar == YYEMPTY && yylen == 1) \
673 yychar = (Token); \
674 yylval = (Value); \
675 yytoken = YYTRANSLATE (yychar); \
676 YYPOPSTACK (1); \
677 goto yybackup; \
679 else \
681 yyerror (YY_("syntax error: cannot back up")); \
682 YYERROR; \
684 while (YYID (0))
687 #define YYTERROR 1
688 #define YYERRCODE 256
691 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
692 If N is 0, then set CURRENT to the empty location which ends
693 the previous symbol: RHS[0] (always defined). */
695 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
696 #ifndef YYLLOC_DEFAULT
697 # define YYLLOC_DEFAULT(Current, Rhs, N) \
698 do \
699 if (YYID (N)) \
701 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
702 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
703 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
704 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
706 else \
708 (Current).first_line = (Current).last_line = \
709 YYRHSLOC (Rhs, 0).last_line; \
710 (Current).first_column = (Current).last_column = \
711 YYRHSLOC (Rhs, 0).last_column; \
713 while (YYID (0))
714 #endif
717 /* YY_LOCATION_PRINT -- Print the location on the stream.
718 This macro was not mandated originally: define only if we know
719 we won't break user code: when these are the locations we know. */
721 #ifndef YY_LOCATION_PRINT
722 # if YYLTYPE_IS_TRIVIAL
723 # define YY_LOCATION_PRINT(File, Loc) \
724 fprintf (File, "%d.%d-%d.%d", \
725 (Loc).first_line, (Loc).first_column, \
726 (Loc).last_line, (Loc).last_column)
727 # else
728 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
729 # endif
730 #endif
733 /* YYLEX -- calling `yylex' with the right arguments. */
735 #ifdef YYLEX_PARAM
736 # define YYLEX yylex (&yylval, YYLEX_PARAM)
737 #else
738 # define YYLEX yylex (&yylval)
739 #endif
741 /* Enable debugging if requested. */
742 #if YYDEBUG
744 # ifndef YYFPRINTF
745 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
746 # define YYFPRINTF fprintf
747 # endif
749 # define YYDPRINTF(Args) \
750 do { \
751 if (yydebug) \
752 YYFPRINTF Args; \
753 } while (YYID (0))
755 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
756 do { \
757 if (yydebug) \
759 YYFPRINTF (stderr, "%s ", Title); \
760 yy_symbol_print (stderr, \
761 Type, Value); \
762 YYFPRINTF (stderr, "\n"); \
764 } while (YYID (0))
767 /*--------------------------------.
768 | Print this symbol on YYOUTPUT. |
769 `--------------------------------*/
771 /*ARGSUSED*/
772 #if (defined __STDC__ || defined __C99__FUNC__ \
773 || defined __cplusplus || defined _MSC_VER)
774 static void
775 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
776 #else
777 static void
778 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
779 FILE *yyoutput;
780 int yytype;
781 YYSTYPE const * const yyvaluep;
782 #endif
784 if (!yyvaluep)
785 return;
786 # ifdef YYPRINT
787 if (yytype < YYNTOKENS)
788 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
789 # else
790 YYUSE (yyoutput);
791 # endif
792 switch (yytype)
794 default:
795 break;
800 /*--------------------------------.
801 | Print this symbol on YYOUTPUT. |
802 `--------------------------------*/
804 #if (defined __STDC__ || defined __C99__FUNC__ \
805 || defined __cplusplus || defined _MSC_VER)
806 static void
807 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
808 #else
809 static void
810 yy_symbol_print (yyoutput, yytype, yyvaluep)
811 FILE *yyoutput;
812 int yytype;
813 YYSTYPE const * const yyvaluep;
814 #endif
816 if (yytype < YYNTOKENS)
817 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
818 else
819 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
821 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
822 YYFPRINTF (yyoutput, ")");
825 /*------------------------------------------------------------------.
826 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
827 | TOP (included). |
828 `------------------------------------------------------------------*/
830 #if (defined __STDC__ || defined __C99__FUNC__ \
831 || defined __cplusplus || defined _MSC_VER)
832 static void
833 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
834 #else
835 static void
836 yy_stack_print (bottom, top)
837 yytype_int16 *bottom;
838 yytype_int16 *top;
839 #endif
841 YYFPRINTF (stderr, "Stack now");
842 for (; bottom <= top; ++bottom)
843 YYFPRINTF (stderr, " %d", *bottom);
844 YYFPRINTF (stderr, "\n");
847 # define YY_STACK_PRINT(Bottom, Top) \
848 do { \
849 if (yydebug) \
850 yy_stack_print ((Bottom), (Top)); \
851 } while (YYID (0))
854 /*------------------------------------------------.
855 | Report that the YYRULE is going to be reduced. |
856 `------------------------------------------------*/
858 #if (defined __STDC__ || defined __C99__FUNC__ \
859 || defined __cplusplus || defined _MSC_VER)
860 static void
861 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
862 #else
863 static void
864 yy_reduce_print (yyvsp, yyrule)
865 YYSTYPE *yyvsp;
866 int yyrule;
867 #endif
869 int yynrhs = yyr2[yyrule];
870 int yyi;
871 unsigned long int yylno = yyrline[yyrule];
872 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
873 yyrule - 1, yylno);
874 /* The symbols being reduced. */
875 for (yyi = 0; yyi < yynrhs; yyi++)
877 fprintf (stderr, " $%d = ", yyi + 1);
878 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
879 &(yyvsp[(yyi + 1) - (yynrhs)])
881 fprintf (stderr, "\n");
885 # define YY_REDUCE_PRINT(Rule) \
886 do { \
887 if (yydebug) \
888 yy_reduce_print (yyvsp, Rule); \
889 } while (YYID (0))
891 /* Nonzero means print parse trace. It is left uninitialized so that
892 multiple parsers can coexist. */
893 int yydebug;
894 #else /* !YYDEBUG */
895 # define YYDPRINTF(Args)
896 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
897 # define YY_STACK_PRINT(Bottom, Top)
898 # define YY_REDUCE_PRINT(Rule)
899 #endif /* !YYDEBUG */
902 /* YYINITDEPTH -- initial size of the parser's stacks. */
903 #ifndef YYINITDEPTH
904 # define YYINITDEPTH 200
905 #endif
907 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
908 if the built-in stack extension method is used).
910 Do not make this value too large; the results are undefined if
911 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
912 evaluated with infinite-precision integer arithmetic. */
914 #ifndef YYMAXDEPTH
915 # define YYMAXDEPTH 10000
916 #endif
920 #if YYERROR_VERBOSE
922 # ifndef yystrlen
923 # if defined __GLIBC__ && defined _STRING_H
924 # define yystrlen strlen
925 # else
926 /* Return the length of YYSTR. */
927 #if (defined __STDC__ || defined __C99__FUNC__ \
928 || defined __cplusplus || defined _MSC_VER)
929 static YYSIZE_T
930 yystrlen (const char *yystr)
931 #else
932 static YYSIZE_T
933 yystrlen (yystr)
934 const char *yystr;
935 #endif
937 YYSIZE_T yylen;
938 for (yylen = 0; yystr[yylen]; yylen++)
939 continue;
940 return yylen;
942 # endif
943 # endif
945 # ifndef yystpcpy
946 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
947 # define yystpcpy stpcpy
948 # else
949 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
950 YYDEST. */
951 #if (defined __STDC__ || defined __C99__FUNC__ \
952 || defined __cplusplus || defined _MSC_VER)
953 static char *
954 yystpcpy (char *yydest, const char *yysrc)
955 #else
956 static char *
957 yystpcpy (yydest, yysrc)
958 char *yydest;
959 const char *yysrc;
960 #endif
962 char *yyd = yydest;
963 const char *yys = yysrc;
965 while ((*yyd++ = *yys++) != '\0')
966 continue;
968 return yyd - 1;
970 # endif
971 # endif
973 # ifndef yytnamerr
974 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
975 quotes and backslashes, so that it's suitable for yyerror. The
976 heuristic is that double-quoting is unnecessary unless the string
977 contains an apostrophe, a comma, or backslash (other than
978 backslash-backslash). YYSTR is taken from yytname. If YYRES is
979 null, do not copy; instead, return the length of what the result
980 would have been. */
981 static YYSIZE_T
982 yytnamerr (char *yyres, const char *yystr)
984 if (*yystr == '"')
986 YYSIZE_T yyn = 0;
987 char const *yyp = yystr;
989 for (;;)
990 switch (*++yyp)
992 case '\'':
993 case ',':
994 goto do_not_strip_quotes;
996 case '\\':
997 if (*++yyp != '\\')
998 goto do_not_strip_quotes;
999 /* Fall through. */
1000 default:
1001 if (yyres)
1002 yyres[yyn] = *yyp;
1003 yyn++;
1004 break;
1006 case '"':
1007 if (yyres)
1008 yyres[yyn] = '\0';
1009 return yyn;
1011 do_not_strip_quotes: ;
1014 if (! yyres)
1015 return yystrlen (yystr);
1017 return yystpcpy (yyres, yystr) - yyres;
1019 # endif
1021 /* Copy into YYRESULT an error message about the unexpected token
1022 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1023 including the terminating null byte. If YYRESULT is null, do not
1024 copy anything; just return the number of bytes that would be
1025 copied. As a special case, return 0 if an ordinary "syntax error"
1026 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1027 size calculation. */
1028 static YYSIZE_T
1029 yysyntax_error (char *yyresult, int yystate, int yychar)
1031 int yyn = yypact[yystate];
1033 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1034 return 0;
1035 else
1037 int yytype = YYTRANSLATE (yychar);
1038 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1039 YYSIZE_T yysize = yysize0;
1040 YYSIZE_T yysize1;
1041 int yysize_overflow = 0;
1042 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1043 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1044 int yyx;
1046 # if 0
1047 /* This is so xgettext sees the translatable formats that are
1048 constructed on the fly. */
1049 YY_("syntax error, unexpected %s");
1050 YY_("syntax error, unexpected %s, expecting %s");
1051 YY_("syntax error, unexpected %s, expecting %s or %s");
1052 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1053 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1054 # endif
1055 char *yyfmt;
1056 char const *yyf;
1057 static char const yyunexpected[] = "syntax error, unexpected %s";
1058 static char const yyexpecting[] = ", expecting %s";
1059 static char const yyor[] = " or %s";
1060 char yyformat[sizeof yyunexpected
1061 + sizeof yyexpecting - 1
1062 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1063 * (sizeof yyor - 1))];
1064 char const *yyprefix = yyexpecting;
1066 /* Start YYX at -YYN if negative to avoid negative indexes in
1067 YYCHECK. */
1068 int yyxbegin = yyn < 0 ? -yyn : 0;
1070 /* Stay within bounds of both yycheck and yytname. */
1071 int yychecklim = YYLAST - yyn + 1;
1072 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1073 int yycount = 1;
1075 yyarg[0] = yytname[yytype];
1076 yyfmt = yystpcpy (yyformat, yyunexpected);
1078 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1079 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1081 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1083 yycount = 1;
1084 yysize = yysize0;
1085 yyformat[sizeof yyunexpected - 1] = '\0';
1086 break;
1088 yyarg[yycount++] = yytname[yyx];
1089 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1090 yysize_overflow |= (yysize1 < yysize);
1091 yysize = yysize1;
1092 yyfmt = yystpcpy (yyfmt, yyprefix);
1093 yyprefix = yyor;
1096 yyf = YY_(yyformat);
1097 yysize1 = yysize + yystrlen (yyf);
1098 yysize_overflow |= (yysize1 < yysize);
1099 yysize = yysize1;
1101 if (yysize_overflow)
1102 return YYSIZE_MAXIMUM;
1104 if (yyresult)
1106 /* Avoid sprintf, as that infringes on the user's name space.
1107 Don't have undefined behavior even if the translation
1108 produced a string with the wrong number of "%s"s. */
1109 char *yyp = yyresult;
1110 int yyi = 0;
1111 while ((*yyp = *yyf) != '\0')
1113 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1115 yyp += yytnamerr (yyp, yyarg[yyi++]);
1116 yyf += 2;
1118 else
1120 yyp++;
1121 yyf++;
1125 return yysize;
1128 #endif /* YYERROR_VERBOSE */
1131 /*-----------------------------------------------.
1132 | Release the memory associated to this symbol. |
1133 `-----------------------------------------------*/
1135 /*ARGSUSED*/
1136 #if (defined __STDC__ || defined __C99__FUNC__ \
1137 || defined __cplusplus || defined _MSC_VER)
1138 static void
1139 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1140 #else
1141 static void
1142 yydestruct (yymsg, yytype, yyvaluep)
1143 const char *yymsg;
1144 int yytype;
1145 YYSTYPE *yyvaluep;
1146 #endif
1148 YYUSE (yyvaluep);
1150 if (!yymsg)
1151 yymsg = "Deleting";
1152 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1154 switch (yytype)
1157 default:
1158 break;
1163 /* Prevent warnings from -Wmissing-prototypes. */
1165 #ifdef YYPARSE_PARAM
1166 #if defined __STDC__ || defined __cplusplus
1167 int yyparse (void *YYPARSE_PARAM);
1168 #else
1169 int yyparse ();
1170 #endif
1171 #else /* ! YYPARSE_PARAM */
1172 #if defined __STDC__ || defined __cplusplus
1173 int yyparse (void);
1174 #else
1175 int yyparse ();
1176 #endif
1177 #endif /* ! YYPARSE_PARAM */
1184 /*----------.
1185 | yyparse. |
1186 `----------*/
1188 #ifdef YYPARSE_PARAM
1189 #if (defined __STDC__ || defined __C99__FUNC__ \
1190 || defined __cplusplus || defined _MSC_VER)
1192 yyparse (void *YYPARSE_PARAM)
1193 #else
1195 yyparse (YYPARSE_PARAM)
1196 void *YYPARSE_PARAM;
1197 #endif
1198 #else /* ! YYPARSE_PARAM */
1199 #if (defined __STDC__ || defined __C99__FUNC__ \
1200 || defined __cplusplus || defined _MSC_VER)
1202 yyparse (void)
1203 #else
1205 yyparse ()
1207 #endif
1208 #endif
1210 /* The look-ahead symbol. */
1211 int yychar;
1213 /* The semantic value of the look-ahead symbol. */
1214 YYSTYPE yylval;
1216 /* Number of syntax errors so far. */
1217 int yynerrs;
1219 int yystate;
1220 int yyn;
1221 int yyresult;
1222 /* Number of tokens to shift before error messages enabled. */
1223 int yyerrstatus;
1224 /* Look-ahead token as an internal (translated) token number. */
1225 int yytoken = 0;
1226 #if YYERROR_VERBOSE
1227 /* Buffer for error messages, and its allocated size. */
1228 char yymsgbuf[128];
1229 char *yymsg = yymsgbuf;
1230 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1231 #endif
1233 /* Three stacks and their tools:
1234 `yyss': related to states,
1235 `yyvs': related to semantic values,
1236 `yyls': related to locations.
1238 Refer to the stacks thru separate pointers, to allow yyoverflow
1239 to reallocate them elsewhere. */
1241 /* The state stack. */
1242 yytype_int16 yyssa[YYINITDEPTH];
1243 yytype_int16 *yyss = yyssa;
1244 yytype_int16 *yyssp;
1246 /* The semantic value stack. */
1247 YYSTYPE yyvsa[YYINITDEPTH];
1248 YYSTYPE *yyvs = yyvsa;
1249 YYSTYPE *yyvsp;
1253 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1255 YYSIZE_T yystacksize = YYINITDEPTH;
1257 /* The variables used to return semantic value and location from the
1258 action routines. */
1259 YYSTYPE yyval;
1262 /* The number of symbols on the RHS of the reduced rule.
1263 Keep to zero when no symbol should be popped. */
1264 int yylen = 0;
1266 YYDPRINTF ((stderr, "Starting parse\n"));
1268 yystate = 0;
1269 yyerrstatus = 0;
1270 yynerrs = 0;
1271 yychar = YYEMPTY; /* Cause a token to be read. */
1273 /* Initialize stack pointers.
1274 Waste one element of value and location stack
1275 so that they stay on the same level as the state stack.
1276 The wasted elements are never initialized. */
1278 yyssp = yyss;
1279 yyvsp = yyvs;
1281 goto yysetstate;
1283 /*------------------------------------------------------------.
1284 | yynewstate -- Push a new state, which is found in yystate. |
1285 `------------------------------------------------------------*/
1286 yynewstate:
1287 /* In all cases, when you get here, the value and location stacks
1288 have just been pushed. So pushing a state here evens the stacks. */
1289 yyssp++;
1291 yysetstate:
1292 *yyssp = yystate;
1294 if (yyss + yystacksize - 1 <= yyssp)
1296 /* Get the current used size of the three stacks, in elements. */
1297 YYSIZE_T yysize = yyssp - yyss + 1;
1299 #ifdef yyoverflow
1301 /* Give user a chance to reallocate the stack. Use copies of
1302 these so that the &'s don't force the real ones into
1303 memory. */
1304 YYSTYPE *yyvs1 = yyvs;
1305 yytype_int16 *yyss1 = yyss;
1308 /* Each stack pointer address is followed by the size of the
1309 data in use in that stack, in bytes. This used to be a
1310 conditional around just the two extra args, but that might
1311 be undefined if yyoverflow is a macro. */
1312 yyoverflow (YY_("memory exhausted"),
1313 &yyss1, yysize * sizeof (*yyssp),
1314 &yyvs1, yysize * sizeof (*yyvsp),
1316 &yystacksize);
1318 yyss = yyss1;
1319 yyvs = yyvs1;
1321 #else /* no yyoverflow */
1322 # ifndef YYSTACK_RELOCATE
1323 goto yyexhaustedlab;
1324 # else
1325 /* Extend the stack our own way. */
1326 if (YYMAXDEPTH <= yystacksize)
1327 goto yyexhaustedlab;
1328 yystacksize *= 2;
1329 if (YYMAXDEPTH < yystacksize)
1330 yystacksize = YYMAXDEPTH;
1333 yytype_int16 *yyss1 = yyss;
1334 union yyalloc *yyptr =
1335 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1336 if (! yyptr)
1337 goto yyexhaustedlab;
1338 YYSTACK_RELOCATE (yyss);
1339 YYSTACK_RELOCATE (yyvs);
1341 # undef YYSTACK_RELOCATE
1342 if (yyss1 != yyssa)
1343 YYSTACK_FREE (yyss1);
1345 # endif
1346 #endif /* no yyoverflow */
1348 yyssp = yyss + yysize - 1;
1349 yyvsp = yyvs + yysize - 1;
1352 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1353 (unsigned long int) yystacksize));
1355 if (yyss + yystacksize - 1 <= yyssp)
1356 YYABORT;
1359 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1361 goto yybackup;
1363 /*-----------.
1364 | yybackup. |
1365 `-----------*/
1366 yybackup:
1368 /* Do appropriate processing given the current state. Read a
1369 look-ahead token if we need one and don't already have one. */
1371 /* First try to decide what to do without reference to look-ahead token. */
1372 yyn = yypact[yystate];
1373 if (yyn == YYPACT_NINF)
1374 goto yydefault;
1376 /* Not known => get a look-ahead token if don't already have one. */
1378 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1379 if (yychar == YYEMPTY)
1381 YYDPRINTF ((stderr, "Reading a token: "));
1382 yychar = YYLEX;
1385 if (yychar <= YYEOF)
1387 yychar = yytoken = YYEOF;
1388 YYDPRINTF ((stderr, "Now at end of input.\n"));
1390 else
1392 yytoken = YYTRANSLATE (yychar);
1393 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1396 /* If the proper action on seeing token YYTOKEN is to reduce or to
1397 detect an error, take that action. */
1398 yyn += yytoken;
1399 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1400 goto yydefault;
1401 yyn = yytable[yyn];
1402 if (yyn <= 0)
1404 if (yyn == 0 || yyn == YYTABLE_NINF)
1405 goto yyerrlab;
1406 yyn = -yyn;
1407 goto yyreduce;
1410 if (yyn == YYFINAL)
1411 YYACCEPT;
1413 /* Count tokens shifted since error; after three, turn off error
1414 status. */
1415 if (yyerrstatus)
1416 yyerrstatus--;
1418 /* Shift the look-ahead token. */
1419 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1421 /* Discard the shifted token unless it is eof. */
1422 if (yychar != YYEOF)
1423 yychar = YYEMPTY;
1425 yystate = yyn;
1426 *++yyvsp = yylval;
1428 goto yynewstate;
1431 /*-----------------------------------------------------------.
1432 | yydefault -- do the default action for the current state. |
1433 `-----------------------------------------------------------*/
1434 yydefault:
1435 yyn = yydefact[yystate];
1436 if (yyn == 0)
1437 goto yyerrlab;
1438 goto yyreduce;
1441 /*-----------------------------.
1442 | yyreduce -- Do a reduction. |
1443 `-----------------------------*/
1444 yyreduce:
1445 /* yyn is the number of a rule to reduce with. */
1446 yylen = yyr2[yyn];
1448 /* If YYLEN is nonzero, implement the default value of the action:
1449 `$$ = $1'.
1451 Otherwise, the following line sets YYVAL to garbage.
1452 This behavior is undocumented and Bison
1453 users should not rely upon it. Assigning to YYVAL
1454 unconditionally makes the parser a bit smaller, and it avoids a
1455 GCC warning that YYVAL may be used uninitialized. */
1456 yyval = yyvsp[1-yylen];
1459 YY_REDUCE_PRINT (yyn);
1460 switch (yyn)
1462 case 2:
1463 #line 153 "../../lyx-devel/intl/plural.y"
1465 if ((yyvsp[(1) - (1)].exp) == NULL)
1466 YYABORT;
1467 ((struct parse_args *) arg)->res = (yyvsp[(1) - (1)].exp);
1469 break;
1471 case 3:
1472 #line 161 "../../lyx-devel/intl/plural.y"
1474 (yyval.exp) = new_exp_3 (qmop, (yyvsp[(1) - (5)].exp), (yyvsp[(3) - (5)].exp), (yyvsp[(5) - (5)].exp));
1476 break;
1478 case 4:
1479 #line 165 "../../lyx-devel/intl/plural.y"
1481 (yyval.exp) = new_exp_2 (lor, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1483 break;
1485 case 5:
1486 #line 169 "../../lyx-devel/intl/plural.y"
1488 (yyval.exp) = new_exp_2 (land, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1490 break;
1492 case 6:
1493 #line 173 "../../lyx-devel/intl/plural.y"
1495 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1497 break;
1499 case 7:
1500 #line 177 "../../lyx-devel/intl/plural.y"
1502 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1504 break;
1506 case 8:
1507 #line 181 "../../lyx-devel/intl/plural.y"
1509 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1511 break;
1513 case 9:
1514 #line 185 "../../lyx-devel/intl/plural.y"
1516 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1518 break;
1520 case 10:
1521 #line 189 "../../lyx-devel/intl/plural.y"
1523 (yyval.exp) = new_exp_1 (lnot, (yyvsp[(2) - (2)].exp));
1525 break;
1527 case 11:
1528 #line 193 "../../lyx-devel/intl/plural.y"
1530 (yyval.exp) = new_exp_0 (var);
1532 break;
1534 case 12:
1535 #line 197 "../../lyx-devel/intl/plural.y"
1537 if (((yyval.exp) = new_exp_0 (num)) != NULL)
1538 (yyval.exp)->val.num = (yyvsp[(1) - (1)].num);
1540 break;
1542 case 13:
1543 #line 202 "../../lyx-devel/intl/plural.y"
1545 (yyval.exp) = (yyvsp[(2) - (3)].exp);
1547 break;
1550 /* Line 1267 of yacc.c. */
1551 #line 1552 "../../lyx-devel/intl/plural.c"
1552 default: break;
1554 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1556 YYPOPSTACK (yylen);
1557 yylen = 0;
1558 YY_STACK_PRINT (yyss, yyssp);
1560 *++yyvsp = yyval;
1563 /* Now `shift' the result of the reduction. Determine what state
1564 that goes to, based on the state we popped back to and the rule
1565 number reduced by. */
1567 yyn = yyr1[yyn];
1569 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1570 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1571 yystate = yytable[yystate];
1572 else
1573 yystate = yydefgoto[yyn - YYNTOKENS];
1575 goto yynewstate;
1578 /*------------------------------------.
1579 | yyerrlab -- here on detecting error |
1580 `------------------------------------*/
1581 yyerrlab:
1582 /* If not already recovering from an error, report this error. */
1583 if (!yyerrstatus)
1585 ++yynerrs;
1586 #if ! YYERROR_VERBOSE
1587 yyerror (YY_("syntax error"));
1588 #else
1590 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1591 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1593 YYSIZE_T yyalloc = 2 * yysize;
1594 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1595 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1596 if (yymsg != yymsgbuf)
1597 YYSTACK_FREE (yymsg);
1598 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1599 if (yymsg)
1600 yymsg_alloc = yyalloc;
1601 else
1603 yymsg = yymsgbuf;
1604 yymsg_alloc = sizeof yymsgbuf;
1608 if (0 < yysize && yysize <= yymsg_alloc)
1610 (void) yysyntax_error (yymsg, yystate, yychar);
1611 yyerror (yymsg);
1613 else
1615 yyerror (YY_("syntax error"));
1616 if (yysize != 0)
1617 goto yyexhaustedlab;
1620 #endif
1625 if (yyerrstatus == 3)
1627 /* If just tried and failed to reuse look-ahead token after an
1628 error, discard it. */
1630 if (yychar <= YYEOF)
1632 /* Return failure if at end of input. */
1633 if (yychar == YYEOF)
1634 YYABORT;
1636 else
1638 yydestruct ("Error: discarding",
1639 yytoken, &yylval);
1640 yychar = YYEMPTY;
1644 /* Else will try to reuse look-ahead token after shifting the error
1645 token. */
1646 goto yyerrlab1;
1649 /*---------------------------------------------------.
1650 | yyerrorlab -- error raised explicitly by YYERROR. |
1651 `---------------------------------------------------*/
1652 yyerrorlab:
1654 /* Pacify compilers like GCC when the user code never invokes
1655 YYERROR and the label yyerrorlab therefore never appears in user
1656 code. */
1657 if (/*CONSTCOND*/ 0)
1658 goto yyerrorlab;
1660 /* Do not reclaim the symbols of the rule which action triggered
1661 this YYERROR. */
1662 YYPOPSTACK (yylen);
1663 yylen = 0;
1664 YY_STACK_PRINT (yyss, yyssp);
1665 yystate = *yyssp;
1666 goto yyerrlab1;
1669 /*-------------------------------------------------------------.
1670 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1671 `-------------------------------------------------------------*/
1672 yyerrlab1:
1673 yyerrstatus = 3; /* Each real token shifted decrements this. */
1675 for (;;)
1677 yyn = yypact[yystate];
1678 if (yyn != YYPACT_NINF)
1680 yyn += YYTERROR;
1681 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1683 yyn = yytable[yyn];
1684 if (0 < yyn)
1685 break;
1689 /* Pop the current state because it cannot handle the error token. */
1690 if (yyssp == yyss)
1691 YYABORT;
1694 yydestruct ("Error: popping",
1695 yystos[yystate], yyvsp);
1696 YYPOPSTACK (1);
1697 yystate = *yyssp;
1698 YY_STACK_PRINT (yyss, yyssp);
1701 if (yyn == YYFINAL)
1702 YYACCEPT;
1704 *++yyvsp = yylval;
1707 /* Shift the error token. */
1708 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1710 yystate = yyn;
1711 goto yynewstate;
1714 /*-------------------------------------.
1715 | yyacceptlab -- YYACCEPT comes here. |
1716 `-------------------------------------*/
1717 yyacceptlab:
1718 yyresult = 0;
1719 goto yyreturn;
1721 /*-----------------------------------.
1722 | yyabortlab -- YYABORT comes here. |
1723 `-----------------------------------*/
1724 yyabortlab:
1725 yyresult = 1;
1726 goto yyreturn;
1728 #ifndef yyoverflow
1729 /*-------------------------------------------------.
1730 | yyexhaustedlab -- memory exhaustion comes here. |
1731 `-------------------------------------------------*/
1732 yyexhaustedlab:
1733 yyerror (YY_("memory exhausted"));
1734 yyresult = 2;
1735 /* Fall through. */
1736 #endif
1738 yyreturn:
1739 if (yychar != YYEOF && yychar != YYEMPTY)
1740 yydestruct ("Cleanup: discarding lookahead",
1741 yytoken, &yylval);
1742 /* Do not reclaim the symbols of the rule which action triggered
1743 this YYABORT or YYACCEPT. */
1744 YYPOPSTACK (yylen);
1745 YY_STACK_PRINT (yyss, yyssp);
1746 while (yyssp != yyss)
1748 yydestruct ("Cleanup: popping",
1749 yystos[*yyssp], yyvsp);
1750 YYPOPSTACK (1);
1752 #ifndef yyoverflow
1753 if (yyss != yyssa)
1754 YYSTACK_FREE (yyss);
1755 #endif
1756 #if YYERROR_VERBOSE
1757 if (yymsg != yymsgbuf)
1758 YYSTACK_FREE (yymsg);
1759 #endif
1760 /* Make sure YYID is used. */
1761 return YYID (yyresult);
1765 #line 207 "../../lyx-devel/intl/plural.y"
1768 void
1769 internal_function
1770 FREE_EXPRESSION (struct expression *exp)
1772 if (exp == NULL)
1773 return;
1775 /* Handle the recursive case. */
1776 switch (exp->nargs)
1778 case 3:
1779 FREE_EXPRESSION (exp->val.args[2]);
1780 /* FALLTHROUGH */
1781 case 2:
1782 FREE_EXPRESSION (exp->val.args[1]);
1783 /* FALLTHROUGH */
1784 case 1:
1785 FREE_EXPRESSION (exp->val.args[0]);
1786 /* FALLTHROUGH */
1787 default:
1788 break;
1791 free (exp);
1795 static int
1796 yylex (YYSTYPE *lval, const char **pexp)
1798 const char *exp = *pexp;
1799 int result;
1801 while (1)
1803 if (exp[0] == '\0')
1805 *pexp = exp;
1806 return YYEOF;
1809 if (exp[0] != ' ' && exp[0] != '\t')
1810 break;
1812 ++exp;
1815 result = *exp++;
1816 switch (result)
1818 case '0': case '1': case '2': case '3': case '4':
1819 case '5': case '6': case '7': case '8': case '9':
1821 unsigned long int n = result - '0';
1822 while (exp[0] >= '0' && exp[0] <= '9')
1824 n *= 10;
1825 n += exp[0] - '0';
1826 ++exp;
1828 lval->num = n;
1829 result = NUMBER;
1831 break;
1833 case '=':
1834 if (exp[0] == '=')
1836 ++exp;
1837 lval->op = equal;
1838 result = EQUOP2;
1840 else
1841 result = YYERRCODE;
1842 break;
1844 case '!':
1845 if (exp[0] == '=')
1847 ++exp;
1848 lval->op = not_equal;
1849 result = EQUOP2;
1851 break;
1853 case '&':
1854 case '|':
1855 if (exp[0] == result)
1856 ++exp;
1857 else
1858 result = YYERRCODE;
1859 break;
1861 case '<':
1862 if (exp[0] == '=')
1864 ++exp;
1865 lval->op = less_or_equal;
1867 else
1868 lval->op = less_than;
1869 result = CMPOP2;
1870 break;
1872 case '>':
1873 if (exp[0] == '=')
1875 ++exp;
1876 lval->op = greater_or_equal;
1878 else
1879 lval->op = greater_than;
1880 result = CMPOP2;
1881 break;
1883 case '*':
1884 lval->op = mult;
1885 result = MULOP2;
1886 break;
1888 case '/':
1889 lval->op = divide;
1890 result = MULOP2;
1891 break;
1893 case '%':
1894 lval->op = module;
1895 result = MULOP2;
1896 break;
1898 case '+':
1899 lval->op = plus;
1900 result = ADDOP2;
1901 break;
1903 case '-':
1904 lval->op = minus;
1905 result = ADDOP2;
1906 break;
1908 case 'n':
1909 case '?':
1910 case ':':
1911 case '(':
1912 case ')':
1913 /* Nothing, just return the character. */
1914 break;
1916 case ';':
1917 case '\n':
1918 case '\0':
1919 /* Be safe and let the user call this function again. */
1920 --exp;
1921 result = YYEOF;
1922 break;
1924 default:
1925 result = YYERRCODE;
1926 #if YYDEBUG != 0
1927 --exp;
1928 #endif
1929 break;
1932 *pexp = exp;
1934 return result;
1938 static void
1939 yyerror (const char *str)
1941 /* Do nothing. We don't print error messages here. */