31 |
# Location type. |
# Location type. |
32 |
m4_define_default([b4_location_type], [yyltype]) |
m4_define_default([b4_location_type], [yyltype]) |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
## ------------------------ ## |
37 |
|
## Pure/impure interfaces. ## |
38 |
|
## ------------------------ ## |
39 |
|
|
40 |
|
|
41 |
|
# b4_lex_param |
42 |
|
# ------------ |
43 |
# Accumule in b4_lex_param all the yylex arguments. |
# Accumule in b4_lex_param all the yylex arguments. |
44 |
# Yes, this is quite ugly... |
# Yes, this is quite ugly... |
45 |
m4_define([b4_lex_param], |
m4_define([b4_lex_param], |
47 |
b4_location_if([, [[YYLTYPE *], [yyllocp]]])])dnl |
b4_location_if([, [[YYLTYPE *], [yyllocp]]])])dnl |
48 |
m4_ifdef([b4_lex_param], [, ]b4_lex_param))) |
m4_ifdef([b4_lex_param], [, ]b4_lex_param))) |
49 |
|
|
|
# Yes, this is quite ugly... |
|
|
m4_define_default([b4_parse_param]) |
|
|
m4_ifdef([b4_parse_param], |
|
|
[m4_define([b4_parse_param], |
|
|
b4_parse_param)]) |
|
50 |
|
|
51 |
|
# b4_user_formals |
52 |
|
# --------------- |
53 |
|
m4_define([b4_user_formals], |
54 |
|
[m4_ifset([b4_parse_param], [, b4_c_ansi_formals(b4_parse_param)])]) |
55 |
|
|
56 |
|
|
57 |
|
# b4_pure_args |
58 |
|
# ------------ |
59 |
|
# Arguments passed to yyerror: user args plus yylloc. |
60 |
|
m4_define([b4_pure_args], |
61 |
|
[b4_pure_if([b4_location_if([, yylocp])])[]b4_user_args]) |
62 |
|
|
63 |
|
|
64 |
|
# b4_pure_formals |
65 |
|
# --------------- |
66 |
|
# Arguments passed to yyerror: user formals plus yyllocp. |
67 |
|
m4_define([b4_pure_formals], |
68 |
|
[b4_pure_if([b4_location_if([, YYLTYPE *yylocp])])[]b4_user_formals]) |
69 |
|
|
70 |
|
|
71 |
|
# b4_lpure_args |
72 |
|
# ------------- |
73 |
|
# Same as above, but on the lookahead, hence yyllocp instead of yylocp. |
74 |
|
m4_define([b4_lpure_args], |
75 |
|
[b4_pure_if([b4_location_if([, yyllocp])])[]b4_user_args]) |
76 |
|
|
77 |
|
|
78 |
|
# b4_lpure_formals |
79 |
|
# ---------------- |
80 |
|
# Same as above, but on the lookahead, hence yyllocp instead of yylocp. |
81 |
|
m4_define([b4_lpure_formals], |
82 |
|
[b4_pure_if([b4_location_if([YYLTYPE *yyllocp])])[]b4_user_formals]) |
83 |
|
|
84 |
|
|
85 |
## ----------------- ## |
## ----------------- ## |
155 |
[ |
[ |
156 |
/* This is the parser code for GLR (Generalized LR) parser. */ |
/* This is the parser code for GLR (Generalized LR) parser. */ |
157 |
|
|
|
/* FIXME: minimize these */ |
|
158 |
#include <assert.h> |
#include <assert.h> |
|
#include <setjmp.h> |
|
|
#include <stdarg.h> |
|
159 |
#include <stdio.h> |
#include <stdio.h> |
160 |
#include <stdlib.h> |
#include <stdlib.h> |
161 |
#include <string.h> |
#include <string.h> |
162 |
|
#include <stdarg.h> |
163 |
|
#include <setjmp.h> |
164 |
|
|
165 |
/* Identify Bison output. */ |
]b4_identification |
166 |
#define YYBISON 1 |
m4_if(b4_prefix[], [yy], [], |
|
|
|
|
/* Pure parsers. */ |
|
|
#define YYPURE ]b4_pure[ |
|
|
|
|
|
/* Using locations. */ |
|
|
#define YYLSP_NEEDED ]b4_locations_flag[ |
|
|
|
|
|
]m4_if(b4_prefix[], [yy], [], |
|
167 |
[/* If NAME_PREFIX is specified substitute the variables and functions |
[/* If NAME_PREFIX is specified substitute the variables and functions |
168 |
names. */ |
names. */ |
169 |
#define yyparse b4_prefix[]parse |
#define yyparse b4_prefix[]parse |
405 |
|
|
406 |
|
|
407 |
/* Prevent warning if -Wmissing-prototypes. */ |
/* Prevent warning if -Wmissing-prototypes. */ |
408 |
]b4_c_ansi_function_decl([yyparse], [int], b4_parse_param) |
]b4_c_ansi_function_decl([yyparse], [int], b4_parse_param)[ |
409 |
|
|
410 |
m4_ifset([b4_parse_param], |
/* Error token number */ |
|
[#define YY_USER_FORMALS , b4_c_ansi_formals(b4_parse_param) |
|
|
#define YY_USER_ARGS , b4_c_args(b4_parse_param)], |
|
|
[#define YY_USER_FORMALS |
|
|
#define YY_USER_ARGS]) |
|
|
|
|
|
|
|
|
[/* Error token number */ |
|
411 |
#define YYTERROR 1 |
#define YYTERROR 1 |
412 |
|
|
413 |
/* YYLLOC_DEFAULT -- Compute the default location (before the actions |
/* YYLLOC_DEFAULT -- Compute the default location (before the actions |
568 |
}; |
}; |
569 |
|
|
570 |
static void yyinitGLRStack (yyGLRStack* yystack, size_t yysize); |
static void yyinitGLRStack (yyGLRStack* yystack, size_t yysize); |
571 |
static void yyexpandGLRStack (yyGLRStack* yystack); |
static void yyexpandGLRStack (yyGLRStack* yystack]b4_pure_formals[); |
572 |
static void yyfreeGLRStack (yyGLRStack* yystack); |
static void yyfreeGLRStack (yyGLRStack* yystack); |
573 |
|
|
574 |
static void |
static void |
575 |
yyFail (yyGLRStack* yystack, const char* yyformat, ...) |
yyFail (yyGLRStack* yystack]b4_pure_formals[, const char* yyformat, ...) |
576 |
{ |
{ |
577 |
if (yyformat != NULL) |
if (yyformat != NULL) |
578 |
{ |
{ |
581 |
va_start (yyap, yyformat); |
va_start (yyap, yyformat); |
582 |
yystack->yyerrflag = 1; |
yystack->yyerrflag = 1; |
583 |
vsprintf (yymsg, yyformat, yyap); |
vsprintf (yymsg, yyformat, yyap); |
584 |
yyerror (yymsg); |
yyerror (yymsg]b4_pure_args[); |
585 |
} |
} |
586 |
longjmp (yystack->yyexception_buffer, 1); |
longjmp (yystack->yyexception_buffer, 1); |
587 |
} |
} |
604 |
static YYRESULTTAG |
static YYRESULTTAG |
605 |
yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp, |
yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp, |
606 |
YYSTYPE* yyvalp, YYLTYPE* yylocp, yyGLRStack* yystack |
YYSTYPE* yyvalp, YYLTYPE* yylocp, yyGLRStack* yystack |
607 |
YY_USER_FORMALS) |
]b4_user_formals[) |
608 |
{ |
{ |
609 |
/* Avoid `unused' warnings in there are no $n. */ |
/* Avoid `unused' warnings in there are no $n. */ |
610 |
(void) yystack; |
(void) yystack; |
636 |
# undef YYBACKUP |
# undef YYBACKUP |
637 |
# define YYBACKUP(Token, Value) \ |
# define YYBACKUP(Token, Value) \ |
638 |
do { \ |
do { \ |
639 |
yyerror ("syntax error: cannot back up"); \ |
yyerror ("syntax error: cannot back up"]b4_pure_args[); \ |
640 |
YYERROR; \ |
YYERROR; \ |
641 |
} while (0) |
} while (0) |
642 |
|
|
664 |
yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1) |
yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1) |
665 |
{ |
{ |
666 |
YYSTYPE yyval = *yy0; |
YYSTYPE yyval = *yy0; |
667 |
/* `Use' the arguments. */ |
/* `Use' the arguments. */ |
668 |
(void) yy0; |
(void) yy0; |
669 |
(void) yy1; |
(void) yy1; |
670 |
|
|
675 |
return yyval; |
return yyval; |
676 |
} |
} |
677 |
[ |
[ |
678 |
/* Bison grammar-table manipulation */ |
/* Bison grammar-table manipulation. */ |
679 |
|
|
680 |
/** Number of symbols composing the right hand side of rule #RULE. */ |
/** Number of symbols composing the right hand side of rule #RULE. */ |
681 |
static inline int |
static inline int |
771 |
|
|
772 |
static void |
static void |
773 |
yyaddDeferredAction (yyGLRStack* yystack, yyGLRState* yystate, |
yyaddDeferredAction (yyGLRStack* yystack, yyGLRState* yystate, |
774 |
yyGLRState* rhs, yyRuleNum yyrule) |
yyGLRState* rhs, yyRuleNum yyrule]b4_pure_formals[) |
775 |
{ |
{ |
776 |
yySemanticOption* yynewItem; |
yySemanticOption* yynewItem; |
777 |
yynewItem = &yystack->yynextFree->yyoption; |
yynewItem = &yystack->yynextFree->yyoption; |
783 |
yynewItem->yynext = yystate->yysemantics.yyfirstVal; |
yynewItem->yynext = yystate->yysemantics.yyfirstVal; |
784 |
yystate->yysemantics.yyfirstVal = yynewItem; |
yystate->yysemantics.yyfirstVal = yynewItem; |
785 |
if (yystack->yyspaceLeft < YYHEADROOM) |
if (yystack->yyspaceLeft < YYHEADROOM) |
786 |
yyexpandGLRStack (yystack); |
yyexpandGLRStack (yystack]b4_pure_args[); |
787 |
} |
} |
788 |
|
|
789 |
/* GLRStacks */ |
/* GLRStacks */ |
828 |
allocation, so that we can avoid having external pointers exist |
allocation, so that we can avoid having external pointers exist |
829 |
across an allocation. */ |
across an allocation. */ |
830 |
static void |
static void |
831 |
yyexpandGLRStack (yyGLRStack* yystack) |
yyexpandGLRStack (yyGLRStack* yystack]b4_pure_formals[) |
832 |
{ |
{ |
833 |
#if YYSTACKEXPANDABLE |
#if YYSTACKEXPANDABLE |
834 |
yyGLRStack yynewStack; |
yyGLRStack yynewStack; |
837 |
size_t yyn; |
size_t yyn; |
838 |
yysize = yystack->yynextFree - yystack->yyitems; |
yysize = yystack->yynextFree - yystack->yyitems; |
839 |
if (YYMAXDEPTH <= yysize) |
if (YYMAXDEPTH <= yysize) |
840 |
yyFail (yystack, "parsing stack overflow (%d items)", yysize); |
yyFail (yystack][]b4_pure_args[, |
841 |
|
"parsing stack overflow (%d items)", yysize); |
842 |
yynewSize = 2*yysize; |
yynewSize = 2*yysize; |
843 |
if (YYMAXDEPTH < yynewSize) |
if (YYMAXDEPTH < yynewSize) |
844 |
yynewSize = YYMAXDEPTH; |
yynewSize = YYMAXDEPTH; |
885 |
|
|
886 |
#else |
#else |
887 |
|
|
888 |
yyFail (yystack, "parsing stack overflow (%d items)", yysize); |
yyFail (yystack][]b4_lpure_args[, |
889 |
|
"parsing stack overflow (%d items)", yysize); |
890 |
#endif |
#endif |
891 |
} |
} |
892 |
|
|
958 |
* LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */ |
* LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */ |
959 |
static inline void |
static inline void |
960 |
yyglrShift (yyGLRStack* yystack, int yyk, yyStateNum yylrState, size_t yyposn, |
yyglrShift (yyGLRStack* yystack, int yyk, yyStateNum yylrState, size_t yyposn, |
961 |
YYSTYPE yysval, YYLTYPE* yylocp) |
YYSTYPE yysval, YYLTYPE* yylocp]b4_user_formals[) |
962 |
{ |
{ |
963 |
yyGLRStackItem* yynewItem; |
yyGLRStackItem* yynewItem; |
964 |
|
|
974 |
yynewItem->yystate.yysemantics.yysval = yysval; |
yynewItem->yystate.yysemantics.yysval = yysval; |
975 |
yynewItem->yystate.yyloc = *yylocp; |
yynewItem->yystate.yyloc = *yylocp; |
976 |
if (yystack->yyspaceLeft < YYHEADROOM) |
if (yystack->yyspaceLeft < YYHEADROOM) |
977 |
yyexpandGLRStack (yystack); |
yyexpandGLRStack (yystack]b4_pure_args[); |
978 |
} |
} |
979 |
|
|
980 |
/** Shift to a new state on stack #K of STACK, to a new state |
/** Shift to a new state on stack #K of STACK, to a new state |
982 |
* the (unresolved) semantic value of RHS under the action for RULE. */ |
* the (unresolved) semantic value of RHS under the action for RULE. */ |
983 |
static inline void |
static inline void |
984 |
yyglrShiftDefer (yyGLRStack* yystack, int yyk, yyStateNum yylrState, |
yyglrShiftDefer (yyGLRStack* yystack, int yyk, yyStateNum yylrState, |
985 |
size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule) |
size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule]b4_pure_formals[) |
986 |
{ |
{ |
987 |
yyGLRStackItem* yynewItem; |
yyGLRStackItem* yynewItem; |
988 |
|
|
996 |
yystack->yytops.yystates[yyk] = &yynewItem->yystate; |
yystack->yytops.yystates[yyk] = &yynewItem->yystate; |
997 |
yystack->yynextFree += 1; |
yystack->yynextFree += 1; |
998 |
yystack->yyspaceLeft -= 1; |
yystack->yyspaceLeft -= 1; |
999 |
yyaddDeferredAction (yystack, &yynewItem->yystate, rhs, yyrule); |
yyaddDeferredAction (yystack, &yynewItem->yystate, rhs, yyrule]b4_pure_args[); |
1000 |
} |
} |
1001 |
|
|
1002 |
/** Pop the symbols consumed by reduction #RULE from the top of stack |
/** Pop the symbols consumed by reduction #RULE from the top of stack |
1007 |
* for userAction. */ |
* for userAction. */ |
1008 |
static inline int |
static inline int |
1009 |
yydoAction (yyGLRStack* yystack, int yyk, yyRuleNum yyrule, |
yydoAction (yyGLRStack* yystack, int yyk, yyRuleNum yyrule, |
1010 |
YYSTYPE* yyvalp, YYLTYPE* yylocp YY_USER_FORMALS) |
YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[) |
1011 |
{ |
{ |
1012 |
int yynrhs = yyrhsLength (yyrule); |
int yynrhs = yyrhsLength (yyrule); |
1013 |
|
|
1030 |
*yylocp = rhs[1-yynrhs].yystate.yyloc; |
*yylocp = rhs[1-yynrhs].yystate.yyloc; |
1031 |
} |
} |
1032 |
return yyuserAction (yyrule, yynrhs, rhs, |
return yyuserAction (yyrule, yynrhs, rhs, |
1033 |
yyvalp, yylocp, yystack YY_USER_ARGS); |
yyvalp, yylocp, yystack]b4_user_args[); |
1034 |
} |
} |
1035 |
else |
else |
1036 |
{ |
{ |
1058 |
*yylocp = yyrhsVals[0].yystate.yyloc; |
*yylocp = yyrhsVals[0].yystate.yyloc; |
1059 |
} |
} |
1060 |
return yyuserAction (yyrule, yynrhs, yyrhsVals + (yynrhs-1), |
return yyuserAction (yyrule, yynrhs, yyrhsVals + (yynrhs-1), |
1061 |
yyvalp, yylocp, yystack YY_USER_ARGS); |
yyvalp, yylocp, yystack]b4_user_args[); |
1062 |
} |
} |
1063 |
} |
} |
1064 |
|
|
1101 |
*/ |
*/ |
1102 |
static inline YYRESULTTAG |
static inline YYRESULTTAG |
1103 |
yyglrReduce (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule, |
yyglrReduce (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule, |
1104 |
bool yyforceEval YY_USER_FORMALS) |
bool yyforceEval]b4_pure_formals[) |
1105 |
{ |
{ |
1106 |
size_t yyposn = yystack->yytops.yystates[yyk]->yyposn; |
size_t yyposn = yystack->yytops.yystates[yyk]->yyposn; |
1107 |
|
|
1111 |
YYLTYPE yyloc; |
YYLTYPE yyloc; |
1112 |
|
|
1113 |
YY_REDUCE_PRINT (yyk, yyrule); |
YY_REDUCE_PRINT (yyk, yyrule); |
1114 |
YYCHK (yydoAction (yystack, yyk, yyrule, &yysval, &yyloc YY_USER_ARGS)); |
YYCHK (yydoAction (yystack, yyk, yyrule, &yysval, &yyloc]b4_user_args[)); |
1115 |
yyglrShift (yystack, yyk, |
yyglrShift (yystack, yyk, |
1116 |
yyLRgotoState (yystack->yytops.yystates[yyk]->yylrState, |
yyLRgotoState (yystack->yytops.yystates[yyk]->yylrState, |
1117 |
yylhsNonterm (yyrule)), |
yylhsNonterm (yyrule)), |
1118 |
yyposn, yysval, &yyloc); |
yyposn, yysval, &yyloc]b4_user_args[); |
1119 |
YYDPRINTF ((stderr, "Stack %d entering state %d\n", |
YYDPRINTF ((stderr, "Stack %d entering state %d\n", |
1120 |
yyk, yystack->yytops.yystates[yyk]->yylrState)); |
yyk, yystack->yytops.yystates[yyk]->yylrState)); |
1121 |
} |
} |
1147 |
{ |
{ |
1148 |
if (yyp->yylrState == yynewLRState && yyp->yypred == yys) |
if (yyp->yylrState == yynewLRState && yyp->yypred == yys) |
1149 |
{ |
{ |
1150 |
yyaddDeferredAction (yystack, yyp, yys0, yyrule); |
yyaddDeferredAction (yystack, yyp, yys0, yyrule]b4_pure_args[); |
1151 |
yymarkStackDeleted (yystack, yyk); |
yymarkStackDeleted (yystack, yyk); |
1152 |
YYDPRINTF ((stderr, "Merging stack %d into stack %d.\n", |
YYDPRINTF ((stderr, "Merging stack %d into stack %d.\n", |
1153 |
yyk, yyi)); |
yyk, yyi)); |
1157 |
} |
} |
1158 |
} |
} |
1159 |
yystack->yytops.yystates[yyk] = yys; |
yystack->yytops.yystates[yyk] = yys; |
1160 |
yyglrShiftDefer (yystack, yyk, yynewLRState, yyposn, yys0, yyrule); |
yyglrShiftDefer (yystack, yyk, yynewLRState, yyposn, yys0, yyrule]b4_pure_args[); |
1161 |
} |
} |
1162 |
return 0; |
return 0; |
1163 |
} |
} |
1257 |
|
|
1258 |
static YYRESULTTAG yyresolveValue (yySemanticOption* yyoptionList, |
static YYRESULTTAG yyresolveValue (yySemanticOption* yyoptionList, |
1259 |
yyGLRStack* yystack, YYSTYPE* yyvalp, |
yyGLRStack* yystack, YYSTYPE* yyvalp, |
1260 |
YYLTYPE* yylocp YY_USER_FORMALS); |
YYLTYPE* yylocp]b4_user_formals[); |
1261 |
|
|
1262 |
static YYRESULTTAG |
static YYRESULTTAG |
1263 |
yyresolveStates (yyGLRState* yys, int yyn, yyGLRStack* yystack YY_USER_FORMALS) |
yyresolveStates (yyGLRState* yys, int yyn, yyGLRStack* yystack]b4_user_formals[) |
1264 |
{ |
{ |
1265 |
YYRESULTTAG yyflag; |
YYRESULTTAG yyflag; |
1266 |
if (0 < yyn) |
if (0 < yyn) |
1267 |
{ |
{ |
1268 |
assert (yys->yypred != NULL); |
assert (yys->yypred != NULL); |
1269 |
yyflag = yyresolveStates (yys->yypred, yyn-1, yystack YY_USER_ARGS); |
yyflag = yyresolveStates (yys->yypred, yyn-1, yystack]b4_user_args[); |
1270 |
if (yyflag != yyok) |
if (yyflag != yyok) |
1271 |
return yyflag; |
return yyflag; |
1272 |
if (! yys->yyresolved) |
if (! yys->yyresolved) |
1273 |
{ |
{ |
1274 |
yyflag = yyresolveValue (yys->yysemantics.yyfirstVal, yystack, |
yyflag = yyresolveValue (yys->yysemantics.yyfirstVal, yystack, |
1275 |
&yys->yysemantics.yysval, &yys->yyloc |
&yys->yysemantics.yysval, &yys->yyloc |
1276 |
YY_USER_ARGS); |
]b4_user_args[); |
1277 |
if (yyflag != yyok) |
if (yyflag != yyok) |
1278 |
return yyflag; |
return yyflag; |
1279 |
yys->yyresolved = yytrue; |
yys->yyresolved = yytrue; |
1284 |
|
|
1285 |
static YYRESULTTAG |
static YYRESULTTAG |
1286 |
yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystack, |
yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystack, |
1287 |
YYSTYPE* yyvalp, YYLTYPE* yylocp YY_USER_FORMALS) |
YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[) |
1288 |
{ |
{ |
1289 |
yyGLRStackItem yyrhsVals[YYMAXRHS]; |
yyGLRStackItem yyrhsVals[YYMAXRHS]; |
1290 |
int yynrhs, yyi; |
int yynrhs, yyi; |
1291 |
yyGLRState* yys; |
yyGLRState* yys; |
1292 |
|
|
1293 |
yynrhs = yyrhsLength (yyopt->yyrule); |
yynrhs = yyrhsLength (yyopt->yyrule); |
1294 |
YYCHK (yyresolveStates (yyopt->yystate, yynrhs, yystack YY_USER_ARGS)); |
YYCHK (yyresolveStates (yyopt->yystate, yynrhs, yystack]b4_user_args[)); |
1295 |
for (yyi = yynrhs-1, yys = yyopt->yystate; 0 <= yyi; |
for (yyi = yynrhs-1, yys = yyopt->yystate; 0 <= yyi; |
1296 |
yyi -= 1, yys = yys->yypred) |
yyi -= 1, yys = yys->yypred) |
1297 |
{ |
{ |
1301 |
yyrhsVals[yyi].yystate.yyloc = yys->yyloc; |
yyrhsVals[yyi].yystate.yyloc = yys->yyloc; |
1302 |
} |
} |
1303 |
return yyuserAction (yyopt->yyrule, yynrhs, yyrhsVals + (yynrhs-1), |
return yyuserAction (yyopt->yyrule, yynrhs, yyrhsVals + (yynrhs-1), |
1304 |
yyvalp, yylocp, yystack YY_USER_ARGS); |
yyvalp, yylocp, yystack]b4_user_args[); |
1305 |
} |
} |
1306 |
|
|
1307 |
#if YYDEBUG |
#if YYDEBUG |
1352 |
|
|
1353 |
static void |
static void |
1354 |
yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1, |
yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1, |
1355 |
yyGLRStack* yystack) |
yyGLRStack* yystack]b4_pure_formals[) |
1356 |
{ |
{ |
1357 |
/* `Unused' warnings. */ |
/* `Unused' warnings. */ |
1358 |
(void) yyx0; |
(void) yyx0; |
1366 |
yyreportTree (yyx1, 2); |
yyreportTree (yyx1, 2); |
1367 |
YYFPRINTF (stderr, "\n"); |
YYFPRINTF (stderr, "\n"); |
1368 |
#endif |
#endif |
1369 |
yyFail (yystack, "ambiguity detected"); |
yyFail (yystack][]b4_pure_args[, "ambiguity detected"); |
1370 |
} |
} |
1371 |
|
|
1372 |
|
|
1374 |
* actions, and return the result. */ |
* actions, and return the result. */ |
1375 |
static YYRESULTTAG |
static YYRESULTTAG |
1376 |
yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystack, |
yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystack, |
1377 |
YYSTYPE* yyvalp, YYLTYPE* yylocp YY_USER_FORMALS) |
YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[) |
1378 |
{ |
{ |
1379 |
yySemanticOption* yybest; |
yySemanticOption* yybest; |
1380 |
yySemanticOption* yyp; |
yySemanticOption* yyp; |
1390 |
switch (yypreference (yybest, yyp)) |
switch (yypreference (yybest, yyp)) |
1391 |
{ |
{ |
1392 |
case 0: |
case 0: |
1393 |
yyreportAmbiguity (yybest, yyp, yystack); |
yyreportAmbiguity (yybest, yyp, yystack]b4_pure_args[); |
1394 |
break; |
break; |
1395 |
case 1: |
case 1: |
1396 |
yymerge = 1; |
yymerge = 1; |
1407 |
if (yymerge) |
if (yymerge) |
1408 |
{ |
{ |
1409 |
int yyprec = yydprec[yybest->yyrule]; |
int yyprec = yydprec[yybest->yyrule]; |
1410 |
YYCHK (yyresolveAction (yybest, yystack, yyvalp, yylocp YY_USER_ARGS)); |
YYCHK (yyresolveAction (yybest, yystack, yyvalp, yylocp]b4_user_args[)); |
1411 |
for (yyp = yybest->yynext; yyp != NULL; yyp = yyp->yynext) |
for (yyp = yybest->yynext; yyp != NULL; yyp = yyp->yynext) |
1412 |
{ |
{ |
1413 |
if (yyprec == yydprec[yyp->yyrule]) |
if (yyprec == yydprec[yyp->yyrule]) |
1414 |
{ |
{ |
1415 |
YYSTYPE yyval1; |
YYSTYPE yyval1; |
1416 |
YYLTYPE yydummy; |
YYLTYPE yydummy; |
1417 |
YYCHK (yyresolveAction (yyp, yystack, &yyval1, &yydummy YY_USER_ARGS)); |
YYCHK (yyresolveAction (yyp, yystack, &yyval1, &yydummy]b4_user_args[)); |
1418 |
*yyvalp = yyuserMerge (yymerger[yyp->yyrule], yyvalp, &yyval1); |
*yyvalp = yyuserMerge (yymerger[yyp->yyrule], yyvalp, &yyval1); |
1419 |
} |
} |
1420 |
} |
} |
1421 |
return yyok; |
return yyok; |
1422 |
} |
} |
1423 |
else |
else |
1424 |
return yyresolveAction (yybest, yystack, yyvalp, yylocp YY_USER_ARGS); |
return yyresolveAction (yybest, yystack, yyvalp, yylocp]b4_user_args[); |
1425 |
} |
} |
1426 |
|
|
1427 |
static YYRESULTTAG |
static YYRESULTTAG |
1428 |
yyresolveStack (yyGLRStack* yystack YY_USER_FORMALS) |
yyresolveStack (yyGLRStack* yystack]b4_user_formals[) |
1429 |
{ |
{ |
1430 |
if (yystack->yysplitPoint != NULL) |
if (yystack->yysplitPoint != NULL) |
1431 |
{ |
{ |
1437 |
yys = yys->yypred, yyn += 1) |
yys = yys->yypred, yyn += 1) |
1438 |
; |
; |
1439 |
YYCHK (yyresolveStates (yystack->yytops.yystates[0], yyn, yystack |
YYCHK (yyresolveStates (yystack->yytops.yystates[0], yyn, yystack |
1440 |
YY_USER_ARGS)); |
]b4_user_args[)); |
1441 |
} |
} |
1442 |
return yyok; |
return yyok; |
1443 |
} |
} |
1475 |
static YYRESULTTAG |
static YYRESULTTAG |
1476 |
yyprocessOneStack (yyGLRStack* yystack, int yyk, |
yyprocessOneStack (yyGLRStack* yystack, int yyk, |
1477 |
size_t yyposn, YYSTYPE* yylvalp, YYLTYPE* yyllocp |
size_t yyposn, YYSTYPE* yylvalp, YYLTYPE* yyllocp |
1478 |
YY_USER_FORMALS) |
]b4_user_formals[) |
1479 |
{ |
{ |
1480 |
int yyaction; |
int yyaction; |
1481 |
const short* yyconflicts; |
const short* yyconflicts; |
1496 |
yymarkStackDeleted (yystack, yyk); |
yymarkStackDeleted (yystack, yyk); |
1497 |
return yyok; |
return yyok; |
1498 |
} |
} |
1499 |
YYCHK (yyglrReduce (yystack, yyk, yyrule, yyfalse YY_USER_ARGS)); |
YYCHK (yyglrReduce (yystack, yyk, yyrule, yyfalse]b4_lpure_args[)); |
1500 |
} |
} |
1501 |
else |
else |
1502 |
{ |
{ |
1516 |
YYDPRINTF ((stderr, "Splitting off stack %d from %d.\n", |
YYDPRINTF ((stderr, "Splitting off stack %d from %d.\n", |
1517 |
yynewStack, yyk)); |
yynewStack, yyk)); |
1518 |
YYCHK (yyglrReduce (yystack, yynewStack, |
YYCHK (yyglrReduce (yystack, yynewStack, |
1519 |
*yyconflicts, yyfalse YY_USER_ARGS)); |
*yyconflicts, yyfalse]b4_lpure_args[)); |
1520 |
YYCHK (yyprocessOneStack (yystack, yynewStack, yyposn, |
YYCHK (yyprocessOneStack (yystack, yynewStack, yyposn, |
1521 |
yylvalp, yyllocp YY_USER_ARGS)); |
yylvalp, yyllocp]b4_user_args[)); |
1522 |
yyconflicts += 1; |
yyconflicts += 1; |
1523 |
} |
} |
1524 |
|
|
1526 |
{ |
{ |
1527 |
YYDPRINTF ((stderr, "Shifting token %s on stack %d, ", |
YYDPRINTF ((stderr, "Shifting token %s on stack %d, ", |
1528 |
yytokenName (*yytokenp), yyk)); |
yytokenName (*yytokenp), yyk)); |
1529 |
yyglrShift (yystack, yyk, yyaction, yyposn+1, *yylvalp, yyllocp); |
yyglrShift (yystack, yyk, yyaction, yyposn+1, |
1530 |
|
*yylvalp, yyllocp]b4_user_args[); |
1531 |
YYDPRINTF ((stderr, "which is now in state #%d\n", |
YYDPRINTF ((stderr, "which is now in state #%d\n", |
1532 |
yystack->yytops.yystates[yyk]->yylrState)); |
yystack->yytops.yystates[yyk]->yylrState)); |
1533 |
break; |
break; |
1539 |
break; |
break; |
1540 |
} |
} |
1541 |
else |
else |
1542 |
YYCHK (yyglrReduce (yystack, yyk, -yyaction, yyfalse YY_USER_ARGS)); |
YYCHK (yyglrReduce (yystack, yyk, -yyaction, yyfalse]b4_lpure_args[)); |
1543 |
} |
} |
1544 |
} |
} |
1545 |
return yyok; |
return yyok; |
1546 |
} |
} |
1547 |
|
|
1548 |
static void |
static void |
1549 |
yyreportParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp) |
yyreportParseError (yyGLRStack* yystack, |
1550 |
|
YYSTYPE* yylvalp, YYLTYPE* yyllocp]b4_user_formals[) |
1551 |
{ |
{ |
1552 |
/* `Unused' warnings. */ |
/* `Unused' warnings. */ |
1553 |
(void) yylvalp; |
(void) yylvalp; |
1591 |
yyprefix = " or "; |
yyprefix = " or "; |
1592 |
} |
} |
1593 |
} |
} |
1594 |
yyerror (yymsg); |
yyerror (yymsg]b4_lpure_args[); |
1595 |
free (yymsg); |
free (yymsg); |
1596 |
} |
} |
1597 |
else |
else |
1598 |
#endif |
#endif |
1599 |
yyerror ("parse error"); |
yyerror ("parse error"]b4_lpure_args[); |
1600 |
yynerrs += 1; |
yynerrs += 1; |
1601 |
} |
} |
1602 |
} |
} |
1605 |
YYLVALP, and YYLLOCP point to the syntactic category, semantic |
YYLVALP, and YYLLOCP point to the syntactic category, semantic |
1606 |
value, and location of the lookahead. */ |
value, and location of the lookahead. */ |
1607 |
static void |
static void |
1608 |
yyrecoverParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp) |
yyrecoverParseError (yyGLRStack* yystack, |
1609 |
|
YYSTYPE* yylvalp, YYLTYPE* yyllocp]b4_user_formals[) |
1610 |
{ |
{ |
1611 |
yySymbol* const yytokenp = yystack->yytokenp; |
yySymbol* const yytokenp = yystack->yytokenp; |
1612 |
size_t yyk; |
size_t yyk; |
1620 |
while (yytrue) |
while (yytrue) |
1621 |
{ |
{ |
1622 |
if (*yytokenp == YYEOF) |
if (*yytokenp == YYEOF) |
1623 |
yyFail (yystack, NULL); |
yyFail (yystack][]b4_lpure_args[, NULL); |
1624 |
if (*yytokenp != YYEMPTY) |
if (*yytokenp != YYEMPTY) |
1625 |
YYDPRINTF ((stderr, "Discarding token %s\n", |
YYDPRINTF ((stderr, "Discarding token %s\n", |
1626 |
yytokenName (*yytokenp))); |
yytokenName (*yytokenp))); |
1631 |
yyj = yypact[yystack->yytops.yystates[0]->yylrState]; |
yyj = yypact[yystack->yytops.yystates[0]->yylrState]; |
1632 |
if (yyj == YYPACT_NINF) |
if (yyj == YYPACT_NINF) |
1633 |
/* Something's not right; we shouldn't be here. */ |
/* Something's not right; we shouldn't be here. */ |
1634 |
yyFail (yystack, NULL); |
yyFail (yystack][]b4_lpure_args[, NULL); |
1635 |
yyj += *yytokenp; |
yyj += *yytokenp; |
1636 |
if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != *yytokenp) |
if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != *yytokenp) |
1637 |
{ |
{ |
1647 |
if (yystack->yytops.yystates[yyk] != NULL) |
if (yystack->yytops.yystates[yyk] != NULL) |
1648 |
break; |
break; |
1649 |
if (yyk >= yystack->yytops.yysize) |
if (yyk >= yystack->yytops.yysize) |
1650 |
yyFail (yystack, NULL); |
yyFail (yystack][]b4_lpure_args[, NULL); |
1651 |
for (yyk += 1; yyk < yystack->yytops.yysize; yyk += 1) |
for (yyk += 1; yyk < yystack->yytops.yysize; yyk += 1) |
1652 |
yymarkStackDeleted (yystack, yyk); |
yymarkStackDeleted (yystack, yyk); |
1653 |
yyremoveDeletes (yystack); |
yyremoveDeletes (yystack); |
1661 |
yycheck[yyj] == YYTERROR && yyisShiftAction (yytable[yyj])) |
yycheck[yyj] == YYTERROR && yyisShiftAction (yytable[yyj])) |
1662 |
{ |
{ |
1663 |
yyglrShift (yystack, 0, yytable[yyj], |
yyglrShift (yystack, 0, yytable[yyj], |
1664 |
yystack->yytops.yystates[0]->yyposn, *yylvalp, yyllocp); |
yystack->yytops.yystates[0]->yyposn, |
1665 |
|
*yylvalp, yyllocp]b4_user_args[); |
1666 |
break; |
break; |
1667 |
} |
} |
1668 |
yystack->yytops.yystates[0] = yystack->yytops.yystates[0]->yypred; |
yystack->yytops.yystates[0] = yystack->yytops.yystates[0]->yypred; |
1670 |
yystack->yyspaceLeft += 1; |
yystack->yyspaceLeft += 1; |
1671 |
} |
} |
1672 |
if (yystack->yytops.yystates[0] == NULL) |
if (yystack->yytops.yystates[0] == NULL) |
1673 |
yyFail (yystack, NULL); |
yyFail (yystack][]b4_lpure_args[, NULL); |
1674 |
} |
} |
1675 |
|
|
1676 |
#define YYCHK1(YYE) \ |
#define YYCHK1(YYE) \ |
1718 |
if (setjmp (yystack.yyexception_buffer) != 0) |
if (setjmp (yystack.yyexception_buffer) != 0) |
1719 |
goto yyDone; |
goto yyDone; |
1720 |
|
|
1721 |
yyglrShift (&yystack, 0, 0, 0, yyval_default, &yyloc_default); |
yyglrShift (&yystack, 0, 0, 0, yyval_default, &yyloc_default]b4_user_args[); |
1722 |
yytoken = YYEMPTY; |
yytoken = YYEMPTY; |
1723 |
yyposn = 0; |
yyposn = 0; |
1724 |
|
|
1743 |
yyrule = yydefaultAction (yystate); |
yyrule = yydefaultAction (yystate); |
1744 |
if (yyrule == 0) |
if (yyrule == 0) |
1745 |
{ |
{ |
1746 |
yyreportParseError (&yystack, yylvalp, yyllocp); |
yyreportParseError (&yystack, yylvalp, yyllocp]b4_user_args[); |
1747 |
goto yyuser_error; |
goto yyuser_error; |
1748 |
} |
} |
1749 |
YYCHK1 (yyglrReduce (&yystack, 0, yyrule, yytrue YY_USER_ARGS)); |
YYCHK1 (yyglrReduce (&yystack, 0, yyrule, yytrue]b4_lpure_args[)); |
1750 |
} |
} |
1751 |
else |
else |
1752 |
{ |
{ |
1768 |
if (yytoken != YYEOF) |
if (yytoken != YYEOF) |
1769 |
yytoken = YYEMPTY; |
yytoken = YYEMPTY; |
1770 |
yyposn += 1; |
yyposn += 1; |
1771 |
yyglrShift (&yystack, 0, yyaction, yyposn, yylval, yyllocp); |
yyglrShift (&yystack, 0, yyaction, yyposn, |
1772 |
|
yylval, yyllocp]b4_user_args[); |
1773 |
if (0 < yystack.yyerrState) |
if (0 < yystack.yyerrState) |
1774 |
yystack.yyerrState -= 1; |
yystack.yyerrState -= 1; |
1775 |
YYDPRINTF ((stderr, "Entering state %d\n", |
YYDPRINTF ((stderr, "Entering state %d\n", |
1777 |
} |
} |
1778 |
else if (yyisErrorAction (yyaction)) |
else if (yyisErrorAction (yyaction)) |
1779 |
{ |
{ |
1780 |
yyreportParseError (&yystack, yylvalp, yyllocp); |
yyreportParseError (&yystack, yylvalp, yyllocp]b4_user_args[); |
1781 |
goto yyuser_error; |
goto yyuser_error; |
1782 |
} |
} |
1783 |
else |
else |
1784 |
YYCHK1 (yyglrReduce (&yystack, 0, -yyaction, yytrue YY_USER_ARGS)); |
YYCHK1 (yyglrReduce (&yystack, 0, -yyaction, yytrue]b4_lpure_args[)); |
1785 |
} |
} |
1786 |
} |
} |
1787 |
|
|
1791 |
int yyn = yystack.yytops.yysize; |
int yyn = yystack.yytops.yysize; |
1792 |
for (yys = 0; yys < yyn; yys += 1) |
for (yys = 0; yys < yyn; yys += 1) |
1793 |
YYCHK1 (yyprocessOneStack (&yystack, yys, yyposn, |
YYCHK1 (yyprocessOneStack (&yystack, yys, yyposn, |
1794 |
yylvalp, yyllocp YY_USER_ARGS)); |
yylvalp, yyllocp]b4_user_args[)); |
1795 |
yytoken = YYEMPTY; |
yytoken = YYEMPTY; |
1796 |
yyposn += 1; |
yyposn += 1; |
1797 |
yyremoveDeletes (&yystack); |
yyremoveDeletes (&yystack); |
1799 |
{ |
{ |
1800 |
yyundeleteLastStack (&yystack); |
yyundeleteLastStack (&yystack); |
1801 |
if (yystack.yytops.yysize == 0) |
if (yystack.yytops.yysize == 0) |
1802 |
yyFail (&yystack, "parse error"); |
yyFail (&yystack][]b4_lpure_args[, "parse error"); |
1803 |
YYCHK1 (yyresolveStack (&yystack YY_USER_ARGS)); |
YYCHK1 (yyresolveStack (&yystack]b4_user_args[)); |
1804 |
YYDPRINTF ((stderr, "Returning to deterministic operation.\n")); |
YYDPRINTF ((stderr, "Returning to deterministic operation.\n")); |
1805 |
yyreportParseError (&yystack, yylvalp, yyllocp); |
yyreportParseError (&yystack, yylvalp, yyllocp]b4_user_args[); |
1806 |
goto yyuser_error; |
goto yyuser_error; |
1807 |
} |
} |
1808 |
else if (yystack.yytops.yysize == 1) |
else if (yystack.yytops.yysize == 1) |
1809 |
{ |
{ |
1810 |
YYCHK1 (yyresolveStack (&yystack YY_USER_ARGS)); |
YYCHK1 (yyresolveStack (&yystack]b4_user_args[)); |
1811 |
YYDPRINTF ((stderr, "Returning to deterministic operation.\n")); |
YYDPRINTF ((stderr, "Returning to deterministic operation.\n")); |
1812 |
yycompressStack (&yystack); |
yycompressStack (&yystack); |
1813 |
break; |
break; |
1815 |
} |
} |
1816 |
continue; |
continue; |
1817 |
yyuser_error: |
yyuser_error: |
1818 |
yyrecoverParseError (&yystack, yylvalp, yyllocp); |
yyrecoverParseError (&yystack, yylvalp, yyllocp]b4_user_args[); |
1819 |
yyposn = yystack.yytops.yystates[0]->yyposn; |
yyposn = yystack.yytops.yystates[0]->yyposn; |
1820 |
} |
} |
1821 |
yyDone: |
yyDone: |