SphinxBase  0.6
jsgf_parser.c
1 /* A Bison parser, made by GNU Bison 3.0.2. */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5  Copyright (C) 1984, 1989-1990, 2000-2013 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.2"
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 typedef union YYSTYPE YYSTYPE;
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 # define YYSTYPE_IS_TRIVIAL 1
159 # define YYSTYPE_IS_DECLARED 1
160 #endif
161 
162 
163 
164 int yyparse (void* yyscanner, jsgf_t *jsgf);
165 
166 #endif /* !YY_YY_JSGF_PARSER_H_INCLUDED */
167 
168 /* Copy the second part of user declarations. */
169 
170 #line 171 "jsgf_parser.c" /* yacc.c:358 */
171 
172 #ifdef short
173 # undef short
174 #endif
175 
176 #ifdef YYTYPE_UINT8
177 typedef YYTYPE_UINT8 yytype_uint8;
178 #else
179 typedef unsigned char yytype_uint8;
180 #endif
181 
182 #ifdef YYTYPE_INT8
183 typedef YYTYPE_INT8 yytype_int8;
184 #else
185 typedef signed char yytype_int8;
186 #endif
187 
188 #ifdef YYTYPE_UINT16
189 typedef YYTYPE_UINT16 yytype_uint16;
190 #else
191 typedef unsigned short int yytype_uint16;
192 #endif
193 
194 #ifdef YYTYPE_INT16
195 typedef YYTYPE_INT16 yytype_int16;
196 #else
197 typedef short int yytype_int16;
198 #endif
199 
200 #ifndef YYSIZE_T
201 # ifdef __SIZE_TYPE__
202 # define YYSIZE_T __SIZE_TYPE__
203 # elif defined size_t
204 # define YYSIZE_T size_t
205 # elif ! defined YYSIZE_T
206 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
207 # define YYSIZE_T size_t
208 # else
209 # define YYSIZE_T unsigned int
210 # endif
211 #endif
212 
213 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
214 
215 #ifndef YY_
216 # if defined YYENABLE_NLS && YYENABLE_NLS
217 # if ENABLE_NLS
218 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
219 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
220 # endif
221 # endif
222 # ifndef YY_
223 # define YY_(Msgid) Msgid
224 # endif
225 #endif
226 
227 #ifndef YY_ATTRIBUTE
228 # if (defined __GNUC__ \
229  && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
230  || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
231 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
232 # else
233 # define YY_ATTRIBUTE(Spec) /* empty */
234 # endif
235 #endif
236 
237 #ifndef YY_ATTRIBUTE_PURE
238 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
239 #endif
240 
241 #ifndef YY_ATTRIBUTE_UNUSED
242 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
243 #endif
244 
245 #if !defined _Noreturn \
246  && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
247 # if defined _MSC_VER && 1200 <= _MSC_VER
248 # define _Noreturn __declspec (noreturn)
249 # else
250 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
251 # endif
252 #endif
253 
254 /* Suppress unused-variable warnings by "using" E. */
255 #if ! defined lint || defined __GNUC__
256 # define YYUSE(E) ((void) (E))
257 #else
258 # define YYUSE(E) /* empty */
259 #endif
260 
261 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
262 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
263 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
264  _Pragma ("GCC diagnostic push") \
265  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
266  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
267 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
268  _Pragma ("GCC diagnostic pop")
269 #else
270 # define YY_INITIAL_VALUE(Value) Value
271 #endif
272 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
273 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
274 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
275 #endif
276 #ifndef YY_INITIAL_VALUE
277 # define YY_INITIAL_VALUE(Value) /* Nothing. */
278 #endif
279 
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 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
424  by yylex, with out-of-bounds checking. */
425 #define YYUNDEFTOK 2
426 #define YYMAXUTOK 265
427 
428 #define YYTRANSLATE(YYX) \
429  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
430 
431 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
432  as returned by yylex, without out-of-bounds checking. */
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 YYOUTPUT. |
672 `----------------------------------------*/
673 
674 static void
675 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void* yyscanner, jsgf_t *jsgf)
676 {
677  FILE *yyo = yyoutput;
678  YYUSE (yyo);
679  YYUSE (yyscanner);
680  YYUSE (jsgf);
681  if (!yyvaluep)
682  return;
683 # ifdef YYPRINT
684  if (yytype < YYNTOKENS)
685  YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
686 # endif
687  YYUSE (yytype);
688 }
689 
690 
691 /*--------------------------------.
692 | Print this symbol on YYOUTPUT. |
693 `--------------------------------*/
694 
695 static void
696 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void* yyscanner, jsgf_t *jsgf)
697 {
698  YYFPRINTF (yyoutput, "%s %s (",
699  yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
700 
701  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf);
702  YYFPRINTF (yyoutput, ")");
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 int 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  /* Fall through. */
852  default:
853  if (yyres)
854  yyres[yyn] = *yyp;
855  yyn++;
856  break;
857 
858  case '"':
859  if (yyres)
860  yyres[yyn] = '\0';
861  return yyn;
862  }
863  do_not_strip_quotes: ;
864  }
865 
866  if (! yyres)
867  return yystrlen (yystr);
868 
869  return yystpcpy (yyres, yystr) - yyres;
870 }
871 # endif
872 
873 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
874  about the unexpected token YYTOKEN for the state stack whose top is
875  YYSSP.
876 
877  Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
878  not large enough to hold the message. In that case, also set
879  *YYMSG_ALLOC to the required number of bytes. Return 2 if the
880  required number of bytes is too large to store. */
881 static int
882 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
883  yytype_int16 *yyssp, int yytoken)
884 {
885  YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
886  YYSIZE_T yysize = yysize0;
887  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
888  /* Internationalized format string. */
889  const char *yyformat = YY_NULLPTR;
890  /* Arguments of yyformat. */
891  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
892  /* Number of reported tokens (one for the "unexpected", one per
893  "expected"). */
894  int yycount = 0;
895 
896  /* There are many possibilities here to consider:
897  - If this state is a consistent state with a default action, then
898  the only way this function was invoked is if the default action
899  is an error action. In that case, don't check for expected
900  tokens because there are none.
901  - The only way there can be no lookahead present (in yychar) is if
902  this state is a consistent state with a default action. Thus,
903  detecting the absence of a lookahead is sufficient to determine
904  that there is no unexpected or expected token to report. In that
905  case, just report a simple "syntax error".
906  - Don't assume there isn't a lookahead just because this state is a
907  consistent state with a default action. There might have been a
908  previous inconsistent state, consistent state with a non-default
909  action, or user semantic action that manipulated yychar.
910  - Of course, the expected token list depends on states to have
911  correct lookahead information, and it depends on the parser not
912  to perform extra reductions after fetching a lookahead from the
913  scanner and before detecting a syntax error. Thus, state merging
914  (from LALR or IELR) and default reductions corrupt the expected
915  token list. However, the list is correct for canonical LR with
916  one exception: it will still contain any token that will not be
917  accepted due to an error action in a later state.
918  */
919  if (yytoken != YYEMPTY)
920  {
921  int yyn = yypact[*yyssp];
922  yyarg[yycount++] = yytname[yytoken];
923  if (!yypact_value_is_default (yyn))
924  {
925  /* Start YYX at -YYN if negative to avoid negative indexes in
926  YYCHECK. In other words, skip the first -YYN actions for
927  this state because they are default actions. */
928  int yyxbegin = yyn < 0 ? -yyn : 0;
929  /* Stay within bounds of both yycheck and yytname. */
930  int yychecklim = YYLAST - yyn + 1;
931  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
932  int yyx;
933 
934  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
935  if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
936  && !yytable_value_is_error (yytable[yyx + yyn]))
937  {
938  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
939  {
940  yycount = 1;
941  yysize = yysize0;
942  break;
943  }
944  yyarg[yycount++] = yytname[yyx];
945  {
946  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
947  if (! (yysize <= yysize1
948  && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
949  return 2;
950  yysize = yysize1;
951  }
952  }
953  }
954  }
955 
956  switch (yycount)
957  {
958 # define YYCASE_(N, S) \
959  case N: \
960  yyformat = S; \
961  break
962  YYCASE_(0, YY_("syntax error"));
963  YYCASE_(1, YY_("syntax error, unexpected %s"));
964  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
965  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
966  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
967  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
968 # undef YYCASE_
969  }
970 
971  {
972  YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
973  if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
974  return 2;
975  yysize = yysize1;
976  }
977 
978  if (*yymsg_alloc < yysize)
979  {
980  *yymsg_alloc = 2 * yysize;
981  if (! (yysize <= *yymsg_alloc
982  && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
983  *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
984  return 1;
985  }
986 
987  /* Avoid sprintf, as that infringes on the user's name space.
988  Don't have undefined behavior even if the translation
989  produced a string with the wrong number of "%s"s. */
990  {
991  char *yyp = *yymsg;
992  int yyi = 0;
993  while ((*yyp = *yyformat) != '\0')
994  if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
995  {
996  yyp += yytnamerr (yyp, yyarg[yyi++]);
997  yyformat += 2;
998  }
999  else
1000  {
1001  yyp++;
1002  yyformat++;
1003  }
1004  }
1005  return 0;
1006 }
1007 #endif /* YYERROR_VERBOSE */
1008 
1009 /*-----------------------------------------------.
1010 | Release the memory associated to this symbol. |
1011 `-----------------------------------------------*/
1012 
1013 static void
1014 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void* yyscanner, jsgf_t *jsgf)
1015 {
1016  YYUSE (yyvaluep);
1017  YYUSE (yyscanner);
1018  YYUSE (jsgf);
1019  if (!yymsg)
1020  yymsg = "Deleting";
1021  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1022 
1023  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1024  YYUSE (yytype);
1025  YY_IGNORE_MAYBE_UNINITIALIZED_END
1026 }
1027 
1028 
1029 
1030 
1031 /*----------.
1032 | yyparse. |
1033 `----------*/
1034 
1035 int
1036 yyparse (void* yyscanner, jsgf_t *jsgf)
1037 {
1038 /* The lookahead symbol. */
1039 int yychar;
1040 
1041 
1042 /* The semantic value of the lookahead symbol. */
1043 /* Default value used for initialization, for pacifying older GCCs
1044  or non-GCC compilers. */
1045 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1046 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1047 
1048  /* Number of syntax errors so far. */
1049  int yynerrs;
1050 
1051  int yystate;
1052  /* Number of tokens to shift before error messages enabled. */
1053  int yyerrstatus;
1054 
1055  /* The stacks and their tools:
1056  'yyss': related to states.
1057  'yyvs': related to semantic values.
1058 
1059  Refer to the stacks through separate pointers, to allow yyoverflow
1060  to reallocate them elsewhere. */
1061 
1062  /* The state stack. */
1063  yytype_int16 yyssa[YYINITDEPTH];
1064  yytype_int16 *yyss;
1065  yytype_int16 *yyssp;
1066 
1067  /* The semantic value stack. */
1068  YYSTYPE yyvsa[YYINITDEPTH];
1069  YYSTYPE *yyvs;
1070  YYSTYPE *yyvsp;
1071 
1072  YYSIZE_T yystacksize;
1073 
1074  int yyn;
1075  int yyresult;
1076  /* Lookahead token as an internal (translated) token number. */
1077  int yytoken = 0;
1078  /* The variables used to return semantic value and location from the
1079  action routines. */
1080  YYSTYPE yyval;
1081 
1082 #if YYERROR_VERBOSE
1083  /* Buffer for error messages, and its allocated size. */
1084  char yymsgbuf[128];
1085  char *yymsg = yymsgbuf;
1086  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1087 #endif
1088 
1089 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1090 
1091  /* The number of symbols on the RHS of the reduced rule.
1092  Keep to zero when no symbol should be popped. */
1093  int yylen = 0;
1094 
1095  yyssp = yyss = yyssa;
1096  yyvsp = yyvs = yyvsa;
1097  yystacksize = YYINITDEPTH;
1098 
1099  YYDPRINTF ((stderr, "Starting parse\n"));
1100 
1101  yystate = 0;
1102  yyerrstatus = 0;
1103  yynerrs = 0;
1104  yychar = YYEMPTY; /* Cause a token to be read. */
1105  goto yysetstate;
1106 
1107 /*------------------------------------------------------------.
1108 | yynewstate -- Push a new state, which is found in yystate. |
1109 `------------------------------------------------------------*/
1110  yynewstate:
1111  /* In all cases, when you get here, the value and location stacks
1112  have just been pushed. So pushing a state here evens the stacks. */
1113  yyssp++;
1114 
1115  yysetstate:
1116  *yyssp = yystate;
1117 
1118  if (yyss + yystacksize - 1 <= yyssp)
1119  {
1120  /* Get the current used size of the three stacks, in elements. */
1121  YYSIZE_T yysize = yyssp - yyss + 1;
1122 
1123 #ifdef yyoverflow
1124  {
1125  /* Give user a chance to reallocate the stack. Use copies of
1126  these so that the &'s don't force the real ones into
1127  memory. */
1128  YYSTYPE *yyvs1 = yyvs;
1129  yytype_int16 *yyss1 = yyss;
1130 
1131  /* Each stack pointer address is followed by the size of the
1132  data in use in that stack, in bytes. This used to be a
1133  conditional around just the two extra args, but that might
1134  be undefined if yyoverflow is a macro. */
1135  yyoverflow (YY_("memory exhausted"),
1136  &yyss1, yysize * sizeof (*yyssp),
1137  &yyvs1, yysize * sizeof (*yyvsp),
1138  &yystacksize);
1139 
1140  yyss = yyss1;
1141  yyvs = yyvs1;
1142  }
1143 #else /* no yyoverflow */
1144 # ifndef YYSTACK_RELOCATE
1145  goto yyexhaustedlab;
1146 # else
1147  /* Extend the stack our own way. */
1148  if (YYMAXDEPTH <= yystacksize)
1149  goto yyexhaustedlab;
1150  yystacksize *= 2;
1151  if (YYMAXDEPTH < yystacksize)
1152  yystacksize = YYMAXDEPTH;
1153 
1154  {
1155  yytype_int16 *yyss1 = yyss;
1156  union yyalloc *yyptr =
1157  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1158  if (! yyptr)
1159  goto yyexhaustedlab;
1160  YYSTACK_RELOCATE (yyss_alloc, yyss);
1161  YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1162 # undef YYSTACK_RELOCATE
1163  if (yyss1 != yyssa)
1164  YYSTACK_FREE (yyss1);
1165  }
1166 # endif
1167 #endif /* no yyoverflow */
1168 
1169  yyssp = yyss + yysize - 1;
1170  yyvsp = yyvs + yysize - 1;
1171 
1172  YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1173  (unsigned long int) yystacksize));
1174 
1175  if (yyss + yystacksize - 1 <= yyssp)
1176  YYABORT;
1177  }
1178 
1179  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1180 
1181  if (yystate == YYFINAL)
1182  YYACCEPT;
1183 
1184  goto yybackup;
1185 
1186 /*-----------.
1187 | yybackup. |
1188 `-----------*/
1189 yybackup:
1190 
1191  /* Do appropriate processing given the current state. Read a
1192  lookahead token if we need one and don't already have one. */
1193 
1194  /* First try to decide what to do without reference to lookahead token. */
1195  yyn = yypact[yystate];
1196  if (yypact_value_is_default (yyn))
1197  goto yydefault;
1198 
1199  /* Not known => get a lookahead token if don't already have one. */
1200 
1201  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1202  if (yychar == YYEMPTY)
1203  {
1204  YYDPRINTF ((stderr, "Reading a token: "));
1205  yychar = yylex (&yylval, yyscanner);
1206  }
1207 
1208  if (yychar <= YYEOF)
1209  {
1210  yychar = yytoken = YYEOF;
1211  YYDPRINTF ((stderr, "Now at end of input.\n"));
1212  }
1213  else
1214  {
1215  yytoken = YYTRANSLATE (yychar);
1216  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1217  }
1218 
1219  /* If the proper action on seeing token YYTOKEN is to reduce or to
1220  detect an error, take that action. */
1221  yyn += yytoken;
1222  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1223  goto yydefault;
1224  yyn = yytable[yyn];
1225  if (yyn <= 0)
1226  {
1227  if (yytable_value_is_error (yyn))
1228  goto yyerrlab;
1229  yyn = -yyn;
1230  goto yyreduce;
1231  }
1232 
1233  /* Count tokens shifted since error; after three, turn off error
1234  status. */
1235  if (yyerrstatus)
1236  yyerrstatus--;
1237 
1238  /* Shift the lookahead token. */
1239  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1240 
1241  /* Discard the shifted token. */
1242  yychar = YYEMPTY;
1243 
1244  yystate = yyn;
1245  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1246  *++yyvsp = yylval;
1247  YY_IGNORE_MAYBE_UNINITIALIZED_END
1248 
1249  goto yynewstate;
1250 
1251 
1252 /*-----------------------------------------------------------.
1253 | yydefault -- do the default action for the current state. |
1254 `-----------------------------------------------------------*/
1255 yydefault:
1256  yyn = yydefact[yystate];
1257  if (yyn == 0)
1258  goto yyerrlab;
1259  goto yyreduce;
1260 
1261 
1262 /*-----------------------------.
1263 | yyreduce -- Do a reduction. |
1264 `-----------------------------*/
1265 yyreduce:
1266  /* yyn is the number of a rule to reduce with. */
1267  yylen = yyr2[yyn];
1268 
1269  /* If YYLEN is nonzero, implement the default value of the action:
1270  '$$ = $1'.
1271 
1272  Otherwise, the following line sets YYVAL to garbage.
1273  This behavior is undocumented and Bison
1274  users should not rely upon it. Assigning to YYVAL
1275  unconditionally makes the parser a bit smaller, and it avoids a
1276  GCC warning that YYVAL may be used uninitialized. */
1277  yyval = yyvsp[1-yylen];
1278 
1279 
1280  YY_REDUCE_PRINT (yyn);
1281  switch (yyn)
1282  {
1283  case 5:
1284 #line 87 "jsgf_parser.y" /* yacc.c:1646 */
1285  { jsgf->name = (yyvsp[0].name); }
1286 #line 1287 "jsgf_parser.c" /* yacc.c:1646 */
1287  break;
1288 
1289  case 7:
1290 #line 91 "jsgf_parser.y" /* yacc.c:1646 */
1291  { jsgf->version = (yyvsp[-1].name); }
1292 #line 1293 "jsgf_parser.c" /* yacc.c:1646 */
1293  break;
1294 
1295  case 8:
1296 #line 92 "jsgf_parser.y" /* yacc.c:1646 */
1297  { jsgf->version = (yyvsp[-2].name); jsgf->charset = (yyvsp[-1].name); }
1298 #line 1299 "jsgf_parser.c" /* yacc.c:1646 */
1299  break;
1300 
1301  case 9:
1302 #line 93 "jsgf_parser.y" /* yacc.c:1646 */
1303  { jsgf->version = (yyvsp[-3].name); jsgf->charset = (yyvsp[-2].name);
1304  jsgf->locale = (yyvsp[-1].name); }
1305 #line 1306 "jsgf_parser.c" /* yacc.c:1646 */
1306  break;
1307 
1308  case 10:
1309 #line 97 "jsgf_parser.y" /* yacc.c:1646 */
1310  { (yyval.name) = (yyvsp[-1].name); }
1311 #line 1312 "jsgf_parser.c" /* yacc.c:1646 */
1312  break;
1313 
1314  case 13:
1315 #line 104 "jsgf_parser.y" /* yacc.c:1646 */
1316  { jsgf_import_rule(jsgf, (yyvsp[-1].name)); ckd_free((yyvsp[-1].name)); }
1317 #line 1318 "jsgf_parser.c" /* yacc.c:1646 */
1318  break;
1319 
1320  case 16:
1321 #line 111 "jsgf_parser.y" /* yacc.c:1646 */
1322  { jsgf_define_rule(jsgf, (yyvsp[-3].name), (yyvsp[-1].rhs), 0); ckd_free((yyvsp[-3].name)); }
1323 #line 1324 "jsgf_parser.c" /* yacc.c:1646 */
1324  break;
1325 
1326  case 17:
1327 #line 112 "jsgf_parser.y" /* yacc.c:1646 */
1328  { jsgf_define_rule(jsgf, (yyvsp[-3].name), (yyvsp[-1].rhs), 1); ckd_free((yyvsp[-3].name)); }
1329 #line 1330 "jsgf_parser.c" /* yacc.c:1646 */
1330  break;
1331 
1332  case 18:
1333 #line 115 "jsgf_parser.y" /* yacc.c:1646 */
1334  { (yyval.rhs) = (yyvsp[0].rhs); (yyval.rhs)->atoms = glist_reverse((yyval.rhs)->atoms); }
1335 #line 1336 "jsgf_parser.c" /* yacc.c:1646 */
1336  break;
1337 
1338  case 19:
1339 #line 116 "jsgf_parser.y" /* yacc.c:1646 */
1340  { (yyval.rhs) = (yyvsp[0].rhs);
1341  (yyval.rhs)->atoms = glist_reverse((yyval.rhs)->atoms);
1342  (yyval.rhs)->alt = (yyvsp[-2].rhs); }
1343 #line 1344 "jsgf_parser.c" /* yacc.c:1646 */
1344  break;
1345 
1346  case 20:
1347 #line 121 "jsgf_parser.y" /* yacc.c:1646 */
1348  { (yyval.rhs) = ckd_calloc(1, sizeof(*(yyval.rhs)));
1349  (yyval.rhs)->atoms = glist_add_ptr((yyval.rhs)->atoms, (yyvsp[0].atom)); }
1350 #line 1351 "jsgf_parser.c" /* yacc.c:1646 */
1351  break;
1352 
1353  case 21:
1354 #line 123 "jsgf_parser.y" /* yacc.c:1646 */
1355  { (yyval.rhs) = (yyvsp[-1].rhs);
1356  (yyval.rhs)->atoms = glist_add_ptr((yyval.rhs)->atoms, (yyvsp[0].atom)); }
1357 #line 1358 "jsgf_parser.c" /* yacc.c:1646 */
1358  break;
1359 
1360  case 23:
1361 #line 128 "jsgf_parser.y" /* yacc.c:1646 */
1362  { (yyval.atom) = (yyvsp[-1].atom);
1363  (yyval.atom)->tags = glist_add_ptr((yyval.atom)->tags, (yyvsp[0].name)); }
1364 #line 1365 "jsgf_parser.c" /* yacc.c:1646 */
1365  break;
1366 
1367  case 25:
1368 #line 133 "jsgf_parser.y" /* yacc.c:1646 */
1369  { (yyval.atom) = (yyvsp[0].atom); (yyval.atom)->weight = (yyvsp[-1].weight); }
1370 #line 1371 "jsgf_parser.c" /* yacc.c:1646 */
1371  break;
1372 
1373  case 26:
1374 #line 136 "jsgf_parser.y" /* yacc.c:1646 */
1375  { (yyval.rule) = jsgf_define_rule(jsgf, NULL, (yyvsp[-1].rhs), 0); }
1376 #line 1377 "jsgf_parser.c" /* yacc.c:1646 */
1377  break;
1378 
1379  case 27:
1380 #line 139 "jsgf_parser.y" /* yacc.c:1646 */
1381  { (yyval.rule) = jsgf_optional_new(jsgf, (yyvsp[-1].rhs)); }
1382 #line 1383 "jsgf_parser.c" /* yacc.c:1646 */
1383  break;
1384 
1385  case 28:
1386 #line 142 "jsgf_parser.y" /* yacc.c:1646 */
1387  { (yyval.atom) = jsgf_atom_new((yyvsp[0].name), 1.0); ckd_free((yyvsp[0].name)); }
1388 #line 1389 "jsgf_parser.c" /* yacc.c:1646 */
1389  break;
1390 
1391  case 29:
1392 #line 143 "jsgf_parser.y" /* yacc.c:1646 */
1393  { (yyval.atom) = jsgf_atom_new((yyvsp[0].name), 1.0); ckd_free((yyvsp[0].name)); }
1394 #line 1395 "jsgf_parser.c" /* yacc.c:1646 */
1395  break;
1396 
1397  case 30:
1398 #line 144 "jsgf_parser.y" /* yacc.c:1646 */
1399  { (yyval.atom) = jsgf_atom_new((yyvsp[0].rule)->name, 1.0); }
1400 #line 1401 "jsgf_parser.c" /* yacc.c:1646 */
1401  break;
1402 
1403  case 31:
1404 #line 145 "jsgf_parser.y" /* yacc.c:1646 */
1405  { (yyval.atom) = jsgf_atom_new((yyvsp[0].rule)->name, 1.0); }
1406 #line 1407 "jsgf_parser.c" /* yacc.c:1646 */
1407  break;
1408 
1409  case 32:
1410 #line 146 "jsgf_parser.y" /* yacc.c:1646 */
1411  { (yyval.atom) = jsgf_kleene_new(jsgf, (yyvsp[-1].atom), 0); }
1412 #line 1413 "jsgf_parser.c" /* yacc.c:1646 */
1413  break;
1414 
1415  case 33:
1416 #line 147 "jsgf_parser.y" /* yacc.c:1646 */
1417  { (yyval.atom) = jsgf_kleene_new(jsgf, (yyvsp[-1].atom), 1); }
1418 #line 1419 "jsgf_parser.c" /* yacc.c:1646 */
1419  break;
1420 
1421 
1422 #line 1423 "jsgf_parser.c" /* yacc.c:1646 */
1423  default: break;
1424  }
1425  /* User semantic actions sometimes alter yychar, and that requires
1426  that yytoken be updated with the new translation. We take the
1427  approach of translating immediately before every use of yytoken.
1428  One alternative is translating here after every semantic action,
1429  but that translation would be missed if the semantic action invokes
1430  YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1431  if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1432  incorrect destructor might then be invoked immediately. In the
1433  case of YYERROR or YYBACKUP, subsequent parser actions might lead
1434  to an incorrect destructor call or verbose syntax error message
1435  before the lookahead is translated. */
1436  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1437 
1438  YYPOPSTACK (yylen);
1439  yylen = 0;
1440  YY_STACK_PRINT (yyss, yyssp);
1441 
1442  *++yyvsp = yyval;
1443 
1444  /* Now 'shift' the result of the reduction. Determine what state
1445  that goes to, based on the state we popped back to and the rule
1446  number reduced by. */
1447 
1448  yyn = yyr1[yyn];
1449 
1450  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1451  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1452  yystate = yytable[yystate];
1453  else
1454  yystate = yydefgoto[yyn - YYNTOKENS];
1455 
1456  goto yynewstate;
1457 
1458 
1459 /*--------------------------------------.
1460 | yyerrlab -- here on detecting error. |
1461 `--------------------------------------*/
1462 yyerrlab:
1463  /* Make sure we have latest lookahead translation. See comments at
1464  user semantic actions for why this is necessary. */
1465  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1466 
1467  /* If not already recovering from an error, report this error. */
1468  if (!yyerrstatus)
1469  {
1470  ++yynerrs;
1471 #if ! YYERROR_VERBOSE
1472  yyerror (yyscanner, jsgf, YY_("syntax error"));
1473 #else
1474 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1475  yyssp, yytoken)
1476  {
1477  char const *yymsgp = YY_("syntax error");
1478  int yysyntax_error_status;
1479  yysyntax_error_status = YYSYNTAX_ERROR;
1480  if (yysyntax_error_status == 0)
1481  yymsgp = yymsg;
1482  else if (yysyntax_error_status == 1)
1483  {
1484  if (yymsg != yymsgbuf)
1485  YYSTACK_FREE (yymsg);
1486  yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1487  if (!yymsg)
1488  {
1489  yymsg = yymsgbuf;
1490  yymsg_alloc = sizeof yymsgbuf;
1491  yysyntax_error_status = 2;
1492  }
1493  else
1494  {
1495  yysyntax_error_status = YYSYNTAX_ERROR;
1496  yymsgp = yymsg;
1497  }
1498  }
1499  yyerror (yyscanner, jsgf, yymsgp);
1500  if (yysyntax_error_status == 2)
1501  goto yyexhaustedlab;
1502  }
1503 # undef YYSYNTAX_ERROR
1504 #endif
1505  }
1506 
1507 
1508 
1509  if (yyerrstatus == 3)
1510  {
1511  /* If just tried and failed to reuse lookahead token after an
1512  error, discard it. */
1513 
1514  if (yychar <= YYEOF)
1515  {
1516  /* Return failure if at end of input. */
1517  if (yychar == YYEOF)
1518  YYABORT;
1519  }
1520  else
1521  {
1522  yydestruct ("Error: discarding",
1523  yytoken, &yylval, yyscanner, jsgf);
1524  yychar = YYEMPTY;
1525  }
1526  }
1527 
1528  /* Else will try to reuse lookahead token after shifting the error
1529  token. */
1530  goto yyerrlab1;
1531 
1532 
1533 /*---------------------------------------------------.
1534 | yyerrorlab -- error raised explicitly by YYERROR. |
1535 `---------------------------------------------------*/
1536 yyerrorlab:
1537 
1538  /* Pacify compilers like GCC when the user code never invokes
1539  YYERROR and the label yyerrorlab therefore never appears in user
1540  code. */
1541  if (/*CONSTCOND*/ 0)
1542  goto yyerrorlab;
1543 
1544  /* Do not reclaim the symbols of the rule whose action triggered
1545  this YYERROR. */
1546  YYPOPSTACK (yylen);
1547  yylen = 0;
1548  YY_STACK_PRINT (yyss, yyssp);
1549  yystate = *yyssp;
1550  goto yyerrlab1;
1551 
1552 
1553 /*-------------------------------------------------------------.
1554 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1555 `-------------------------------------------------------------*/
1556 yyerrlab1:
1557  yyerrstatus = 3; /* Each real token shifted decrements this. */
1558 
1559  for (;;)
1560  {
1561  yyn = yypact[yystate];
1562  if (!yypact_value_is_default (yyn))
1563  {
1564  yyn += YYTERROR;
1565  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1566  {
1567  yyn = yytable[yyn];
1568  if (0 < yyn)
1569  break;
1570  }
1571  }
1572 
1573  /* Pop the current state because it cannot handle the error token. */
1574  if (yyssp == yyss)
1575  YYABORT;
1576 
1577 
1578  yydestruct ("Error: popping",
1579  yystos[yystate], yyvsp, yyscanner, jsgf);
1580  YYPOPSTACK (1);
1581  yystate = *yyssp;
1582  YY_STACK_PRINT (yyss, yyssp);
1583  }
1584 
1585  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1586  *++yyvsp = yylval;
1587  YY_IGNORE_MAYBE_UNINITIALIZED_END
1588 
1589 
1590  /* Shift the error token. */
1591  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1592 
1593  yystate = yyn;
1594  goto yynewstate;
1595 
1596 
1597 /*-------------------------------------.
1598 | yyacceptlab -- YYACCEPT comes here. |
1599 `-------------------------------------*/
1600 yyacceptlab:
1601  yyresult = 0;
1602  goto yyreturn;
1603 
1604 /*-----------------------------------.
1605 | yyabortlab -- YYABORT comes here. |
1606 `-----------------------------------*/
1607 yyabortlab:
1608  yyresult = 1;
1609  goto yyreturn;
1610 
1611 #if !defined yyoverflow || YYERROR_VERBOSE
1612 /*-------------------------------------------------.
1613 | yyexhaustedlab -- memory exhaustion comes here. |
1614 `-------------------------------------------------*/
1615 yyexhaustedlab:
1616  yyerror (yyscanner, jsgf, YY_("memory exhausted"));
1617  yyresult = 2;
1618  /* Fall through. */
1619 #endif
1620 
1621 yyreturn:
1622  if (yychar != YYEMPTY)
1623  {
1624  /* Make sure we have latest lookahead translation. See comments at
1625  user semantic actions for why this is necessary. */
1626  yytoken = YYTRANSLATE (yychar);
1627  yydestruct ("Cleanup: discarding lookahead",
1628  yytoken, &yylval, yyscanner, jsgf);
1629  }
1630  /* Do not reclaim the symbols of the rule whose action triggered
1631  this YYABORT or YYACCEPT. */
1632  YYPOPSTACK (yylen);
1633  YY_STACK_PRINT (yyss, yyssp);
1634  while (yyssp != yyss)
1635  {
1636  yydestruct ("Cleanup: popping",
1637  yystos[*yyssp], yyvsp, yyscanner, jsgf);
1638  YYPOPSTACK (1);
1639  }
1640 #ifndef yyoverflow
1641  if (yyss != yyssa)
1642  YYSTACK_FREE (yyss);
1643 #endif
1644 #if YYERROR_VERBOSE
1645  if (yymsg != yymsgbuf)
1646  YYSTACK_FREE (yymsg);
1647 #endif
1648  return yyresult;
1649 }
1650 #line 150 "jsgf_parser.y" /* yacc.c:1906 */
1651 
1652 
1653 void
1654 yyerror(yyscan_t lex, jsgf_t *jsgf, const char *s)
1655 {
1656  E_ERROR("%s at line %d current token '%s'\n", s, yyget_lineno(lex), yyget_text(lex));
1657 }
Internal definitions for JSGF grammar compiler.
#define ckd_calloc(n, sz)
Macros to simplify the use of above functions.
Definition: ckd_alloc.h:248
Sphinx's memory allocation/deallocation routines.
SPHINXBASE_EXPORT void ckd_free(void *ptr)
Test and free a 1-D array.
Definition: ckd_alloc.c:241
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:73
char * charset
JSGF charset (default UTF-8)
Definition: jsgf_internal.h:71
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:70
#define E_ERROR
Print error message to standard error stream.
Definition: err.h:169
Hash table implementation.
char * locale
JSGF locale (default C)
Definition: jsgf_internal.h:72