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