SphinxBase  5prealpha
jsgf_parser.c
1 /* A Bison parser, made by GNU Bison 3.7.6. */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5  Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
6  Inc.
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <https://www.gnu.org/licenses/>. */
20 
21 /* As a special exception, you may create a larger work that contains
22  part or all of the Bison parser skeleton and distribute that work
23  under terms of your choice, so long as that work isn't itself a
24  parser generator using the skeleton or a modified version thereof
25  as a parser skeleton. Alternatively, if you modify or redistribute
26  the parser skeleton itself, you may (at your option) remove this
27  special exception, which will cause the skeleton and the resulting
28  Bison output files to be licensed under the GNU General Public
29  License without this special exception.
30 
31  This special exception was added by the Free Software Foundation in
32  version 2.2 of Bison. */
33 
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35  simplifying the original so-called "semantic" parser. */
36 
37 /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38  especially those whose name start with YY_ or yy_. They are
39  private implementation details that can be changed or removed. */
40 
41 /* All symbols defined below should begin with yy or YY, to avoid
42  infringing on user name space. This should be done even for local
43  variables, as they might otherwise be expanded by user macros.
44  There are some unavoidable exceptions within include files to
45  define necessary library symbols; they are noted "INFRINGES ON
46  USER NAME SPACE" below. */
47 
48 /* Identify Bison output, and Bison version. */
49 #define YYBISON 30706
50 
51 /* Bison version string. */
52 #define YYBISON_VERSION "3.7.6"
53 
54 /* Skeleton name. */
55 #define YYSKELETON_NAME "yacc.c"
56 
57 /* Pure parsers. */
58 #define YYPURE 1
59 
60 /* Push parsers. */
61 #define YYPUSH 0
62 
63 /* Pull parsers. */
64 #define YYPULL 1
65 
66 
67 
68 
69 /* First part of user prologue. */
70 #line 37 "jsgf_parser.y"
71 
72 #define YYERROR_VERBOSE
73 
74 #include <stdio.h>
75 #include <string.h>
76 
77 #include <sphinxbase/hash_table.h>
78 #include <sphinxbase/ckd_alloc.h>
79 #include <sphinxbase/err.h>
80 
81 #include "jsgf_internal.h"
82 #include "jsgf_parser.h"
83 #include "jsgf_scanner.h"
84 
85 /* Suppress warnings from generated code */
86 #if defined _MSC_VER
87 #pragma warning(disable: 4273)
88 #endif
89 
90 void yyerror(yyscan_t lex, jsgf_t *jsgf, const char *s);
91 
92 
93 #line 94 "jsgf_parser.c"
94 
95 # ifndef YY_CAST
96 # ifdef __cplusplus
97 # define YY_CAST(Type, Val) static_cast<Type> (Val)
98 # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
99 # else
100 # define YY_CAST(Type, Val) ((Type) (Val))
101 # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
102 # endif
103 # endif
104 # ifndef YY_NULLPTR
105 # if defined __cplusplus
106 # if 201103L <= __cplusplus
107 # define YY_NULLPTR nullptr
108 # else
109 # define YY_NULLPTR 0
110 # endif
111 # else
112 # define YY_NULLPTR ((void*)0)
113 # endif
114 # endif
115 
116 /* Use api.header.include to #include this header
117  instead of duplicating it here. */
118 #ifndef YY_YY_JSGF_PARSER_H_INCLUDED
119 # define YY_YY_JSGF_PARSER_H_INCLUDED
120 /* Debug traces. */
121 #ifndef YYDEBUG
122 # define YYDEBUG 0
123 #endif
124 #if YYDEBUG
125 extern int yydebug;
126 #endif
127 
128 /* Token kinds. */
129 #ifndef YYTOKENTYPE
130 # define YYTOKENTYPE
131  enum yytokentype
132  {
133  YYEMPTY = -2,
134  YYEOF = 0, /* "end of file" */
135  YYerror = 256, /* error */
136  YYUNDEF = 257, /* "invalid token" */
137  HEADER = 258, /* HEADER */
138  GRAMMAR = 259, /* GRAMMAR */
139  IMPORT = 260, /* IMPORT */
140  PUBLIC = 261, /* PUBLIC */
141  TOKEN = 262, /* TOKEN */
142  RULENAME = 263, /* RULENAME */
143  TAG = 264, /* TAG */
144  WEIGHT = 265 /* WEIGHT */
145  };
146  typedef enum yytokentype yytoken_kind_t;
147 #endif
148 /* Token kinds. */
149 #define YYEMPTY -2
150 #define YYEOF 0
151 #define YYerror 256
152 #define YYUNDEF 257
153 #define HEADER 258
154 #define GRAMMAR 259
155 #define IMPORT 260
156 #define PUBLIC 261
157 #define TOKEN 262
158 #define RULENAME 263
159 #define TAG 264
160 #define WEIGHT 265
161 
162 /* Value type. */
163 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
164 union YYSTYPE
165 {
166 #line 65 "jsgf_parser.y"
167 
168  char *name;
169  float weight;
170  jsgf_rule_t *rule;
171  jsgf_rhs_t *rhs;
172  jsgf_atom_t *atom;
173 
174 #line 175 "jsgf_parser.c"
175 
176 };
177 typedef union YYSTYPE YYSTYPE;
178 # define YYSTYPE_IS_TRIVIAL 1
179 # define YYSTYPE_IS_DECLARED 1
180 #endif
181 
182 
183 
184 int yyparse (void* yyscanner, jsgf_t *jsgf);
185 
186 #endif /* !YY_YY_JSGF_PARSER_H_INCLUDED */
187 /* Symbol kind. */
188 enum yysymbol_kind_t
189 {
190  YYSYMBOL_YYEMPTY = -2,
191  YYSYMBOL_YYEOF = 0, /* "end of file" */
192  YYSYMBOL_YYerror = 1, /* error */
193  YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
194  YYSYMBOL_HEADER = 3, /* HEADER */
195  YYSYMBOL_GRAMMAR = 4, /* GRAMMAR */
196  YYSYMBOL_IMPORT = 5, /* IMPORT */
197  YYSYMBOL_PUBLIC = 6, /* PUBLIC */
198  YYSYMBOL_TOKEN = 7, /* TOKEN */
199  YYSYMBOL_RULENAME = 8, /* RULENAME */
200  YYSYMBOL_TAG = 9, /* TAG */
201  YYSYMBOL_WEIGHT = 10, /* WEIGHT */
202  YYSYMBOL_11_ = 11, /* ';' */
203  YYSYMBOL_12_ = 12, /* '=' */
204  YYSYMBOL_13_ = 13, /* '|' */
205  YYSYMBOL_14_ = 14, /* '(' */
206  YYSYMBOL_15_ = 15, /* ')' */
207  YYSYMBOL_16_ = 16, /* '[' */
208  YYSYMBOL_17_ = 17, /* ']' */
209  YYSYMBOL_18_ = 18, /* '*' */
210  YYSYMBOL_19_ = 19, /* '+' */
211  YYSYMBOL_YYACCEPT = 20, /* $accept */
212  YYSYMBOL_grammar = 21, /* grammar */
213  YYSYMBOL_header = 22, /* header */
214  YYSYMBOL_jsgf_header = 23, /* jsgf_header */
215  YYSYMBOL_grammar_header = 24, /* grammar_header */
216  YYSYMBOL_import_header = 25, /* import_header */
217  YYSYMBOL_import_statement = 26, /* import_statement */
218  YYSYMBOL_rule_list = 27, /* rule_list */
219  YYSYMBOL_rule = 28, /* rule */
220  YYSYMBOL_alternate_list = 29, /* alternate_list */
221  YYSYMBOL_rule_expansion = 30, /* rule_expansion */
222  YYSYMBOL_tagged_rule_item = 31, /* tagged_rule_item */
223  YYSYMBOL_rule_item = 32, /* rule_item */
224  YYSYMBOL_rule_group = 33, /* rule_group */
225  YYSYMBOL_rule_optional = 34, /* rule_optional */
226  YYSYMBOL_rule_atom = 35 /* rule_atom */
227 };
228 typedef enum yysymbol_kind_t yysymbol_kind_t;
229 
230 
231 
232 
233 #ifdef short
234 # undef short
235 #endif
236 
237 /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
238  <limits.h> and (if available) <stdint.h> are included
239  so that the code can choose integer types of a good width. */
240 
241 #ifndef __PTRDIFF_MAX__
242 # include <limits.h> /* INFRINGES ON USER NAME SPACE */
243 # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
244 # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
245 # define YY_STDINT_H
246 # endif
247 #endif
248 
249 /* Narrow types that promote to a signed type and that can represent a
250  signed or unsigned integer of at least N bits. In tables they can
251  save space and decrease cache pressure. Promoting to a signed type
252  helps avoid bugs in integer arithmetic. */
253 
254 #ifdef __INT_LEAST8_MAX__
255 typedef __INT_LEAST8_TYPE__ yytype_int8;
256 #elif defined YY_STDINT_H
257 typedef int_least8_t yytype_int8;
258 #else
259 typedef signed char yytype_int8;
260 #endif
261 
262 #ifdef __INT_LEAST16_MAX__
263 typedef __INT_LEAST16_TYPE__ yytype_int16;
264 #elif defined YY_STDINT_H
265 typedef int_least16_t yytype_int16;
266 #else
267 typedef short yytype_int16;
268 #endif
269 
270 /* Work around bug in HP-UX 11.23, which defines these macros
271  incorrectly for preprocessor constants. This workaround can likely
272  be removed in 2023, as HPE has promised support for HP-UX 11.23
273  (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
274  <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
275 #ifdef __hpux
276 # undef UINT_LEAST8_MAX
277 # undef UINT_LEAST16_MAX
278 # define UINT_LEAST8_MAX 255
279 # define UINT_LEAST16_MAX 65535
280 #endif
281 
282 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
283 typedef __UINT_LEAST8_TYPE__ yytype_uint8;
284 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
285  && UINT_LEAST8_MAX <= INT_MAX)
286 typedef uint_least8_t yytype_uint8;
287 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
288 typedef unsigned char yytype_uint8;
289 #else
290 typedef short yytype_uint8;
291 #endif
292 
293 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
294 typedef __UINT_LEAST16_TYPE__ yytype_uint16;
295 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
296  && UINT_LEAST16_MAX <= INT_MAX)
297 typedef uint_least16_t yytype_uint16;
298 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
299 typedef unsigned short yytype_uint16;
300 #else
301 typedef int yytype_uint16;
302 #endif
303 
304 #ifndef YYPTRDIFF_T
305 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
306 # define YYPTRDIFF_T __PTRDIFF_TYPE__
307 # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
308 # elif defined PTRDIFF_MAX
309 # ifndef ptrdiff_t
310 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
311 # endif
312 # define YYPTRDIFF_T ptrdiff_t
313 # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
314 # else
315 # define YYPTRDIFF_T long
316 # define YYPTRDIFF_MAXIMUM LONG_MAX
317 # endif
318 #endif
319 
320 #ifndef YYSIZE_T
321 # ifdef __SIZE_TYPE__
322 # define YYSIZE_T __SIZE_TYPE__
323 # elif defined size_t
324 # define YYSIZE_T size_t
325 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
326 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
327 # define YYSIZE_T size_t
328 # else
329 # define YYSIZE_T unsigned
330 # endif
331 #endif
332 
333 #define YYSIZE_MAXIMUM \
334  YY_CAST (YYPTRDIFF_T, \
335  (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
336  ? YYPTRDIFF_MAXIMUM \
337  : YY_CAST (YYSIZE_T, -1)))
338 
339 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
340 
341 
342 /* Stored state numbers (used for stacks). */
343 typedef yytype_int8 yy_state_t;
344 
345 /* State numbers in computations. */
346 typedef int yy_state_fast_t;
347 
348 #ifndef YY_
349 # if defined YYENABLE_NLS && YYENABLE_NLS
350 # if ENABLE_NLS
351 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
352 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
353 # endif
354 # endif
355 # ifndef YY_
356 # define YY_(Msgid) Msgid
357 # endif
358 #endif
359 
360 
361 #ifndef YY_ATTRIBUTE_PURE
362 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
363 # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
364 # else
365 # define YY_ATTRIBUTE_PURE
366 # endif
367 #endif
368 
369 #ifndef YY_ATTRIBUTE_UNUSED
370 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
371 # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
372 # else
373 # define YY_ATTRIBUTE_UNUSED
374 # endif
375 #endif
376 
377 /* Suppress unused-variable warnings by "using" E. */
378 #if ! defined lint || defined __GNUC__
379 # define YY_USE(E) ((void) (E))
380 #else
381 # define YY_USE(E) /* empty */
382 #endif
383 
384 #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
385 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
386 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
387  _Pragma ("GCC diagnostic push") \
388  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
389  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
390 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
391  _Pragma ("GCC diagnostic pop")
392 #else
393 # define YY_INITIAL_VALUE(Value) Value
394 #endif
395 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
396 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
397 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
398 #endif
399 #ifndef YY_INITIAL_VALUE
400 # define YY_INITIAL_VALUE(Value) /* Nothing. */
401 #endif
402 
403 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
404 # define YY_IGNORE_USELESS_CAST_BEGIN \
405  _Pragma ("GCC diagnostic push") \
406  _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
407 # define YY_IGNORE_USELESS_CAST_END \
408  _Pragma ("GCC diagnostic pop")
409 #endif
410 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
411 # define YY_IGNORE_USELESS_CAST_BEGIN
412 # define YY_IGNORE_USELESS_CAST_END
413 #endif
414 
415 
416 #define YY_ASSERT(E) ((void) (0 && (E)))
417 
418 #if !defined yyoverflow
419 
420 /* The parser invokes alloca or malloc; define the necessary symbols. */
421 
422 # ifdef YYSTACK_USE_ALLOCA
423 # if YYSTACK_USE_ALLOCA
424 # ifdef __GNUC__
425 # define YYSTACK_ALLOC __builtin_alloca
426 # elif defined __BUILTIN_VA_ARG_INCR
427 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
428 # elif defined _AIX
429 # define YYSTACK_ALLOC __alloca
430 # elif defined _MSC_VER
431 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
432 # define alloca _alloca
433 # else
434 # define YYSTACK_ALLOC alloca
435 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
436 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
437  /* Use EXIT_SUCCESS as a witness for stdlib.h. */
438 # ifndef EXIT_SUCCESS
439 # define EXIT_SUCCESS 0
440 # endif
441 # endif
442 # endif
443 # endif
444 # endif
445 
446 # ifdef YYSTACK_ALLOC
447  /* Pacify GCC's 'empty if-body' warning. */
448 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
449 # ifndef YYSTACK_ALLOC_MAXIMUM
450  /* The OS might guarantee only one guard page at the bottom of the stack,
451  and a page size can be as small as 4096 bytes. So we cannot safely
452  invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
453  to allow for a few compiler-allocated temporary stack slots. */
454 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
455 # endif
456 # else
457 # define YYSTACK_ALLOC YYMALLOC
458 # define YYSTACK_FREE YYFREE
459 # ifndef YYSTACK_ALLOC_MAXIMUM
460 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
461 # endif
462 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
463  && ! ((defined YYMALLOC || defined malloc) \
464  && (defined YYFREE || defined free)))
465 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
466 # ifndef EXIT_SUCCESS
467 # define EXIT_SUCCESS 0
468 # endif
469 # endif
470 # ifndef YYMALLOC
471 # define YYMALLOC malloc
472 # if ! defined malloc && ! defined EXIT_SUCCESS
473 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
474 # endif
475 # endif
476 # ifndef YYFREE
477 # define YYFREE free
478 # if ! defined free && ! defined EXIT_SUCCESS
479 void free (void *); /* INFRINGES ON USER NAME SPACE */
480 # endif
481 # endif
482 # endif
483 #endif /* !defined yyoverflow */
484 
485 #if (! defined yyoverflow \
486  && (! defined __cplusplus \
487  || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
488 
489 /* A type that is properly aligned for any stack member. */
490 union yyalloc
491 {
492  yy_state_t yyss_alloc;
493  YYSTYPE yyvs_alloc;
494 };
495 
496 /* The size of the maximum gap between one aligned stack and the next. */
497 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
498 
499 /* The size of an array large to enough to hold all stacks, each with
500  N elements. */
501 # define YYSTACK_BYTES(N) \
502  ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
503  + YYSTACK_GAP_MAXIMUM)
504 
505 # define YYCOPY_NEEDED 1
506 
507 /* Relocate STACK from its old location to the new one. The
508  local variables YYSIZE and YYSTACKSIZE give the old and new number of
509  elements in the stack, and YYPTR gives the new location of the
510  stack. Advance YYPTR to a properly aligned location for the next
511  stack. */
512 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
513  do \
514  { \
515  YYPTRDIFF_T yynewbytes; \
516  YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
517  Stack = &yyptr->Stack_alloc; \
518  yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
519  yyptr += yynewbytes / YYSIZEOF (*yyptr); \
520  } \
521  while (0)
522 
523 #endif
524 
525 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
526 /* Copy COUNT objects from SRC to DST. The source and destination do
527  not overlap. */
528 # ifndef YYCOPY
529 # if defined __GNUC__ && 1 < __GNUC__
530 # define YYCOPY(Dst, Src, Count) \
531  __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
532 # else
533 # define YYCOPY(Dst, Src, Count) \
534  do \
535  { \
536  YYPTRDIFF_T yyi; \
537  for (yyi = 0; yyi < (Count); yyi++) \
538  (Dst)[yyi] = (Src)[yyi]; \
539  } \
540  while (0)
541 # endif
542 # endif
543 #endif /* !YYCOPY_NEEDED */
544 
545 /* YYFINAL -- State number of the termination state. */
546 #define YYFINAL 7
547 /* YYLAST -- Last index in YYTABLE. */
548 #define YYLAST 54
549 
550 /* YYNTOKENS -- Number of terminals. */
551 #define YYNTOKENS 20
552 /* YYNNTS -- Number of nonterminals. */
553 #define YYNNTS 16
554 /* YYNRULES -- Number of rules. */
555 #define YYNRULES 33
556 /* YYNSTATES -- Number of states. */
557 #define YYNSTATES 58
558 
559 /* YYMAXUTOK -- Last valid token kind. */
560 #define YYMAXUTOK 265
561 
562 
563 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
564  as returned by yylex, with out-of-bounds checking. */
565 #define YYTRANSLATE(YYX) \
566  (0 <= (YYX) && (YYX) <= YYMAXUTOK \
567  ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
568  : YYSYMBOL_YYUNDEF)
569 
570 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
571  as returned by yylex. */
572 static const yytype_int8 yytranslate[] =
573 {
574  0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
575  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
576  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
577  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
578  14, 15, 18, 19, 2, 2, 2, 2, 2, 2,
579  2, 2, 2, 2, 2, 2, 2, 2, 2, 11,
580  2, 12, 2, 2, 2, 2, 2, 2, 2, 2,
581  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
582  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
583  2, 16, 2, 17, 2, 2, 2, 2, 2, 2,
584  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
585  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
586  2, 2, 2, 2, 13, 2, 2, 2, 2, 2,
587  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
588  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
589  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
590  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
591  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
592  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
593  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
594  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
595  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
596  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
597  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
598  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
599  2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
600  5, 6, 7, 8, 9, 10
601 };
602 
603 #if YYDEBUG
604  /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
605 static const yytype_uint8 yyrline[] =
606 {
607  0, 82, 82, 83, 84, 87, 90, 91, 92, 93,
608  97, 100, 101, 104, 107, 108, 111, 112, 115, 116,
609  121, 123, 127, 128, 132, 133, 136, 139, 142, 143,
610  144, 145, 146, 147
611 };
612 #endif
613 
615 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
616 
617 #if YYDEBUG || 0
618 /* The user-facing name of the symbol whose (internal) number is
619  YYSYMBOL. No bounds checking. */
620 static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
621 
622 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
623  First, the terminals, then, starting at YYNTOKENS, nonterminals. */
624 static const char *const yytname[] =
625 {
626  "\"end of file\"", "error", "\"invalid token\"", "HEADER", "GRAMMAR",
627  "IMPORT", "PUBLIC", "TOKEN", "RULENAME", "TAG", "WEIGHT", "';'", "'='",
628  "'|'", "'('", "')'", "'['", "']'", "'*'", "'+'", "$accept", "grammar",
629  "header", "jsgf_header", "grammar_header", "import_header",
630  "import_statement", "rule_list", "rule", "alternate_list",
631  "rule_expansion", "tagged_rule_item", "rule_item", "rule_group",
632  "rule_optional", "rule_atom", YY_NULLPTR
633 };
634 
635 static const char *
636 yysymbol_name (yysymbol_kind_t yysymbol)
637 {
638  return yytname[yysymbol];
639 }
640 #endif
641 
642 #ifdef YYPRINT
643 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
644  (internal) symbol number NUM (which must be that of a token). */
645 static const yytype_int16 yytoknum[] =
646 {
647  0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
648  265, 59, 61, 124, 40, 41, 91, 93, 42, 43
649 };
650 #endif
651 
652 #define YYPACT_NINF (-37)
653 
654 #define yypact_value_is_default(Yyn) \
655  ((Yyn) == YYPACT_NINF)
656 
657 #define YYTABLE_NINF (-1)
658 
659 #define yytable_value_is_error(Yyn) \
660  0
661 
662  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
663  STATE-NUM. */
664 static const yytype_int8 yypact[] =
665 {
666  -1, -2, 36, 22, 35, 8, -37, -37, 32, 33,
667  30, 22, -37, 17, -37, 37, -37, 13, -37, 34,
668  31, -4, -37, 17, -37, 38, 39, -37, -37, -4,
669  -37, -37, 0, -4, -4, 18, -4, 42, -37, -37,
670  -37, 19, -37, -37, 21, 19, 20, 9, -37, -4,
671  42, -37, -37, -37, -37, -37, -37, -4
672 };
673 
674  /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
675  Performed when YYTABLE does not specify something else to do. Zero
676  means the default is an error. */
677 static const yytype_int8 yydefact[] =
678 {
679  0, 0, 0, 2, 0, 0, 6, 1, 0, 0,
680  0, 0, 11, 3, 14, 0, 5, 0, 7, 0,
681  0, 0, 12, 4, 15, 0, 0, 8, 13, 0,
682  28, 29, 0, 0, 0, 0, 18, 20, 22, 30,
683  31, 24, 10, 9, 0, 25, 0, 0, 16, 0,
684  21, 23, 32, 33, 17, 26, 27, 19
685 };
686 
687  /* YYPGOTO[NTERM-NUM]. */
688 static const yytype_int8 yypgoto[] =
689 {
690  -37, -37, -37, -37, -37, -37, 41, 43, -12, -16,
691  -3, -36, -37, -37, -37, 15
692 };
693 
694  /* YYDEFGOTO[NTERM-NUM]. */
695 static const yytype_int8 yydefgoto[] =
696 {
697  0, 2, 3, 4, 16, 11, 12, 13, 14, 35,
698  36, 37, 38, 39, 40, 41
699 };
700 
701  /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
702  positive, shift that token. If negative, reduce the rule whose
703  number is the opposite. If YYTABLE_NINF, syntax error. */
704 static const yytype_int8 yytable[] =
705 {
706  50, 24, 1, 30, 31, 5, 32, 30, 31, 6,
707  33, 24, 34, 44, 33, 17, 34, 46, 47, 18,
708  26, 50, 49, 9, 27, 10, 56, 8, 9, 48,
709  10, 49, 54, 49, 49, 55, 7, 52, 53, 15,
710  19, 20, 21, 29, 25, 28, 57, 45, 0, 42,
711  43, 51, 22, 0, 23
712 };
713 
714 static const yytype_int8 yycheck[] =
715 {
716  36, 13, 3, 7, 8, 7, 10, 7, 8, 11,
717  14, 23, 16, 29, 14, 7, 16, 33, 34, 11,
718  7, 57, 13, 6, 11, 8, 17, 5, 6, 11,
719  8, 13, 11, 13, 13, 15, 0, 18, 19, 4,
720  8, 8, 12, 12, 7, 11, 49, 32, -1, 11,
721  11, 9, 11, -1, 11
722 };
723 
724  /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
725  symbol of state STATE-NUM. */
726 static const yytype_int8 yystos[] =
727 {
728  0, 3, 21, 22, 23, 7, 11, 0, 5, 6,
729  8, 25, 26, 27, 28, 4, 24, 7, 11, 8,
730  8, 12, 26, 27, 28, 7, 7, 11, 11, 12,
731  7, 8, 10, 14, 16, 29, 30, 31, 32, 33,
732  34, 35, 11, 11, 29, 35, 29, 29, 11, 13,
733  31, 9, 18, 19, 11, 15, 17, 30
734 };
735 
736  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
737 static const yytype_int8 yyr1[] =
738 {
739  0, 20, 21, 21, 21, 22, 23, 23, 23, 23,
740  24, 25, 25, 26, 27, 27, 28, 28, 29, 29,
741  30, 30, 31, 31, 32, 32, 33, 34, 35, 35,
742  35, 35, 35, 35
743 };
744 
745  /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
746 static const yytype_int8 yyr2[] =
747 {
748  0, 2, 1, 2, 3, 2, 2, 3, 4, 5,
749  3, 1, 2, 3, 1, 2, 4, 5, 1, 3,
750  1, 2, 1, 2, 1, 2, 3, 3, 1, 1,
751  1, 1, 2, 2
752 };
753 
754 
755 enum { YYENOMEM = -2 };
756 
757 #define yyerrok (yyerrstatus = 0)
758 #define yyclearin (yychar = YYEMPTY)
759 
760 #define YYACCEPT goto yyacceptlab
761 #define YYABORT goto yyabortlab
762 #define YYERROR goto yyerrorlab
763 
764 
765 #define YYRECOVERING() (!!yyerrstatus)
766 
767 #define YYBACKUP(Token, Value) \
768  do \
769  if (yychar == YYEMPTY) \
770  { \
771  yychar = (Token); \
772  yylval = (Value); \
773  YYPOPSTACK (yylen); \
774  yystate = *yyssp; \
775  goto yybackup; \
776  } \
777  else \
778  { \
779  yyerror (yyscanner, jsgf, YY_("syntax error: cannot back up")); \
780  YYERROR; \
781  } \
782  while (0)
783 
784 /* Backward compatibility with an undocumented macro.
785  Use YYerror or YYUNDEF. */
786 #define YYERRCODE YYUNDEF
787 
788 
789 /* Enable debugging if requested. */
790 #if YYDEBUG
791 
792 # ifndef YYFPRINTF
793 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
794 # define YYFPRINTF fprintf
795 # endif
796 
797 # define YYDPRINTF(Args) \
798 do { \
799  if (yydebug) \
800  YYFPRINTF Args; \
801 } while (0)
802 
803 /* This macro is provided for backward compatibility. */
804 # ifndef YY_LOCATION_PRINT
805 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
806 # endif
807 
808 
809 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
810 do { \
811  if (yydebug) \
812  { \
813  YYFPRINTF (stderr, "%s ", Title); \
814  yy_symbol_print (stderr, \
815  Kind, Value, yyscanner, jsgf); \
816  YYFPRINTF (stderr, "\n"); \
817  } \
818 } while (0)
819 
820 
821 /*-----------------------------------.
822 | Print this symbol's value on YYO. |
823 `-----------------------------------*/
824 
825 static void
826 yy_symbol_value_print (FILE *yyo,
827  yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, void* yyscanner, jsgf_t *jsgf)
828 {
829  FILE *yyoutput = yyo;
830  YY_USE (yyoutput);
831  YY_USE (yyscanner);
832  YY_USE (jsgf);
833  if (!yyvaluep)
834  return;
835 # ifdef YYPRINT
836  if (yykind < YYNTOKENS)
837  YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
838 # endif
839  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
840  YY_USE (yykind);
841  YY_IGNORE_MAYBE_UNINITIALIZED_END
842 }
843 
844 
845 /*---------------------------.
846 | Print this symbol on YYO. |
847 `---------------------------*/
848 
849 static void
850 yy_symbol_print (FILE *yyo,
851  yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, void* yyscanner, jsgf_t *jsgf)
852 {
853  YYFPRINTF (yyo, "%s %s (",
854  yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
855 
856  yy_symbol_value_print (yyo, yykind, yyvaluep, yyscanner, jsgf);
857  YYFPRINTF (yyo, ")");
858 }
859 
860 /*------------------------------------------------------------------.
861 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
862 | TOP (included). |
863 `------------------------------------------------------------------*/
864 
865 static void
866 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
867 {
868  YYFPRINTF (stderr, "Stack now");
869  for (; yybottom <= yytop; yybottom++)
870  {
871  int yybot = *yybottom;
872  YYFPRINTF (stderr, " %d", yybot);
873  }
874  YYFPRINTF (stderr, "\n");
875 }
876 
877 # define YY_STACK_PRINT(Bottom, Top) \
878 do { \
879  if (yydebug) \
880  yy_stack_print ((Bottom), (Top)); \
881 } while (0)
882 
883 
884 /*------------------------------------------------.
885 | Report that the YYRULE is going to be reduced. |
886 `------------------------------------------------*/
887 
888 static void
889 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
890  int yyrule, void* yyscanner, jsgf_t *jsgf)
891 {
892  int yylno = yyrline[yyrule];
893  int yynrhs = yyr2[yyrule];
894  int yyi;
895  YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
896  yyrule - 1, yylno);
897  /* The symbols being reduced. */
898  for (yyi = 0; yyi < yynrhs; yyi++)
899  {
900  YYFPRINTF (stderr, " $%d = ", yyi + 1);
901  yy_symbol_print (stderr,
902  YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
903  &yyvsp[(yyi + 1) - (yynrhs)], yyscanner, jsgf);
904  YYFPRINTF (stderr, "\n");
905  }
906 }
907 
908 # define YY_REDUCE_PRINT(Rule) \
909 do { \
910  if (yydebug) \
911  yy_reduce_print (yyssp, yyvsp, Rule, yyscanner, jsgf); \
912 } while (0)
913 
914 /* Nonzero means print parse trace. It is left uninitialized so that
915  multiple parsers can coexist. */
916 int yydebug;
917 #else /* !YYDEBUG */
918 # define YYDPRINTF(Args) ((void) 0)
919 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
920 # define YY_STACK_PRINT(Bottom, Top)
921 # define YY_REDUCE_PRINT(Rule)
922 #endif /* !YYDEBUG */
923 
924 
925 /* YYINITDEPTH -- initial size of the parser's stacks. */
926 #ifndef YYINITDEPTH
927 # define YYINITDEPTH 200
928 #endif
929 
930 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
931  if the built-in stack extension method is used).
932 
933  Do not make this value too large; the results are undefined if
934  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
935  evaluated with infinite-precision integer arithmetic. */
936 
937 #ifndef YYMAXDEPTH
938 # define YYMAXDEPTH 10000
939 #endif
940 
941 
942 
943 
944 
945 
946 /*-----------------------------------------------.
947 | Release the memory associated to this symbol. |
948 `-----------------------------------------------*/
949 
950 static void
951 yydestruct (const char *yymsg,
952  yysymbol_kind_t yykind, YYSTYPE *yyvaluep, void* yyscanner, jsgf_t *jsgf)
953 {
954  YY_USE (yyvaluep);
955  YY_USE (yyscanner);
956  YY_USE (jsgf);
957  if (!yymsg)
958  yymsg = "Deleting";
959  YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
960 
961  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
962  YY_USE (yykind);
963  YY_IGNORE_MAYBE_UNINITIALIZED_END
964 }
965 
966 
967 
968 
969 
970 
971 /*----------.
972 | yyparse. |
973 `----------*/
974 
975 int
976 yyparse (void* yyscanner, jsgf_t *jsgf)
977 {
978 /* Lookahead token kind. */
979 int yychar;
980 
981 
982 /* The semantic value of the lookahead symbol. */
983 /* Default value used for initialization, for pacifying older GCCs
984  or non-GCC compilers. */
985 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
986 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
987 
988  /* Number of syntax errors so far. */
989  int yynerrs = 0;
990 
991  yy_state_fast_t yystate = 0;
992  /* Number of tokens to shift before error messages enabled. */
993  int yyerrstatus = 0;
994 
995  /* Refer to the stacks through separate pointers, to allow yyoverflow
996  to reallocate them elsewhere. */
997 
998  /* Their size. */
999  YYPTRDIFF_T yystacksize = YYINITDEPTH;
1000 
1001  /* The state stack: array, bottom, top. */
1002  yy_state_t yyssa[YYINITDEPTH];
1003  yy_state_t *yyss = yyssa;
1004  yy_state_t *yyssp = yyss;
1005 
1006  /* The semantic value stack: array, bottom, top. */
1007  YYSTYPE yyvsa[YYINITDEPTH];
1008  YYSTYPE *yyvs = yyvsa;
1009  YYSTYPE *yyvsp = yyvs;
1010 
1011  int yyn;
1012  /* The return value of yyparse. */
1013  int yyresult;
1014  /* Lookahead symbol kind. */
1015  yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1016  /* The variables used to return semantic value and location from the
1017  action routines. */
1018  YYSTYPE yyval;
1019 
1020 
1021 
1022 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1023 
1024  /* The number of symbols on the RHS of the reduced rule.
1025  Keep to zero when no symbol should be popped. */
1026  int yylen = 0;
1027 
1028  YYDPRINTF ((stderr, "Starting parse\n"));
1029 
1030  yychar = YYEMPTY; /* Cause a token to be read. */
1031  goto yysetstate;
1032 
1033 
1034 /*------------------------------------------------------------.
1035 | yynewstate -- push a new state, which is found in yystate. |
1036 `------------------------------------------------------------*/
1037 yynewstate:
1038  /* In all cases, when you get here, the value and location stacks
1039  have just been pushed. So pushing a state here evens the stacks. */
1040  yyssp++;
1041 
1042 
1043 /*--------------------------------------------------------------------.
1044 | yysetstate -- set current state (the top of the stack) to yystate. |
1045 `--------------------------------------------------------------------*/
1046 yysetstate:
1047  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1048  YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1049  YY_IGNORE_USELESS_CAST_BEGIN
1050  *yyssp = YY_CAST (yy_state_t, yystate);
1051  YY_IGNORE_USELESS_CAST_END
1052  YY_STACK_PRINT (yyss, yyssp);
1053 
1054  if (yyss + yystacksize - 1 <= yyssp)
1055 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1056  goto yyexhaustedlab;
1057 #else
1058  {
1059  /* Get the current used size of the three stacks, in elements. */
1060  YYPTRDIFF_T yysize = yyssp - yyss + 1;
1061 
1062 # if defined yyoverflow
1063  {
1064  /* Give user a chance to reallocate the stack. Use copies of
1065  these so that the &'s don't force the real ones into
1066  memory. */
1067  yy_state_t *yyss1 = yyss;
1068  YYSTYPE *yyvs1 = yyvs;
1069 
1070  /* Each stack pointer address is followed by the size of the
1071  data in use in that stack, in bytes. This used to be a
1072  conditional around just the two extra args, but that might
1073  be undefined if yyoverflow is a macro. */
1074  yyoverflow (YY_("memory exhausted"),
1075  &yyss1, yysize * YYSIZEOF (*yyssp),
1076  &yyvs1, yysize * YYSIZEOF (*yyvsp),
1077  &yystacksize);
1078  yyss = yyss1;
1079  yyvs = yyvs1;
1080  }
1081 # else /* defined YYSTACK_RELOCATE */
1082  /* Extend the stack our own way. */
1083  if (YYMAXDEPTH <= yystacksize)
1084  goto yyexhaustedlab;
1085  yystacksize *= 2;
1086  if (YYMAXDEPTH < yystacksize)
1087  yystacksize = YYMAXDEPTH;
1088 
1089  {
1090  yy_state_t *yyss1 = yyss;
1091  union yyalloc *yyptr =
1092  YY_CAST (union yyalloc *,
1093  YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1094  if (! yyptr)
1095  goto yyexhaustedlab;
1096  YYSTACK_RELOCATE (yyss_alloc, yyss);
1097  YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1098 # undef YYSTACK_RELOCATE
1099  if (yyss1 != yyssa)
1100  YYSTACK_FREE (yyss1);
1101  }
1102 # endif
1103 
1104  yyssp = yyss + yysize - 1;
1105  yyvsp = yyvs + yysize - 1;
1106 
1107  YY_IGNORE_USELESS_CAST_BEGIN
1108  YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1109  YY_CAST (long, yystacksize)));
1110  YY_IGNORE_USELESS_CAST_END
1111 
1112  if (yyss + yystacksize - 1 <= yyssp)
1113  YYABORT;
1114  }
1115 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1116 
1117  if (yystate == YYFINAL)
1118  YYACCEPT;
1119 
1120  goto yybackup;
1121 
1122 
1123 /*-----------.
1124 | yybackup. |
1125 `-----------*/
1126 yybackup:
1127  /* Do appropriate processing given the current state. Read a
1128  lookahead token if we need one and don't already have one. */
1129 
1130  /* First try to decide what to do without reference to lookahead token. */
1131  yyn = yypact[yystate];
1132  if (yypact_value_is_default (yyn))
1133  goto yydefault;
1134 
1135  /* Not known => get a lookahead token if don't already have one. */
1136 
1137  /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1138  if (yychar == YYEMPTY)
1139  {
1140  YYDPRINTF ((stderr, "Reading a token\n"));
1141  yychar = yylex (&yylval, yyscanner);
1142  }
1143 
1144  if (yychar <= YYEOF)
1145  {
1146  yychar = YYEOF;
1147  yytoken = YYSYMBOL_YYEOF;
1148  YYDPRINTF ((stderr, "Now at end of input.\n"));
1149  }
1150  else if (yychar == YYerror)
1151  {
1152  /* The scanner already issued an error message, process directly
1153  to error recovery. But do not keep the error token as
1154  lookahead, it is too special and may lead us to an endless
1155  loop in error recovery. */
1156  yychar = YYUNDEF;
1157  yytoken = YYSYMBOL_YYerror;
1158  goto yyerrlab1;
1159  }
1160  else
1161  {
1162  yytoken = YYTRANSLATE (yychar);
1163  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1164  }
1165 
1166  /* If the proper action on seeing token YYTOKEN is to reduce or to
1167  detect an error, take that action. */
1168  yyn += yytoken;
1169  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1170  goto yydefault;
1171  yyn = yytable[yyn];
1172  if (yyn <= 0)
1173  {
1174  if (yytable_value_is_error (yyn))
1175  goto yyerrlab;
1176  yyn = -yyn;
1177  goto yyreduce;
1178  }
1179 
1180  /* Count tokens shifted since error; after three, turn off error
1181  status. */
1182  if (yyerrstatus)
1183  yyerrstatus--;
1184 
1185  /* Shift the lookahead token. */
1186  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1187  yystate = yyn;
1188  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1189  *++yyvsp = yylval;
1190  YY_IGNORE_MAYBE_UNINITIALIZED_END
1191 
1192  /* Discard the shifted token. */
1193  yychar = YYEMPTY;
1194  goto yynewstate;
1195 
1196 
1197 /*-----------------------------------------------------------.
1198 | yydefault -- do the default action for the current state. |
1199 `-----------------------------------------------------------*/
1200 yydefault:
1201  yyn = yydefact[yystate];
1202  if (yyn == 0)
1203  goto yyerrlab;
1204  goto yyreduce;
1205 
1206 
1207 /*-----------------------------.
1208 | yyreduce -- do a reduction. |
1209 `-----------------------------*/
1210 yyreduce:
1211  /* yyn is the number of a rule to reduce with. */
1212  yylen = yyr2[yyn];
1213 
1214  /* If YYLEN is nonzero, implement the default value of the action:
1215  '$$ = $1'.
1216 
1217  Otherwise, the following line sets YYVAL to garbage.
1218  This behavior is undocumented and Bison
1219  users should not rely upon it. Assigning to YYVAL
1220  unconditionally makes the parser a bit smaller, and it avoids a
1221  GCC warning that YYVAL may be used uninitialized. */
1222  yyval = yyvsp[1-yylen];
1223 
1224 
1225  YY_REDUCE_PRINT (yyn);
1226  switch (yyn)
1227  {
1228  case 5: /* header: jsgf_header grammar_header */
1229 #line 87 "jsgf_parser.y"
1230  { jsgf->name = (yyvsp[0].name); }
1231 #line 1232 "jsgf_parser.c"
1232  break;
1233 
1234  case 7: /* jsgf_header: HEADER TOKEN ';' */
1235 #line 91 "jsgf_parser.y"
1236  { jsgf->version = (yyvsp[-1].name); }
1237 #line 1238 "jsgf_parser.c"
1238  break;
1239 
1240  case 8: /* jsgf_header: HEADER TOKEN TOKEN ';' */
1241 #line 92 "jsgf_parser.y"
1242  { jsgf->version = (yyvsp[-2].name); jsgf->charset = (yyvsp[-1].name); }
1243 #line 1244 "jsgf_parser.c"
1244  break;
1245 
1246  case 9: /* jsgf_header: HEADER TOKEN TOKEN TOKEN ';' */
1247 #line 93 "jsgf_parser.y"
1248  { jsgf->version = (yyvsp[-3].name); jsgf->charset = (yyvsp[-2].name);
1249  jsgf->locale = (yyvsp[-1].name); }
1250 #line 1251 "jsgf_parser.c"
1251  break;
1252 
1253  case 10: /* grammar_header: GRAMMAR TOKEN ';' */
1254 #line 97 "jsgf_parser.y"
1255  { (yyval.name) = (yyvsp[-1].name); }
1256 #line 1257 "jsgf_parser.c"
1257  break;
1258 
1259  case 13: /* import_statement: IMPORT RULENAME ';' */
1260 #line 104 "jsgf_parser.y"
1261  { jsgf_import_rule(jsgf, (yyvsp[-1].name)); ckd_free((yyvsp[-1].name)); }
1262 #line 1263 "jsgf_parser.c"
1263  break;
1264 
1265  case 16: /* rule: RULENAME '=' alternate_list ';' */
1266 #line 111 "jsgf_parser.y"
1267  { jsgf_define_rule(jsgf, (yyvsp[-3].name), (yyvsp[-1].rhs), 0); ckd_free((yyvsp[-3].name)); }
1268 #line 1269 "jsgf_parser.c"
1269  break;
1270 
1271  case 17: /* rule: PUBLIC RULENAME '=' alternate_list ';' */
1272 #line 112 "jsgf_parser.y"
1273  { jsgf_define_rule(jsgf, (yyvsp[-3].name), (yyvsp[-1].rhs), 1); ckd_free((yyvsp[-3].name)); }
1274 #line 1275 "jsgf_parser.c"
1275  break;
1276 
1277  case 18: /* alternate_list: rule_expansion */
1278 #line 115 "jsgf_parser.y"
1279  { (yyval.rhs) = (yyvsp[0].rhs); (yyval.rhs)->atoms = glist_reverse((yyval.rhs)->atoms); }
1280 #line 1281 "jsgf_parser.c"
1281  break;
1282 
1283  case 19: /* alternate_list: alternate_list '|' rule_expansion */
1284 #line 116 "jsgf_parser.y"
1285  { (yyval.rhs) = (yyvsp[0].rhs);
1286  (yyval.rhs)->atoms = glist_reverse((yyval.rhs)->atoms);
1287  (yyval.rhs)->alt = (yyvsp[-2].rhs); }
1288 #line 1289 "jsgf_parser.c"
1289  break;
1290 
1291  case 20: /* rule_expansion: tagged_rule_item */
1292 #line 121 "jsgf_parser.y"
1293  { (yyval.rhs) = ckd_calloc(1, sizeof(*(yyval.rhs)));
1294  (yyval.rhs)->atoms = glist_add_ptr((yyval.rhs)->atoms, (yyvsp[0].atom)); }
1295 #line 1296 "jsgf_parser.c"
1296  break;
1297 
1298  case 21: /* rule_expansion: rule_expansion tagged_rule_item */
1299 #line 123 "jsgf_parser.y"
1300  { (yyval.rhs) = (yyvsp[-1].rhs);
1301  (yyval.rhs)->atoms = glist_add_ptr((yyval.rhs)->atoms, (yyvsp[0].atom)); }
1302 #line 1303 "jsgf_parser.c"
1303  break;
1304 
1305  case 23: /* tagged_rule_item: tagged_rule_item TAG */
1306 #line 128 "jsgf_parser.y"
1307  { (yyval.atom) = (yyvsp[-1].atom);
1308  (yyval.atom)->tags = glist_add_ptr((yyval.atom)->tags, (yyvsp[0].name)); }
1309 #line 1310 "jsgf_parser.c"
1310  break;
1311 
1312  case 25: /* rule_item: WEIGHT rule_atom */
1313 #line 133 "jsgf_parser.y"
1314  { (yyval.atom) = (yyvsp[0].atom); (yyval.atom)->weight = (yyvsp[-1].weight); }
1315 #line 1316 "jsgf_parser.c"
1316  break;
1317 
1318  case 26: /* rule_group: '(' alternate_list ')' */
1319 #line 136 "jsgf_parser.y"
1320  { (yyval.rule) = jsgf_define_rule(jsgf, NULL, (yyvsp[-1].rhs), 0); }
1321 #line 1322 "jsgf_parser.c"
1322  break;
1323 
1324  case 27: /* rule_optional: '[' alternate_list ']' */
1325 #line 139 "jsgf_parser.y"
1326  { (yyval.rule) = jsgf_optional_new(jsgf, (yyvsp[-1].rhs)); }
1327 #line 1328 "jsgf_parser.c"
1328  break;
1329 
1330  case 28: /* rule_atom: TOKEN */
1331 #line 142 "jsgf_parser.y"
1332  { (yyval.atom) = jsgf_atom_new((yyvsp[0].name), 1.0); ckd_free((yyvsp[0].name)); }
1333 #line 1334 "jsgf_parser.c"
1334  break;
1335 
1336  case 29: /* rule_atom: RULENAME */
1337 #line 143 "jsgf_parser.y"
1338  { (yyval.atom) = jsgf_atom_new((yyvsp[0].name), 1.0); ckd_free((yyvsp[0].name)); }
1339 #line 1340 "jsgf_parser.c"
1340  break;
1341 
1342  case 30: /* rule_atom: rule_group */
1343 #line 144 "jsgf_parser.y"
1344  { (yyval.atom) = jsgf_atom_new((yyvsp[0].rule)->name, 1.0); }
1345 #line 1346 "jsgf_parser.c"
1346  break;
1347 
1348  case 31: /* rule_atom: rule_optional */
1349 #line 145 "jsgf_parser.y"
1350  { (yyval.atom) = jsgf_atom_new((yyvsp[0].rule)->name, 1.0); }
1351 #line 1352 "jsgf_parser.c"
1352  break;
1353 
1354  case 32: /* rule_atom: rule_atom '*' */
1355 #line 146 "jsgf_parser.y"
1356  { (yyval.atom) = jsgf_kleene_new(jsgf, (yyvsp[-1].atom), 0); }
1357 #line 1358 "jsgf_parser.c"
1358  break;
1359 
1360  case 33: /* rule_atom: rule_atom '+' */
1361 #line 147 "jsgf_parser.y"
1362  { (yyval.atom) = jsgf_kleene_new(jsgf, (yyvsp[-1].atom), 1); }
1363 #line 1364 "jsgf_parser.c"
1364  break;
1365 
1366 
1367 #line 1368 "jsgf_parser.c"
1368 
1369  default: break;
1370  }
1371  /* User semantic actions sometimes alter yychar, and that requires
1372  that yytoken be updated with the new translation. We take the
1373  approach of translating immediately before every use of yytoken.
1374  One alternative is translating here after every semantic action,
1375  but that translation would be missed if the semantic action invokes
1376  YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1377  if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1378  incorrect destructor might then be invoked immediately. In the
1379  case of YYERROR or YYBACKUP, subsequent parser actions might lead
1380  to an incorrect destructor call or verbose syntax error message
1381  before the lookahead is translated. */
1382  YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1383 
1384  YYPOPSTACK (yylen);
1385  yylen = 0;
1386 
1387  *++yyvsp = yyval;
1388 
1389  /* Now 'shift' the result of the reduction. Determine what state
1390  that goes to, based on the state we popped back to and the rule
1391  number reduced by. */
1392  {
1393  const int yylhs = yyr1[yyn] - YYNTOKENS;
1394  const int yyi = yypgoto[yylhs] + *yyssp;
1395  yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1396  ? yytable[yyi]
1397  : yydefgoto[yylhs]);
1398  }
1399 
1400  goto yynewstate;
1401 
1402 
1403 /*--------------------------------------.
1404 | yyerrlab -- here on detecting error. |
1405 `--------------------------------------*/
1406 yyerrlab:
1407  /* Make sure we have latest lookahead translation. See comments at
1408  user semantic actions for why this is necessary. */
1409  yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
1410  /* If not already recovering from an error, report this error. */
1411  if (!yyerrstatus)
1412  {
1413  ++yynerrs;
1414  yyerror (yyscanner, jsgf, YY_("syntax error"));
1415  }
1416 
1417  if (yyerrstatus == 3)
1418  {
1419  /* If just tried and failed to reuse lookahead token after an
1420  error, discard it. */
1421 
1422  if (yychar <= YYEOF)
1423  {
1424  /* Return failure if at end of input. */
1425  if (yychar == YYEOF)
1426  YYABORT;
1427  }
1428  else
1429  {
1430  yydestruct ("Error: discarding",
1431  yytoken, &yylval, yyscanner, jsgf);
1432  yychar = YYEMPTY;
1433  }
1434  }
1435 
1436  /* Else will try to reuse lookahead token after shifting the error
1437  token. */
1438  goto yyerrlab1;
1439 
1440 
1441 /*---------------------------------------------------.
1442 | yyerrorlab -- error raised explicitly by YYERROR. |
1443 `---------------------------------------------------*/
1444 yyerrorlab:
1445  /* Pacify compilers when the user code never invokes YYERROR and the
1446  label yyerrorlab therefore never appears in user code. */
1447  if (0)
1448  YYERROR;
1449 
1450  /* Do not reclaim the symbols of the rule whose action triggered
1451  this YYERROR. */
1452  YYPOPSTACK (yylen);
1453  yylen = 0;
1454  YY_STACK_PRINT (yyss, yyssp);
1455  yystate = *yyssp;
1456  goto yyerrlab1;
1457 
1458 
1459 /*-------------------------------------------------------------.
1460 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1461 `-------------------------------------------------------------*/
1462 yyerrlab1:
1463  yyerrstatus = 3; /* Each real token shifted decrements this. */
1464 
1465  /* Pop stack until we find a state that shifts the error token. */
1466  for (;;)
1467  {
1468  yyn = yypact[yystate];
1469  if (!yypact_value_is_default (yyn))
1470  {
1471  yyn += YYSYMBOL_YYerror;
1472  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1473  {
1474  yyn = yytable[yyn];
1475  if (0 < yyn)
1476  break;
1477  }
1478  }
1479 
1480  /* Pop the current state because it cannot handle the error token. */
1481  if (yyssp == yyss)
1482  YYABORT;
1483 
1484 
1485  yydestruct ("Error: popping",
1486  YY_ACCESSING_SYMBOL (yystate), yyvsp, yyscanner, jsgf);
1487  YYPOPSTACK (1);
1488  yystate = *yyssp;
1489  YY_STACK_PRINT (yyss, yyssp);
1490  }
1491 
1492  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1493  *++yyvsp = yylval;
1494  YY_IGNORE_MAYBE_UNINITIALIZED_END
1495 
1496 
1497  /* Shift the error token. */
1498  YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1499 
1500  yystate = yyn;
1501  goto yynewstate;
1502 
1503 
1504 /*-------------------------------------.
1505 | yyacceptlab -- YYACCEPT comes here. |
1506 `-------------------------------------*/
1507 yyacceptlab:
1508  yyresult = 0;
1509  goto yyreturn;
1510 
1511 
1512 /*-----------------------------------.
1513 | yyabortlab -- YYABORT comes here. |
1514 `-----------------------------------*/
1515 yyabortlab:
1516  yyresult = 1;
1517  goto yyreturn;
1518 
1519 
1520 #if !defined yyoverflow
1521 /*-------------------------------------------------.
1522 | yyexhaustedlab -- memory exhaustion comes here. |
1523 `-------------------------------------------------*/
1524 yyexhaustedlab:
1525  yyerror (yyscanner, jsgf, YY_("memory exhausted"));
1526  yyresult = 2;
1527  goto yyreturn;
1528 #endif
1529 
1530 
1531 /*-------------------------------------------------------.
1532 | yyreturn -- parsing is finished, clean up and return. |
1533 `-------------------------------------------------------*/
1534 yyreturn:
1535  if (yychar != YYEMPTY)
1536  {
1537  /* Make sure we have latest lookahead translation. See comments at
1538  user semantic actions for why this is necessary. */
1539  yytoken = YYTRANSLATE (yychar);
1540  yydestruct ("Cleanup: discarding lookahead",
1541  yytoken, &yylval, yyscanner, jsgf);
1542  }
1543  /* Do not reclaim the symbols of the rule whose action triggered
1544  this YYABORT or YYACCEPT. */
1545  YYPOPSTACK (yylen);
1546  YY_STACK_PRINT (yyss, yyssp);
1547  while (yyssp != yyss)
1548  {
1549  yydestruct ("Cleanup: popping",
1550  YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, yyscanner, jsgf);
1551  YYPOPSTACK (1);
1552  }
1553 #ifndef yyoverflow
1554  if (yyss != yyssa)
1555  YYSTACK_FREE (yyss);
1556 #endif
1557 
1558  return yyresult;
1559 }
1560 
1561 #line 150 "jsgf_parser.y"
1562 
1563 
1564 void
1565 yyerror(yyscan_t lex, jsgf_t *jsgf, const char *s)
1566 {
1567  E_ERROR("%s at line %d current token '%s'\n", s, yyget_lineno(lex), yyget_text(lex));
1568 }
Sphinx's memory allocation/deallocation routines.
SPHINXBASE_EXPORT void ckd_free(void *ptr)
Test and free a 1-D array.
Definition: ckd_alloc.c:244
#define ckd_calloc(n, sz)
Macros to simplify the use of above functions.
Definition: ckd_alloc.h:248
Implementation of logging routines.
#define E_ERROR(...)
Print error message to error log.
Definition: err.h:104
SPHINXBASE_EXPORT glist_t glist_reverse(glist_t g)
Reverse the order of the given glist.
Definition: glist.c:169
SPHINXBASE_EXPORT glist_t glist_add_ptr(glist_t g, void *ptr)
Create and prepend a new list node, with the given user-defined data, at the HEAD of the given generi...
Definition: glist.c:74
Hash table implementation.
Internal definitions for JSGF grammar compiler.
char * locale
JSGF locale (default C)
Definition: jsgf_internal.h:78
char * name
Grammar name.
Definition: jsgf_internal.h:79
char * charset
JSGF charset (default UTF-8)
Definition: jsgf_internal.h:77
char * version
JSGF version (from header)
Definition: jsgf_internal.h:76