47 #define YYBISON_VERSION "2.5"
50 #define YYSKELETON_NAME "yacc.c"
62 #define YYLSP_NEEDED 0
69 #line 37 "jsgf_parser.y"
71 #define YYERROR_VERBOSE
81 #include "jsgf_parser.h"
82 #include "jsgf_scanner.h"
86 #pragma warning(disable: 4273)
89 void yyerror(yyscan_t lex,
jsgf_t *jsgf,
const char *s);
94 #line 95 "jsgf_parser.c"
102 #ifdef YYERROR_VERBOSE
103 # undef YYERROR_VERBOSE
104 # define YYERROR_VERBOSE 1
106 # define YYERROR_VERBOSE 0
110 #ifndef YYTOKEN_TABLE
111 # define YYTOKEN_TABLE 0
144 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
149 #line 65 "jsgf_parser.y"
160 #line 161 "jsgf_parser.c"
162 # define YYSTYPE_IS_TRIVIAL 1
163 # define yystype YYSTYPE
164 # define YYSTYPE_IS_DECLARED 1
172 #line 173 "jsgf_parser.c"
179 typedef YYTYPE_UINT8 yytype_uint8;
181 typedef unsigned char yytype_uint8;
185 typedef YYTYPE_INT8 yytype_int8;
186 #elif (defined __STDC__ || defined __C99__FUNC__ \
187 || defined __cplusplus || defined _MSC_VER)
188 typedef signed char yytype_int8;
190 typedef short int yytype_int8;
194 typedef YYTYPE_UINT16 yytype_uint16;
196 typedef unsigned short int yytype_uint16;
200 typedef YYTYPE_INT16 yytype_int16;
202 typedef short int yytype_int16;
206 # ifdef __SIZE_TYPE__
207 # define YYSIZE_T __SIZE_TYPE__
208 # elif defined size_t
209 # define YYSIZE_T size_t
210 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
211 || defined __cplusplus || defined _MSC_VER)
213 # define YYSIZE_T size_t
215 # define YYSIZE_T unsigned int
219 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
222 # if defined YYENABLE_NLS && YYENABLE_NLS
224 # include <libintl.h>
225 # define YY_(msgid) dgettext ("bison-runtime", msgid)
229 # define YY_(msgid) msgid
234 #if ! defined lint || defined __GNUC__
235 # define YYUSE(e) ((void) (e))
244 #if (defined __STDC__ || defined __C99__FUNC__ \
245 || defined __cplusplus || defined _MSC_VER)
258 #if ! defined yyoverflow || YYERROR_VERBOSE
262 # ifdef YYSTACK_USE_ALLOCA
263 # if YYSTACK_USE_ALLOCA
265 # define YYSTACK_ALLOC __builtin_alloca
266 # elif defined __BUILTIN_VA_ARG_INCR
269 # define YYSTACK_ALLOC __alloca
270 # elif defined _MSC_VER
272 # define alloca _alloca
274 # define YYSTACK_ALLOC alloca
275 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
276 || defined __cplusplus || defined _MSC_VER)
278 # ifndef EXIT_SUCCESS
279 # define EXIT_SUCCESS 0
286 # ifdef YYSTACK_ALLOC
288 # define YYSTACK_FREE(Ptr) do { ; } while (YYID (0))
289 # ifndef YYSTACK_ALLOC_MAXIMUM
294 # define YYSTACK_ALLOC_MAXIMUM 4032
297 # define YYSTACK_ALLOC YYMALLOC
298 # define YYSTACK_FREE YYFREE
299 # ifndef YYSTACK_ALLOC_MAXIMUM
300 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
302 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
303 && ! ((defined YYMALLOC || defined malloc) \
304 && (defined YYFREE || defined free)))
306 # ifndef EXIT_SUCCESS
307 # define EXIT_SUCCESS 0
311 # define YYMALLOC malloc
312 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
313 || defined __cplusplus || defined _MSC_VER)
314 void *malloc (YYSIZE_T);
319 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
320 || defined __cplusplus || defined _MSC_VER)
328 #if (! defined yyoverflow \
329 && (! defined __cplusplus \
330 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
335 yytype_int16 yyss_alloc;
340 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
344 # define YYSTACK_BYTES(N) \
345 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
346 + YYSTACK_GAP_MAXIMUM)
348 # define YYCOPY_NEEDED 1
355 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
358 YYSIZE_T yynewbytes; \
359 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
360 Stack = &yyptr->Stack_alloc; \
361 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
362 yyptr += yynewbytes / sizeof (*yyptr); \
368 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
372 # if defined __GNUC__ && 1 < __GNUC__
373 # define YYCOPY(To, From, Count) \
374 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
376 # define YYCOPY(To, From, Count) \
380 for (yyi = 0; yyi < (Count); yyi++) \
381 (To)[yyi] = (From)[yyi]; \
404 #define YYMAXUTOK 265
406 #define YYTRANSLATE(YYX) \
407 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
410 static const yytype_uint8 yytranslate[] =
412 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
413 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
414 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
415 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
416 14, 15, 18, 19, 2, 2, 2, 2, 2, 2,
417 2, 2, 2, 2, 2, 2, 2, 2, 2, 11,
418 2, 12, 2, 2, 2, 2, 2, 2, 2, 2,
419 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
421 2, 16, 2, 17, 2, 2, 2, 2, 2, 2,
422 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
424 2, 2, 2, 2, 13, 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, 2, 2, 2, 2,
436 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
437 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
444 static const yytype_uint8 yyprhs[] =
446 0, 0, 3, 5, 8, 12, 15, 18, 22, 27,
447 33, 37, 39, 42, 46, 48, 51, 56, 62, 64,
448 68, 70, 73, 75, 78, 80, 83, 87, 91, 93,
453 static const yytype_int8 yyrhs[] =
455 21, 0, -1, 22, -1, 22, 27, -1, 22, 25,
456 27, -1, 23, 24, -1, 3, 11, -1, 3, 7,
457 11, -1, 3, 7, 7, 11, -1, 3, 7, 7,
458 7, 11, -1, 4, 7, 11, -1, 26, -1, 25,
459 26, -1, 5, 8, 11, -1, 28, -1, 27, 28,
460 -1, 8, 12, 29, 11, -1, 6, 8, 12, 29,
461 11, -1, 30, -1, 29, 13, 30, -1, 31, -1,
462 30, 31, -1, 32, -1, 31, 9, -1, 35, -1,
463 10, 35, -1, 14, 29, 15, -1, 16, 29, 17,
464 -1, 7, -1, 8, -1, 33, -1, 34, -1, 35,
469 static const yytype_uint8 yyrline[] =
471 0, 82, 82, 83, 84, 87, 90, 91, 92, 93,
472 97, 100, 101, 104, 107, 108, 111, 112, 115, 116,
473 121, 123, 127, 128, 132, 133, 136, 139, 142, 143,
478 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
481 static const char *
const yytname[] =
483 "$end",
"error",
"$undefined",
"HEADER",
"GRAMMAR",
"IMPORT",
"PUBLIC",
484 "TOKEN",
"RULENAME",
"TAG",
"WEIGHT",
"';'",
"'='",
"'|'",
"'('",
"')'",
485 "'['",
"']'",
"'*'",
"'+'",
"$accept",
"grammar",
"header",
486 "jsgf_header",
"grammar_header",
"import_header",
"import_statement",
487 "rule_list",
"rule",
"alternate_list",
"rule_expansion",
488 "tagged_rule_item",
"rule_item",
"rule_group",
"rule_optional",
496 static const yytype_uint16 yytoknum[] =
498 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
499 265, 59, 61, 124, 40, 41, 91, 93, 42, 43
504 static const yytype_uint8 yyr1[] =
506 0, 20, 21, 21, 21, 22, 23, 23, 23, 23,
507 24, 25, 25, 26, 27, 27, 28, 28, 29, 29,
508 30, 30, 31, 31, 32, 32, 33, 34, 35, 35,
513 static const yytype_uint8 yyr2[] =
515 0, 2, 1, 2, 3, 2, 2, 3, 4, 5,
516 3, 1, 2, 3, 1, 2, 4, 5, 1, 3,
517 1, 2, 1, 2, 1, 2, 3, 3, 1, 1,
524 static const yytype_uint8 yydefact[] =
526 0, 0, 0, 2, 0, 0, 6, 1, 0, 0,
527 0, 0, 11, 3, 14, 0, 5, 0, 7, 0,
528 0, 0, 12, 4, 15, 0, 0, 8, 13, 0,
529 28, 29, 0, 0, 0, 0, 18, 20, 22, 30,
530 31, 24, 10, 9, 0, 25, 0, 0, 16, 0,
531 21, 23, 32, 33, 17, 26, 27, 19
535 static const yytype_int8 yydefgoto[] =
537 -1, 2, 3, 4, 16, 11, 12, 13, 14, 35,
538 36, 37, 38, 39, 40, 41
543 #define YYPACT_NINF -37
544 static const yytype_int8 yypact[] =
546 -1, -2, 36, 22, 35, 8, -37, -37, 32, 33,
547 30, 22, -37, 17, -37, 37, -37, 13, -37, 34,
548 31, -4, -37, 17, -37, 38, 39, -37, -37, -4,
549 -37, -37, 0, -4, -4, 18, -4, 42, -37, -37,
550 -37, 19, -37, -37, 21, 19, 20, 9, -37, -4,
551 42, -37, -37, -37, -37, -37, -37, -4
555 static const yytype_int8 yypgoto[] =
557 -37, -37, -37, -37, -37, -37, 41, 43, -12, -16,
558 -3, -36, -37, -37, -37, 15
564 #define YYTABLE_NINF -1
565 static const yytype_uint8 yytable[] =
567 50, 24, 1, 30, 31, 5, 32, 30, 31, 6,
568 33, 24, 34, 44, 33, 17, 34, 46, 47, 18,
569 26, 50, 49, 9, 27, 10, 56, 8, 9, 48,
570 10, 49, 54, 49, 49, 55, 7, 52, 53, 15,
571 19, 20, 21, 29, 25, 28, 57, 45, 0, 42,
575 #define yypact_value_is_default(yystate) \
578 #define yytable_value_is_error(yytable_value) \
581 static const yytype_int8 yycheck[] =
583 36, 13, 3, 7, 8, 7, 10, 7, 8, 11,
584 14, 23, 16, 29, 14, 7, 16, 33, 34, 11,
585 7, 57, 13, 6, 11, 8, 17, 5, 6, 11,
586 8, 13, 11, 13, 13, 15, 0, 18, 19, 4,
587 8, 8, 12, 12, 7, 11, 49, 32, -1, 11,
593 static const yytype_uint8 yystos[] =
595 0, 3, 21, 22, 23, 7, 11, 0, 5, 6,
596 8, 25, 26, 27, 28, 4, 24, 7, 11, 8,
597 8, 12, 26, 27, 28, 7, 7, 11, 11, 12,
598 7, 8, 10, 14, 16, 29, 30, 31, 32, 33,
599 34, 35, 11, 11, 29, 35, 29, 29, 11, 13,
600 31, 9, 18, 19, 11, 15, 17, 30
603 #define yyerrok (yyerrstatus = 0)
604 #define yyclearin (yychar = YYEMPTY)
608 #define YYACCEPT goto yyacceptlab
609 #define YYABORT goto yyabortlab
610 #define YYERROR goto yyerrorlab
620 #define YYFAIL goto yyerrlab
628 #define YYRECOVERING() (!!yyerrstatus)
630 #define YYBACKUP(Token, Value) \
632 if (yychar == YYEMPTY && yylen == 1) \
641 yyerror (yyscanner, jsgf, YY_("syntax error: cannot back up")); \
648 #define YYERRCODE 256
655 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
656 #ifndef YYLLOC_DEFAULT
657 # define YYLLOC_DEFAULT(Current, Rhs, N) \
661 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
662 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
663 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
664 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
668 (Current).first_line = (Current).last_line = \
669 YYRHSLOC (Rhs, 0).last_line; \
670 (Current).first_column = (Current).last_column = \
671 YYRHSLOC (Rhs, 0).last_column; \
679 #ifndef YY_LOCATION_PRINT
680 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
687 # define YYLEX yylex (&yylval, YYLEX_PARAM)
689 # define YYLEX yylex (&yylval, yyscanner)
697 # define YYFPRINTF fprintf
700 # define YYDPRINTF(Args) \
706 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
710 YYFPRINTF (stderr, "%s ", Title); \
711 yy_symbol_print (stderr, \
712 Type, Value, yyscanner, jsgf); \
713 YYFPRINTF (stderr, "\n"); \
723 #if (defined __STDC__ || defined __C99__FUNC__ \
724 || defined __cplusplus || defined _MSC_VER)
726 yy_symbol_value_print (FILE *yyoutput,
int yytype,
YYSTYPE const *
const yyvaluep,
void* yyscanner,
jsgf_t *jsgf)
729 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf)
732 YYSTYPE const * const yyvaluep;
742 if (yytype < YYNTOKENS)
743 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
759 #if (defined __STDC__ || defined __C99__FUNC__ \
760 || defined __cplusplus || defined _MSC_VER)
762 yy_symbol_print (FILE *yyoutput,
int yytype,
YYSTYPE const *
const yyvaluep,
void* yyscanner,
jsgf_t *jsgf)
765 yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf)
768 YYSTYPE const * const yyvaluep;
773 if (yytype < YYNTOKENS)
774 YYFPRINTF (yyoutput,
"token %s (", yytname[yytype]);
776 YYFPRINTF (yyoutput,
"nterm %s (", yytname[yytype]);
778 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, jsgf);
779 YYFPRINTF (yyoutput,
")");
787 #if (defined __STDC__ || defined __C99__FUNC__ \
788 || defined __cplusplus || defined _MSC_VER)
790 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
793 yy_stack_print (yybottom, yytop)
794 yytype_int16 *yybottom;
798 YYFPRINTF (stderr,
"Stack now");
799 for (; yybottom <= yytop; yybottom++)
801 int yybot = *yybottom;
802 YYFPRINTF (stderr,
" %d", yybot);
804 YYFPRINTF (stderr,
"\n");
807 # define YY_STACK_PRINT(Bottom, Top) \
810 yy_stack_print ((Bottom), (Top)); \
818 #if (defined __STDC__ || defined __C99__FUNC__ \
819 || defined __cplusplus || defined _MSC_VER)
821 yy_reduce_print (
YYSTYPE *yyvsp,
int yyrule,
void* yyscanner,
jsgf_t *jsgf)
824 yy_reduce_print (yyvsp, yyrule, yyscanner, jsgf)
831 int yynrhs = yyr2[yyrule];
833 unsigned long int yylno = yyrline[yyrule];
834 YYFPRINTF (stderr,
"Reducing stack by rule %d (line %lu):\n",
837 for (yyi = 0; yyi < yynrhs; yyi++)
839 YYFPRINTF (stderr,
" $%d = ", yyi + 1);
840 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
841 &(yyvsp[(yyi + 1) - (yynrhs)])
843 YYFPRINTF (stderr,
"\n");
847 # define YY_REDUCE_PRINT(Rule) \
850 yy_reduce_print (yyvsp, Rule, yyscanner, jsgf); \
857 # define YYDPRINTF(Args)
858 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
859 # define YY_STACK_PRINT(Bottom, Top)
860 # define YY_REDUCE_PRINT(Rule)
866 # define YYINITDEPTH 200
877 # define YYMAXDEPTH 10000
884 # if defined __GLIBC__ && defined _STRING_H
885 # define yystrlen strlen
888 #if (defined __STDC__ || defined __C99__FUNC__ \
889 || defined __cplusplus || defined _MSC_VER)
891 yystrlen (
const char *yystr)
899 for (yylen = 0; yystr[yylen]; yylen++)
907 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
908 # define yystpcpy stpcpy
912 #if (defined __STDC__ || defined __C99__FUNC__ \
913 || defined __cplusplus || defined _MSC_VER)
915 yystpcpy (
char *yydest,
const char *yysrc)
918 yystpcpy (yydest, yysrc)
924 const char *yys = yysrc;
926 while ((*yyd++ = *yys++) !=
'\0')
943 yytnamerr (
char *yyres,
const char *yystr)
948 char const *yyp = yystr;
955 goto do_not_strip_quotes;
959 goto do_not_strip_quotes;
972 do_not_strip_quotes: ;
976 return yystrlen (yystr);
978 return yystpcpy (yyres, yystr) - yyres;
991 yysyntax_error (YYSIZE_T *yymsg_alloc,
char **yymsg,
992 yytype_int16 *yyssp,
int yytoken)
994 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
995 YYSIZE_T yysize = yysize0;
997 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
999 const char *yyformat = 0;
1001 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1033 if (yytoken != YYEMPTY)
1035 int yyn = yypact[*yyssp];
1036 yyarg[yycount++] = yytname[yytoken];
1037 if (!yypact_value_is_default (yyn))
1042 int yyxbegin = yyn < 0 ? -yyn : 0;
1044 int yychecklim = YYLAST - yyn + 1;
1045 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1048 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1049 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1050 && !yytable_value_is_error (yytable[yyx + yyn]))
1052 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1058 yyarg[yycount++] = yytname[yyx];
1059 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1060 if (! (yysize <= yysize1
1061 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1070 # define YYCASE_(N, S) \
1074 YYCASE_(0, YY_(
"syntax error"));
1075 YYCASE_(1, YY_(
"syntax error, unexpected %s"));
1076 YYCASE_(2, YY_(
"syntax error, unexpected %s, expecting %s"));
1077 YYCASE_(3, YY_(
"syntax error, unexpected %s, expecting %s or %s"));
1078 YYCASE_(4, YY_(
"syntax error, unexpected %s, expecting %s or %s or %s"));
1079 YYCASE_(5, YY_(
"syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1083 yysize1 = yysize + yystrlen (yyformat);
1084 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1088 if (*yymsg_alloc < yysize)
1090 *yymsg_alloc = 2 * yysize;
1091 if (! (yysize <= *yymsg_alloc
1092 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1093 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1103 while ((*yyp = *yyformat) !=
'\0')
1104 if (*yyp ==
'%' && yyformat[1] ==
's' && yyi < yycount)
1106 yyp += yytnamerr (yyp, yyarg[yyi++]);
1124 #if (defined __STDC__ || defined __C99__FUNC__ \
1125 || defined __cplusplus || defined _MSC_VER)
1127 yydestruct (
const char *yymsg,
int yytype,
YYSTYPE *yyvaluep,
void* yyscanner,
jsgf_t *jsgf)
1130 yydestruct (yymsg, yytype, yyvaluep, yyscanner, jsgf)
1144 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1156 #ifdef YYPARSE_PARAM
1157 #if defined __STDC__ || defined __cplusplus
1158 int yyparse (
void *YYPARSE_PARAM);
1163 #if defined __STDC__ || defined __cplusplus
1164 int yyparse (
void* yyscanner,
jsgf_t *jsgf);
1175 #ifdef YYPARSE_PARAM
1176 #if (defined __STDC__ || defined __C99__FUNC__ \
1177 || defined __cplusplus || defined _MSC_VER)
1179 yyparse (
void *YYPARSE_PARAM)
1182 yyparse (YYPARSE_PARAM)
1183 void *YYPARSE_PARAM;
1186 #if (defined __STDC__ || defined __C99__FUNC__ \
1187 || defined __cplusplus || defined _MSC_VER)
1189 yyparse (
void* yyscanner,
jsgf_t *jsgf)
1192 yyparse (yyscanner, jsgf)
1219 yytype_int16 yyssa[YYINITDEPTH];
1221 yytype_int16 *yyssp;
1228 YYSIZE_T yystacksize;
1241 char *yymsg = yymsgbuf;
1242 YYSIZE_T yymsg_alloc =
sizeof yymsgbuf;
1245 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1254 yystacksize = YYINITDEPTH;
1256 YYDPRINTF ((stderr,
"Starting parse\n"));
1283 if (yyss + yystacksize - 1 <= yyssp)
1286 YYSIZE_T yysize = yyssp - yyss + 1;
1294 yytype_int16 *yyss1 = yyss;
1300 yyoverflow (YY_(
"memory exhausted"),
1301 &yyss1, yysize *
sizeof (*yyssp),
1302 &yyvs1, yysize *
sizeof (*yyvsp),
1309 # ifndef YYSTACK_RELOCATE
1310 goto yyexhaustedlab;
1313 if (YYMAXDEPTH <= yystacksize)
1314 goto yyexhaustedlab;
1316 if (YYMAXDEPTH < yystacksize)
1317 yystacksize = YYMAXDEPTH;
1320 yytype_int16 *yyss1 = yyss;
1322 (
union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1324 goto yyexhaustedlab;
1325 YYSTACK_RELOCATE (yyss_alloc, yyss);
1326 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1327 # undef YYSTACK_RELOCATE
1329 YYSTACK_FREE (yyss1);
1334 yyssp = yyss + yysize - 1;
1335 yyvsp = yyvs + yysize - 1;
1337 YYDPRINTF ((stderr,
"Stack size increased to %lu\n",
1338 (
unsigned long int) yystacksize));
1340 if (yyss + yystacksize - 1 <= yyssp)
1344 YYDPRINTF ((stderr,
"Entering state %d\n", yystate));
1346 if (yystate == YYFINAL)
1360 yyn = yypact[yystate];
1361 if (yypact_value_is_default (yyn))
1367 if (yychar == YYEMPTY)
1369 YYDPRINTF ((stderr,
"Reading a token: "));
1373 if (yychar <= YYEOF)
1375 yychar = yytoken = YYEOF;
1376 YYDPRINTF ((stderr,
"Now at end of input.\n"));
1380 yytoken = YYTRANSLATE (yychar);
1381 YY_SYMBOL_PRINT (
"Next token is", yytoken, &yylval, &yylloc);
1387 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1392 if (yytable_value_is_error (yyn))
1404 YY_SYMBOL_PRINT (
"Shifting", yytoken, &yylval, &yylloc);
1419 yyn = yydefact[yystate];
1440 yyval = yyvsp[1-yylen];
1443 YY_REDUCE_PRINT (yyn);
1449 #line 87 "jsgf_parser.y"
1450 { jsgf->
name = (yyvsp[(2) - (2)].name); }
1456 #line 91 "jsgf_parser.y"
1457 { jsgf->
version = (yyvsp[(2) - (3)].name); }
1463 #line 92 "jsgf_parser.y"
1464 { jsgf->
version = (yyvsp[(2) - (4)].name); jsgf->
charset = (yyvsp[(3) - (4)].name); }
1470 #line 93 "jsgf_parser.y"
1471 { jsgf->
version = (yyvsp[(2) - (5)].name); jsgf->
charset = (yyvsp[(3) - (5)].name);
1472 jsgf->
locale = (yyvsp[(4) - (5)].name); }
1478 #line 97 "jsgf_parser.y"
1479 { (yyval.name) = (yyvsp[(2) - (3)].name); }
1485 #line 104 "jsgf_parser.y"
1486 { jsgf_import_rule(jsgf, (yyvsp[(2) - (3)].name));
ckd_free((yyvsp[(2) - (3)].name)); }
1492 #line 111 "jsgf_parser.y"
1493 { jsgf_define_rule(jsgf, (yyvsp[(1) - (4)].name), (yyvsp[(3) - (4)].rhs), 0);
ckd_free((yyvsp[(1) - (4)].name)); }
1499 #line 112 "jsgf_parser.y"
1500 { jsgf_define_rule(jsgf, (yyvsp[(2) - (5)].name), (yyvsp[(4) - (5)].rhs), 1);
ckd_free((yyvsp[(2) - (5)].name)); }
1506 #line 115 "jsgf_parser.y"
1507 { (yyval.rhs) = (yyvsp[(1) - (1)].rhs); (yyval.rhs)->atoms =
glist_reverse((yyval.rhs)->atoms); }
1513 #line 116 "jsgf_parser.y"
1514 { (yyval.rhs) = (yyvsp[(3) - (3)].rhs);
1516 (yyval.rhs)->alt = (yyvsp[(1) - (3)].rhs); }
1522 #line 121 "jsgf_parser.y"
1523 { (yyval.rhs) =
ckd_calloc(1,
sizeof(*(yyval.rhs)));
1524 (yyval.rhs)->atoms =
glist_add_ptr((yyval.rhs)->atoms, (yyvsp[(1) - (1)].atom)); }
1530 #line 123 "jsgf_parser.y"
1531 { (yyval.rhs) = (yyvsp[(1) - (2)].rhs);
1532 (yyval.rhs)->atoms =
glist_add_ptr((yyval.rhs)->atoms, (yyvsp[(2) - (2)].atom)); }
1538 #line 128 "jsgf_parser.y"
1539 { (yyval.atom) = (yyvsp[(1) - (2)].atom);
1540 (yyval.atom)->tags =
glist_add_ptr((yyval.atom)->tags, (yyvsp[(2) - (2)].name)); }
1546 #line 133 "jsgf_parser.y"
1547 { (yyval.atom) = (yyvsp[(2) - (2)].atom); (yyval.atom)->weight = (yyvsp[(1) - (2)].weight); }
1553 #line 136 "jsgf_parser.y"
1554 { (yyval.rule) = jsgf_define_rule(jsgf, NULL, (yyvsp[(2) - (3)].rhs), 0); }
1560 #line 139 "jsgf_parser.y"
1561 { (yyval.rule) = jsgf_optional_new(jsgf, (yyvsp[(2) - (3)].rhs)); }
1567 #line 142 "jsgf_parser.y"
1568 { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].name), 1.0);
ckd_free((yyvsp[(1) - (1)].name)); }
1574 #line 143 "jsgf_parser.y"
1575 { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].name), 1.0);
ckd_free((yyvsp[(1) - (1)].name)); }
1581 #line 144 "jsgf_parser.y"
1582 { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].rule)->name, 1.0); }
1588 #line 145 "jsgf_parser.y"
1589 { (yyval.atom) = jsgf_atom_new((yyvsp[(1) - (1)].rule)->name, 1.0); }
1595 #line 146 "jsgf_parser.y"
1596 { (yyval.atom) = jsgf_kleene_new(jsgf, (yyvsp[(1) - (2)].atom), 0); }
1602 #line 147 "jsgf_parser.y"
1603 { (yyval.atom) = jsgf_kleene_new(jsgf, (yyvsp[(1) - (2)].atom), 1); }
1609 #line 1610 "jsgf_parser.c"
1623 YY_SYMBOL_PRINT (
"-> $$ =", yyr1[yyn], &yyval, &yyloc);
1627 YY_STACK_PRINT (yyss, yyssp);
1637 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1638 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1639 yystate = yytable[yystate];
1641 yystate = yydefgoto[yyn - YYNTOKENS];
1652 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1658 #if ! YYERROR_VERBOSE
1659 yyerror (yyscanner, jsgf, YY_(
"syntax error"));
1661 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1664 char const *yymsgp = YY_(
"syntax error");
1665 int yysyntax_error_status;
1666 yysyntax_error_status = YYSYNTAX_ERROR;
1667 if (yysyntax_error_status == 0)
1669 else if (yysyntax_error_status == 1)
1671 if (yymsg != yymsgbuf)
1672 YYSTACK_FREE (yymsg);
1673 yymsg = (
char *) YYSTACK_ALLOC (yymsg_alloc);
1677 yymsg_alloc =
sizeof yymsgbuf;
1678 yysyntax_error_status = 2;
1682 yysyntax_error_status = YYSYNTAX_ERROR;
1686 yyerror (yyscanner, jsgf, yymsgp);
1687 if (yysyntax_error_status == 2)
1688 goto yyexhaustedlab;
1690 # undef YYSYNTAX_ERROR
1696 if (yyerrstatus == 3)
1701 if (yychar <= YYEOF)
1704 if (yychar == YYEOF)
1709 yydestruct (
"Error: discarding",
1710 yytoken, &yylval, yyscanner, jsgf);
1735 YY_STACK_PRINT (yyss, yyssp);
1748 yyn = yypact[yystate];
1749 if (!yypact_value_is_default (yyn))
1752 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1765 yydestruct (
"Error: popping",
1766 yystos[yystate], yyvsp, yyscanner, jsgf);
1769 YY_STACK_PRINT (yyss, yyssp);
1776 YY_SYMBOL_PRINT (
"Shifting", yystos[yyn], yyvsp, yylsp);
1796 #if !defined(yyoverflow) || YYERROR_VERBOSE
1801 yyerror (yyscanner, jsgf, YY_(
"memory exhausted"));
1807 if (yychar != YYEMPTY)
1811 yytoken = YYTRANSLATE (yychar);
1812 yydestruct (
"Cleanup: discarding lookahead",
1813 yytoken, &yylval, yyscanner, jsgf);
1818 YY_STACK_PRINT (yyss, yyssp);
1819 while (yyssp != yyss)
1821 yydestruct (
"Cleanup: popping",
1822 yystos[*yyssp], yyvsp, yyscanner, jsgf);
1827 YYSTACK_FREE (yyss);
1830 if (yymsg != yymsgbuf)
1831 YYSTACK_FREE (yymsg);
1834 return YYID (yyresult);
1840 #line 150 "jsgf_parser.y"
1844 yyerror(yyscan_t lex,
jsgf_t *jsgf,
const char *s)
1846 E_ERROR(
"%s at line %d current token '%s'\n", s, yyget_lineno(lex), yyget_text(lex));