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