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