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