SphinxBase  5prealpha
jsgf_parser.c
1 /* A Bison parser, made by GNU Bison 3.0.5. */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5  Copyright (C) 1984, 1989-1990, 2000-2015, 2018 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.5"
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  default: /* Avoid compiler warnings. */
965  YYCASE_(0, YY_("syntax error"));
966  YYCASE_(1, YY_("syntax error, unexpected %s"));
967  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
968  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
969  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
970  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
971 # undef YYCASE_
972  }
973 
974  {
975  YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
976  if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
977  return 2;
978  yysize = yysize1;
979  }
980 
981  if (*yymsg_alloc < yysize)
982  {
983  *yymsg_alloc = 2 * yysize;
984  if (! (yysize <= *yymsg_alloc
985  && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
986  *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
987  return 1;
988  }
989 
990  /* Avoid sprintf, as that infringes on the user's name space.
991  Don't have undefined behavior even if the translation
992  produced a string with the wrong number of "%s"s. */
993  {
994  char *yyp = *yymsg;
995  int yyi = 0;
996  while ((*yyp = *yyformat) != '\0')
997  if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
998  {
999  yyp += yytnamerr (yyp, yyarg[yyi++]);
1000  yyformat += 2;
1001  }
1002  else
1003  {
1004  yyp++;
1005  yyformat++;
1006  }
1007  }
1008  return 0;
1009 }
1010 #endif /* YYERROR_VERBOSE */
1011 
1012 /*-----------------------------------------------.
1013 | Release the memory associated to this symbol. |
1014 `-----------------------------------------------*/
1015 
1016 static void
1017 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void* yyscanner, jsgf_t *jsgf)
1018 {
1019  YYUSE (yyvaluep);
1020  YYUSE (yyscanner);
1021  YYUSE (jsgf);
1022  if (!yymsg)
1023  yymsg = "Deleting";
1024  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1025 
1026  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1027  YYUSE (yytype);
1028  YY_IGNORE_MAYBE_UNINITIALIZED_END
1029 }
1030 
1031 
1032 
1033 
1034 /*----------.
1035 | yyparse. |
1036 `----------*/
1037 
1038 int
1039 yyparse (void* yyscanner, jsgf_t *jsgf)
1040 {
1041 /* The lookahead symbol. */
1042 int yychar;
1043 
1044 
1045 /* The semantic value of the lookahead symbol. */
1046 /* Default value used for initialization, for pacifying older GCCs
1047  or non-GCC compilers. */
1048 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1049 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1050 
1051  /* Number of syntax errors so far. */
1052  int yynerrs;
1053 
1054  int yystate;
1055  /* Number of tokens to shift before error messages enabled. */
1056  int yyerrstatus;
1057 
1058  /* The stacks and their tools:
1059  'yyss': related to states.
1060  'yyvs': related to semantic values.
1061 
1062  Refer to the stacks through separate pointers, to allow yyoverflow
1063  to reallocate them elsewhere. */
1064 
1065  /* The state stack. */
1066  yytype_int16 yyssa[YYINITDEPTH];
1067  yytype_int16 *yyss;
1068  yytype_int16 *yyssp;
1069 
1070  /* The semantic value stack. */
1071  YYSTYPE yyvsa[YYINITDEPTH];
1072  YYSTYPE *yyvs;
1073  YYSTYPE *yyvsp;
1074 
1075  YYSIZE_T yystacksize;
1076 
1077  int yyn;
1078  int yyresult;
1079  /* Lookahead token as an internal (translated) token number. */
1080  int yytoken = 0;
1081  /* The variables used to return semantic value and location from the
1082  action routines. */
1083  YYSTYPE yyval;
1084 
1085 #if YYERROR_VERBOSE
1086  /* Buffer for error messages, and its allocated size. */
1087  char yymsgbuf[128];
1088  char *yymsg = yymsgbuf;
1089  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1090 #endif
1091 
1092 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1093 
1094  /* The number of symbols on the RHS of the reduced rule.
1095  Keep to zero when no symbol should be popped. */
1096  int yylen = 0;
1097 
1098  yyssp = yyss = yyssa;
1099  yyvsp = yyvs = yyvsa;
1100  yystacksize = YYINITDEPTH;
1101 
1102  YYDPRINTF ((stderr, "Starting parse\n"));
1103 
1104  yystate = 0;
1105  yyerrstatus = 0;
1106  yynerrs = 0;
1107  yychar = YYEMPTY; /* Cause a token to be read. */
1108  goto yysetstate;
1109 
1110 /*------------------------------------------------------------.
1111 | yynewstate -- Push a new state, which is found in yystate. |
1112 `------------------------------------------------------------*/
1113  yynewstate:
1114  /* In all cases, when you get here, the value and location stacks
1115  have just been pushed. So pushing a state here evens the stacks. */
1116  yyssp++;
1117 
1118  yysetstate:
1119  *yyssp = yystate;
1120 
1121  if (yyss + yystacksize - 1 <= yyssp)
1122  {
1123  /* Get the current used size of the three stacks, in elements. */
1124  YYSIZE_T yysize = yyssp - yyss + 1;
1125 
1126 #ifdef yyoverflow
1127  {
1128  /* Give user a chance to reallocate the stack. Use copies of
1129  these so that the &'s don't force the real ones into
1130  memory. */
1131  YYSTYPE *yyvs1 = yyvs;
1132  yytype_int16 *yyss1 = yyss;
1133 
1134  /* Each stack pointer address is followed by the size of the
1135  data in use in that stack, in bytes. This used to be a
1136  conditional around just the two extra args, but that might
1137  be undefined if yyoverflow is a macro. */
1138  yyoverflow (YY_("memory exhausted"),
1139  &yyss1, yysize * sizeof (*yyssp),
1140  &yyvs1, yysize * sizeof (*yyvsp),
1141  &yystacksize);
1142 
1143  yyss = yyss1;
1144  yyvs = yyvs1;
1145  }
1146 #else /* no yyoverflow */
1147 # ifndef YYSTACK_RELOCATE
1148  goto yyexhaustedlab;
1149 # else
1150  /* Extend the stack our own way. */
1151  if (YYMAXDEPTH <= yystacksize)
1152  goto yyexhaustedlab;
1153  yystacksize *= 2;
1154  if (YYMAXDEPTH < yystacksize)
1155  yystacksize = YYMAXDEPTH;
1156 
1157  {
1158  yytype_int16 *yyss1 = yyss;
1159  union yyalloc *yyptr =
1160  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1161  if (! yyptr)
1162  goto yyexhaustedlab;
1163  YYSTACK_RELOCATE (yyss_alloc, yyss);
1164  YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1165 # undef YYSTACK_RELOCATE
1166  if (yyss1 != yyssa)
1167  YYSTACK_FREE (yyss1);
1168  }
1169 # endif
1170 #endif /* no yyoverflow */
1171 
1172  yyssp = yyss + yysize - 1;
1173  yyvsp = yyvs + yysize - 1;
1174 
1175  YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1176  (unsigned long int) yystacksize));
1177 
1178  if (yyss + yystacksize - 1 <= yyssp)
1179  YYABORT;
1180  }
1181 
1182  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1183 
1184  if (yystate == YYFINAL)
1185  YYACCEPT;
1186 
1187  goto yybackup;
1188 
1189 /*-----------.
1190 | yybackup. |
1191 `-----------*/
1192 yybackup:
1193 
1194  /* Do appropriate processing given the current state. Read a
1195  lookahead token if we need one and don't already have one. */
1196 
1197  /* First try to decide what to do without reference to lookahead token. */
1198  yyn = yypact[yystate];
1199  if (yypact_value_is_default (yyn))
1200  goto yydefault;
1201 
1202  /* Not known => get a lookahead token if don't already have one. */
1203 
1204  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1205  if (yychar == YYEMPTY)
1206  {
1207  YYDPRINTF ((stderr, "Reading a token: "));
1208  yychar = yylex (&yylval, yyscanner);
1209  }
1210 
1211  if (yychar <= YYEOF)
1212  {
1213  yychar = yytoken = YYEOF;
1214  YYDPRINTF ((stderr, "Now at end of input.\n"));
1215  }
1216  else
1217  {
1218  yytoken = YYTRANSLATE (yychar);
1219  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1220  }
1221 
1222  /* If the proper action on seeing token YYTOKEN is to reduce or to
1223  detect an error, take that action. */
1224  yyn += yytoken;
1225  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1226  goto yydefault;
1227  yyn = yytable[yyn];
1228  if (yyn <= 0)
1229  {
1230  if (yytable_value_is_error (yyn))
1231  goto yyerrlab;
1232  yyn = -yyn;
1233  goto yyreduce;
1234  }
1235 
1236  /* Count tokens shifted since error; after three, turn off error
1237  status. */
1238  if (yyerrstatus)
1239  yyerrstatus--;
1240 
1241  /* Shift the lookahead token. */
1242  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1243 
1244  /* Discard the shifted token. */
1245  yychar = YYEMPTY;
1246 
1247  yystate = yyn;
1248  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1249  *++yyvsp = yylval;
1250  YY_IGNORE_MAYBE_UNINITIALIZED_END
1251 
1252  goto yynewstate;
1253 
1254 
1255 /*-----------------------------------------------------------.
1256 | yydefault -- do the default action for the current state. |
1257 `-----------------------------------------------------------*/
1258 yydefault:
1259  yyn = yydefact[yystate];
1260  if (yyn == 0)
1261  goto yyerrlab;
1262  goto yyreduce;
1263 
1264 
1265 /*-----------------------------.
1266 | yyreduce -- Do a reduction. |
1267 `-----------------------------*/
1268 yyreduce:
1269  /* yyn is the number of a rule to reduce with. */
1270  yylen = yyr2[yyn];
1271 
1272  /* If YYLEN is nonzero, implement the default value of the action:
1273  '$$ = $1'.
1274 
1275  Otherwise, the following line sets YYVAL to garbage.
1276  This behavior is undocumented and Bison
1277  users should not rely upon it. Assigning to YYVAL
1278  unconditionally makes the parser a bit smaller, and it avoids a
1279  GCC warning that YYVAL may be used uninitialized. */
1280  yyval = yyvsp[1-yylen];
1281 
1282 
1283  YY_REDUCE_PRINT (yyn);
1284  switch (yyn)
1285  {
1286  case 5:
1287 #line 87 "jsgf_parser.y" /* yacc.c:1648 */
1288  { jsgf->name = (yyvsp[0].name); }
1289 #line 1290 "jsgf_parser.c" /* yacc.c:1648 */
1290  break;
1291 
1292  case 7:
1293 #line 91 "jsgf_parser.y" /* yacc.c:1648 */
1294  { jsgf->version = (yyvsp[-1].name); }
1295 #line 1296 "jsgf_parser.c" /* yacc.c:1648 */
1296  break;
1297 
1298  case 8:
1299 #line 92 "jsgf_parser.y" /* yacc.c:1648 */
1300  { jsgf->version = (yyvsp[-2].name); jsgf->charset = (yyvsp[-1].name); }
1301 #line 1302 "jsgf_parser.c" /* yacc.c:1648 */
1302  break;
1303 
1304  case 9:
1305 #line 93 "jsgf_parser.y" /* yacc.c:1648 */
1306  { jsgf->version = (yyvsp[-3].name); jsgf->charset = (yyvsp[-2].name);
1307  jsgf->locale = (yyvsp[-1].name); }
1308 #line 1309 "jsgf_parser.c" /* yacc.c:1648 */
1309  break;
1310 
1311  case 10:
1312 #line 97 "jsgf_parser.y" /* yacc.c:1648 */
1313  { (yyval.name) = (yyvsp[-1].name); }
1314 #line 1315 "jsgf_parser.c" /* yacc.c:1648 */
1315  break;
1316 
1317  case 13:
1318 #line 104 "jsgf_parser.y" /* yacc.c:1648 */
1319  { jsgf_import_rule(jsgf, (yyvsp[-1].name)); ckd_free((yyvsp[-1].name)); }
1320 #line 1321 "jsgf_parser.c" /* yacc.c:1648 */
1321  break;
1322 
1323  case 16:
1324 #line 111 "jsgf_parser.y" /* yacc.c:1648 */
1325  { jsgf_define_rule(jsgf, (yyvsp[-3].name), (yyvsp[-1].rhs), 0); ckd_free((yyvsp[-3].name)); }
1326 #line 1327 "jsgf_parser.c" /* yacc.c:1648 */
1327  break;
1328 
1329  case 17:
1330 #line 112 "jsgf_parser.y" /* yacc.c:1648 */
1331  { jsgf_define_rule(jsgf, (yyvsp[-3].name), (yyvsp[-1].rhs), 1); ckd_free((yyvsp[-3].name)); }
1332 #line 1333 "jsgf_parser.c" /* yacc.c:1648 */
1333  break;
1334 
1335  case 18:
1336 #line 115 "jsgf_parser.y" /* yacc.c:1648 */
1337  { (yyval.rhs) = (yyvsp[0].rhs); (yyval.rhs)->atoms = glist_reverse((yyval.rhs)->atoms); }
1338 #line 1339 "jsgf_parser.c" /* yacc.c:1648 */
1339  break;
1340 
1341  case 19:
1342 #line 116 "jsgf_parser.y" /* yacc.c:1648 */
1343  { (yyval.rhs) = (yyvsp[0].rhs);
1344  (yyval.rhs)->atoms = glist_reverse((yyval.rhs)->atoms);
1345  (yyval.rhs)->alt = (yyvsp[-2].rhs); }
1346 #line 1347 "jsgf_parser.c" /* yacc.c:1648 */
1347  break;
1348 
1349  case 20:
1350 #line 121 "jsgf_parser.y" /* yacc.c:1648 */
1351  { (yyval.rhs) = ckd_calloc(1, sizeof(*(yyval.rhs)));
1352  (yyval.rhs)->atoms = glist_add_ptr((yyval.rhs)->atoms, (yyvsp[0].atom)); }
1353 #line 1354 "jsgf_parser.c" /* yacc.c:1648 */
1354  break;
1355 
1356  case 21:
1357 #line 123 "jsgf_parser.y" /* yacc.c:1648 */
1358  { (yyval.rhs) = (yyvsp[-1].rhs);
1359  (yyval.rhs)->atoms = glist_add_ptr((yyval.rhs)->atoms, (yyvsp[0].atom)); }
1360 #line 1361 "jsgf_parser.c" /* yacc.c:1648 */
1361  break;
1362 
1363  case 23:
1364 #line 128 "jsgf_parser.y" /* yacc.c:1648 */
1365  { (yyval.atom) = (yyvsp[-1].atom);
1366  (yyval.atom)->tags = glist_add_ptr((yyval.atom)->tags, (yyvsp[0].name)); }
1367 #line 1368 "jsgf_parser.c" /* yacc.c:1648 */
1368  break;
1369 
1370  case 25:
1371 #line 133 "jsgf_parser.y" /* yacc.c:1648 */
1372  { (yyval.atom) = (yyvsp[0].atom); (yyval.atom)->weight = (yyvsp[-1].weight); }
1373 #line 1374 "jsgf_parser.c" /* yacc.c:1648 */
1374  break;
1375 
1376  case 26:
1377 #line 136 "jsgf_parser.y" /* yacc.c:1648 */
1378  { (yyval.rule) = jsgf_define_rule(jsgf, NULL, (yyvsp[-1].rhs), 0); }
1379 #line 1380 "jsgf_parser.c" /* yacc.c:1648 */
1380  break;
1381 
1382  case 27:
1383 #line 139 "jsgf_parser.y" /* yacc.c:1648 */
1384  { (yyval.rule) = jsgf_optional_new(jsgf, (yyvsp[-1].rhs)); }
1385 #line 1386 "jsgf_parser.c" /* yacc.c:1648 */
1386  break;
1387 
1388  case 28:
1389 #line 142 "jsgf_parser.y" /* yacc.c:1648 */
1390  { (yyval.atom) = jsgf_atom_new((yyvsp[0].name), 1.0); ckd_free((yyvsp[0].name)); }
1391 #line 1392 "jsgf_parser.c" /* yacc.c:1648 */
1392  break;
1393 
1394  case 29:
1395 #line 143 "jsgf_parser.y" /* yacc.c:1648 */
1396  { (yyval.atom) = jsgf_atom_new((yyvsp[0].name), 1.0); ckd_free((yyvsp[0].name)); }
1397 #line 1398 "jsgf_parser.c" /* yacc.c:1648 */
1398  break;
1399 
1400  case 30:
1401 #line 144 "jsgf_parser.y" /* yacc.c:1648 */
1402  { (yyval.atom) = jsgf_atom_new((yyvsp[0].rule)->name, 1.0); }
1403 #line 1404 "jsgf_parser.c" /* yacc.c:1648 */
1404  break;
1405 
1406  case 31:
1407 #line 145 "jsgf_parser.y" /* yacc.c:1648 */
1408  { (yyval.atom) = jsgf_atom_new((yyvsp[0].rule)->name, 1.0); }
1409 #line 1410 "jsgf_parser.c" /* yacc.c:1648 */
1410  break;
1411 
1412  case 32:
1413 #line 146 "jsgf_parser.y" /* yacc.c:1648 */
1414  { (yyval.atom) = jsgf_kleene_new(jsgf, (yyvsp[-1].atom), 0); }
1415 #line 1416 "jsgf_parser.c" /* yacc.c:1648 */
1416  break;
1417 
1418  case 33:
1419 #line 147 "jsgf_parser.y" /* yacc.c:1648 */
1420  { (yyval.atom) = jsgf_kleene_new(jsgf, (yyvsp[-1].atom), 1); }
1421 #line 1422 "jsgf_parser.c" /* yacc.c:1648 */
1422  break;
1423 
1424 
1425 #line 1426 "jsgf_parser.c" /* yacc.c:1648 */
1426  default: break;
1427  }
1428  /* User semantic actions sometimes alter yychar, and that requires
1429  that yytoken be updated with the new translation. We take the
1430  approach of translating immediately before every use of yytoken.
1431  One alternative is translating here after every semantic action,
1432  but that translation would be missed if the semantic action invokes
1433  YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1434  if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1435  incorrect destructor might then be invoked immediately. In the
1436  case of YYERROR or YYBACKUP, subsequent parser actions might lead
1437  to an incorrect destructor call or verbose syntax error message
1438  before the lookahead is translated. */
1439  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1440 
1441  YYPOPSTACK (yylen);
1442  yylen = 0;
1443  YY_STACK_PRINT (yyss, yyssp);
1444 
1445  *++yyvsp = yyval;
1446 
1447  /* Now 'shift' the result of the reduction. Determine what state
1448  that goes to, based on the state we popped back to and the rule
1449  number reduced by. */
1450 
1451  yyn = yyr1[yyn];
1452 
1453  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1454  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1455  yystate = yytable[yystate];
1456  else
1457  yystate = yydefgoto[yyn - YYNTOKENS];
1458 
1459  goto yynewstate;
1460 
1461 
1462 /*--------------------------------------.
1463 | yyerrlab -- here on detecting error. |
1464 `--------------------------------------*/
1465 yyerrlab:
1466  /* Make sure we have latest lookahead translation. See comments at
1467  user semantic actions for why this is necessary. */
1468  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1469 
1470  /* If not already recovering from an error, report this error. */
1471  if (!yyerrstatus)
1472  {
1473  ++yynerrs;
1474 #if ! YYERROR_VERBOSE
1475  yyerror (yyscanner, jsgf, YY_("syntax error"));
1476 #else
1477 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1478  yyssp, yytoken)
1479  {
1480  char const *yymsgp = YY_("syntax error");
1481  int yysyntax_error_status;
1482  yysyntax_error_status = YYSYNTAX_ERROR;
1483  if (yysyntax_error_status == 0)
1484  yymsgp = yymsg;
1485  else if (yysyntax_error_status == 1)
1486  {
1487  if (yymsg != yymsgbuf)
1488  YYSTACK_FREE (yymsg);
1489  yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1490  if (!yymsg)
1491  {
1492  yymsg = yymsgbuf;
1493  yymsg_alloc = sizeof yymsgbuf;
1494  yysyntax_error_status = 2;
1495  }
1496  else
1497  {
1498  yysyntax_error_status = YYSYNTAX_ERROR;
1499  yymsgp = yymsg;
1500  }
1501  }
1502  yyerror (yyscanner, jsgf, yymsgp);
1503  if (yysyntax_error_status == 2)
1504  goto yyexhaustedlab;
1505  }
1506 # undef YYSYNTAX_ERROR
1507 #endif
1508  }
1509 
1510 
1511 
1512  if (yyerrstatus == 3)
1513  {
1514  /* If just tried and failed to reuse lookahead token after an
1515  error, discard it. */
1516 
1517  if (yychar <= YYEOF)
1518  {
1519  /* Return failure if at end of input. */
1520  if (yychar == YYEOF)
1521  YYABORT;
1522  }
1523  else
1524  {
1525  yydestruct ("Error: discarding",
1526  yytoken, &yylval, yyscanner, jsgf);
1527  yychar = YYEMPTY;
1528  }
1529  }
1530 
1531  /* Else will try to reuse lookahead token after shifting the error
1532  token. */
1533  goto yyerrlab1;
1534 
1535 
1536 /*---------------------------------------------------.
1537 | yyerrorlab -- error raised explicitly by YYERROR. |
1538 `---------------------------------------------------*/
1539 yyerrorlab:
1540 
1541  /* Pacify compilers like GCC when the user code never invokes
1542  YYERROR and the label yyerrorlab therefore never appears in user
1543  code. */
1544  if (/*CONSTCOND*/ 0)
1545  goto yyerrorlab;
1546 
1547  /* Do not reclaim the symbols of the rule whose action triggered
1548  this YYERROR. */
1549  YYPOPSTACK (yylen);
1550  yylen = 0;
1551  YY_STACK_PRINT (yyss, yyssp);
1552  yystate = *yyssp;
1553  goto yyerrlab1;
1554 
1555 
1556 /*-------------------------------------------------------------.
1557 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1558 `-------------------------------------------------------------*/
1559 yyerrlab1:
1560  yyerrstatus = 3; /* Each real token shifted decrements this. */
1561 
1562  for (;;)
1563  {
1564  yyn = yypact[yystate];
1565  if (!yypact_value_is_default (yyn))
1566  {
1567  yyn += YYTERROR;
1568  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1569  {
1570  yyn = yytable[yyn];
1571  if (0 < yyn)
1572  break;
1573  }
1574  }
1575 
1576  /* Pop the current state because it cannot handle the error token. */
1577  if (yyssp == yyss)
1578  YYABORT;
1579 
1580 
1581  yydestruct ("Error: popping",
1582  yystos[yystate], yyvsp, yyscanner, jsgf);
1583  YYPOPSTACK (1);
1584  yystate = *yyssp;
1585  YY_STACK_PRINT (yyss, yyssp);
1586  }
1587 
1588  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1589  *++yyvsp = yylval;
1590  YY_IGNORE_MAYBE_UNINITIALIZED_END
1591 
1592 
1593  /* Shift the error token. */
1594  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1595 
1596  yystate = yyn;
1597  goto yynewstate;
1598 
1599 
1600 /*-------------------------------------.
1601 | yyacceptlab -- YYACCEPT comes here. |
1602 `-------------------------------------*/
1603 yyacceptlab:
1604  yyresult = 0;
1605  goto yyreturn;
1606 
1607 /*-----------------------------------.
1608 | yyabortlab -- YYABORT comes here. |
1609 `-----------------------------------*/
1610 yyabortlab:
1611  yyresult = 1;
1612  goto yyreturn;
1613 
1614 #if !defined yyoverflow || YYERROR_VERBOSE
1615 /*-------------------------------------------------.
1616 | yyexhaustedlab -- memory exhaustion comes here. |
1617 `-------------------------------------------------*/
1618 yyexhaustedlab:
1619  yyerror (yyscanner, jsgf, YY_("memory exhausted"));
1620  yyresult = 2;
1621  /* Fall through. */
1622 #endif
1623 
1624 yyreturn:
1625  if (yychar != YYEMPTY)
1626  {
1627  /* Make sure we have latest lookahead translation. See comments at
1628  user semantic actions for why this is necessary. */
1629  yytoken = YYTRANSLATE (yychar);
1630  yydestruct ("Cleanup: discarding lookahead",
1631  yytoken, &yylval, yyscanner, jsgf);
1632  }
1633  /* Do not reclaim the symbols of the rule whose action triggered
1634  this YYABORT or YYACCEPT. */
1635  YYPOPSTACK (yylen);
1636  YY_STACK_PRINT (yyss, yyssp);
1637  while (yyssp != yyss)
1638  {
1639  yydestruct ("Cleanup: popping",
1640  yystos[*yyssp], yyvsp, yyscanner, jsgf);
1641  YYPOPSTACK (1);
1642  }
1643 #ifndef yyoverflow
1644  if (yyss != yyssa)
1645  YYSTACK_FREE (yyss);
1646 #endif
1647 #if YYERROR_VERBOSE
1648  if (yymsg != yymsgbuf)
1649  YYSTACK_FREE (yymsg);
1650 #endif
1651  return yyresult;
1652 }
1653 #line 150 "jsgf_parser.y" /* yacc.c:1907 */
1654 
1655 
1656 void
1657 yyerror(yyscan_t lex, jsgf_t *jsgf, const char *s)
1658 {
1659  E_ERROR("%s at line %d current token '%s'\n", s, yyget_lineno(lex), yyget_text(lex));
1660 }
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