SphinxBase  0.6
jsgf_parser.c
1 /* A Bison parser, made by GNU Bison 2.7. */
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.7"
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 371 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 371 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 387 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 387 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 390 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 /* Error token number */
666 #define YYTERROR 1
667 #define YYERRCODE 256
668 
669 
670 /* This macro is provided for backward compatibility. */
671 #ifndef YY_LOCATION_PRINT
672 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
673 #endif
674 
675 
676 /* YYLEX -- calling `yylex' with the right arguments. */
677 #ifdef YYLEX_PARAM
678 # define YYLEX yylex (&yylval, YYLEX_PARAM)
679 #else
680 # define YYLEX yylex (&yylval, yyscanner)
681 #endif
682 
683 /* Enable debugging if requested. */
684 #if YYDEBUG
685 
686 # ifndef YYFPRINTF
687 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
688 # define YYFPRINTF fprintf
689 # endif
690 
691 # define YYDPRINTF(Args) \
692 do { \
693  if (yydebug) \
694  YYFPRINTF Args; \
695 } while (YYID (0))
696 
697 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
698 do { \
699  if (yydebug) \
700  { \
701  YYFPRINTF (stderr, "%s ", Title); \
702  yy_symbol_print (stderr, \
703  Type, Value, yyscanner, jsgf); \
704  YYFPRINTF (stderr, "\n"); \
705  } \
706 } while (YYID (0))
707 
708 
709 /*--------------------------------.
710 | Print this symbol on YYOUTPUT. |
711 `--------------------------------*/
712 
713 /*ARGSUSED*/
714 #if (defined __STDC__ || defined __C99__FUNC__ \
715  || defined __cplusplus || defined _MSC_VER)
716 static void
717 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void* yyscanner, jsgf_t *jsgf)
718 #else
719 static void
720 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf)
721  FILE *yyoutput;
722  int yytype;
723  YYSTYPE const * const yyvaluep;
724  void* yyscanner;
725  jsgf_t *jsgf;
726 #endif
727 {
728  FILE *yyo = yyoutput;
729  YYUSE (yyo);
730  if (!yyvaluep)
731  return;
732  YYUSE (yyscanner);
733  YYUSE (jsgf);
734 # ifdef YYPRINT
735  if (yytype < YYNTOKENS)
736  YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
737 # else
738  YYUSE (yyoutput);
739 # endif
740  switch (yytype)
741  {
742  default:
743  break;
744  }
745 }
746 
747 
748 /*--------------------------------.
749 | Print this symbol on YYOUTPUT. |
750 `--------------------------------*/
751 
752 #if (defined __STDC__ || defined __C99__FUNC__ \
753  || defined __cplusplus || defined _MSC_VER)
754 static void
755 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void* yyscanner, jsgf_t *jsgf)
756 #else
757 static void
758 yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf)
759  FILE *yyoutput;
760  int yytype;
761  YYSTYPE const * const yyvaluep;
762  void* yyscanner;
763  jsgf_t *jsgf;
764 #endif
765 {
766  if (yytype < YYNTOKENS)
767  YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
768  else
769  YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
770 
771  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf);
772  YYFPRINTF (yyoutput, ")");
773 }
774 
775 /*------------------------------------------------------------------.
776 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
777 | TOP (included). |
778 `------------------------------------------------------------------*/
779 
780 #if (defined __STDC__ || defined __C99__FUNC__ \
781  || defined __cplusplus || defined _MSC_VER)
782 static void
783 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
784 #else
785 static void
786 yy_stack_print (yybottom, yytop)
787  yytype_int16 *yybottom;
788  yytype_int16 *yytop;
789 #endif
790 {
791  YYFPRINTF (stderr, "Stack now");
792  for (; yybottom <= yytop; yybottom++)
793  {
794  int yybot = *yybottom;
795  YYFPRINTF (stderr, " %d", yybot);
796  }
797  YYFPRINTF (stderr, "\n");
798 }
799 
800 # define YY_STACK_PRINT(Bottom, Top) \
801 do { \
802  if (yydebug) \
803  yy_stack_print ((Bottom), (Top)); \
804 } while (YYID (0))
805 
806 
807 /*------------------------------------------------.
808 | Report that the YYRULE is going to be reduced. |
809 `------------------------------------------------*/
810 
811 #if (defined __STDC__ || defined __C99__FUNC__ \
812  || defined __cplusplus || defined _MSC_VER)
813 static void
814 yy_reduce_print (YYSTYPE *yyvsp, int yyrule, void* yyscanner, jsgf_t *jsgf)
815 #else
816 static void
817 yy_reduce_print (yyvsp, yyrule, yyscanner, jsgf)
818  YYSTYPE *yyvsp;
819  int yyrule;
820  void* yyscanner;
821  jsgf_t *jsgf;
822 #endif
823 {
824  int yynrhs = yyr2[yyrule];
825  int yyi;
826  unsigned long int yylno = yyrline[yyrule];
827  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
828  yyrule - 1, yylno);
829  /* The symbols being reduced. */
830  for (yyi = 0; yyi < yynrhs; yyi++)
831  {
832  YYFPRINTF (stderr, " $%d = ", yyi + 1);
833  yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
834  &(yyvsp[(yyi + 1) - (yynrhs)])
835  , yyscanner, jsgf);
836  YYFPRINTF (stderr, "\n");
837  }
838 }
839 
840 # define YY_REDUCE_PRINT(Rule) \
841 do { \
842  if (yydebug) \
843  yy_reduce_print (yyvsp, Rule, yyscanner, jsgf); \
844 } while (YYID (0))
845 
846 /* Nonzero means print parse trace. It is left uninitialized so that
847  multiple parsers can coexist. */
848 int yydebug;
849 #else /* !YYDEBUG */
850 # define YYDPRINTF(Args)
851 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
852 # define YY_STACK_PRINT(Bottom, Top)
853 # define YY_REDUCE_PRINT(Rule)
854 #endif /* !YYDEBUG */
855 
856 
857 /* YYINITDEPTH -- initial size of the parser's stacks. */
858 #ifndef YYINITDEPTH
859 # define YYINITDEPTH 200
860 #endif
861 
862 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
863  if the built-in stack extension method is used).
864 
865  Do not make this value too large; the results are undefined if
866  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
867  evaluated with infinite-precision integer arithmetic. */
868 
869 #ifndef YYMAXDEPTH
870 # define YYMAXDEPTH 10000
871 #endif
872 
873 
874 #if YYERROR_VERBOSE
875 
876 # ifndef yystrlen
877 # if defined __GLIBC__ && defined _STRING_H
878 # define yystrlen strlen
879 # else
880 /* Return the length of YYSTR. */
881 #if (defined __STDC__ || defined __C99__FUNC__ \
882  || defined __cplusplus || defined _MSC_VER)
883 static YYSIZE_T
884 yystrlen (const char *yystr)
885 #else
886 static YYSIZE_T
887 yystrlen (yystr)
888  const char *yystr;
889 #endif
890 {
891  YYSIZE_T yylen;
892  for (yylen = 0; yystr[yylen]; yylen++)
893  continue;
894  return yylen;
895 }
896 # endif
897 # endif
898 
899 # ifndef yystpcpy
900 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
901 # define yystpcpy stpcpy
902 # else
903 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
904  YYDEST. */
905 #if (defined __STDC__ || defined __C99__FUNC__ \
906  || defined __cplusplus || defined _MSC_VER)
907 static char *
908 yystpcpy (char *yydest, const char *yysrc)
909 #else
910 static char *
911 yystpcpy (yydest, yysrc)
912  char *yydest;
913  const char *yysrc;
914 #endif
915 {
916  char *yyd = yydest;
917  const char *yys = yysrc;
918 
919  while ((*yyd++ = *yys++) != '\0')
920  continue;
921 
922  return yyd - 1;
923 }
924 # endif
925 # endif
926 
927 # ifndef yytnamerr
928 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
929  quotes and backslashes, so that it's suitable for yyerror. The
930  heuristic is that double-quoting is unnecessary unless the string
931  contains an apostrophe, a comma, or backslash (other than
932  backslash-backslash). YYSTR is taken from yytname. If YYRES is
933  null, do not copy; instead, return the length of what the result
934  would have been. */
935 static YYSIZE_T
936 yytnamerr (char *yyres, const char *yystr)
937 {
938  if (*yystr == '"')
939  {
940  YYSIZE_T yyn = 0;
941  char const *yyp = yystr;
942 
943  for (;;)
944  switch (*++yyp)
945  {
946  case '\'':
947  case ',':
948  goto do_not_strip_quotes;
949 
950  case '\\':
951  if (*++yyp != '\\')
952  goto do_not_strip_quotes;
953  /* Fall through. */
954  default:
955  if (yyres)
956  yyres[yyn] = *yyp;
957  yyn++;
958  break;
959 
960  case '"':
961  if (yyres)
962  yyres[yyn] = '\0';
963  return yyn;
964  }
965  do_not_strip_quotes: ;
966  }
967 
968  if (! yyres)
969  return yystrlen (yystr);
970 
971  return yystpcpy (yyres, yystr) - yyres;
972 }
973 # endif
974 
975 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
976  about the unexpected token YYTOKEN for the state stack whose top is
977  YYSSP.
978 
979  Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
980  not large enough to hold the message. In that case, also set
981  *YYMSG_ALLOC to the required number of bytes. Return 2 if the
982  required number of bytes is too large to store. */
983 static int
984 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
985  yytype_int16 *yyssp, int yytoken)
986 {
987  YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
988  YYSIZE_T yysize = yysize0;
989  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
990  /* Internationalized format string. */
991  const char *yyformat = YY_NULL;
992  /* Arguments of yyformat. */
993  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
994  /* Number of reported tokens (one for the "unexpected", one per
995  "expected"). */
996  int yycount = 0;
997 
998  /* There are many possibilities here to consider:
999  - Assume YYFAIL is not used. It's too flawed to consider. See
1000  <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1001  for details. YYERROR is fine as it does not invoke this
1002  function.
1003  - If this state is a consistent state with a default action, then
1004  the only way this function was invoked is if the default action
1005  is an error action. In that case, don't check for expected
1006  tokens because there are none.
1007  - The only way there can be no lookahead present (in yychar) is if
1008  this state is a consistent state with a default action. Thus,
1009  detecting the absence of a lookahead is sufficient to determine
1010  that there is no unexpected or expected token to report. In that
1011  case, just report a simple "syntax error".
1012  - Don't assume there isn't a lookahead just because this state is a
1013  consistent state with a default action. There might have been a
1014  previous inconsistent state, consistent state with a non-default
1015  action, or user semantic action that manipulated yychar.
1016  - Of course, the expected token list depends on states to have
1017  correct lookahead information, and it depends on the parser not
1018  to perform extra reductions after fetching a lookahead from the
1019  scanner and before detecting a syntax error. Thus, state merging
1020  (from LALR or IELR) and default reductions corrupt the expected
1021  token list. However, the list is correct for canonical LR with
1022  one exception: it will still contain any token that will not be
1023  accepted due to an error action in a later state.
1024  */
1025  if (yytoken != YYEMPTY)
1026  {
1027  int yyn = yypact[*yyssp];
1028  yyarg[yycount++] = yytname[yytoken];
1029  if (!yypact_value_is_default (yyn))
1030  {
1031  /* Start YYX at -YYN if negative to avoid negative indexes in
1032  YYCHECK. In other words, skip the first -YYN actions for
1033  this state because they are default actions. */
1034  int yyxbegin = yyn < 0 ? -yyn : 0;
1035  /* Stay within bounds of both yycheck and yytname. */
1036  int yychecklim = YYLAST - yyn + 1;
1037  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1038  int yyx;
1039 
1040  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1041  if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1042  && !yytable_value_is_error (yytable[yyx + yyn]))
1043  {
1044  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1045  {
1046  yycount = 1;
1047  yysize = yysize0;
1048  break;
1049  }
1050  yyarg[yycount++] = yytname[yyx];
1051  {
1052  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1053  if (! (yysize <= yysize1
1054  && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1055  return 2;
1056  yysize = yysize1;
1057  }
1058  }
1059  }
1060  }
1061 
1062  switch (yycount)
1063  {
1064 # define YYCASE_(N, S) \
1065  case N: \
1066  yyformat = S; \
1067  break
1068  YYCASE_(0, YY_("syntax error"));
1069  YYCASE_(1, YY_("syntax error, unexpected %s"));
1070  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1071  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1072  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1073  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1074 # undef YYCASE_
1075  }
1076 
1077  {
1078  YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1079  if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1080  return 2;
1081  yysize = yysize1;
1082  }
1083 
1084  if (*yymsg_alloc < yysize)
1085  {
1086  *yymsg_alloc = 2 * yysize;
1087  if (! (yysize <= *yymsg_alloc
1088  && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1089  *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1090  return 1;
1091  }
1092 
1093  /* Avoid sprintf, as that infringes on the user's name space.
1094  Don't have undefined behavior even if the translation
1095  produced a string with the wrong number of "%s"s. */
1096  {
1097  char *yyp = *yymsg;
1098  int yyi = 0;
1099  while ((*yyp = *yyformat) != '\0')
1100  if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1101  {
1102  yyp += yytnamerr (yyp, yyarg[yyi++]);
1103  yyformat += 2;
1104  }
1105  else
1106  {
1107  yyp++;
1108  yyformat++;
1109  }
1110  }
1111  return 0;
1112 }
1113 #endif /* YYERROR_VERBOSE */
1114 
1115 /*-----------------------------------------------.
1116 | Release the memory associated to this symbol. |
1117 `-----------------------------------------------*/
1118 
1119 /*ARGSUSED*/
1120 #if (defined __STDC__ || defined __C99__FUNC__ \
1121  || defined __cplusplus || defined _MSC_VER)
1122 static void
1123 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void* yyscanner, jsgf_t *jsgf)
1124 #else
1125 static void
1126 yydestruct (yymsg, yytype, yyvaluep, yyscanner, jsgf)
1127  const char *yymsg;
1128  int yytype;
1129  YYSTYPE *yyvaluep;
1130  void* yyscanner;
1131  jsgf_t *jsgf;
1132 #endif
1133 {
1134  YYUSE (yyvaluep);
1135  YYUSE (yyscanner);
1136  YYUSE (jsgf);
1137 
1138  if (!yymsg)
1139  yymsg = "Deleting";
1140  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1141 
1142  switch (yytype)
1143  {
1144 
1145  default:
1146  break;
1147  }
1148 }
1149 
1150 
1151 
1152 
1153 /*----------.
1154 | yyparse. |
1155 `----------*/
1156 
1157 #ifdef YYPARSE_PARAM
1158 #if (defined __STDC__ || defined __C99__FUNC__ \
1159  || defined __cplusplus || defined _MSC_VER)
1160 int
1161 yyparse (void *YYPARSE_PARAM)
1162 #else
1163 int
1164 yyparse (YYPARSE_PARAM)
1165  void *YYPARSE_PARAM;
1166 #endif
1167 #else /* ! YYPARSE_PARAM */
1168 #if (defined __STDC__ || defined __C99__FUNC__ \
1169  || defined __cplusplus || defined _MSC_VER)
1170 int
1171 yyparse (void* yyscanner, jsgf_t *jsgf)
1172 #else
1173 int
1174 yyparse (yyscanner, jsgf)
1175  void* yyscanner;
1176  jsgf_t *jsgf;
1177 #endif
1178 #endif
1179 {
1180 /* The lookahead symbol. */
1181 int yychar;
1182 
1183 
1184 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
1185 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
1186 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
1187  _Pragma ("GCC diagnostic push") \
1188  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
1189  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
1190 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
1191  _Pragma ("GCC diagnostic pop")
1192 #else
1193 /* Default value used for initialization, for pacifying older GCCs
1194  or non-GCC compilers. */
1195 static YYSTYPE yyval_default;
1196 # define YY_INITIAL_VALUE(Value) = Value
1197 #endif
1198 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1199 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1200 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1201 #endif
1202 #ifndef YY_INITIAL_VALUE
1203 # define YY_INITIAL_VALUE(Value) /* Nothing. */
1204 #endif
1205 
1206 /* The semantic value of the lookahead symbol. */
1207 YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
1208 
1209  /* Number of syntax errors so far. */
1210  int yynerrs;
1211 
1212  int yystate;
1213  /* Number of tokens to shift before error messages enabled. */
1214  int yyerrstatus;
1215 
1216  /* The stacks and their tools:
1217  `yyss': related to states.
1218  `yyvs': related to semantic values.
1219 
1220  Refer to the stacks through separate pointers, to allow yyoverflow
1221  to reallocate them elsewhere. */
1222 
1223  /* The state stack. */
1224  yytype_int16 yyssa[YYINITDEPTH];
1225  yytype_int16 *yyss;
1226  yytype_int16 *yyssp;
1227 
1228  /* The semantic value stack. */
1229  YYSTYPE yyvsa[YYINITDEPTH];
1230  YYSTYPE *yyvs;
1231  YYSTYPE *yyvsp;
1232 
1233  YYSIZE_T yystacksize;
1234 
1235  int yyn;
1236  int yyresult;
1237  /* Lookahead token as an internal (translated) token number. */
1238  int yytoken = 0;
1239  /* The variables used to return semantic value and location from the
1240  action routines. */
1241  YYSTYPE yyval;
1242 
1243 #if YYERROR_VERBOSE
1244  /* Buffer for error messages, and its allocated size. */
1245  char yymsgbuf[128];
1246  char *yymsg = yymsgbuf;
1247  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1248 #endif
1249 
1250 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1251 
1252  /* The number of symbols on the RHS of the reduced rule.
1253  Keep to zero when no symbol should be popped. */
1254  int yylen = 0;
1255 
1256  yyssp = yyss = yyssa;
1257  yyvsp = yyvs = yyvsa;
1258  yystacksize = YYINITDEPTH;
1259 
1260  YYDPRINTF ((stderr, "Starting parse\n"));
1261 
1262  yystate = 0;
1263  yyerrstatus = 0;
1264  yynerrs = 0;
1265  yychar = YYEMPTY; /* Cause a token to be read. */
1266  goto yysetstate;
1267 
1268 /*------------------------------------------------------------.
1269 | yynewstate -- Push a new state, which is found in yystate. |
1270 `------------------------------------------------------------*/
1271  yynewstate:
1272  /* In all cases, when you get here, the value and location stacks
1273  have just been pushed. So pushing a state here evens the stacks. */
1274  yyssp++;
1275 
1276  yysetstate:
1277  *yyssp = yystate;
1278 
1279  if (yyss + yystacksize - 1 <= yyssp)
1280  {
1281  /* Get the current used size of the three stacks, in elements. */
1282  YYSIZE_T yysize = yyssp - yyss + 1;
1283 
1284 #ifdef yyoverflow
1285  {
1286  /* Give user a chance to reallocate the stack. Use copies of
1287  these so that the &'s don't force the real ones into
1288  memory. */
1289  YYSTYPE *yyvs1 = yyvs;
1290  yytype_int16 *yyss1 = yyss;
1291 
1292  /* Each stack pointer address is followed by the size of the
1293  data in use in that stack, in bytes. This used to be a
1294  conditional around just the two extra args, but that might
1295  be undefined if yyoverflow is a macro. */
1296  yyoverflow (YY_("memory exhausted"),
1297  &yyss1, yysize * sizeof (*yyssp),
1298  &yyvs1, yysize * sizeof (*yyvsp),
1299  &yystacksize);
1300 
1301  yyss = yyss1;
1302  yyvs = yyvs1;
1303  }
1304 #else /* no yyoverflow */
1305 # ifndef YYSTACK_RELOCATE
1306  goto yyexhaustedlab;
1307 # else
1308  /* Extend the stack our own way. */
1309  if (YYMAXDEPTH <= yystacksize)
1310  goto yyexhaustedlab;
1311  yystacksize *= 2;
1312  if (YYMAXDEPTH < yystacksize)
1313  yystacksize = YYMAXDEPTH;
1314 
1315  {
1316  yytype_int16 *yyss1 = yyss;
1317  union yyalloc *yyptr =
1318  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1319  if (! yyptr)
1320  goto yyexhaustedlab;
1321  YYSTACK_RELOCATE (yyss_alloc, yyss);
1322  YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1323 # undef YYSTACK_RELOCATE
1324  if (yyss1 != yyssa)
1325  YYSTACK_FREE (yyss1);
1326  }
1327 # endif
1328 #endif /* no yyoverflow */
1329 
1330  yyssp = yyss + yysize - 1;
1331  yyvsp = yyvs + yysize - 1;
1332 
1333  YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1334  (unsigned long int) yystacksize));
1335 
1336  if (yyss + yystacksize - 1 <= yyssp)
1337  YYABORT;
1338  }
1339 
1340  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1341 
1342  if (yystate == YYFINAL)
1343  YYACCEPT;
1344 
1345  goto yybackup;
1346 
1347 /*-----------.
1348 | yybackup. |
1349 `-----------*/
1350 yybackup:
1351 
1352  /* Do appropriate processing given the current state. Read a
1353  lookahead token if we need one and don't already have one. */
1354 
1355  /* First try to decide what to do without reference to lookahead token. */
1356  yyn = yypact[yystate];
1357  if (yypact_value_is_default (yyn))
1358  goto yydefault;
1359 
1360  /* Not known => get a lookahead token if don't already have one. */
1361 
1362  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1363  if (yychar == YYEMPTY)
1364  {
1365  YYDPRINTF ((stderr, "Reading a token: "));
1366  yychar = YYLEX;
1367  }
1368 
1369  if (yychar <= YYEOF)
1370  {
1371  yychar = yytoken = YYEOF;
1372  YYDPRINTF ((stderr, "Now at end of input.\n"));
1373  }
1374  else
1375  {
1376  yytoken = YYTRANSLATE (yychar);
1377  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1378  }
1379 
1380  /* If the proper action on seeing token YYTOKEN is to reduce or to
1381  detect an error, take that action. */
1382  yyn += yytoken;
1383  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1384  goto yydefault;
1385  yyn = yytable[yyn];
1386  if (yyn <= 0)
1387  {
1388  if (yytable_value_is_error (yyn))
1389  goto yyerrlab;
1390  yyn = -yyn;
1391  goto yyreduce;
1392  }
1393 
1394  /* Count tokens shifted since error; after three, turn off error
1395  status. */
1396  if (yyerrstatus)
1397  yyerrstatus--;
1398 
1399  /* Shift the lookahead token. */
1400  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1401 
1402  /* Discard the shifted token. */
1403  yychar = YYEMPTY;
1404 
1405  yystate = yyn;
1406  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1407  *++yyvsp = yylval;
1408  YY_IGNORE_MAYBE_UNINITIALIZED_END
1409 
1410  goto yynewstate;
1411 
1412 
1413 /*-----------------------------------------------------------.
1414 | yydefault -- do the default action for the current state. |
1415 `-----------------------------------------------------------*/
1416 yydefault:
1417  yyn = yydefact[yystate];
1418  if (yyn == 0)
1419  goto yyerrlab;
1420  goto yyreduce;
1421 
1422 
1423 /*-----------------------------.
1424 | yyreduce -- Do a reduction. |
1425 `-----------------------------*/
1426 yyreduce:
1427  /* yyn is the number of a rule to reduce with. */
1428  yylen = yyr2[yyn];
1429 
1430  /* If YYLEN is nonzero, implement the default value of the action:
1431  `$$ = $1'.
1432 
1433  Otherwise, the following line sets YYVAL to garbage.
1434  This behavior is undocumented and Bison
1435  users should not rely upon it. Assigning to YYVAL
1436  unconditionally makes the parser a bit smaller, and it avoids a
1437  GCC warning that YYVAL may be used uninitialized. */
1438  yyval = yyvsp[1-yylen];
1439 
1440 
1441  YY_REDUCE_PRINT (yyn);
1442  switch (yyn)
1443  {
1444  case 5:
1445 /* Line 1792 of yacc.c */
1446 #line 87 "jsgf_parser.y"
1447  { jsgf->name = (yyvsp[(2) - (2)].name); }
1448  break;
1449 
1450  case 7:
1451 /* Line 1792 of yacc.c */
1452 #line 91 "jsgf_parser.y"
1453  { jsgf->version = (yyvsp[(2) - (3)].name); }
1454  break;
1455 
1456  case 8:
1457 /* Line 1792 of yacc.c */
1458 #line 92 "jsgf_parser.y"
1459  { jsgf->version = (yyvsp[(2) - (4)].name); jsgf->charset = (yyvsp[(3) - (4)].name); }
1460  break;
1461 
1462  case 9:
1463 /* Line 1792 of yacc.c */
1464 #line 93 "jsgf_parser.y"
1465  { jsgf->version = (yyvsp[(2) - (5)].name); jsgf->charset = (yyvsp[(3) - (5)].name);
1466  jsgf->locale = (yyvsp[(4) - (5)].name); }
1467  break;
1468 
1469  case 10:
1470 /* Line 1792 of yacc.c */
1471 #line 97 "jsgf_parser.y"
1472  { (yyval.name) = (yyvsp[(2) - (3)].name); }
1473  break;
1474 
1475  case 13:
1476 /* Line 1792 of yacc.c */
1477 #line 104 "jsgf_parser.y"
1478  { jsgf_import_rule(jsgf, (yyvsp[(2) - (3)].name)); ckd_free((yyvsp[(2) - (3)].name)); }
1479  break;
1480 
1481  case 16:
1482 /* Line 1792 of yacc.c */
1483 #line 111 "jsgf_parser.y"
1484  { jsgf_define_rule(jsgf, (yyvsp[(1) - (4)].name), (yyvsp[(3) - (4)].rhs), 0); ckd_free((yyvsp[(1) - (4)].name)); }
1485  break;
1486 
1487  case 17:
1488 /* Line 1792 of yacc.c */
1489 #line 112 "jsgf_parser.y"
1490  { jsgf_define_rule(jsgf, (yyvsp[(2) - (5)].name), (yyvsp[(4) - (5)].rhs), 1); ckd_free((yyvsp[(2) - (5)].name)); }
1491  break;
1492 
1493  case 18:
1494 /* Line 1792 of yacc.c */
1495 #line 115 "jsgf_parser.y"
1496  { (yyval.rhs) = (yyvsp[(1) - (1)].rhs); (yyval.rhs)->atoms = glist_reverse((yyval.rhs)->atoms); }
1497  break;
1498 
1499  case 19:
1500 /* Line 1792 of yacc.c */
1501 #line 116 "jsgf_parser.y"
1502  { (yyval.rhs) = (yyvsp[(3) - (3)].rhs);
1503  (yyval.rhs)->atoms = glist_reverse((yyval.rhs)->atoms);
1504  (yyval.rhs)->alt = (yyvsp[(1) - (3)].rhs); }
1505  break;
1506 
1507  case 20:
1508 /* Line 1792 of yacc.c */
1509 #line 121 "jsgf_parser.y"
1510  { (yyval.rhs) = ckd_calloc(1, sizeof(*(yyval.rhs)));
1511  (yyval.rhs)->atoms = glist_add_ptr((yyval.rhs)->atoms, (yyvsp[(1) - (1)].atom)); }
1512  break;
1513 
1514  case 21:
1515 /* Line 1792 of yacc.c */
1516 #line 123 "jsgf_parser.y"
1517  { (yyval.rhs) = (yyvsp[(1) - (2)].rhs);
1518  (yyval.rhs)->atoms = glist_add_ptr((yyval.rhs)->atoms, (yyvsp[(2) - (2)].atom)); }
1519  break;
1520 
1521  case 23:
1522 /* Line 1792 of yacc.c */
1523 #line 128 "jsgf_parser.y"
1524  { (yyval.atom) = (yyvsp[(1) - (2)].atom);
1525  (yyval.atom)->tags = glist_add_ptr((yyval.atom)->tags, (yyvsp[(2) - (2)].name)); }
1526  break;
1527 
1528  case 25:
1529 /* Line 1792 of yacc.c */
1530 #line 133 "jsgf_parser.y"
1531  { (yyval.atom) = (yyvsp[(2) - (2)].atom); (yyval.atom)->weight = (yyvsp[(1) - (2)].weight); }
1532  break;
1533 
1534  case 26:
1535 /* Line 1792 of yacc.c */
1536 #line 136 "jsgf_parser.y"
1537  { (yyval.rule) = jsgf_define_rule(jsgf, NULL, (yyvsp[(2) - (3)].rhs), 0); }
1538  break;
1539 
1540  case 27:
1541 /* Line 1792 of yacc.c */
1542 #line 139 "jsgf_parser.y"
1543  { (yyval.rule) = jsgf_optional_new(jsgf, (yyvsp[(2) - (3)].rhs)); }
1544  break;
1545 
1546  case 28:
1547 /* Line 1792 of yacc.c */
1548 #line 142 "jsgf_parser.y"
1549  { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].name), 1.0); ckd_free((yyvsp[(1) - (1)].name)); }
1550  break;
1551 
1552  case 29:
1553 /* Line 1792 of yacc.c */
1554 #line 143 "jsgf_parser.y"
1555  { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].name), 1.0); ckd_free((yyvsp[(1) - (1)].name)); }
1556  break;
1557 
1558  case 30:
1559 /* Line 1792 of yacc.c */
1560 #line 144 "jsgf_parser.y"
1561  { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].rule)->name, 1.0); }
1562  break;
1563 
1564  case 31:
1565 /* Line 1792 of yacc.c */
1566 #line 145 "jsgf_parser.y"
1567  { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].rule)->name, 1.0); }
1568  break;
1569 
1570  case 32:
1571 /* Line 1792 of yacc.c */
1572 #line 146 "jsgf_parser.y"
1573  { (yyval.atom) = jsgf_kleene_new(jsgf, (yyvsp[(1) - (2)].atom), 0); }
1574  break;
1575 
1576  case 33:
1577 /* Line 1792 of yacc.c */
1578 #line 147 "jsgf_parser.y"
1579  { (yyval.atom) = jsgf_kleene_new(jsgf, (yyvsp[(1) - (2)].atom), 1); }
1580  break;
1581 
1582 
1583 /* Line 1792 of yacc.c */
1584 #line 1585 "jsgf_parser.c"
1585  default: break;
1586  }
1587  /* User semantic actions sometimes alter yychar, and that requires
1588  that yytoken be updated with the new translation. We take the
1589  approach of translating immediately before every use of yytoken.
1590  One alternative is translating here after every semantic action,
1591  but that translation would be missed if the semantic action invokes
1592  YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1593  if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1594  incorrect destructor might then be invoked immediately. In the
1595  case of YYERROR or YYBACKUP, subsequent parser actions might lead
1596  to an incorrect destructor call or verbose syntax error message
1597  before the lookahead is translated. */
1598  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1599 
1600  YYPOPSTACK (yylen);
1601  yylen = 0;
1602  YY_STACK_PRINT (yyss, yyssp);
1603 
1604  *++yyvsp = yyval;
1605 
1606  /* Now `shift' the result of the reduction. Determine what state
1607  that goes to, based on the state we popped back to and the rule
1608  number reduced by. */
1609 
1610  yyn = yyr1[yyn];
1611 
1612  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1613  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1614  yystate = yytable[yystate];
1615  else
1616  yystate = yydefgoto[yyn - YYNTOKENS];
1617 
1618  goto yynewstate;
1619 
1620 
1621 /*------------------------------------.
1622 | yyerrlab -- here on detecting error |
1623 `------------------------------------*/
1624 yyerrlab:
1625  /* Make sure we have latest lookahead translation. See comments at
1626  user semantic actions for why this is necessary. */
1627  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1628 
1629  /* If not already recovering from an error, report this error. */
1630  if (!yyerrstatus)
1631  {
1632  ++yynerrs;
1633 #if ! YYERROR_VERBOSE
1634  yyerror (yyscanner, jsgf, YY_("syntax error"));
1635 #else
1636 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1637  yyssp, yytoken)
1638  {
1639  char const *yymsgp = YY_("syntax error");
1640  int yysyntax_error_status;
1641  yysyntax_error_status = YYSYNTAX_ERROR;
1642  if (yysyntax_error_status == 0)
1643  yymsgp = yymsg;
1644  else if (yysyntax_error_status == 1)
1645  {
1646  if (yymsg != yymsgbuf)
1647  YYSTACK_FREE (yymsg);
1648  yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1649  if (!yymsg)
1650  {
1651  yymsg = yymsgbuf;
1652  yymsg_alloc = sizeof yymsgbuf;
1653  yysyntax_error_status = 2;
1654  }
1655  else
1656  {
1657  yysyntax_error_status = YYSYNTAX_ERROR;
1658  yymsgp = yymsg;
1659  }
1660  }
1661  yyerror (yyscanner, jsgf, yymsgp);
1662  if (yysyntax_error_status == 2)
1663  goto yyexhaustedlab;
1664  }
1665 # undef YYSYNTAX_ERROR
1666 #endif
1667  }
1668 
1669 
1670 
1671  if (yyerrstatus == 3)
1672  {
1673  /* If just tried and failed to reuse lookahead token after an
1674  error, discard it. */
1675 
1676  if (yychar <= YYEOF)
1677  {
1678  /* Return failure if at end of input. */
1679  if (yychar == YYEOF)
1680  YYABORT;
1681  }
1682  else
1683  {
1684  yydestruct ("Error: discarding",
1685  yytoken, &yylval, yyscanner, jsgf);
1686  yychar = YYEMPTY;
1687  }
1688  }
1689 
1690  /* Else will try to reuse lookahead token after shifting the error
1691  token. */
1692  goto yyerrlab1;
1693 
1694 
1695 /*---------------------------------------------------.
1696 | yyerrorlab -- error raised explicitly by YYERROR. |
1697 `---------------------------------------------------*/
1698 yyerrorlab:
1699 
1700  /* Pacify compilers like GCC when the user code never invokes
1701  YYERROR and the label yyerrorlab therefore never appears in user
1702  code. */
1703  if (/*CONSTCOND*/ 0)
1704  goto yyerrorlab;
1705 
1706  /* Do not reclaim the symbols of the rule which action triggered
1707  this YYERROR. */
1708  YYPOPSTACK (yylen);
1709  yylen = 0;
1710  YY_STACK_PRINT (yyss, yyssp);
1711  yystate = *yyssp;
1712  goto yyerrlab1;
1713 
1714 
1715 /*-------------------------------------------------------------.
1716 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1717 `-------------------------------------------------------------*/
1718 yyerrlab1:
1719  yyerrstatus = 3; /* Each real token shifted decrements this. */
1720 
1721  for (;;)
1722  {
1723  yyn = yypact[yystate];
1724  if (!yypact_value_is_default (yyn))
1725  {
1726  yyn += YYTERROR;
1727  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1728  {
1729  yyn = yytable[yyn];
1730  if (0 < yyn)
1731  break;
1732  }
1733  }
1734 
1735  /* Pop the current state because it cannot handle the error token. */
1736  if (yyssp == yyss)
1737  YYABORT;
1738 
1739 
1740  yydestruct ("Error: popping",
1741  yystos[yystate], yyvsp, yyscanner, jsgf);
1742  YYPOPSTACK (1);
1743  yystate = *yyssp;
1744  YY_STACK_PRINT (yyss, yyssp);
1745  }
1746 
1747  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1748  *++yyvsp = yylval;
1749  YY_IGNORE_MAYBE_UNINITIALIZED_END
1750 
1751 
1752  /* Shift the error token. */
1753  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1754 
1755  yystate = yyn;
1756  goto yynewstate;
1757 
1758 
1759 /*-------------------------------------.
1760 | yyacceptlab -- YYACCEPT comes here. |
1761 `-------------------------------------*/
1762 yyacceptlab:
1763  yyresult = 0;
1764  goto yyreturn;
1765 
1766 /*-----------------------------------.
1767 | yyabortlab -- YYABORT comes here. |
1768 `-----------------------------------*/
1769 yyabortlab:
1770  yyresult = 1;
1771  goto yyreturn;
1772 
1773 #if !defined yyoverflow || YYERROR_VERBOSE
1774 /*-------------------------------------------------.
1775 | yyexhaustedlab -- memory exhaustion comes here. |
1776 `-------------------------------------------------*/
1777 yyexhaustedlab:
1778  yyerror (yyscanner, jsgf, YY_("memory exhausted"));
1779  yyresult = 2;
1780  /* Fall through. */
1781 #endif
1782 
1783 yyreturn:
1784  if (yychar != YYEMPTY)
1785  {
1786  /* Make sure we have latest lookahead translation. See comments at
1787  user semantic actions for why this is necessary. */
1788  yytoken = YYTRANSLATE (yychar);
1789  yydestruct ("Cleanup: discarding lookahead",
1790  yytoken, &yylval, yyscanner, jsgf);
1791  }
1792  /* Do not reclaim the symbols of the rule which action triggered
1793  this YYABORT or YYACCEPT. */
1794  YYPOPSTACK (yylen);
1795  YY_STACK_PRINT (yyss, yyssp);
1796  while (yyssp != yyss)
1797  {
1798  yydestruct ("Cleanup: popping",
1799  yystos[*yyssp], yyvsp, yyscanner, jsgf);
1800  YYPOPSTACK (1);
1801  }
1802 #ifndef yyoverflow
1803  if (yyss != yyssa)
1804  YYSTACK_FREE (yyss);
1805 #endif
1806 #if YYERROR_VERBOSE
1807  if (yymsg != yymsgbuf)
1808  YYSTACK_FREE (yymsg);
1809 #endif
1810  /* Make sure YYID is used. */
1811  return YYID (yyresult);
1812 }
1813 
1814 
1815 /* Line 2055 of yacc.c */
1816 #line 150 "jsgf_parser.y"
1817 
1818 
1819 void
1820 yyerror(yyscan_t lex, jsgf_t *jsgf, const char *s)
1821 {
1822  E_ERROR("%s at line %d current token '%s'\n", s, yyget_lineno(lex), yyget_text(lex));
1823 }