SphinxBase  0.6
jsgf_parser.c
1 /* A Bison parser, made by GNU Bison 2.6.4. */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5  Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
6 
7  This program is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 
20 /* As a special exception, you may create a larger work that contains
21  part or all of the Bison parser skeleton and distribute that work
22  under terms of your choice, so long as that work isn't itself a
23  parser generator using the skeleton or a modified version thereof
24  as a parser skeleton. Alternatively, if you modify or redistribute
25  the parser skeleton itself, you may (at your option) remove this
26  special exception, which will cause the skeleton and the resulting
27  Bison output files to be licensed under the GNU General Public
28  License without this special exception.
29 
30  This special exception was added by the Free Software Foundation in
31  version 2.2 of Bison. */
32 
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34  simplifying the original so-called "semantic" parser. */
35 
36 /* All symbols defined below should begin with yy or YY, to avoid
37  infringing on user name space. This should be done even for local
38  variables, as they might otherwise be expanded by user macros.
39  There are some unavoidable exceptions within include files to
40  define necessary library symbols; they are noted "INFRINGES ON
41  USER NAME SPACE" below. */
42 
43 /* Identify Bison output. */
44 #define YYBISON 1
45 
46 /* Bison version. */
47 #define YYBISON_VERSION "2.6.4"
48 
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51 
52 /* Pure parsers. */
53 #define YYPURE 1
54 
55 /* Push parsers. */
56 #define YYPUSH 0
57 
58 /* Pull parsers. */
59 #define YYPULL 1
60 
61 
62 
63 
64 /* Copy the first part of user declarations. */
65 /* Line 358 of yacc.c */
66 #line 37 "jsgf_parser.y"
67 
68 #define YYERROR_VERBOSE
69 
70 #include <stdio.h>
71 #include <string.h>
72 
73 #include <sphinxbase/hash_table.h>
74 #include <sphinxbase/ckd_alloc.h>
75 #include <sphinxbase/err.h>
76 
77 #include "jsgf_internal.h"
78 #include "jsgf_parser.h"
79 #include "jsgf_scanner.h"
80 
81 /* Suppress warnings from generated code */
82 #if defined _MSC_VER
83 #pragma warning(disable: 4273)
84 #endif
85 
86 void yyerror(yyscan_t lex, jsgf_t *jsgf, const char *s);
87 
88 
89 /* Line 358 of yacc.c */
90 #line 91 "jsgf_parser.c"
91 
92 # ifndef YY_NULL
93 # if defined __cplusplus && 201103L <= __cplusplus
94 # define YY_NULL nullptr
95 # else
96 # define YY_NULL 0
97 # endif
98 # endif
99 
100 /* Enabling verbose error messages. */
101 #ifdef YYERROR_VERBOSE
102 # undef YYERROR_VERBOSE
103 # define YYERROR_VERBOSE 1
104 #else
105 # define YYERROR_VERBOSE 0
106 #endif
107 
108 /* In a future release of Bison, this section will be replaced
109  by #include "y.tab.h". */
110 #ifndef YY_YY_JSGF_PARSER_H_INCLUDED
111 # define YY_YY_JSGF_PARSER_H_INCLUDED
112 /* Enabling traces. */
113 #ifndef YYDEBUG
114 # define YYDEBUG 0
115 #endif
116 #if YYDEBUG
117 extern int yydebug;
118 #endif
119 
120 /* Tokens. */
121 #ifndef YYTOKENTYPE
122 # define YYTOKENTYPE
123  /* Put the tokens into the symbol table, so that GDB and other debuggers
124  know about them. */
125  enum yytokentype {
126  HEADER = 258,
127  GRAMMAR = 259,
128  IMPORT = 260,
129  PUBLIC = 261,
130  TOKEN = 262,
131  RULENAME = 263,
132  TAG = 264,
133  WEIGHT = 265
134  };
135 #endif
136 /* Tokens. */
137 #define HEADER 258
138 #define GRAMMAR 259
139 #define IMPORT 260
140 #define PUBLIC 261
141 #define TOKEN 262
142 #define RULENAME 263
143 #define TAG 264
144 #define WEIGHT 265
145 
146 
147 
148 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
149 typedef union YYSTYPE
150 {
151 /* Line 374 of yacc.c */
152 #line 65 "jsgf_parser.y"
153 
154  char *name;
155  float weight;
156  jsgf_rule_t *rule;
157  jsgf_rhs_t *rhs;
158  jsgf_atom_t *atom;
159 
160 
161 /* Line 374 of yacc.c */
162 #line 163 "jsgf_parser.c"
163 } YYSTYPE;
164 # define YYSTYPE_IS_TRIVIAL 1
165 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
166 # define YYSTYPE_IS_DECLARED 1
167 #endif
168 
169 
170 #ifdef YYPARSE_PARAM
171 #if defined __STDC__ || defined __cplusplus
172 int yyparse (void *YYPARSE_PARAM);
173 #else
174 int yyparse ();
175 #endif
176 #else /* ! YYPARSE_PARAM */
177 #if defined __STDC__ || defined __cplusplus
178 int yyparse (void* yyscanner, jsgf_t *jsgf);
179 #else
180 int yyparse ();
181 #endif
182 #endif /* ! YYPARSE_PARAM */
183 
184 #endif /* !YY_YY_JSGF_PARSER_H_INCLUDED */
185 
186 /* Copy the second part of user declarations. */
187 
188 /* Line 377 of yacc.c */
189 #line 190 "jsgf_parser.c"
190 
191 #ifdef short
192 # undef short
193 #endif
194 
195 #ifdef YYTYPE_UINT8
196 typedef YYTYPE_UINT8 yytype_uint8;
197 #else
198 typedef unsigned char yytype_uint8;
199 #endif
200 
201 #ifdef YYTYPE_INT8
202 typedef YYTYPE_INT8 yytype_int8;
203 #elif (defined __STDC__ || defined __C99__FUNC__ \
204  || defined __cplusplus || defined _MSC_VER)
205 typedef signed char yytype_int8;
206 #else
207 typedef short int yytype_int8;
208 #endif
209 
210 #ifdef YYTYPE_UINT16
211 typedef YYTYPE_UINT16 yytype_uint16;
212 #else
213 typedef unsigned short int yytype_uint16;
214 #endif
215 
216 #ifdef YYTYPE_INT16
217 typedef YYTYPE_INT16 yytype_int16;
218 #else
219 typedef short int yytype_int16;
220 #endif
221 
222 #ifndef YYSIZE_T
223 # ifdef __SIZE_TYPE__
224 # define YYSIZE_T __SIZE_TYPE__
225 # elif defined size_t
226 # define YYSIZE_T size_t
227 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
228  || defined __cplusplus || defined _MSC_VER)
229 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
230 # define YYSIZE_T size_t
231 # else
232 # define YYSIZE_T unsigned int
233 # endif
234 #endif
235 
236 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
237 
238 #ifndef YY_
239 # if defined YYENABLE_NLS && YYENABLE_NLS
240 # if ENABLE_NLS
241 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
242 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
243 # endif
244 # endif
245 # ifndef YY_
246 # define YY_(Msgid) Msgid
247 # endif
248 #endif
249 
250 /* Suppress unused-variable warnings by "using" E. */
251 #if ! defined lint || defined __GNUC__
252 # define YYUSE(E) ((void) (E))
253 #else
254 # define YYUSE(E) /* empty */
255 #endif
256 
257 /* Identity function, used to suppress warnings about constant conditions. */
258 #ifndef lint
259 # define YYID(N) (N)
260 #else
261 #if (defined __STDC__ || defined __C99__FUNC__ \
262  || defined __cplusplus || defined _MSC_VER)
263 static int
264 YYID (int yyi)
265 #else
266 static int
267 YYID (yyi)
268  int yyi;
269 #endif
270 {
271  return yyi;
272 }
273 #endif
274 
275 #if ! defined yyoverflow || YYERROR_VERBOSE
276 
277 /* The parser invokes alloca or malloc; define the necessary symbols. */
278 
279 # ifdef YYSTACK_USE_ALLOCA
280 # if YYSTACK_USE_ALLOCA
281 # ifdef __GNUC__
282 # define YYSTACK_ALLOC __builtin_alloca
283 # elif defined __BUILTIN_VA_ARG_INCR
284 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
285 # elif defined _AIX
286 # define YYSTACK_ALLOC __alloca
287 # elif defined _MSC_VER
288 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
289 # define alloca _alloca
290 # else
291 # define YYSTACK_ALLOC alloca
292 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
293  || defined __cplusplus || defined _MSC_VER)
294 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
295  /* Use EXIT_SUCCESS as a witness for stdlib.h. */
296 # ifndef EXIT_SUCCESS
297 # define EXIT_SUCCESS 0
298 # endif
299 # endif
300 # endif
301 # endif
302 # endif
303 
304 # ifdef YYSTACK_ALLOC
305  /* Pacify GCC's `empty if-body' warning. */
306 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
307 # ifndef YYSTACK_ALLOC_MAXIMUM
308  /* The OS might guarantee only one guard page at the bottom of the stack,
309  and a page size can be as small as 4096 bytes. So we cannot safely
310  invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
311  to allow for a few compiler-allocated temporary stack slots. */
312 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
313 # endif
314 # else
315 # define YYSTACK_ALLOC YYMALLOC
316 # define YYSTACK_FREE YYFREE
317 # ifndef YYSTACK_ALLOC_MAXIMUM
318 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
319 # endif
320 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
321  && ! ((defined YYMALLOC || defined malloc) \
322  && (defined YYFREE || defined free)))
323 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
324 # ifndef EXIT_SUCCESS
325 # define EXIT_SUCCESS 0
326 # endif
327 # endif
328 # ifndef YYMALLOC
329 # define YYMALLOC malloc
330 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
331  || defined __cplusplus || defined _MSC_VER)
332 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
333 # endif
334 # endif
335 # ifndef YYFREE
336 # define YYFREE free
337 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
338  || defined __cplusplus || defined _MSC_VER)
339 void free (void *); /* INFRINGES ON USER NAME SPACE */
340 # endif
341 # endif
342 # endif
343 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
344 
345 
346 #if (! defined yyoverflow \
347  && (! defined __cplusplus \
348  || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
349 
350 /* A type that is properly aligned for any stack member. */
351 union yyalloc
352 {
353  yytype_int16 yyss_alloc;
354  YYSTYPE yyvs_alloc;
355 };
356 
357 /* The size of the maximum gap between one aligned stack and the next. */
358 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
359 
360 /* The size of an array large to enough to hold all stacks, each with
361  N elements. */
362 # define YYSTACK_BYTES(N) \
363  ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
364  + YYSTACK_GAP_MAXIMUM)
365 
366 # define YYCOPY_NEEDED 1
367 
368 /* Relocate STACK from its old location to the new one. The
369  local variables YYSIZE and YYSTACKSIZE give the old and new number of
370  elements in the stack, and YYPTR gives the new location of the
371  stack. Advance YYPTR to a properly aligned location for the next
372  stack. */
373 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
374  do \
375  { \
376  YYSIZE_T yynewbytes; \
377  YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
378  Stack = &yyptr->Stack_alloc; \
379  yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
380  yyptr += yynewbytes / sizeof (*yyptr); \
381  } \
382  while (YYID (0))
383 
384 #endif
385 
386 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
387 /* Copy COUNT objects from SRC to DST. The source and destination do
388  not overlap. */
389 # ifndef YYCOPY
390 # if defined __GNUC__ && 1 < __GNUC__
391 # define YYCOPY(Dst, Src, Count) \
392  __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
393 # else
394 # define YYCOPY(Dst, Src, Count) \
395  do \
396  { \
397  YYSIZE_T yyi; \
398  for (yyi = 0; yyi < (Count); yyi++) \
399  (Dst)[yyi] = (Src)[yyi]; \
400  } \
401  while (YYID (0))
402 # endif
403 # endif
404 #endif /* !YYCOPY_NEEDED */
405 
406 /* YYFINAL -- State number of the termination state. */
407 #define YYFINAL 7
408 /* YYLAST -- Last index in YYTABLE. */
409 #define YYLAST 54
410 
411 /* YYNTOKENS -- Number of terminals. */
412 #define YYNTOKENS 20
413 /* YYNNTS -- Number of nonterminals. */
414 #define YYNNTS 16
415 /* YYNRULES -- Number of rules. */
416 #define YYNRULES 33
417 /* YYNRULES -- Number of states. */
418 #define YYNSTATES 58
419 
420 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
421 #define YYUNDEFTOK 2
422 #define YYMAXUTOK 265
423 
424 #define YYTRANSLATE(YYX) \
425  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
426 
427 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
428 static const yytype_uint8 yytranslate[] =
429 {
430  0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
431  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
432  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
433  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
434  14, 15, 18, 19, 2, 2, 2, 2, 2, 2,
435  2, 2, 2, 2, 2, 2, 2, 2, 2, 11,
436  2, 12, 2, 2, 2, 2, 2, 2, 2, 2,
437  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
438  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
439  2, 16, 2, 17, 2, 2, 2, 2, 2, 2,
440  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
441  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
442  2, 2, 2, 2, 13, 2, 2, 2, 2, 2,
443  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
444  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
445  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
446  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
447  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
448  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
449  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
450  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
451  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
452  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
453  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
454  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
455  2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
456  5, 6, 7, 8, 9, 10
457 };
458 
459 #if YYDEBUG
460 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
461  YYRHS. */
462 static const yytype_uint8 yyprhs[] =
463 {
464  0, 0, 3, 5, 8, 12, 15, 18, 22, 27,
465  33, 37, 39, 42, 46, 48, 51, 56, 62, 64,
466  68, 70, 73, 75, 78, 80, 83, 87, 91, 93,
467  95, 97, 99, 102
468 };
469 
470 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
471 static const yytype_int8 yyrhs[] =
472 {
473  21, 0, -1, 22, -1, 22, 27, -1, 22, 25,
474  27, -1, 23, 24, -1, 3, 11, -1, 3, 7,
475  11, -1, 3, 7, 7, 11, -1, 3, 7, 7,
476  7, 11, -1, 4, 7, 11, -1, 26, -1, 25,
477  26, -1, 5, 8, 11, -1, 28, -1, 27, 28,
478  -1, 8, 12, 29, 11, -1, 6, 8, 12, 29,
479  11, -1, 30, -1, 29, 13, 30, -1, 31, -1,
480  30, 31, -1, 32, -1, 31, 9, -1, 35, -1,
481  10, 35, -1, 14, 29, 15, -1, 16, 29, 17,
482  -1, 7, -1, 8, -1, 33, -1, 34, -1, 35,
483  18, -1, 35, 19, -1
484 };
485 
486 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
487 static const yytype_uint8 yyrline[] =
488 {
489  0, 82, 82, 83, 84, 87, 90, 91, 92, 93,
490  97, 100, 101, 104, 107, 108, 111, 112, 115, 116,
491  121, 123, 127, 128, 132, 133, 136, 139, 142, 143,
492  144, 145, 146, 147
493 };
494 #endif
495 
496 #if YYDEBUG || YYERROR_VERBOSE || 0
497 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
498  First, the terminals, then, starting at YYNTOKENS, nonterminals. */
499 static const char *const yytname[] =
500 {
501  "$end", "error", "$undefined", "HEADER", "GRAMMAR", "IMPORT", "PUBLIC",
502  "TOKEN", "RULENAME", "TAG", "WEIGHT", "';'", "'='", "'|'", "'('", "')'",
503  "'['", "']'", "'*'", "'+'", "$accept", "grammar", "header",
504  "jsgf_header", "grammar_header", "import_header", "import_statement",
505  "rule_list", "rule", "alternate_list", "rule_expansion",
506  "tagged_rule_item", "rule_item", "rule_group", "rule_optional",
507  "rule_atom", YY_NULL
508 };
509 #endif
510 
511 # ifdef YYPRINT
512 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
513  token YYLEX-NUM. */
514 static const yytype_uint16 yytoknum[] =
515 {
516  0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
517  265, 59, 61, 124, 40, 41, 91, 93, 42, 43
518 };
519 # endif
520 
521 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
522 static const yytype_uint8 yyr1[] =
523 {
524  0, 20, 21, 21, 21, 22, 23, 23, 23, 23,
525  24, 25, 25, 26, 27, 27, 28, 28, 29, 29,
526  30, 30, 31, 31, 32, 32, 33, 34, 35, 35,
527  35, 35, 35, 35
528 };
529 
530 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
531 static const yytype_uint8 yyr2[] =
532 {
533  0, 2, 1, 2, 3, 2, 2, 3, 4, 5,
534  3, 1, 2, 3, 1, 2, 4, 5, 1, 3,
535  1, 2, 1, 2, 1, 2, 3, 3, 1, 1,
536  1, 1, 2, 2
537 };
538 
539 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
540  Performed when YYTABLE doesn't specify something else to do. Zero
541  means the default is an error. */
542 static const yytype_uint8 yydefact[] =
543 {
544  0, 0, 0, 2, 0, 0, 6, 1, 0, 0,
545  0, 0, 11, 3, 14, 0, 5, 0, 7, 0,
546  0, 0, 12, 4, 15, 0, 0, 8, 13, 0,
547  28, 29, 0, 0, 0, 0, 18, 20, 22, 30,
548  31, 24, 10, 9, 0, 25, 0, 0, 16, 0,
549  21, 23, 32, 33, 17, 26, 27, 19
550 };
551 
552 /* YYDEFGOTO[NTERM-NUM]. */
553 static const yytype_int8 yydefgoto[] =
554 {
555  -1, 2, 3, 4, 16, 11, 12, 13, 14, 35,
556  36, 37, 38, 39, 40, 41
557 };
558 
559 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
560  STATE-NUM. */
561 #define YYPACT_NINF -37
562 static const yytype_int8 yypact[] =
563 {
564  -1, -2, 36, 22, 35, 8, -37, -37, 32, 33,
565  30, 22, -37, 17, -37, 37, -37, 13, -37, 34,
566  31, -4, -37, 17, -37, 38, 39, -37, -37, -4,
567  -37, -37, 0, -4, -4, 18, -4, 42, -37, -37,
568  -37, 19, -37, -37, 21, 19, 20, 9, -37, -4,
569  42, -37, -37, -37, -37, -37, -37, -4
570 };
571 
572 /* YYPGOTO[NTERM-NUM]. */
573 static const yytype_int8 yypgoto[] =
574 {
575  -37, -37, -37, -37, -37, -37, 41, 43, -12, -16,
576  -3, -36, -37, -37, -37, 15
577 };
578 
579 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
580  positive, shift that token. If negative, reduce the rule which
581  number is the opposite. If YYTABLE_NINF, syntax error. */
582 #define YYTABLE_NINF -1
583 static const yytype_uint8 yytable[] =
584 {
585  50, 24, 1, 30, 31, 5, 32, 30, 31, 6,
586  33, 24, 34, 44, 33, 17, 34, 46, 47, 18,
587  26, 50, 49, 9, 27, 10, 56, 8, 9, 48,
588  10, 49, 54, 49, 49, 55, 7, 52, 53, 15,
589  19, 20, 21, 29, 25, 28, 57, 45, 0, 42,
590  43, 51, 22, 0, 23
591 };
592 
593 #define yypact_value_is_default(Yystate) \
594  (!!((Yystate) == (-37)))
595 
596 #define yytable_value_is_error(Yytable_value) \
597  YYID (0)
598 
599 static const yytype_int8 yycheck[] =
600 {
601  36, 13, 3, 7, 8, 7, 10, 7, 8, 11,
602  14, 23, 16, 29, 14, 7, 16, 33, 34, 11,
603  7, 57, 13, 6, 11, 8, 17, 5, 6, 11,
604  8, 13, 11, 13, 13, 15, 0, 18, 19, 4,
605  8, 8, 12, 12, 7, 11, 49, 32, -1, 11,
606  11, 9, 11, -1, 11
607 };
608 
609 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
610  symbol of state STATE-NUM. */
611 static const yytype_uint8 yystos[] =
612 {
613  0, 3, 21, 22, 23, 7, 11, 0, 5, 6,
614  8, 25, 26, 27, 28, 4, 24, 7, 11, 8,
615  8, 12, 26, 27, 28, 7, 7, 11, 11, 12,
616  7, 8, 10, 14, 16, 29, 30, 31, 32, 33,
617  34, 35, 11, 11, 29, 35, 29, 29, 11, 13,
618  31, 9, 18, 19, 11, 15, 17, 30
619 };
620 
621 #define yyerrok (yyerrstatus = 0)
622 #define yyclearin (yychar = YYEMPTY)
623 #define YYEMPTY (-2)
624 #define YYEOF 0
625 
626 #define YYACCEPT goto yyacceptlab
627 #define YYABORT goto yyabortlab
628 #define YYERROR goto yyerrorlab
629 
630 
631 /* Like YYERROR except do call yyerror. This remains here temporarily
632  to ease the transition to the new meaning of YYERROR, for GCC.
633  Once GCC version 2 has supplanted version 1, this can go. However,
634  YYFAIL appears to be in use. Nevertheless, it is formally deprecated
635  in Bison 2.4.2's NEWS entry, where a plan to phase it out is
636  discussed. */
637 
638 #define YYFAIL goto yyerrlab
639 #if defined YYFAIL
640  /* This is here to suppress warnings from the GCC cpp's
641  -Wunused-macros. Normally we don't worry about that warning, but
642  some users do, and we want to make it easy for users to remove
643  YYFAIL uses, which will produce warnings from Bison 2.5. */
644 #endif
645 
646 #define YYRECOVERING() (!!yyerrstatus)
647 
648 #define YYBACKUP(Token, Value) \
649 do \
650  if (yychar == YYEMPTY) \
651  { \
652  yychar = (Token); \
653  yylval = (Value); \
654  YYPOPSTACK (yylen); \
655  yystate = *yyssp; \
656  goto yybackup; \
657  } \
658  else \
659  { \
660  yyerror (yyscanner, jsgf, YY_("syntax error: cannot back up")); \
661  YYERROR; \
662  } \
663 while (YYID (0))
664 
665 
666 #define YYTERROR 1
667 #define YYERRCODE 256
668 
669 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
670  If N is 0, then set CURRENT to the empty location which ends
671  the previous symbol: RHS[0] (always defined). */
672 
673 #ifndef YYLLOC_DEFAULT
674 # define YYLLOC_DEFAULT(Current, Rhs, N) \
675  do \
676  if (YYID (N)) \
677  { \
678  (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
679  (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
680  (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
681  (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
682  } \
683  else \
684  { \
685  (Current).first_line = (Current).last_line = \
686  YYRHSLOC (Rhs, 0).last_line; \
687  (Current).first_column = (Current).last_column = \
688  YYRHSLOC (Rhs, 0).last_column; \
689  } \
690  while (YYID (0))
691 #endif
692 
693 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
694 
695 
696 
697 /* This macro is provided for backward compatibility. */
698 
699 #ifndef YY_LOCATION_PRINT
700 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
701 #endif
702 
703 
704 /* YYLEX -- calling `yylex' with the right arguments. */
705 
706 #ifdef YYLEX_PARAM
707 # define YYLEX yylex (&yylval, YYLEX_PARAM)
708 #else
709 # define YYLEX yylex (&yylval, yyscanner)
710 #endif
711 
712 /* Enable debugging if requested. */
713 #if YYDEBUG
714 
715 # ifndef YYFPRINTF
716 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
717 # define YYFPRINTF fprintf
718 # endif
719 
720 # define YYDPRINTF(Args) \
721 do { \
722  if (yydebug) \
723  YYFPRINTF Args; \
724 } while (YYID (0))
725 
726 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
727 do { \
728  if (yydebug) \
729  { \
730  YYFPRINTF (stderr, "%s ", Title); \
731  yy_symbol_print (stderr, \
732  Type, Value, yyscanner, jsgf); \
733  YYFPRINTF (stderr, "\n"); \
734  } \
735 } while (YYID (0))
736 
737 
738 /*--------------------------------.
739 | Print this symbol on YYOUTPUT. |
740 `--------------------------------*/
741 
742 /*ARGSUSED*/
743 #if (defined __STDC__ || defined __C99__FUNC__ \
744  || defined __cplusplus || defined _MSC_VER)
745 static void
746 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void* yyscanner, jsgf_t *jsgf)
747 #else
748 static void
749 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf)
750  FILE *yyoutput;
751  int yytype;
752  YYSTYPE const * const yyvaluep;
753  void* yyscanner;
754  jsgf_t *jsgf;
755 #endif
756 {
757  FILE *yyo = yyoutput;
758  YYUSE (yyo);
759  if (!yyvaluep)
760  return;
761  YYUSE (yyscanner);
762  YYUSE (jsgf);
763 # ifdef YYPRINT
764  if (yytype < YYNTOKENS)
765  YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
766 # else
767  YYUSE (yyoutput);
768 # endif
769  switch (yytype)
770  {
771  default:
772  break;
773  }
774 }
775 
776 
777 /*--------------------------------.
778 | Print this symbol on YYOUTPUT. |
779 `--------------------------------*/
780 
781 #if (defined __STDC__ || defined __C99__FUNC__ \
782  || defined __cplusplus || defined _MSC_VER)
783 static void
784 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void* yyscanner, jsgf_t *jsgf)
785 #else
786 static void
787 yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf)
788  FILE *yyoutput;
789  int yytype;
790  YYSTYPE const * const yyvaluep;
791  void* yyscanner;
792  jsgf_t *jsgf;
793 #endif
794 {
795  if (yytype < YYNTOKENS)
796  YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
797  else
798  YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
799 
800  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf);
801  YYFPRINTF (yyoutput, ")");
802 }
803 
804 /*------------------------------------------------------------------.
805 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
806 | TOP (included). |
807 `------------------------------------------------------------------*/
808 
809 #if (defined __STDC__ || defined __C99__FUNC__ \
810  || defined __cplusplus || defined _MSC_VER)
811 static void
812 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
813 #else
814 static void
815 yy_stack_print (yybottom, yytop)
816  yytype_int16 *yybottom;
817  yytype_int16 *yytop;
818 #endif
819 {
820  YYFPRINTF (stderr, "Stack now");
821  for (; yybottom <= yytop; yybottom++)
822  {
823  int yybot = *yybottom;
824  YYFPRINTF (stderr, " %d", yybot);
825  }
826  YYFPRINTF (stderr, "\n");
827 }
828 
829 # define YY_STACK_PRINT(Bottom, Top) \
830 do { \
831  if (yydebug) \
832  yy_stack_print ((Bottom), (Top)); \
833 } while (YYID (0))
834 
835 
836 /*------------------------------------------------.
837 | Report that the YYRULE is going to be reduced. |
838 `------------------------------------------------*/
839 
840 #if (defined __STDC__ || defined __C99__FUNC__ \
841  || defined __cplusplus || defined _MSC_VER)
842 static void
843 yy_reduce_print (YYSTYPE *yyvsp, int yyrule, void* yyscanner, jsgf_t *jsgf)
844 #else
845 static void
846 yy_reduce_print (yyvsp, yyrule, yyscanner, jsgf)
847  YYSTYPE *yyvsp;
848  int yyrule;
849  void* yyscanner;
850  jsgf_t *jsgf;
851 #endif
852 {
853  int yynrhs = yyr2[yyrule];
854  int yyi;
855  unsigned long int yylno = yyrline[yyrule];
856  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
857  yyrule - 1, yylno);
858  /* The symbols being reduced. */
859  for (yyi = 0; yyi < yynrhs; yyi++)
860  {
861  YYFPRINTF (stderr, " $%d = ", yyi + 1);
862  yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
863  &(yyvsp[(yyi + 1) - (yynrhs)])
864  , yyscanner, jsgf);
865  YYFPRINTF (stderr, "\n");
866  }
867 }
868 
869 # define YY_REDUCE_PRINT(Rule) \
870 do { \
871  if (yydebug) \
872  yy_reduce_print (yyvsp, Rule, yyscanner, jsgf); \
873 } while (YYID (0))
874 
875 /* Nonzero means print parse trace. It is left uninitialized so that
876  multiple parsers can coexist. */
877 int yydebug;
878 #else /* !YYDEBUG */
879 # define YYDPRINTF(Args)
880 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
881 # define YY_STACK_PRINT(Bottom, Top)
882 # define YY_REDUCE_PRINT(Rule)
883 #endif /* !YYDEBUG */
884 
885 
886 /* YYINITDEPTH -- initial size of the parser's stacks. */
887 #ifndef YYINITDEPTH
888 # define YYINITDEPTH 200
889 #endif
890 
891 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
892  if the built-in stack extension method is used).
893 
894  Do not make this value too large; the results are undefined if
895  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
896  evaluated with infinite-precision integer arithmetic. */
897 
898 #ifndef YYMAXDEPTH
899 # define YYMAXDEPTH 10000
900 #endif
901 
902 
903 #if YYERROR_VERBOSE
904 
905 # ifndef yystrlen
906 # if defined __GLIBC__ && defined _STRING_H
907 # define yystrlen strlen
908 # else
909 /* Return the length of YYSTR. */
910 #if (defined __STDC__ || defined __C99__FUNC__ \
911  || defined __cplusplus || defined _MSC_VER)
912 static YYSIZE_T
913 yystrlen (const char *yystr)
914 #else
915 static YYSIZE_T
916 yystrlen (yystr)
917  const char *yystr;
918 #endif
919 {
920  YYSIZE_T yylen;
921  for (yylen = 0; yystr[yylen]; yylen++)
922  continue;
923  return yylen;
924 }
925 # endif
926 # endif
927 
928 # ifndef yystpcpy
929 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
930 # define yystpcpy stpcpy
931 # else
932 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
933  YYDEST. */
934 #if (defined __STDC__ || defined __C99__FUNC__ \
935  || defined __cplusplus || defined _MSC_VER)
936 static char *
937 yystpcpy (char *yydest, const char *yysrc)
938 #else
939 static char *
940 yystpcpy (yydest, yysrc)
941  char *yydest;
942  const char *yysrc;
943 #endif
944 {
945  char *yyd = yydest;
946  const char *yys = yysrc;
947 
948  while ((*yyd++ = *yys++) != '\0')
949  continue;
950 
951  return yyd - 1;
952 }
953 # endif
954 # endif
955 
956 # ifndef yytnamerr
957 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
958  quotes and backslashes, so that it's suitable for yyerror. The
959  heuristic is that double-quoting is unnecessary unless the string
960  contains an apostrophe, a comma, or backslash (other than
961  backslash-backslash). YYSTR is taken from yytname. If YYRES is
962  null, do not copy; instead, return the length of what the result
963  would have been. */
964 static YYSIZE_T
965 yytnamerr (char *yyres, const char *yystr)
966 {
967  if (*yystr == '"')
968  {
969  YYSIZE_T yyn = 0;
970  char const *yyp = yystr;
971 
972  for (;;)
973  switch (*++yyp)
974  {
975  case '\'':
976  case ',':
977  goto do_not_strip_quotes;
978 
979  case '\\':
980  if (*++yyp != '\\')
981  goto do_not_strip_quotes;
982  /* Fall through. */
983  default:
984  if (yyres)
985  yyres[yyn] = *yyp;
986  yyn++;
987  break;
988 
989  case '"':
990  if (yyres)
991  yyres[yyn] = '\0';
992  return yyn;
993  }
994  do_not_strip_quotes: ;
995  }
996 
997  if (! yyres)
998  return yystrlen (yystr);
999 
1000  return yystpcpy (yyres, yystr) - yyres;
1001 }
1002 # endif
1003 
1004 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1005  about the unexpected token YYTOKEN for the state stack whose top is
1006  YYSSP.
1007 
1008  Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1009  not large enough to hold the message. In that case, also set
1010  *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1011  required number of bytes is too large to store. */
1012 static int
1013 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1014  yytype_int16 *yyssp, int yytoken)
1015 {
1016  YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
1017  YYSIZE_T yysize = yysize0;
1018  YYSIZE_T yysize1;
1019  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1020  /* Internationalized format string. */
1021  const char *yyformat = YY_NULL;
1022  /* Arguments of yyformat. */
1023  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1024  /* Number of reported tokens (one for the "unexpected", one per
1025  "expected"). */
1026  int yycount = 0;
1027 
1028  /* There are many possibilities here to consider:
1029  - Assume YYFAIL is not used. It's too flawed to consider. See
1030  <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1031  for details. YYERROR is fine as it does not invoke this
1032  function.
1033  - If this state is a consistent state with a default action, then
1034  the only way this function was invoked is if the default action
1035  is an error action. In that case, don't check for expected
1036  tokens because there are none.
1037  - The only way there can be no lookahead present (in yychar) is if
1038  this state is a consistent state with a default action. Thus,
1039  detecting the absence of a lookahead is sufficient to determine
1040  that there is no unexpected or expected token to report. In that
1041  case, just report a simple "syntax error".
1042  - Don't assume there isn't a lookahead just because this state is a
1043  consistent state with a default action. There might have been a
1044  previous inconsistent state, consistent state with a non-default
1045  action, or user semantic action that manipulated yychar.
1046  - Of course, the expected token list depends on states to have
1047  correct lookahead information, and it depends on the parser not
1048  to perform extra reductions after fetching a lookahead from the
1049  scanner and before detecting a syntax error. Thus, state merging
1050  (from LALR or IELR) and default reductions corrupt the expected
1051  token list. However, the list is correct for canonical LR with
1052  one exception: it will still contain any token that will not be
1053  accepted due to an error action in a later state.
1054  */
1055  if (yytoken != YYEMPTY)
1056  {
1057  int yyn = yypact[*yyssp];
1058  yyarg[yycount++] = yytname[yytoken];
1059  if (!yypact_value_is_default (yyn))
1060  {
1061  /* Start YYX at -YYN if negative to avoid negative indexes in
1062  YYCHECK. In other words, skip the first -YYN actions for
1063  this state because they are default actions. */
1064  int yyxbegin = yyn < 0 ? -yyn : 0;
1065  /* Stay within bounds of both yycheck and yytname. */
1066  int yychecklim = YYLAST - yyn + 1;
1067  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1068  int yyx;
1069 
1070  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1071  if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1072  && !yytable_value_is_error (yytable[yyx + yyn]))
1073  {
1074  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1075  {
1076  yycount = 1;
1077  yysize = yysize0;
1078  break;
1079  }
1080  yyarg[yycount++] = yytname[yyx];
1081  yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1082  if (! (yysize <= yysize1
1083  && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1084  return 2;
1085  yysize = yysize1;
1086  }
1087  }
1088  }
1089 
1090  switch (yycount)
1091  {
1092 # define YYCASE_(N, S) \
1093  case N: \
1094  yyformat = S; \
1095  break
1096  YYCASE_(0, YY_("syntax error"));
1097  YYCASE_(1, YY_("syntax error, unexpected %s"));
1098  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1099  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1100  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1101  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1102 # undef YYCASE_
1103  }
1104 
1105  yysize1 = yysize + yystrlen (yyformat);
1106  if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1107  return 2;
1108  yysize = yysize1;
1109 
1110  if (*yymsg_alloc < yysize)
1111  {
1112  *yymsg_alloc = 2 * yysize;
1113  if (! (yysize <= *yymsg_alloc
1114  && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1115  *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1116  return 1;
1117  }
1118 
1119  /* Avoid sprintf, as that infringes on the user's name space.
1120  Don't have undefined behavior even if the translation
1121  produced a string with the wrong number of "%s"s. */
1122  {
1123  char *yyp = *yymsg;
1124  int yyi = 0;
1125  while ((*yyp = *yyformat) != '\0')
1126  if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1127  {
1128  yyp += yytnamerr (yyp, yyarg[yyi++]);
1129  yyformat += 2;
1130  }
1131  else
1132  {
1133  yyp++;
1134  yyformat++;
1135  }
1136  }
1137  return 0;
1138 }
1139 #endif /* YYERROR_VERBOSE */
1140 
1141 /*-----------------------------------------------.
1142 | Release the memory associated to this symbol. |
1143 `-----------------------------------------------*/
1144 
1145 /*ARGSUSED*/
1146 #if (defined __STDC__ || defined __C99__FUNC__ \
1147  || defined __cplusplus || defined _MSC_VER)
1148 static void
1149 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void* yyscanner, jsgf_t *jsgf)
1150 #else
1151 static void
1152 yydestruct (yymsg, yytype, yyvaluep, yyscanner, jsgf)
1153  const char *yymsg;
1154  int yytype;
1155  YYSTYPE *yyvaluep;
1156  void* yyscanner;
1157  jsgf_t *jsgf;
1158 #endif
1159 {
1160  YYUSE (yyvaluep);
1161  YYUSE (yyscanner);
1162  YYUSE (jsgf);
1163 
1164  if (!yymsg)
1165  yymsg = "Deleting";
1166  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1167 
1168  switch (yytype)
1169  {
1170 
1171  default:
1172  break;
1173  }
1174 }
1175 
1176 
1177 
1178 
1179 /*----------.
1180 | yyparse. |
1181 `----------*/
1182 
1183 #ifdef YYPARSE_PARAM
1184 #if (defined __STDC__ || defined __C99__FUNC__ \
1185  || defined __cplusplus || defined _MSC_VER)
1186 int
1187 yyparse (void *YYPARSE_PARAM)
1188 #else
1189 int
1190 yyparse (YYPARSE_PARAM)
1191  void *YYPARSE_PARAM;
1192 #endif
1193 #else /* ! YYPARSE_PARAM */
1194 #if (defined __STDC__ || defined __C99__FUNC__ \
1195  || defined __cplusplus || defined _MSC_VER)
1196 int
1197 yyparse (void* yyscanner, jsgf_t *jsgf)
1198 #else
1199 int
1200 yyparse (yyscanner, jsgf)
1201  void* yyscanner;
1202  jsgf_t *jsgf;
1203 #endif
1204 #endif
1205 {
1206 /* The lookahead symbol. */
1207 int yychar;
1208 
1209 
1210 #if defined __GNUC__ && (4 < __GNUC__ + (6 <= __GNUC_MINOR__))
1211 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
1212 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
1213  _Pragma ("GCC diagnostic push") \
1214  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
1215 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
1216  _Pragma ("GCC diagnostic pop")
1217 #else
1218 /* Default value used for initialization, for pacifying older GCCs
1219  or non-GCC compilers. */
1220 static YYSTYPE yyval_default;
1221 # define YYLVAL_INITIALIZE() (yylval = yyval_default)
1222 #endif
1223 #ifndef YYLVAL_INITIALIZE
1224 # define YYLVAL_INITIALIZE()
1225 #endif
1226 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1227 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1228 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1229 #endif
1230 
1231 /* The semantic value of the lookahead symbol. */
1232 YYSTYPE yylval;
1233 
1234  /* Number of syntax errors so far. */
1235  int yynerrs;
1236 
1237  int yystate;
1238  /* Number of tokens to shift before error messages enabled. */
1239  int yyerrstatus;
1240 
1241  /* The stacks and their tools:
1242  `yyss': related to states.
1243  `yyvs': related to semantic values.
1244 
1245  Refer to the stacks through separate pointers, to allow yyoverflow
1246  to reallocate them elsewhere. */
1247 
1248  /* The state stack. */
1249  yytype_int16 yyssa[YYINITDEPTH];
1250  yytype_int16 *yyss;
1251  yytype_int16 *yyssp;
1252 
1253  /* The semantic value stack. */
1254  YYSTYPE yyvsa[YYINITDEPTH];
1255  YYSTYPE *yyvs;
1256  YYSTYPE *yyvsp;
1257 
1258  YYSIZE_T yystacksize;
1259 
1260  int yyn;
1261  int yyresult;
1262  /* Lookahead token as an internal (translated) token number. */
1263  int yytoken = 0;
1264  /* The variables used to return semantic value and location from the
1265  action routines. */
1266  YYSTYPE yyval;
1267 
1268 #if YYERROR_VERBOSE
1269  /* Buffer for error messages, and its allocated size. */
1270  char yymsgbuf[128];
1271  char *yymsg = yymsgbuf;
1272  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1273 #endif
1274 
1275 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1276 
1277  /* The number of symbols on the RHS of the reduced rule.
1278  Keep to zero when no symbol should be popped. */
1279  int yylen = 0;
1280 
1281  yyss = yyssa;
1282  yyvs = yyvsa;
1283  yystacksize = YYINITDEPTH;
1284 
1285  YYDPRINTF ((stderr, "Starting parse\n"));
1286 
1287  yystate = 0;
1288  yyerrstatus = 0;
1289  yynerrs = 0;
1290  yychar = YYEMPTY; /* Cause a token to be read. */
1291 
1292  /* Initialize stack pointers.
1293  Waste one element of value and location stack
1294  so that they stay on the same level as the state stack.
1295  The wasted elements are never initialized. */
1296  yyssp = yyss;
1297  yyvsp = yyvs;
1298 
1299  YYLVAL_INITIALIZE ();
1300  goto yysetstate;
1301 
1302 /*------------------------------------------------------------.
1303 | yynewstate -- Push a new state, which is found in yystate. |
1304 `------------------------------------------------------------*/
1305  yynewstate:
1306  /* In all cases, when you get here, the value and location stacks
1307  have just been pushed. So pushing a state here evens the stacks. */
1308  yyssp++;
1309 
1310  yysetstate:
1311  *yyssp = yystate;
1312 
1313  if (yyss + yystacksize - 1 <= yyssp)
1314  {
1315  /* Get the current used size of the three stacks, in elements. */
1316  YYSIZE_T yysize = yyssp - yyss + 1;
1317 
1318 #ifdef yyoverflow
1319  {
1320  /* Give user a chance to reallocate the stack. Use copies of
1321  these so that the &'s don't force the real ones into
1322  memory. */
1323  YYSTYPE *yyvs1 = yyvs;
1324  yytype_int16 *yyss1 = yyss;
1325 
1326  /* Each stack pointer address is followed by the size of the
1327  data in use in that stack, in bytes. This used to be a
1328  conditional around just the two extra args, but that might
1329  be undefined if yyoverflow is a macro. */
1330  yyoverflow (YY_("memory exhausted"),
1331  &yyss1, yysize * sizeof (*yyssp),
1332  &yyvs1, yysize * sizeof (*yyvsp),
1333  &yystacksize);
1334 
1335  yyss = yyss1;
1336  yyvs = yyvs1;
1337  }
1338 #else /* no yyoverflow */
1339 # ifndef YYSTACK_RELOCATE
1340  goto yyexhaustedlab;
1341 # else
1342  /* Extend the stack our own way. */
1343  if (YYMAXDEPTH <= yystacksize)
1344  goto yyexhaustedlab;
1345  yystacksize *= 2;
1346  if (YYMAXDEPTH < yystacksize)
1347  yystacksize = YYMAXDEPTH;
1348 
1349  {
1350  yytype_int16 *yyss1 = yyss;
1351  union yyalloc *yyptr =
1352  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1353  if (! yyptr)
1354  goto yyexhaustedlab;
1355  YYSTACK_RELOCATE (yyss_alloc, yyss);
1356  YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1357 # undef YYSTACK_RELOCATE
1358  if (yyss1 != yyssa)
1359  YYSTACK_FREE (yyss1);
1360  }
1361 # endif
1362 #endif /* no yyoverflow */
1363 
1364  yyssp = yyss + yysize - 1;
1365  yyvsp = yyvs + yysize - 1;
1366 
1367  YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1368  (unsigned long int) yystacksize));
1369 
1370  if (yyss + yystacksize - 1 <= yyssp)
1371  YYABORT;
1372  }
1373 
1374  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1375 
1376  if (yystate == YYFINAL)
1377  YYACCEPT;
1378 
1379  goto yybackup;
1380 
1381 /*-----------.
1382 | yybackup. |
1383 `-----------*/
1384 yybackup:
1385 
1386  /* Do appropriate processing given the current state. Read a
1387  lookahead token if we need one and don't already have one. */
1388 
1389  /* First try to decide what to do without reference to lookahead token. */
1390  yyn = yypact[yystate];
1391  if (yypact_value_is_default (yyn))
1392  goto yydefault;
1393 
1394  /* Not known => get a lookahead token if don't already have one. */
1395 
1396  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1397  if (yychar == YYEMPTY)
1398  {
1399  YYDPRINTF ((stderr, "Reading a token: "));
1400  yychar = YYLEX;
1401  }
1402 
1403  if (yychar <= YYEOF)
1404  {
1405  yychar = yytoken = YYEOF;
1406  YYDPRINTF ((stderr, "Now at end of input.\n"));
1407  }
1408  else
1409  {
1410  yytoken = YYTRANSLATE (yychar);
1411  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1412  }
1413 
1414  /* If the proper action on seeing token YYTOKEN is to reduce or to
1415  detect an error, take that action. */
1416  yyn += yytoken;
1417  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1418  goto yydefault;
1419  yyn = yytable[yyn];
1420  if (yyn <= 0)
1421  {
1422  if (yytable_value_is_error (yyn))
1423  goto yyerrlab;
1424  yyn = -yyn;
1425  goto yyreduce;
1426  }
1427 
1428  /* Count tokens shifted since error; after three, turn off error
1429  status. */
1430  if (yyerrstatus)
1431  yyerrstatus--;
1432 
1433  /* Shift the lookahead token. */
1434  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1435 
1436  /* Discard the shifted token. */
1437  yychar = YYEMPTY;
1438 
1439  yystate = yyn;
1440  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1441  *++yyvsp = yylval;
1442  YY_IGNORE_MAYBE_UNINITIALIZED_END
1443 
1444  goto yynewstate;
1445 
1446 
1447 /*-----------------------------------------------------------.
1448 | yydefault -- do the default action for the current state. |
1449 `-----------------------------------------------------------*/
1450 yydefault:
1451  yyn = yydefact[yystate];
1452  if (yyn == 0)
1453  goto yyerrlab;
1454  goto yyreduce;
1455 
1456 
1457 /*-----------------------------.
1458 | yyreduce -- Do a reduction. |
1459 `-----------------------------*/
1460 yyreduce:
1461  /* yyn is the number of a rule to reduce with. */
1462  yylen = yyr2[yyn];
1463 
1464  /* If YYLEN is nonzero, implement the default value of the action:
1465  `$$ = $1'.
1466 
1467  Otherwise, the following line sets YYVAL to garbage.
1468  This behavior is undocumented and Bison
1469  users should not rely upon it. Assigning to YYVAL
1470  unconditionally makes the parser a bit smaller, and it avoids a
1471  GCC warning that YYVAL may be used uninitialized. */
1472  yyval = yyvsp[1-yylen];
1473 
1474 
1475  YY_REDUCE_PRINT (yyn);
1476  switch (yyn)
1477  {
1478  case 5:
1479 /* Line 1813 of yacc.c */
1480 #line 87 "jsgf_parser.y"
1481  { jsgf->name = (yyvsp[(2) - (2)].name); }
1482  break;
1483 
1484  case 7:
1485 /* Line 1813 of yacc.c */
1486 #line 91 "jsgf_parser.y"
1487  { jsgf->version = (yyvsp[(2) - (3)].name); }
1488  break;
1489 
1490  case 8:
1491 /* Line 1813 of yacc.c */
1492 #line 92 "jsgf_parser.y"
1493  { jsgf->version = (yyvsp[(2) - (4)].name); jsgf->charset = (yyvsp[(3) - (4)].name); }
1494  break;
1495 
1496  case 9:
1497 /* Line 1813 of yacc.c */
1498 #line 93 "jsgf_parser.y"
1499  { jsgf->version = (yyvsp[(2) - (5)].name); jsgf->charset = (yyvsp[(3) - (5)].name);
1500  jsgf->locale = (yyvsp[(4) - (5)].name); }
1501  break;
1502 
1503  case 10:
1504 /* Line 1813 of yacc.c */
1505 #line 97 "jsgf_parser.y"
1506  { (yyval.name) = (yyvsp[(2) - (3)].name); }
1507  break;
1508 
1509  case 13:
1510 /* Line 1813 of yacc.c */
1511 #line 104 "jsgf_parser.y"
1512  { jsgf_import_rule(jsgf, (yyvsp[(2) - (3)].name)); ckd_free((yyvsp[(2) - (3)].name)); }
1513  break;
1514 
1515  case 16:
1516 /* Line 1813 of yacc.c */
1517 #line 111 "jsgf_parser.y"
1518  { jsgf_define_rule(jsgf, (yyvsp[(1) - (4)].name), (yyvsp[(3) - (4)].rhs), 0); ckd_free((yyvsp[(1) - (4)].name)); }
1519  break;
1520 
1521  case 17:
1522 /* Line 1813 of yacc.c */
1523 #line 112 "jsgf_parser.y"
1524  { jsgf_define_rule(jsgf, (yyvsp[(2) - (5)].name), (yyvsp[(4) - (5)].rhs), 1); ckd_free((yyvsp[(2) - (5)].name)); }
1525  break;
1526 
1527  case 18:
1528 /* Line 1813 of yacc.c */
1529 #line 115 "jsgf_parser.y"
1530  { (yyval.rhs) = (yyvsp[(1) - (1)].rhs); (yyval.rhs)->atoms = glist_reverse((yyval.rhs)->atoms); }
1531  break;
1532 
1533  case 19:
1534 /* Line 1813 of yacc.c */
1535 #line 116 "jsgf_parser.y"
1536  { (yyval.rhs) = (yyvsp[(3) - (3)].rhs);
1537  (yyval.rhs)->atoms = glist_reverse((yyval.rhs)->atoms);
1538  (yyval.rhs)->alt = (yyvsp[(1) - (3)].rhs); }
1539  break;
1540 
1541  case 20:
1542 /* Line 1813 of yacc.c */
1543 #line 121 "jsgf_parser.y"
1544  { (yyval.rhs) = ckd_calloc(1, sizeof(*(yyval.rhs)));
1545  (yyval.rhs)->atoms = glist_add_ptr((yyval.rhs)->atoms, (yyvsp[(1) - (1)].atom)); }
1546  break;
1547 
1548  case 21:
1549 /* Line 1813 of yacc.c */
1550 #line 123 "jsgf_parser.y"
1551  { (yyval.rhs) = (yyvsp[(1) - (2)].rhs);
1552  (yyval.rhs)->atoms = glist_add_ptr((yyval.rhs)->atoms, (yyvsp[(2) - (2)].atom)); }
1553  break;
1554 
1555  case 23:
1556 /* Line 1813 of yacc.c */
1557 #line 128 "jsgf_parser.y"
1558  { (yyval.atom) = (yyvsp[(1) - (2)].atom);
1559  (yyval.atom)->tags = glist_add_ptr((yyval.atom)->tags, (yyvsp[(2) - (2)].name)); }
1560  break;
1561 
1562  case 25:
1563 /* Line 1813 of yacc.c */
1564 #line 133 "jsgf_parser.y"
1565  { (yyval.atom) = (yyvsp[(2) - (2)].atom); (yyval.atom)->weight = (yyvsp[(1) - (2)].weight); }
1566  break;
1567 
1568  case 26:
1569 /* Line 1813 of yacc.c */
1570 #line 136 "jsgf_parser.y"
1571  { (yyval.rule) = jsgf_define_rule(jsgf, NULL, (yyvsp[(2) - (3)].rhs), 0); }
1572  break;
1573 
1574  case 27:
1575 /* Line 1813 of yacc.c */
1576 #line 139 "jsgf_parser.y"
1577  { (yyval.rule) = jsgf_optional_new(jsgf, (yyvsp[(2) - (3)].rhs)); }
1578  break;
1579 
1580  case 28:
1581 /* Line 1813 of yacc.c */
1582 #line 142 "jsgf_parser.y"
1583  { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].name), 1.0); ckd_free((yyvsp[(1) - (1)].name)); }
1584  break;
1585 
1586  case 29:
1587 /* Line 1813 of yacc.c */
1588 #line 143 "jsgf_parser.y"
1589  { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].name), 1.0); ckd_free((yyvsp[(1) - (1)].name)); }
1590  break;
1591 
1592  case 30:
1593 /* Line 1813 of yacc.c */
1594 #line 144 "jsgf_parser.y"
1595  { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].rule)->name, 1.0); }
1596  break;
1597 
1598  case 31:
1599 /* Line 1813 of yacc.c */
1600 #line 145 "jsgf_parser.y"
1601  { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].rule)->name, 1.0); }
1602  break;
1603 
1604  case 32:
1605 /* Line 1813 of yacc.c */
1606 #line 146 "jsgf_parser.y"
1607  { (yyval.atom) = jsgf_kleene_new(jsgf, (yyvsp[(1) - (2)].atom), 0); }
1608  break;
1609 
1610  case 33:
1611 /* Line 1813 of yacc.c */
1612 #line 147 "jsgf_parser.y"
1613  { (yyval.atom) = jsgf_kleene_new(jsgf, (yyvsp[(1) - (2)].atom), 1); }
1614  break;
1615 
1616 
1617 /* Line 1813 of yacc.c */
1618 #line 1619 "jsgf_parser.c"
1619  default: break;
1620  }
1621  /* User semantic actions sometimes alter yychar, and that requires
1622  that yytoken be updated with the new translation. We take the
1623  approach of translating immediately before every use of yytoken.
1624  One alternative is translating here after every semantic action,
1625  but that translation would be missed if the semantic action invokes
1626  YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1627  if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1628  incorrect destructor might then be invoked immediately. In the
1629  case of YYERROR or YYBACKUP, subsequent parser actions might lead
1630  to an incorrect destructor call or verbose syntax error message
1631  before the lookahead is translated. */
1632  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1633 
1634  YYPOPSTACK (yylen);
1635  yylen = 0;
1636  YY_STACK_PRINT (yyss, yyssp);
1637 
1638  *++yyvsp = yyval;
1639 
1640  /* Now `shift' the result of the reduction. Determine what state
1641  that goes to, based on the state we popped back to and the rule
1642  number reduced by. */
1643 
1644  yyn = yyr1[yyn];
1645 
1646  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1647  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1648  yystate = yytable[yystate];
1649  else
1650  yystate = yydefgoto[yyn - YYNTOKENS];
1651 
1652  goto yynewstate;
1653 
1654 
1655 /*------------------------------------.
1656 | yyerrlab -- here on detecting error |
1657 `------------------------------------*/
1658 yyerrlab:
1659  /* Make sure we have latest lookahead translation. See comments at
1660  user semantic actions for why this is necessary. */
1661  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1662 
1663  /* If not already recovering from an error, report this error. */
1664  if (!yyerrstatus)
1665  {
1666  ++yynerrs;
1667 #if ! YYERROR_VERBOSE
1668  yyerror (yyscanner, jsgf, YY_("syntax error"));
1669 #else
1670 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1671  yyssp, yytoken)
1672  {
1673  char const *yymsgp = YY_("syntax error");
1674  int yysyntax_error_status;
1675  yysyntax_error_status = YYSYNTAX_ERROR;
1676  if (yysyntax_error_status == 0)
1677  yymsgp = yymsg;
1678  else if (yysyntax_error_status == 1)
1679  {
1680  if (yymsg != yymsgbuf)
1681  YYSTACK_FREE (yymsg);
1682  yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1683  if (!yymsg)
1684  {
1685  yymsg = yymsgbuf;
1686  yymsg_alloc = sizeof yymsgbuf;
1687  yysyntax_error_status = 2;
1688  }
1689  else
1690  {
1691  yysyntax_error_status = YYSYNTAX_ERROR;
1692  yymsgp = yymsg;
1693  }
1694  }
1695  yyerror (yyscanner, jsgf, yymsgp);
1696  if (yysyntax_error_status == 2)
1697  goto yyexhaustedlab;
1698  }
1699 # undef YYSYNTAX_ERROR
1700 #endif
1701  }
1702 
1703 
1704 
1705  if (yyerrstatus == 3)
1706  {
1707  /* If just tried and failed to reuse lookahead token after an
1708  error, discard it. */
1709 
1710  if (yychar <= YYEOF)
1711  {
1712  /* Return failure if at end of input. */
1713  if (yychar == YYEOF)
1714  YYABORT;
1715  }
1716  else
1717  {
1718  yydestruct ("Error: discarding",
1719  yytoken, &yylval, yyscanner, jsgf);
1720  yychar = YYEMPTY;
1721  }
1722  }
1723 
1724  /* Else will try to reuse lookahead token after shifting the error
1725  token. */
1726  goto yyerrlab1;
1727 
1728 
1729 /*---------------------------------------------------.
1730 | yyerrorlab -- error raised explicitly by YYERROR. |
1731 `---------------------------------------------------*/
1732 yyerrorlab:
1733 
1734  /* Pacify compilers like GCC when the user code never invokes
1735  YYERROR and the label yyerrorlab therefore never appears in user
1736  code. */
1737  if (/*CONSTCOND*/ 0)
1738  goto yyerrorlab;
1739 
1740  /* Do not reclaim the symbols of the rule which action triggered
1741  this YYERROR. */
1742  YYPOPSTACK (yylen);
1743  yylen = 0;
1744  YY_STACK_PRINT (yyss, yyssp);
1745  yystate = *yyssp;
1746  goto yyerrlab1;
1747 
1748 
1749 /*-------------------------------------------------------------.
1750 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1751 `-------------------------------------------------------------*/
1752 yyerrlab1:
1753  yyerrstatus = 3; /* Each real token shifted decrements this. */
1754 
1755  for (;;)
1756  {
1757  yyn = yypact[yystate];
1758  if (!yypact_value_is_default (yyn))
1759  {
1760  yyn += YYTERROR;
1761  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1762  {
1763  yyn = yytable[yyn];
1764  if (0 < yyn)
1765  break;
1766  }
1767  }
1768 
1769  /* Pop the current state because it cannot handle the error token. */
1770  if (yyssp == yyss)
1771  YYABORT;
1772 
1773 
1774  yydestruct ("Error: popping",
1775  yystos[yystate], yyvsp, yyscanner, jsgf);
1776  YYPOPSTACK (1);
1777  yystate = *yyssp;
1778  YY_STACK_PRINT (yyss, yyssp);
1779  }
1780 
1781  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1782  *++yyvsp = yylval;
1783  YY_IGNORE_MAYBE_UNINITIALIZED_END
1784 
1785 
1786  /* Shift the error token. */
1787  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1788 
1789  yystate = yyn;
1790  goto yynewstate;
1791 
1792 
1793 /*-------------------------------------.
1794 | yyacceptlab -- YYACCEPT comes here. |
1795 `-------------------------------------*/
1796 yyacceptlab:
1797  yyresult = 0;
1798  goto yyreturn;
1799 
1800 /*-----------------------------------.
1801 | yyabortlab -- YYABORT comes here. |
1802 `-----------------------------------*/
1803 yyabortlab:
1804  yyresult = 1;
1805  goto yyreturn;
1806 
1807 #if !defined yyoverflow || YYERROR_VERBOSE
1808 /*-------------------------------------------------.
1809 | yyexhaustedlab -- memory exhaustion comes here. |
1810 `-------------------------------------------------*/
1811 yyexhaustedlab:
1812  yyerror (yyscanner, jsgf, YY_("memory exhausted"));
1813  yyresult = 2;
1814  /* Fall through. */
1815 #endif
1816 
1817 yyreturn:
1818  if (yychar != YYEMPTY)
1819  {
1820  /* Make sure we have latest lookahead translation. See comments at
1821  user semantic actions for why this is necessary. */
1822  yytoken = YYTRANSLATE (yychar);
1823  yydestruct ("Cleanup: discarding lookahead",
1824  yytoken, &yylval, yyscanner, jsgf);
1825  }
1826  /* Do not reclaim the symbols of the rule which action triggered
1827  this YYABORT or YYACCEPT. */
1828  YYPOPSTACK (yylen);
1829  YY_STACK_PRINT (yyss, yyssp);
1830  while (yyssp != yyss)
1831  {
1832  yydestruct ("Cleanup: popping",
1833  yystos[*yyssp], yyvsp, yyscanner, jsgf);
1834  YYPOPSTACK (1);
1835  }
1836 #ifndef yyoverflow
1837  if (yyss != yyssa)
1838  YYSTACK_FREE (yyss);
1839 #endif
1840 #if YYERROR_VERBOSE
1841  if (yymsg != yymsgbuf)
1842  YYSTACK_FREE (yymsg);
1843 #endif
1844  /* Make sure YYID is used. */
1845  return YYID (yyresult);
1846 }
1847 
1848 
1849 /* Line 2076 of yacc.c */
1850 #line 150 "jsgf_parser.y"
1851 
1852 
1853 void
1854 yyerror(yyscan_t lex, jsgf_t *jsgf, const char *s)
1855 {
1856  E_ERROR("%s at line %d current token '%s'\n", s, yyget_lineno(lex), yyget_text(lex));
1857 }