49 #define YYBISON_VERSION "2.4.1"
52 #define YYSKELETON_NAME "yacc.c"
64 #define YYLSP_NEEDED 0
71 #line 37 "jsgf_parser.y"
73 #define YYERROR_VERBOSE
83 #include "jsgf_parser.h"
84 #include "jsgf_scanner.h"
88 #pragma warning(disable: 4273)
91 void yyerror(yyscan_t lex,
jsgf_t *jsgf,
const char *s);
96 #line 97 "jsgf_parser.c"
104 #ifdef YYERROR_VERBOSE
105 # undef YYERROR_VERBOSE
106 # define YYERROR_VERBOSE 1
108 # define YYERROR_VERBOSE 0
112 #ifndef YYTOKEN_TABLE
113 # define YYTOKEN_TABLE 0
146 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
151 #line 65 "jsgf_parser.y"
162 #line 163 "jsgf_parser.c"
164 # define YYSTYPE_IS_TRIVIAL 1
165 # define yystype YYSTYPE
166 # define YYSTYPE_IS_DECLARED 1
174 #line 175 "jsgf_parser.c"
181 typedef YYTYPE_UINT8 yytype_uint8;
183 typedef unsigned char yytype_uint8;
187 typedef YYTYPE_INT8 yytype_int8;
188 #elif (defined __STDC__ || defined __C99__FUNC__ \
189 || defined __cplusplus || defined _MSC_VER)
190 typedef signed char yytype_int8;
192 typedef short int yytype_int8;
196 typedef YYTYPE_UINT16 yytype_uint16;
198 typedef unsigned short int yytype_uint16;
202 typedef YYTYPE_INT16 yytype_int16;
204 typedef short int yytype_int16;
208 # ifdef __SIZE_TYPE__
209 # define YYSIZE_T __SIZE_TYPE__
210 # elif defined size_t
211 # define YYSIZE_T size_t
212 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
213 || defined __cplusplus || defined _MSC_VER)
215 # define YYSIZE_T size_t
217 # define YYSIZE_T unsigned int
221 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
226 # include <libintl.h>
227 # define YY_(msgid) dgettext ("bison-runtime", msgid)
231 # define YY_(msgid) msgid
236 #if ! defined lint || defined __GNUC__
237 # define YYUSE(e) ((void) (e))
246 #if (defined __STDC__ || defined __C99__FUNC__ \
247 || defined __cplusplus || defined _MSC_VER)
260 #if ! defined yyoverflow || YYERROR_VERBOSE
264 # ifdef YYSTACK_USE_ALLOCA
265 # if YYSTACK_USE_ALLOCA
267 # define YYSTACK_ALLOC __builtin_alloca
268 # elif defined __BUILTIN_VA_ARG_INCR
271 # define YYSTACK_ALLOC __alloca
272 # elif defined _MSC_VER
274 # define alloca _alloca
276 # define YYSTACK_ALLOC alloca
277 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
278 || defined __cplusplus || defined _MSC_VER)
288 # ifdef YYSTACK_ALLOC
290 # define YYSTACK_FREE(Ptr) do { ; } while (YYID (0))
291 # ifndef YYSTACK_ALLOC_MAXIMUM
296 # define YYSTACK_ALLOC_MAXIMUM 4032
299 # define YYSTACK_ALLOC YYMALLOC
300 # define YYSTACK_FREE YYFREE
301 # ifndef YYSTACK_ALLOC_MAXIMUM
302 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
304 # if (defined __cplusplus && ! defined _STDLIB_H \
305 && ! ((defined YYMALLOC || defined malloc) \
306 && (defined YYFREE || defined free)))
313 # define YYMALLOC malloc
314 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
315 || defined __cplusplus || defined _MSC_VER)
316 void *malloc (YYSIZE_T);
321 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
322 || defined __cplusplus || defined _MSC_VER)
330 #if (! defined yyoverflow \
331 && (! defined __cplusplus \
332 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
337 yytype_int16 yyss_alloc;
342 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
346 # define YYSTACK_BYTES(N) \
347 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
348 + YYSTACK_GAP_MAXIMUM)
353 # if defined __GNUC__ && 1 < __GNUC__
354 # define YYCOPY(To, From, Count) \
355 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
357 # define YYCOPY(To, From, Count) \
361 for (yyi = 0; yyi < (Count); yyi++) \
362 (To)[yyi] = (From)[yyi]; \
373 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
376 YYSIZE_T yynewbytes; \
377 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
378 Stack = &yyptr->Stack_alloc; \
379 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
380 yyptr += yynewbytes / sizeof (*yyptr); \
402 #define YYMAXUTOK 265
404 #define YYTRANSLATE(YYX) \
405 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
408 static const yytype_uint8 yytranslate[] =
410 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
411 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
412 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
413 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
414 14, 15, 18, 19, 2, 2, 2, 2, 2, 2,
415 2, 2, 2, 2, 2, 2, 2, 2, 2, 11,
416 2, 12, 2, 2, 2, 2, 2, 2, 2, 2,
417 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
418 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
419 2, 16, 2, 17, 2, 2, 2, 2, 2, 2,
420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
422 2, 2, 2, 2, 13, 2, 2, 2, 2, 2,
423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
424 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
425 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
426 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
427 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
428 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
430 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
431 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
432 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
433 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
434 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
435 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
442 static const yytype_uint8 yyprhs[] =
444 0, 0, 3, 5, 8, 12, 15, 18, 22, 27,
445 33, 37, 39, 42, 46, 48, 51, 56, 62, 64,
446 68, 70, 73, 75, 78, 80, 83, 87, 91, 93,
451 static const yytype_int8 yyrhs[] =
453 21, 0, -1, 22, -1, 22, 27, -1, 22, 25,
454 27, -1, 23, 24, -1, 3, 11, -1, 3, 7,
455 11, -1, 3, 7, 7, 11, -1, 3, 7, 7,
456 7, 11, -1, 4, 7, 11, -1, 26, -1, 25,
457 26, -1, 5, 8, 11, -1, 28, -1, 27, 28,
458 -1, 8, 12, 29, 11, -1, 6, 8, 12, 29,
459 11, -1, 30, -1, 29, 13, 30, -1, 31, -1,
460 30, 31, -1, 32, -1, 31, 9, -1, 35, -1,
461 10, 35, -1, 14, 29, 15, -1, 16, 29, 17,
462 -1, 7, -1, 8, -1, 33, -1, 34, -1, 35,
467 static const yytype_uint8 yyrline[] =
469 0, 82, 82, 83, 84, 87, 90, 91, 92, 93,
470 97, 100, 101, 104, 107, 108, 111, 112, 115, 116,
471 121, 123, 127, 128, 132, 133, 136, 139, 142, 143,
476 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
479 static const char *
const yytname[] =
481 "$end",
"error",
"$undefined",
"HEADER",
"GRAMMAR",
"IMPORT",
"PUBLIC",
482 "TOKEN",
"RULENAME",
"TAG",
"WEIGHT",
"';'",
"'='",
"'|'",
"'('",
"')'",
483 "'['",
"']'",
"'*'",
"'+'",
"$accept",
"grammar",
"header",
484 "jsgf_header",
"grammar_header",
"import_header",
"import_statement",
485 "rule_list",
"rule",
"alternate_list",
"rule_expansion",
486 "tagged_rule_item",
"rule_item",
"rule_group",
"rule_optional",
494 static const yytype_uint16 yytoknum[] =
496 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
497 265, 59, 61, 124, 40, 41, 91, 93, 42, 43
502 static const yytype_uint8 yyr1[] =
504 0, 20, 21, 21, 21, 22, 23, 23, 23, 23,
505 24, 25, 25, 26, 27, 27, 28, 28, 29, 29,
506 30, 30, 31, 31, 32, 32, 33, 34, 35, 35,
511 static const yytype_uint8 yyr2[] =
513 0, 2, 1, 2, 3, 2, 2, 3, 4, 5,
514 3, 1, 2, 3, 1, 2, 4, 5, 1, 3,
515 1, 2, 1, 2, 1, 2, 3, 3, 1, 1,
522 static const yytype_uint8 yydefact[] =
524 0, 0, 0, 2, 0, 0, 6, 1, 0, 0,
525 0, 0, 11, 3, 14, 0, 5, 0, 7, 0,
526 0, 0, 12, 4, 15, 0, 0, 8, 13, 0,
527 28, 29, 0, 0, 0, 0, 18, 20, 22, 30,
528 31, 24, 10, 9, 0, 25, 0, 0, 16, 0,
529 21, 23, 32, 33, 17, 26, 27, 19
533 static const yytype_int8 yydefgoto[] =
535 -1, 2, 3, 4, 16, 11, 12, 13, 14, 35,
536 36, 37, 38, 39, 40, 41
541 #define YYPACT_NINF -37
542 static const yytype_int8 yypact[] =
544 -1, -2, 36, 22, 35, 8, -37, -37, 32, 33,
545 30, 22, -37, 17, -37, 37, -37, 13, -37, 34,
546 31, -4, -37, 17, -37, 38, 39, -37, -37, -4,
547 -37, -37, 0, -4, -4, 18, -4, 42, -37, -37,
548 -37, 19, -37, -37, 21, 19, 20, 9, -37, -4,
549 42, -37, -37, -37, -37, -37, -37, -4
553 static const yytype_int8 yypgoto[] =
555 -37, -37, -37, -37, -37, -37, 41, 43, -12, -16,
556 -3, -36, -37, -37, -37, 15
563 #define YYTABLE_NINF -1
564 static const yytype_uint8 yytable[] =
566 50, 24, 1, 30, 31, 5, 32, 30, 31, 6,
567 33, 24, 34, 44, 33, 17, 34, 46, 47, 18,
568 26, 50, 49, 9, 27, 10, 56, 8, 9, 48,
569 10, 49, 54, 49, 49, 55, 7, 52, 53, 15,
570 19, 20, 21, 29, 25, 28, 57, 45, 0, 42,
574 static const yytype_int8 yycheck[] =
576 36, 13, 3, 7, 8, 7, 10, 7, 8, 11,
577 14, 23, 16, 29, 14, 7, 16, 33, 34, 11,
578 7, 57, 13, 6, 11, 8, 17, 5, 6, 11,
579 8, 13, 11, 13, 13, 15, 0, 18, 19, 4,
580 8, 8, 12, 12, 7, 11, 49, 32, -1, 11,
586 static const yytype_uint8 yystos[] =
588 0, 3, 21, 22, 23, 7, 11, 0, 5, 6,
589 8, 25, 26, 27, 28, 4, 24, 7, 11, 8,
590 8, 12, 26, 27, 28, 7, 7, 11, 11, 12,
591 7, 8, 10, 14, 16, 29, 30, 31, 32, 33,
592 34, 35, 11, 11, 29, 35, 29, 29, 11, 13,
593 31, 9, 18, 19, 11, 15, 17, 30
596 #define yyerrok (yyerrstatus = 0)
597 #define yyclearin (yychar = YYEMPTY)
601 #define YYACCEPT goto yyacceptlab
602 #define YYABORT goto yyabortlab
603 #define YYERROR goto yyerrorlab
610 #define YYFAIL goto yyerrlab
612 #define YYRECOVERING() (!!yyerrstatus)
614 #define YYBACKUP(Token, Value) \
616 if (yychar == YYEMPTY && yylen == 1) \
620 yytoken = YYTRANSLATE (yychar); \
626 yyerror (yyscanner, jsgf, YY_("syntax error: cannot back up")); \
633 #define YYERRCODE 256
640 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
641 #ifndef YYLLOC_DEFAULT
642 # define YYLLOC_DEFAULT(Current, Rhs, N) \
646 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
647 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
648 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
649 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
653 (Current).first_line = (Current).last_line = \
654 YYRHSLOC (Rhs, 0).last_line; \
655 (Current).first_column = (Current).last_column = \
656 YYRHSLOC (Rhs, 0).last_column; \
666 #ifndef YY_LOCATION_PRINT
667 # if YYLTYPE_IS_TRIVIAL
668 # define YY_LOCATION_PRINT(File, Loc) \
669 fprintf (File, "%d.%d-%d.%d", \
670 (Loc).first_line, (Loc).first_column, \
671 (Loc).last_line, (Loc).last_column)
673 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
681 # define YYLEX yylex (&yylval, YYLEX_PARAM)
683 # define YYLEX yylex (&yylval, yyscanner)
691 # define YYFPRINTF fprintf
694 # define YYDPRINTF(Args) \
700 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
704 YYFPRINTF (stderr, "%s ", Title); \
705 yy_symbol_print (stderr, \
706 Type, Value, yyscanner, jsgf); \
707 YYFPRINTF (stderr, "\n"); \
717 #if (defined __STDC__ || defined __C99__FUNC__ \
718 || defined __cplusplus || defined _MSC_VER)
720 yy_symbol_value_print (FILE *yyoutput,
int yytype,
YYSTYPE const *
const yyvaluep,
void* yyscanner,
jsgf_t *jsgf)
723 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf)
726 YYSTYPE const * const yyvaluep;
736 if (yytype < YYNTOKENS)
737 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
753 #if (defined __STDC__ || defined __C99__FUNC__ \
754 || defined __cplusplus || defined _MSC_VER)
756 yy_symbol_print (FILE *yyoutput,
int yytype,
YYSTYPE const *
const yyvaluep,
void* yyscanner,
jsgf_t *jsgf)
759 yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf)
762 YYSTYPE const * const yyvaluep;
767 if (yytype < YYNTOKENS)
768 YYFPRINTF (yyoutput,
"token %s (", yytname[yytype]);
770 YYFPRINTF (yyoutput,
"nterm %s (", yytname[yytype]);
772 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf);
773 YYFPRINTF (yyoutput,
")");
781 #if (defined __STDC__ || defined __C99__FUNC__ \
782 || defined __cplusplus || defined _MSC_VER)
784 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
787 yy_stack_print (yybottom, yytop)
788 yytype_int16 *yybottom;
792 YYFPRINTF (stderr,
"Stack now");
793 for (; yybottom <= yytop; yybottom++)
795 int yybot = *yybottom;
796 YYFPRINTF (stderr,
" %d", yybot);
798 YYFPRINTF (stderr,
"\n");
801 # define YY_STACK_PRINT(Bottom, Top) \
804 yy_stack_print ((Bottom), (Top)); \
812 #if (defined __STDC__ || defined __C99__FUNC__ \
813 || defined __cplusplus || defined _MSC_VER)
815 yy_reduce_print (
YYSTYPE *yyvsp,
int yyrule,
void* yyscanner,
jsgf_t *jsgf)
818 yy_reduce_print (yyvsp, yyrule, yyscanner, jsgf)
825 int yynrhs = yyr2[yyrule];
827 unsigned long int yylno = yyrline[yyrule];
828 YYFPRINTF (stderr,
"Reducing stack by rule %d (line %lu):\n",
831 for (yyi = 0; yyi < yynrhs; yyi++)
833 YYFPRINTF (stderr,
" $%d = ", yyi + 1);
834 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
835 &(yyvsp[(yyi + 1) - (yynrhs)])
837 YYFPRINTF (stderr,
"\n");
841 # define YY_REDUCE_PRINT(Rule) \
844 yy_reduce_print (yyvsp, Rule, yyscanner, jsgf); \
851 # define YYDPRINTF(Args)
852 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
853 # define YY_STACK_PRINT(Bottom, Top)
854 # define YY_REDUCE_PRINT(Rule)
860 # define YYINITDEPTH 200
871 # define YYMAXDEPTH 10000
879 # if defined __GLIBC__ && defined _STRING_H
880 # define yystrlen strlen
883 #if (defined __STDC__ || defined __C99__FUNC__ \
884 || defined __cplusplus || defined _MSC_VER)
886 yystrlen (
const char *yystr)
894 for (yylen = 0; yystr[yylen]; yylen++)
902 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
903 # define yystpcpy stpcpy
907 #if (defined __STDC__ || defined __C99__FUNC__ \
908 || defined __cplusplus || defined _MSC_VER)
910 yystpcpy (
char *yydest,
const char *yysrc)
913 yystpcpy (yydest, yysrc)
919 const char *yys = yysrc;
921 while ((*yyd++ = *yys++) !=
'\0')
938 yytnamerr (
char *yyres,
const char *yystr)
943 char const *yyp = yystr;
950 goto do_not_strip_quotes;
954 goto do_not_strip_quotes;
967 do_not_strip_quotes: ;
971 return yystrlen (yystr);
973 return yystpcpy (yyres, yystr) - yyres;
985 yysyntax_error (
char *yyresult,
int yystate,
int yychar)
987 int yyn = yypact[yystate];
989 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
993 int yytype = YYTRANSLATE (yychar);
994 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
995 YYSIZE_T yysize = yysize0;
997 int yysize_overflow = 0;
998 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
999 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1005 YY_(
"syntax error, unexpected %s");
1006 YY_(
"syntax error, unexpected %s, expecting %s");
1007 YY_(
"syntax error, unexpected %s, expecting %s or %s");
1008 YY_(
"syntax error, unexpected %s, expecting %s or %s or %s");
1009 YY_(
"syntax error, unexpected %s, expecting %s or %s or %s or %s");
1013 static char const yyunexpected[] =
"syntax error, unexpected %s";
1014 static char const yyexpecting[] =
", expecting %s";
1015 static char const yyor[] =
" or %s";
1016 char yyformat[
sizeof yyunexpected
1017 +
sizeof yyexpecting - 1
1018 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1019 * (
sizeof yyor - 1))];
1020 char const *yyprefix = yyexpecting;
1024 int yyxbegin = yyn < 0 ? -yyn : 0;
1027 int yychecklim = YYLAST - yyn + 1;
1028 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1031 yyarg[0] = yytname[yytype];
1032 yyfmt = yystpcpy (yyformat, yyunexpected);
1034 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1035 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1037 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1041 yyformat[
sizeof yyunexpected - 1] =
'\0';
1044 yyarg[yycount++] = yytname[yyx];
1045 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1046 yysize_overflow |= (yysize1 < yysize);
1048 yyfmt = yystpcpy (yyfmt, yyprefix);
1052 yyf = YY_(yyformat);
1053 yysize1 = yysize + yystrlen (yyf);
1054 yysize_overflow |= (yysize1 < yysize);
1057 if (yysize_overflow)
1058 return YYSIZE_MAXIMUM;
1065 char *yyp = yyresult;
1067 while ((*yyp = *yyf) !=
'\0')
1069 if (*yyp ==
'%' && yyf[1] ==
's' && yyi < yycount)
1071 yyp += yytnamerr (yyp, yyarg[yyi++]);
1092 #if (defined __STDC__ || defined __C99__FUNC__ \
1093 || defined __cplusplus || defined _MSC_VER)
1095 yydestruct (
const char *yymsg,
int yytype,
YYSTYPE *yyvaluep,
void* yyscanner,
jsgf_t *jsgf)
1098 yydestruct (yymsg, yytype, yyvaluep, yyscanner, jsgf)
1112 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1123 #ifdef YYPARSE_PARAM
1124 #if defined __STDC__ || defined __cplusplus
1125 int yyparse (
void *YYPARSE_PARAM);
1130 #if defined __STDC__ || defined __cplusplus
1131 int yyparse (
void* yyscanner,
jsgf_t *jsgf);
1145 #ifdef YYPARSE_PARAM
1146 #if (defined __STDC__ || defined __C99__FUNC__ \
1147 || defined __cplusplus || defined _MSC_VER)
1149 yyparse (
void *YYPARSE_PARAM)
1152 yyparse (YYPARSE_PARAM)
1153 void *YYPARSE_PARAM;
1156 #if (defined __STDC__ || defined __C99__FUNC__ \
1157 || defined __cplusplus || defined _MSC_VER)
1159 yyparse (
void* yyscanner,
jsgf_t *jsgf)
1162 yyparse (yyscanner, jsgf)
1189 yytype_int16 yyssa[YYINITDEPTH];
1191 yytype_int16 *yyssp;
1198 YYSIZE_T yystacksize;
1211 char *yymsg = yymsgbuf;
1212 YYSIZE_T yymsg_alloc =
sizeof yymsgbuf;
1215 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1224 yystacksize = YYINITDEPTH;
1226 YYDPRINTF ((stderr,
"Starting parse\n"));
1253 if (yyss + yystacksize - 1 <= yyssp)
1256 YYSIZE_T yysize = yyssp - yyss + 1;
1264 yytype_int16 *yyss1 = yyss;
1270 yyoverflow (YY_(
"memory exhausted"),
1271 &yyss1, yysize *
sizeof (*yyssp),
1272 &yyvs1, yysize *
sizeof (*yyvsp),
1279 # ifndef YYSTACK_RELOCATE
1280 goto yyexhaustedlab;
1283 if (YYMAXDEPTH <= yystacksize)
1284 goto yyexhaustedlab;
1286 if (YYMAXDEPTH < yystacksize)
1287 yystacksize = YYMAXDEPTH;
1290 yytype_int16 *yyss1 = yyss;
1292 (
union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1294 goto yyexhaustedlab;
1295 YYSTACK_RELOCATE (yyss_alloc, yyss);
1296 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1297 # undef YYSTACK_RELOCATE
1299 YYSTACK_FREE (yyss1);
1304 yyssp = yyss + yysize - 1;
1305 yyvsp = yyvs + yysize - 1;
1307 YYDPRINTF ((stderr,
"Stack size increased to %lu\n",
1308 (
unsigned long int) yystacksize));
1310 if (yyss + yystacksize - 1 <= yyssp)
1314 YYDPRINTF ((stderr,
"Entering state %d\n", yystate));
1316 if (yystate == YYFINAL)
1330 yyn = yypact[yystate];
1331 if (yyn == YYPACT_NINF)
1337 if (yychar == YYEMPTY)
1339 YYDPRINTF ((stderr,
"Reading a token: "));
1343 if (yychar <= YYEOF)
1345 yychar = yytoken = YYEOF;
1346 YYDPRINTF ((stderr,
"Now at end of input.\n"));
1350 yytoken = YYTRANSLATE (yychar);
1351 YY_SYMBOL_PRINT (
"Next token is", yytoken, &yylval, &yylloc);
1357 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1362 if (yyn == 0 || yyn == YYTABLE_NINF)
1374 YY_SYMBOL_PRINT (
"Shifting", yytoken, &yylval, &yylloc);
1389 yyn = yydefact[yystate];
1410 yyval = yyvsp[1-yylen];
1413 YY_REDUCE_PRINT (yyn);
1419 #line 87 "jsgf_parser.y"
1420 { jsgf->
name = (yyvsp[(2) - (2)].name); }
1426 #line 91 "jsgf_parser.y"
1427 { jsgf->
version = (yyvsp[(2) - (3)].name); }
1433 #line 92 "jsgf_parser.y"
1434 { jsgf->
version = (yyvsp[(2) - (4)].name); jsgf->
charset = (yyvsp[(3) - (4)].name); }
1440 #line 93 "jsgf_parser.y"
1441 { jsgf->
version = (yyvsp[(2) - (5)].name); jsgf->
charset = (yyvsp[(3) - (5)].name);
1442 jsgf->
locale = (yyvsp[(4) - (5)].name); }
1448 #line 97 "jsgf_parser.y"
1449 { (yyval.name) = (yyvsp[(2) - (3)].name); }
1455 #line 104 "jsgf_parser.y"
1456 { jsgf_import_rule(jsgf, (yyvsp[(2) - (3)].name));
ckd_free((yyvsp[(2) - (3)].name)); }
1462 #line 111 "jsgf_parser.y"
1463 { jsgf_define_rule(jsgf, (yyvsp[(1) - (4)].name), (yyvsp[(3) - (4)].rhs), 0);
ckd_free((yyvsp[(1) - (4)].name)); }
1469 #line 112 "jsgf_parser.y"
1470 { jsgf_define_rule(jsgf, (yyvsp[(2) - (5)].name), (yyvsp[(4) - (5)].rhs), 1);
ckd_free((yyvsp[(2) - (5)].name)); }
1476 #line 115 "jsgf_parser.y"
1477 { (yyval.rhs) = (yyvsp[(1) - (1)].rhs); (yyval.rhs)->atoms =
glist_reverse((yyval.rhs)->atoms); }
1483 #line 116 "jsgf_parser.y"
1484 { (yyval.rhs) = (yyvsp[(3) - (3)].rhs);
1486 (yyval.rhs)->alt = (yyvsp[(1) - (3)].rhs); }
1492 #line 121 "jsgf_parser.y"
1493 { (yyval.rhs) =
ckd_calloc(1,
sizeof(*(yyval.rhs)));
1494 (yyval.rhs)->atoms =
glist_add_ptr((yyval.rhs)->atoms, (yyvsp[(1) - (1)].atom)); }
1500 #line 123 "jsgf_parser.y"
1501 { (yyval.rhs) = (yyvsp[(1) - (2)].rhs);
1502 (yyval.rhs)->atoms =
glist_add_ptr((yyval.rhs)->atoms, (yyvsp[(2) - (2)].atom)); }
1508 #line 128 "jsgf_parser.y"
1509 { (yyval.atom) = (yyvsp[(1) - (2)].atom);
1510 (yyval.atom)->tags =
glist_add_ptr((yyval.atom)->tags, (yyvsp[(2) - (2)].name)); }
1516 #line 133 "jsgf_parser.y"
1517 { (yyval.atom) = (yyvsp[(2) - (2)].atom); (yyval.atom)->weight = (yyvsp[(1) - (2)].weight); }
1523 #line 136 "jsgf_parser.y"
1524 { (yyval.rule) = jsgf_define_rule(jsgf, NULL, (yyvsp[(2) - (3)].rhs), 0); }
1530 #line 139 "jsgf_parser.y"
1531 { (yyval.rule) = jsgf_optional_new(jsgf, (yyvsp[(2) - (3)].rhs)); }
1537 #line 142 "jsgf_parser.y"
1538 { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].name), 1.0);
ckd_free((yyvsp[(1) - (1)].name)); }
1544 #line 143 "jsgf_parser.y"
1545 { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].name), 1.0);
ckd_free((yyvsp[(1) - (1)].name)); }
1551 #line 144 "jsgf_parser.y"
1552 { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].rule)->name, 1.0); }
1558 #line 145 "jsgf_parser.y"
1559 { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].rule)->name, 1.0); }
1565 #line 146 "jsgf_parser.y"
1566 { (yyval.atom) = jsgf_kleene_new(jsgf, (yyvsp[(1) - (2)].atom), 0); }
1572 #line 147 "jsgf_parser.y"
1573 { (yyval.atom) = jsgf_kleene_new(jsgf, (yyvsp[(1) - (2)].atom), 1); }
1579 #line 1580 "jsgf_parser.c"
1582 YY_SYMBOL_PRINT (
"-> $$ =", yyr1[yyn], &yyval, &yyloc);
1586 YY_STACK_PRINT (yyss, yyssp);
1596 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1597 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1598 yystate = yytable[yystate];
1600 yystate = yydefgoto[yyn - YYNTOKENS];
1613 #if ! YYERROR_VERBOSE
1614 yyerror (yyscanner, jsgf, YY_(
"syntax error"));
1617 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1618 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1620 YYSIZE_T
yyalloc = 2 * yysize;
1621 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1622 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1623 if (yymsg != yymsgbuf)
1624 YYSTACK_FREE (yymsg);
1625 yymsg = (
char *) YYSTACK_ALLOC (yyalloc);
1627 yymsg_alloc = yyalloc;
1631 yymsg_alloc =
sizeof yymsgbuf;
1635 if (0 < yysize && yysize <= yymsg_alloc)
1637 (void) yysyntax_error (yymsg, yystate, yychar);
1638 yyerror (yyscanner, jsgf, yymsg);
1642 yyerror (yyscanner, jsgf, YY_(
"syntax error"));
1644 goto yyexhaustedlab;
1652 if (yyerrstatus == 3)
1657 if (yychar <= YYEOF)
1660 if (yychar == YYEOF)
1665 yydestruct (
"Error: discarding",
1666 yytoken, &yylval, yyscanner, jsgf);
1691 YY_STACK_PRINT (yyss, yyssp);
1704 yyn = yypact[yystate];
1705 if (yyn != YYPACT_NINF)
1708 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1721 yydestruct (
"Error: popping",
1722 yystos[yystate], yyvsp, yyscanner, jsgf);
1725 YY_STACK_PRINT (yyss, yyssp);
1732 YY_SYMBOL_PRINT (
"Shifting", yystos[yyn], yyvsp, yylsp);
1752 #if !defined(yyoverflow) || YYERROR_VERBOSE
1757 yyerror (yyscanner, jsgf, YY_(
"memory exhausted"));
1763 if (yychar != YYEMPTY)
1764 yydestruct (
"Cleanup: discarding lookahead",
1765 yytoken, &yylval, yyscanner, jsgf);
1769 YY_STACK_PRINT (yyss, yyssp);
1770 while (yyssp != yyss)
1772 yydestruct (
"Cleanup: popping",
1773 yystos[*yyssp], yyvsp, yyscanner, jsgf);
1778 YYSTACK_FREE (yyss);
1781 if (yymsg != yymsgbuf)
1782 YYSTACK_FREE (yymsg);
1785 return YYID (yyresult);
1791 #line 150 "jsgf_parser.y"
1795 yyerror(yyscan_t lex,
jsgf_t *jsgf,
const char *s)
1797 E_ERROR(
"%s at line %d current token '%s'\n", s, yyget_lineno(lex), yyget_text(lex));
Internal definitions for JSGF grammar compiler.
#define ckd_calloc(n, sz)
Macros to simplify the use of above functions.
#define E_ERROR(...)
Print error message to error log.
Sphinx's memory allocation/deallocation routines.
SPHINXBASE_EXPORT void ckd_free(void *ptr)
Test and free a 1-D array.
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...
char * charset
JSGF charset (default UTF-8)
SPHINXBASE_EXPORT glist_t glist_reverse(glist_t g)
Reverse the order of the given glist.
Implementation of logging routines.
char * version
JSGF version (from header)
Hash table implementation.
char * locale
JSGF locale (default C)