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