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