SphinxBase  0.6
jsgf_parser.c
1 /* A Bison parser, made by GNU Bison 2.7.12-4996. */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5  Copyright (C) 1984, 1989-1990, 2000-2013 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.12-4996"
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_Y_TAB_H_INCLUDED
111 # define YY_YY_Y_TAB_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_Y_TAB_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 #ifndef __attribute__
251 /* This feature is available in gcc versions 2.5 and later. */
252 # if (! defined __GNUC__ || __GNUC__ < 2 \
253  || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
254 # define __attribute__(Spec) /* empty */
255 # endif
256 #endif
257 
258 /* Suppress unused-variable warnings by "using" E. */
259 #if ! defined lint || defined __GNUC__
260 # define YYUSE(E) ((void) (E))
261 #else
262 # define YYUSE(E) /* empty */
263 #endif
264 
265 
266 /* Identity function, used to suppress warnings about constant conditions. */
267 #ifndef lint
268 # define YYID(N) (N)
269 #else
270 #if (defined __STDC__ || defined __C99__FUNC__ \
271  || defined __cplusplus || defined _MSC_VER)
272 static int
273 YYID (int yyi)
274 #else
275 static int
276 YYID (yyi)
277  int yyi;
278 #endif
279 {
280  return yyi;
281 }
282 #endif
283 
284 #if ! defined yyoverflow || YYERROR_VERBOSE
285 
286 /* The parser invokes alloca or malloc; define the necessary symbols. */
287 
288 # ifdef YYSTACK_USE_ALLOCA
289 # if YYSTACK_USE_ALLOCA
290 # ifdef __GNUC__
291 # define YYSTACK_ALLOC __builtin_alloca
292 # elif defined __BUILTIN_VA_ARG_INCR
293 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
294 # elif defined _AIX
295 # define YYSTACK_ALLOC __alloca
296 # elif defined _MSC_VER
297 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
298 # define alloca _alloca
299 # else
300 # define YYSTACK_ALLOC alloca
301 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
302  || defined __cplusplus || defined _MSC_VER)
303 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
304  /* Use EXIT_SUCCESS as a witness for stdlib.h. */
305 # ifndef EXIT_SUCCESS
306 # define EXIT_SUCCESS 0
307 # endif
308 # endif
309 # endif
310 # endif
311 # endif
312 
313 # ifdef YYSTACK_ALLOC
314  /* Pacify GCC's `empty if-body' warning. */
315 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
316 # ifndef YYSTACK_ALLOC_MAXIMUM
317  /* The OS might guarantee only one guard page at the bottom of the stack,
318  and a page size can be as small as 4096 bytes. So we cannot safely
319  invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
320  to allow for a few compiler-allocated temporary stack slots. */
321 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
322 # endif
323 # else
324 # define YYSTACK_ALLOC YYMALLOC
325 # define YYSTACK_FREE YYFREE
326 # ifndef YYSTACK_ALLOC_MAXIMUM
327 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
328 # endif
329 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
330  && ! ((defined YYMALLOC || defined malloc) \
331  && (defined YYFREE || defined free)))
332 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
333 # ifndef EXIT_SUCCESS
334 # define EXIT_SUCCESS 0
335 # endif
336 # endif
337 # ifndef YYMALLOC
338 # define YYMALLOC malloc
339 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
340  || defined __cplusplus || defined _MSC_VER)
341 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
342 # endif
343 # endif
344 # ifndef YYFREE
345 # define YYFREE free
346 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
347  || defined __cplusplus || defined _MSC_VER)
348 void free (void *); /* INFRINGES ON USER NAME SPACE */
349 # endif
350 # endif
351 # endif
352 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
353 
354 
355 #if (! defined yyoverflow \
356  && (! defined __cplusplus \
357  || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
358 
359 /* A type that is properly aligned for any stack member. */
360 union yyalloc
361 {
362  yytype_int16 yyss_alloc;
363  YYSTYPE yyvs_alloc;
364 };
365 
366 /* The size of the maximum gap between one aligned stack and the next. */
367 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
368 
369 /* The size of an array large to enough to hold all stacks, each with
370  N elements. */
371 # define YYSTACK_BYTES(N) \
372  ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
373  + YYSTACK_GAP_MAXIMUM)
374 
375 # define YYCOPY_NEEDED 1
376 
377 /* Relocate STACK from its old location to the new one. The
378  local variables YYSIZE and YYSTACKSIZE give the old and new number of
379  elements in the stack, and YYPTR gives the new location of the
380  stack. Advance YYPTR to a properly aligned location for the next
381  stack. */
382 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
383  do \
384  { \
385  YYSIZE_T yynewbytes; \
386  YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
387  Stack = &yyptr->Stack_alloc; \
388  yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
389  yyptr += yynewbytes / sizeof (*yyptr); \
390  } \
391  while (YYID (0))
392 
393 #endif
394 
395 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
396 /* Copy COUNT objects from SRC to DST. The source and destination do
397  not overlap. */
398 # ifndef YYCOPY
399 # if defined __GNUC__ && 1 < __GNUC__
400 # define YYCOPY(Dst, Src, Count) \
401  __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
402 # else
403 # define YYCOPY(Dst, Src, Count) \
404  do \
405  { \
406  YYSIZE_T yyi; \
407  for (yyi = 0; yyi < (Count); yyi++) \
408  (Dst)[yyi] = (Src)[yyi]; \
409  } \
410  while (YYID (0))
411 # endif
412 # endif
413 #endif /* !YYCOPY_NEEDED */
414 
415 /* YYFINAL -- State number of the termination state. */
416 #define YYFINAL 7
417 /* YYLAST -- Last index in YYTABLE. */
418 #define YYLAST 54
419 
420 /* YYNTOKENS -- Number of terminals. */
421 #define YYNTOKENS 20
422 /* YYNNTS -- Number of nonterminals. */
423 #define YYNNTS 16
424 /* YYNRULES -- Number of rules. */
425 #define YYNRULES 33
426 /* YYNRULES -- Number of states. */
427 #define YYNSTATES 58
428 
429 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
430 #define YYUNDEFTOK 2
431 #define YYMAXUTOK 265
432 
433 #define YYTRANSLATE(YYX) \
434  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
435 
436 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
437 static const yytype_uint8 yytranslate[] =
438 {
439  0, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2,
443  14, 15, 18, 19, 2, 2, 2, 2, 2, 2,
444  2, 2, 2, 2, 2, 2, 2, 2, 2, 11,
445  2, 12, 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, 16, 2, 17, 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, 13, 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, 2, 2, 2, 2,
456  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
457  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
458  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
459  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
460  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
461  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
462  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
463  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
464  2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
465  5, 6, 7, 8, 9, 10
466 };
467 
468 #if YYDEBUG
469 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
470  YYRHS. */
471 static const yytype_uint8 yyprhs[] =
472 {
473  0, 0, 3, 5, 8, 12, 15, 18, 22, 27,
474  33, 37, 39, 42, 46, 48, 51, 56, 62, 64,
475  68, 70, 73, 75, 78, 80, 83, 87, 91, 93,
476  95, 97, 99, 102
477 };
478 
479 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
480 static const yytype_int8 yyrhs[] =
481 {
482  21, 0, -1, 22, -1, 22, 27, -1, 22, 25,
483  27, -1, 23, 24, -1, 3, 11, -1, 3, 7,
484  11, -1, 3, 7, 7, 11, -1, 3, 7, 7,
485  7, 11, -1, 4, 7, 11, -1, 26, -1, 25,
486  26, -1, 5, 8, 11, -1, 28, -1, 27, 28,
487  -1, 8, 12, 29, 11, -1, 6, 8, 12, 29,
488  11, -1, 30, -1, 29, 13, 30, -1, 31, -1,
489  30, 31, -1, 32, -1, 31, 9, -1, 35, -1,
490  10, 35, -1, 14, 29, 15, -1, 16, 29, 17,
491  -1, 7, -1, 8, -1, 33, -1, 34, -1, 35,
492  18, -1, 35, 19, -1
493 };
494 
495 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
496 static const yytype_uint8 yyrline[] =
497 {
498  0, 82, 82, 83, 84, 87, 90, 91, 92, 93,
499  97, 100, 101, 104, 107, 108, 111, 112, 115, 116,
500  121, 123, 127, 128, 132, 133, 136, 139, 142, 143,
501  144, 145, 146, 147
502 };
503 #endif
504 
505 #if YYDEBUG || YYERROR_VERBOSE || 0
506 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
507  First, the terminals, then, starting at YYNTOKENS, nonterminals. */
508 static const char *const yytname[] =
509 {
510  "$end", "error", "$undefined", "HEADER", "GRAMMAR", "IMPORT", "PUBLIC",
511  "TOKEN", "RULENAME", "TAG", "WEIGHT", "';'", "'='", "'|'", "'('", "')'",
512  "'['", "']'", "'*'", "'+'", "$accept", "grammar", "header",
513  "jsgf_header", "grammar_header", "import_header", "import_statement",
514  "rule_list", "rule", "alternate_list", "rule_expansion",
515  "tagged_rule_item", "rule_item", "rule_group", "rule_optional",
516  "rule_atom", YY_NULL
517 };
518 #endif
519 
520 # ifdef YYPRINT
521 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
522  token YYLEX-NUM. */
523 static const yytype_uint16 yytoknum[] =
524 {
525  0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
526  265, 59, 61, 124, 40, 41, 91, 93, 42, 43
527 };
528 # endif
529 
530 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
531 static const yytype_uint8 yyr1[] =
532 {
533  0, 20, 21, 21, 21, 22, 23, 23, 23, 23,
534  24, 25, 25, 26, 27, 27, 28, 28, 29, 29,
535  30, 30, 31, 31, 32, 32, 33, 34, 35, 35,
536  35, 35, 35, 35
537 };
538 
539 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
540 static const yytype_uint8 yyr2[] =
541 {
542  0, 2, 1, 2, 3, 2, 2, 3, 4, 5,
543  3, 1, 2, 3, 1, 2, 4, 5, 1, 3,
544  1, 2, 1, 2, 1, 2, 3, 3, 1, 1,
545  1, 1, 2, 2
546 };
547 
548 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
549  Performed when YYTABLE doesn't specify something else to do. Zero
550  means the default is an error. */
551 static const yytype_uint8 yydefact[] =
552 {
553  0, 0, 0, 2, 0, 0, 6, 1, 0, 0,
554  0, 0, 11, 3, 14, 0, 5, 0, 7, 0,
555  0, 0, 12, 4, 15, 0, 0, 8, 13, 0,
556  28, 29, 0, 0, 0, 0, 18, 20, 22, 30,
557  31, 24, 10, 9, 0, 25, 0, 0, 16, 0,
558  21, 23, 32, 33, 17, 26, 27, 19
559 };
560 
561 /* YYDEFGOTO[NTERM-NUM]. */
562 static const yytype_int8 yydefgoto[] =
563 {
564  -1, 2, 3, 4, 16, 11, 12, 13, 14, 35,
565  36, 37, 38, 39, 40, 41
566 };
567 
568 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
569  STATE-NUM. */
570 #define YYPACT_NINF -37
571 static const yytype_int8 yypact[] =
572 {
573  -1, -2, 36, 22, 35, 8, -37, -37, 32, 33,
574  30, 22, -37, 17, -37, 37, -37, 13, -37, 34,
575  31, -4, -37, 17, -37, 38, 39, -37, -37, -4,
576  -37, -37, 0, -4, -4, 18, -4, 42, -37, -37,
577  -37, 19, -37, -37, 21, 19, 20, 9, -37, -4,
578  42, -37, -37, -37, -37, -37, -37, -4
579 };
580 
581 /* YYPGOTO[NTERM-NUM]. */
582 static const yytype_int8 yypgoto[] =
583 {
584  -37, -37, -37, -37, -37, -37, 41, 43, -12, -16,
585  -3, -36, -37, -37, -37, 15
586 };
587 
588 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
589  positive, shift that token. If negative, reduce the rule which
590  number is the opposite. If YYTABLE_NINF, syntax error. */
591 #define YYTABLE_NINF -1
592 static const yytype_uint8 yytable[] =
593 {
594  50, 24, 1, 30, 31, 5, 32, 30, 31, 6,
595  33, 24, 34, 44, 33, 17, 34, 46, 47, 18,
596  26, 50, 49, 9, 27, 10, 56, 8, 9, 48,
597  10, 49, 54, 49, 49, 55, 7, 52, 53, 15,
598  19, 20, 21, 29, 25, 28, 57, 45, 0, 42,
599  43, 51, 22, 0, 23
600 };
601 
602 #define yypact_value_is_default(Yystate) \
603  (!!((Yystate) == (-37)))
604 
605 #define yytable_value_is_error(Yytable_value) \
606  YYID (0)
607 
608 static const yytype_int8 yycheck[] =
609 {
610  36, 13, 3, 7, 8, 7, 10, 7, 8, 11,
611  14, 23, 16, 29, 14, 7, 16, 33, 34, 11,
612  7, 57, 13, 6, 11, 8, 17, 5, 6, 11,
613  8, 13, 11, 13, 13, 15, 0, 18, 19, 4,
614  8, 8, 12, 12, 7, 11, 49, 32, -1, 11,
615  11, 9, 11, -1, 11
616 };
617 
618 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
619  symbol of state STATE-NUM. */
620 static const yytype_uint8 yystos[] =
621 {
622  0, 3, 21, 22, 23, 7, 11, 0, 5, 6,
623  8, 25, 26, 27, 28, 4, 24, 7, 11, 8,
624  8, 12, 26, 27, 28, 7, 7, 11, 11, 12,
625  7, 8, 10, 14, 16, 29, 30, 31, 32, 33,
626  34, 35, 11, 11, 29, 35, 29, 29, 11, 13,
627  31, 9, 18, 19, 11, 15, 17, 30
628 };
629 
630 #define yyerrok (yyerrstatus = 0)
631 #define yyclearin (yychar = YYEMPTY)
632 #define YYEMPTY (-2)
633 #define YYEOF 0
634 
635 #define YYACCEPT goto yyacceptlab
636 #define YYABORT goto yyabortlab
637 #define YYERROR goto yyerrorlab
638 
639 
640 /* Like YYERROR except do call yyerror. This remains here temporarily
641  to ease the transition to the new meaning of YYERROR, for GCC.
642  Once GCC version 2 has supplanted version 1, this can go. However,
643  YYFAIL appears to be in use. Nevertheless, it is formally deprecated
644  in Bison 2.4.2's NEWS entry, where a plan to phase it out is
645  discussed. */
646 
647 #define YYFAIL goto yyerrlab
648 #if defined YYFAIL
649  /* This is here to suppress warnings from the GCC cpp's
650  -Wunused-macros. Normally we don't worry about that warning, but
651  some users do, and we want to make it easy for users to remove
652  YYFAIL uses, which will produce warnings from Bison 2.5. */
653 #endif
654 
655 #define YYRECOVERING() (!!yyerrstatus)
656 
657 #define YYBACKUP(Token, Value) \
658 do \
659  if (yychar == YYEMPTY) \
660  { \
661  yychar = (Token); \
662  yylval = (Value); \
663  YYPOPSTACK (yylen); \
664  yystate = *yyssp; \
665  goto yybackup; \
666  } \
667  else \
668  { \
669  yyerror (yyscanner, jsgf, YY_("syntax error: cannot back up")); \
670  YYERROR; \
671  } \
672 while (YYID (0))
673 
674 /* Error token number */
675 #define YYTERROR 1
676 #define YYERRCODE 256
677 
678 
679 /* This macro is provided for backward compatibility. */
680 #ifndef YY_LOCATION_PRINT
681 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
682 #endif
683 
684 
685 /* YYLEX -- calling `yylex' with the right arguments. */
686 #ifdef YYLEX_PARAM
687 # define YYLEX yylex (&yylval, YYLEX_PARAM)
688 #else
689 # define YYLEX yylex (&yylval, yyscanner)
690 #endif
691 
692 /* Enable debugging if requested. */
693 #if YYDEBUG
694 
695 # ifndef YYFPRINTF
696 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
697 # define YYFPRINTF fprintf
698 # endif
699 
700 # define YYDPRINTF(Args) \
701 do { \
702  if (yydebug) \
703  YYFPRINTF Args; \
704 } while (YYID (0))
705 
706 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
707 do { \
708  if (yydebug) \
709  { \
710  YYFPRINTF (stderr, "%s ", Title); \
711  yy_symbol_print (stderr, \
712  Type, Value, yyscanner, jsgf); \
713  YYFPRINTF (stderr, "\n"); \
714  } \
715 } while (YYID (0))
716 
717 
718 /*--------------------------------.
719 | Print this symbol on YYOUTPUT. |
720 `--------------------------------*/
721 
722 /*ARGSUSED*/
723 #if (defined __STDC__ || defined __C99__FUNC__ \
724  || defined __cplusplus || defined _MSC_VER)
725 static void
726 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void* yyscanner, jsgf_t *jsgf)
727 #else
728 static void
729 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf)
730  FILE *yyoutput;
731  int yytype;
732  YYSTYPE const * const yyvaluep;
733  void* yyscanner;
734  jsgf_t *jsgf;
735 #endif
736 {
737  FILE *yyo = yyoutput;
738  YYUSE (yyo);
739  if (!yyvaluep)
740  return;
741  YYUSE (yyscanner);
742  YYUSE (jsgf);
743 # ifdef YYPRINT
744  if (yytype < YYNTOKENS)
745  YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
746 # else
747  YYUSE (yyoutput);
748 # endif
749  YYUSE (yytype);
750 }
751 
752 
753 /*--------------------------------.
754 | Print this symbol on YYOUTPUT. |
755 `--------------------------------*/
756 
757 #if (defined __STDC__ || defined __C99__FUNC__ \
758  || defined __cplusplus || defined _MSC_VER)
759 static void
760 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void* yyscanner, jsgf_t *jsgf)
761 #else
762 static void
763 yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf)
764  FILE *yyoutput;
765  int yytype;
766  YYSTYPE const * const yyvaluep;
767  void* yyscanner;
768  jsgf_t *jsgf;
769 #endif
770 {
771  if (yytype < YYNTOKENS)
772  YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
773  else
774  YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
775 
776  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf);
777  YYFPRINTF (yyoutput, ")");
778 }
779 
780 /*------------------------------------------------------------------.
781 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
782 | TOP (included). |
783 `------------------------------------------------------------------*/
784 
785 #if (defined __STDC__ || defined __C99__FUNC__ \
786  || defined __cplusplus || defined _MSC_VER)
787 static void
788 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
789 #else
790 static void
791 yy_stack_print (yybottom, yytop)
792  yytype_int16 *yybottom;
793  yytype_int16 *yytop;
794 #endif
795 {
796  YYFPRINTF (stderr, "Stack now");
797  for (; yybottom <= yytop; yybottom++)
798  {
799  int yybot = *yybottom;
800  YYFPRINTF (stderr, " %d", yybot);
801  }
802  YYFPRINTF (stderr, "\n");
803 }
804 
805 # define YY_STACK_PRINT(Bottom, Top) \
806 do { \
807  if (yydebug) \
808  yy_stack_print ((Bottom), (Top)); \
809 } while (YYID (0))
810 
811 
812 /*------------------------------------------------.
813 | Report that the YYRULE is going to be reduced. |
814 `------------------------------------------------*/
815 
816 #if (defined __STDC__ || defined __C99__FUNC__ \
817  || defined __cplusplus || defined _MSC_VER)
818 static void
819 yy_reduce_print (YYSTYPE *yyvsp, int yyrule, void* yyscanner, jsgf_t *jsgf)
820 #else
821 static void
822 yy_reduce_print (yyvsp, yyrule, yyscanner, jsgf)
823  YYSTYPE *yyvsp;
824  int yyrule;
825  void* yyscanner;
826  jsgf_t *jsgf;
827 #endif
828 {
829  int yynrhs = yyr2[yyrule];
830  int yyi;
831  unsigned long int yylno = yyrline[yyrule];
832  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
833  yyrule - 1, yylno);
834  /* The symbols being reduced. */
835  for (yyi = 0; yyi < yynrhs; yyi++)
836  {
837  YYFPRINTF (stderr, " $%d = ", yyi + 1);
838  yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
839  &(yyvsp[(yyi + 1) - (yynrhs)])
840  , yyscanner, jsgf);
841  YYFPRINTF (stderr, "\n");
842  }
843 }
844 
845 # define YY_REDUCE_PRINT(Rule) \
846 do { \
847  if (yydebug) \
848  yy_reduce_print (yyvsp, Rule, yyscanner, jsgf); \
849 } while (YYID (0))
850 
851 /* Nonzero means print parse trace. It is left uninitialized so that
852  multiple parsers can coexist. */
853 int yydebug;
854 #else /* !YYDEBUG */
855 # define YYDPRINTF(Args)
856 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
857 # define YY_STACK_PRINT(Bottom, Top)
858 # define YY_REDUCE_PRINT(Rule)
859 #endif /* !YYDEBUG */
860 
861 
862 /* YYINITDEPTH -- initial size of the parser's stacks. */
863 #ifndef YYINITDEPTH
864 # define YYINITDEPTH 200
865 #endif
866 
867 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
868  if the built-in stack extension method is used).
869 
870  Do not make this value too large; the results are undefined if
871  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
872  evaluated with infinite-precision integer arithmetic. */
873 
874 #ifndef YYMAXDEPTH
875 # define YYMAXDEPTH 10000
876 #endif
877 
878 
879 #if YYERROR_VERBOSE
880 
881 # ifndef yystrlen
882 # if defined __GLIBC__ && defined _STRING_H
883 # define yystrlen strlen
884 # else
885 /* Return the length of YYSTR. */
886 #if (defined __STDC__ || defined __C99__FUNC__ \
887  || defined __cplusplus || defined _MSC_VER)
888 static YYSIZE_T
889 yystrlen (const char *yystr)
890 #else
891 static YYSIZE_T
892 yystrlen (yystr)
893  const char *yystr;
894 #endif
895 {
896  YYSIZE_T yylen;
897  for (yylen = 0; yystr[yylen]; yylen++)
898  continue;
899  return yylen;
900 }
901 # endif
902 # endif
903 
904 # ifndef yystpcpy
905 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
906 # define yystpcpy stpcpy
907 # else
908 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
909  YYDEST. */
910 #if (defined __STDC__ || defined __C99__FUNC__ \
911  || defined __cplusplus || defined _MSC_VER)
912 static char *
913 yystpcpy (char *yydest, const char *yysrc)
914 #else
915 static char *
916 yystpcpy (yydest, yysrc)
917  char *yydest;
918  const char *yysrc;
919 #endif
920 {
921  char *yyd = yydest;
922  const char *yys = yysrc;
923 
924  while ((*yyd++ = *yys++) != '\0')
925  continue;
926 
927  return yyd - 1;
928 }
929 # endif
930 # endif
931 
932 # ifndef yytnamerr
933 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
934  quotes and backslashes, so that it's suitable for yyerror. The
935  heuristic is that double-quoting is unnecessary unless the string
936  contains an apostrophe, a comma, or backslash (other than
937  backslash-backslash). YYSTR is taken from yytname. If YYRES is
938  null, do not copy; instead, return the length of what the result
939  would have been. */
940 static YYSIZE_T
941 yytnamerr (char *yyres, const char *yystr)
942 {
943  if (*yystr == '"')
944  {
945  YYSIZE_T yyn = 0;
946  char const *yyp = yystr;
947 
948  for (;;)
949  switch (*++yyp)
950  {
951  case '\'':
952  case ',':
953  goto do_not_strip_quotes;
954 
955  case '\\':
956  if (*++yyp != '\\')
957  goto do_not_strip_quotes;
958  /* Fall through. */
959  default:
960  if (yyres)
961  yyres[yyn] = *yyp;
962  yyn++;
963  break;
964 
965  case '"':
966  if (yyres)
967  yyres[yyn] = '\0';
968  return yyn;
969  }
970  do_not_strip_quotes: ;
971  }
972 
973  if (! yyres)
974  return yystrlen (yystr);
975 
976  return yystpcpy (yyres, yystr) - yyres;
977 }
978 # endif
979 
980 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
981  about the unexpected token YYTOKEN for the state stack whose top is
982  YYSSP.
983 
984  Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
985  not large enough to hold the message. In that case, also set
986  *YYMSG_ALLOC to the required number of bytes. Return 2 if the
987  required number of bytes is too large to store. */
988 static int
989 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
990  yytype_int16 *yyssp, int yytoken)
991 {
992  YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
993  YYSIZE_T yysize = yysize0;
994  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
995  /* Internationalized format string. */
996  const char *yyformat = YY_NULL;
997  /* Arguments of yyformat. */
998  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
999  /* Number of reported tokens (one for the "unexpected", one per
1000  "expected"). */
1001  int yycount = 0;
1002 
1003  /* There are many possibilities here to consider:
1004  - Assume YYFAIL is not used. It's too flawed to consider. See
1005  <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1006  for details. YYERROR is fine as it does not invoke this
1007  function.
1008  - If this state is a consistent state with a default action, then
1009  the only way this function was invoked is if the default action
1010  is an error action. In that case, don't check for expected
1011  tokens because there are none.
1012  - The only way there can be no lookahead present (in yychar) is if
1013  this state is a consistent state with a default action. Thus,
1014  detecting the absence of a lookahead is sufficient to determine
1015  that there is no unexpected or expected token to report. In that
1016  case, just report a simple "syntax error".
1017  - Don't assume there isn't a lookahead just because this state is a
1018  consistent state with a default action. There might have been a
1019  previous inconsistent state, consistent state with a non-default
1020  action, or user semantic action that manipulated yychar.
1021  - Of course, the expected token list depends on states to have
1022  correct lookahead information, and it depends on the parser not
1023  to perform extra reductions after fetching a lookahead from the
1024  scanner and before detecting a syntax error. Thus, state merging
1025  (from LALR or IELR) and default reductions corrupt the expected
1026  token list. However, the list is correct for canonical LR with
1027  one exception: it will still contain any token that will not be
1028  accepted due to an error action in a later state.
1029  */
1030  if (yytoken != YYEMPTY)
1031  {
1032  int yyn = yypact[*yyssp];
1033  yyarg[yycount++] = yytname[yytoken];
1034  if (!yypact_value_is_default (yyn))
1035  {
1036  /* Start YYX at -YYN if negative to avoid negative indexes in
1037  YYCHECK. In other words, skip the first -YYN actions for
1038  this state because they are default actions. */
1039  int yyxbegin = yyn < 0 ? -yyn : 0;
1040  /* Stay within bounds of both yycheck and yytname. */
1041  int yychecklim = YYLAST - yyn + 1;
1042  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1043  int yyx;
1044 
1045  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1046  if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1047  && !yytable_value_is_error (yytable[yyx + yyn]))
1048  {
1049  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1050  {
1051  yycount = 1;
1052  yysize = yysize0;
1053  break;
1054  }
1055  yyarg[yycount++] = yytname[yyx];
1056  {
1057  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1058  if (! (yysize <= yysize1
1059  && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1060  return 2;
1061  yysize = yysize1;
1062  }
1063  }
1064  }
1065  }
1066 
1067  switch (yycount)
1068  {
1069 # define YYCASE_(N, S) \
1070  case N: \
1071  yyformat = S; \
1072  break
1073  YYCASE_(0, YY_("syntax error"));
1074  YYCASE_(1, YY_("syntax error, unexpected %s"));
1075  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1076  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1077  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1078  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1079 # undef YYCASE_
1080  }
1081 
1082  {
1083  YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1084  if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1085  return 2;
1086  yysize = yysize1;
1087  }
1088 
1089  if (*yymsg_alloc < yysize)
1090  {
1091  *yymsg_alloc = 2 * yysize;
1092  if (! (yysize <= *yymsg_alloc
1093  && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1094  *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1095  return 1;
1096  }
1097 
1098  /* Avoid sprintf, as that infringes on the user's name space.
1099  Don't have undefined behavior even if the translation
1100  produced a string with the wrong number of "%s"s. */
1101  {
1102  char *yyp = *yymsg;
1103  int yyi = 0;
1104  while ((*yyp = *yyformat) != '\0')
1105  if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1106  {
1107  yyp += yytnamerr (yyp, yyarg[yyi++]);
1108  yyformat += 2;
1109  }
1110  else
1111  {
1112  yyp++;
1113  yyformat++;
1114  }
1115  }
1116  return 0;
1117 }
1118 #endif /* YYERROR_VERBOSE */
1119 
1120 /*-----------------------------------------------.
1121 | Release the memory associated to this symbol. |
1122 `-----------------------------------------------*/
1123 
1124 /*ARGSUSED*/
1125 #if (defined __STDC__ || defined __C99__FUNC__ \
1126  || defined __cplusplus || defined _MSC_VER)
1127 static void
1128 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void* yyscanner, jsgf_t *jsgf)
1129 #else
1130 static void
1131 yydestruct (yymsg, yytype, yyvaluep, yyscanner, jsgf)
1132  const char *yymsg;
1133  int yytype;
1134  YYSTYPE *yyvaluep;
1135  void* yyscanner;
1136  jsgf_t *jsgf;
1137 #endif
1138 {
1139  YYUSE (yyvaluep);
1140  YYUSE (yyscanner);
1141  YYUSE (jsgf);
1142 
1143  if (!yymsg)
1144  yymsg = "Deleting";
1145  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1146 
1147  YYUSE (yytype);
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 1787 of yacc.c */
1446 #line 87 "jsgf_parser.y"
1447  { jsgf->name = (yyvsp[(2) - (2)].name); }
1448  break;
1449 
1450  case 7:
1451 /* Line 1787 of yacc.c */
1452 #line 91 "jsgf_parser.y"
1453  { jsgf->version = (yyvsp[(2) - (3)].name); }
1454  break;
1455 
1456  case 8:
1457 /* Line 1787 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 1787 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 1787 of yacc.c */
1471 #line 97 "jsgf_parser.y"
1472  { (yyval.name) = (yyvsp[(2) - (3)].name); }
1473  break;
1474 
1475  case 13:
1476 /* Line 1787 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 1787 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 1787 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 1787 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 1787 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 1787 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 1787 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 1787 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 1787 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 1787 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 1787 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 1787 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 1787 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 1787 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 1787 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 1787 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 1787 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 1787 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 2050 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 }