1 c72688ef 2003-12-04 devnull #define YYFLAG -1000
2 cae9bfe9 2005-02-14 devnull #define YYERROR goto yyerrlab
3 cae9bfe9 2005-02-14 devnull #define YYACCEPT return(0)
4 cae9bfe9 2005-02-14 devnull #define YYABORT return(1)
5 c72688ef 2003-12-04 devnull #define yyclearin yychar = -1
6 c72688ef 2003-12-04 devnull #define yyerrok yyerrflag = 0
8 c72688ef 2003-12-04 devnull #ifdef yydebug
9 c72688ef 2003-12-04 devnull #include "y.debug"
11 c72688ef 2003-12-04 devnull #define yydebug 0
12 cae9bfe9 2005-02-14 devnull static const char* yytoknames[1]; /* for debugging */
13 cae9bfe9 2005-02-14 devnull static const char* yystates[1]; /* for debugging */
16 c72688ef 2003-12-04 devnull /* parser for yacc output */
17 cae9bfe9 2005-02-14 devnull #ifdef YYARG
18 cae9bfe9 2005-02-14 devnull #define yynerrs yyarg->yynerrs
19 cae9bfe9 2005-02-14 devnull #define yyerrflag yyarg->yyerrflag
20 cae9bfe9 2005-02-14 devnull #define yyval yyarg->yyval
21 cae9bfe9 2005-02-14 devnull #define yylval yyarg->yylval
23 c72688ef 2003-12-04 devnull int yynerrs = 0; /* number of errors */
24 c72688ef 2003-12-04 devnull int yyerrflag = 0; /* error recovery flag */
27 c72688ef 2003-12-04 devnull extern int fprint(int, char*, ...);
28 c72688ef 2003-12-04 devnull extern int sprint(char*, char*, ...);
30 cae9bfe9 2005-02-14 devnull static const char*
31 c72688ef 2003-12-04 devnull yytokname(int yyc)
33 c72688ef 2003-12-04 devnull static char x[10];
35 c72688ef 2003-12-04 devnull if(yyc > 0 && yyc <= sizeof(yytoknames)/sizeof(yytoknames[0]))
36 c72688ef 2003-12-04 devnull if(yytoknames[yyc-1])
37 c72688ef 2003-12-04 devnull return yytoknames[yyc-1];
38 c72688ef 2003-12-04 devnull sprint(x, "<%d>", yyc);
39 c72688ef 2003-12-04 devnull return x;
42 cae9bfe9 2005-02-14 devnull static const char*
43 c72688ef 2003-12-04 devnull yystatname(int yys)
45 c72688ef 2003-12-04 devnull static char x[10];
47 c72688ef 2003-12-04 devnull if(yys >= 0 && yys < sizeof(yystates)/sizeof(yystates[0]))
48 c72688ef 2003-12-04 devnull if(yystates[yys])
49 c72688ef 2003-12-04 devnull return yystates[yys];
50 c72688ef 2003-12-04 devnull sprint(x, "<%d>\n", yys);
51 c72688ef 2003-12-04 devnull return x;
54 cae9bfe9 2005-02-14 devnull static long
55 cae9bfe9 2005-02-14 devnull #ifdef YYARG
56 cae9bfe9 2005-02-14 devnull yylex1(struct Yyarg *yyarg)
58 c72688ef 2003-12-04 devnull yylex1(void)
61 c72688ef 2003-12-04 devnull long yychar;
62 cae9bfe9 2005-02-14 devnull const long *t3p;
65 cae9bfe9 2005-02-14 devnull #ifdef YYARG
66 cae9bfe9 2005-02-14 devnull yychar = yylex(yyarg);
68 c72688ef 2003-12-04 devnull yychar = yylex();
70 c72688ef 2003-12-04 devnull if(yychar <= 0) {
71 c72688ef 2003-12-04 devnull c = yytok1[0];
72 c72688ef 2003-12-04 devnull goto out;
74 c72688ef 2003-12-04 devnull if(yychar < sizeof(yytok1)/sizeof(yytok1[0])) {
75 c72688ef 2003-12-04 devnull c = yytok1[yychar];
76 c72688ef 2003-12-04 devnull goto out;
78 c72688ef 2003-12-04 devnull if(yychar >= YYPRIVATE)
79 c72688ef 2003-12-04 devnull if(yychar < YYPRIVATE+sizeof(yytok2)/sizeof(yytok2[0])) {
80 c72688ef 2003-12-04 devnull c = yytok2[yychar-YYPRIVATE];
81 c72688ef 2003-12-04 devnull goto out;
83 c72688ef 2003-12-04 devnull for(t3p=yytok3;; t3p+=2) {
84 c72688ef 2003-12-04 devnull c = t3p[0];
85 c72688ef 2003-12-04 devnull if(c == yychar) {
86 c72688ef 2003-12-04 devnull c = t3p[1];
87 c72688ef 2003-12-04 devnull goto out;
89 c72688ef 2003-12-04 devnull if(c == 0)
95 c72688ef 2003-12-04 devnull if(c == 0)
96 c72688ef 2003-12-04 devnull c = yytok2[1]; /* unknown char */
97 c72688ef 2003-12-04 devnull if(yydebug >= 3)
98 c72688ef 2003-12-04 devnull fprint(2, "lex %.4lux %s\n", yychar, yytokname(c));
99 c72688ef 2003-12-04 devnull return c;
103 cae9bfe9 2005-02-14 devnull #ifdef YYARG
104 cae9bfe9 2005-02-14 devnull yyparse(struct Yyarg *yyarg)
106 c72688ef 2003-12-04 devnull yyparse(void)
111 c72688ef 2003-12-04 devnull YYSTYPE yyv;
112 c72688ef 2003-12-04 devnull int yys;
113 c72688ef 2003-12-04 devnull } yys[YYMAXDEPTH], *yyp, *yypt;
114 cae9bfe9 2005-02-14 devnull const short *yyxi;
115 c72688ef 2003-12-04 devnull int yyj, yym, yystate, yyn, yyg;
116 c72688ef 2003-12-04 devnull long yychar;
117 cae9bfe9 2005-02-14 devnull #ifndef YYARG
118 c72688ef 2003-12-04 devnull YYSTYPE save1, save2;
119 c72688ef 2003-12-04 devnull int save3, save4;
121 c72688ef 2003-12-04 devnull save1 = yylval;
122 c72688ef 2003-12-04 devnull save2 = yyval;
123 c72688ef 2003-12-04 devnull save3 = yynerrs;
124 c72688ef 2003-12-04 devnull save4 = yyerrflag;
127 c72688ef 2003-12-04 devnull yystate = 0;
128 c72688ef 2003-12-04 devnull yychar = -1;
129 c72688ef 2003-12-04 devnull yynerrs = 0;
130 c72688ef 2003-12-04 devnull yyerrflag = 0;
131 310ae033 2017-01-06 rsc yyp = &yys[0];
133 c72688ef 2003-12-04 devnull goto yystack;
136 c72688ef 2003-12-04 devnull yyn = 0;
137 c72688ef 2003-12-04 devnull goto ret;
140 c72688ef 2003-12-04 devnull yyn = 1;
141 c72688ef 2003-12-04 devnull goto ret;
144 cae9bfe9 2005-02-14 devnull #ifndef YYARG
145 c72688ef 2003-12-04 devnull yylval = save1;
146 c72688ef 2003-12-04 devnull yyval = save2;
147 c72688ef 2003-12-04 devnull yynerrs = save3;
148 c72688ef 2003-12-04 devnull yyerrflag = save4;
150 c72688ef 2003-12-04 devnull return yyn;
152 c72688ef 2003-12-04 devnull yystack:
153 c72688ef 2003-12-04 devnull /* put a state and value onto the stack */
154 c72688ef 2003-12-04 devnull if(yydebug >= 4)
155 c72688ef 2003-12-04 devnull fprint(2, "char %s in %s", yytokname(yychar), yystatname(yystate));
158 c72688ef 2003-12-04 devnull if(yyp >= &yys[YYMAXDEPTH]) {
159 c72688ef 2003-12-04 devnull yyerror("yacc stack overflow");
160 c72688ef 2003-12-04 devnull goto ret1;
162 c72688ef 2003-12-04 devnull yyp->yys = yystate;
163 c72688ef 2003-12-04 devnull yyp->yyv = yyval;
165 c72688ef 2003-12-04 devnull yynewstate:
166 c72688ef 2003-12-04 devnull yyn = yypact[yystate];
167 c72688ef 2003-12-04 devnull if(yyn <= YYFLAG)
168 c72688ef 2003-12-04 devnull goto yydefault; /* simple state */
169 c72688ef 2003-12-04 devnull if(yychar < 0)
170 cae9bfe9 2005-02-14 devnull #ifdef YYARG
171 cae9bfe9 2005-02-14 devnull yychar = yylex1(yyarg);
173 c72688ef 2003-12-04 devnull yychar = yylex1();
175 c72688ef 2003-12-04 devnull yyn += yychar;
176 c72688ef 2003-12-04 devnull if(yyn < 0 || yyn >= YYLAST)
177 c72688ef 2003-12-04 devnull goto yydefault;
178 c72688ef 2003-12-04 devnull yyn = yyact[yyn];
179 c72688ef 2003-12-04 devnull if(yychk[yyn] == yychar) { /* valid shift */
180 c72688ef 2003-12-04 devnull yychar = -1;
181 c72688ef 2003-12-04 devnull yyval = yylval;
182 c72688ef 2003-12-04 devnull yystate = yyn;
183 c72688ef 2003-12-04 devnull if(yyerrflag > 0)
184 c72688ef 2003-12-04 devnull yyerrflag--;
185 c72688ef 2003-12-04 devnull goto yystack;
188 c72688ef 2003-12-04 devnull yydefault:
189 c72688ef 2003-12-04 devnull /* default state action */
190 c72688ef 2003-12-04 devnull yyn = yydef[yystate];
191 c72688ef 2003-12-04 devnull if(yyn == -2) {
192 c72688ef 2003-12-04 devnull if(yychar < 0)
193 cae9bfe9 2005-02-14 devnull #ifdef YYARG
194 cae9bfe9 2005-02-14 devnull yychar = yylex1(yyarg);
196 cae9bfe9 2005-02-14 devnull yychar = yylex1();
199 c72688ef 2003-12-04 devnull /* look through exception table */
200 c72688ef 2003-12-04 devnull for(yyxi=yyexca;; yyxi+=2)
201 c72688ef 2003-12-04 devnull if(yyxi[0] == -1 && yyxi[1] == yystate)
203 c72688ef 2003-12-04 devnull for(yyxi += 2;; yyxi += 2) {
204 c72688ef 2003-12-04 devnull yyn = yyxi[0];
205 c72688ef 2003-12-04 devnull if(yyn < 0 || yyn == yychar)
208 c72688ef 2003-12-04 devnull yyn = yyxi[1];
209 c72688ef 2003-12-04 devnull if(yyn < 0)
210 c72688ef 2003-12-04 devnull goto ret0;
212 c72688ef 2003-12-04 devnull if(yyn == 0) {
213 c72688ef 2003-12-04 devnull /* error ... attempt to resume parsing */
214 c72688ef 2003-12-04 devnull switch(yyerrflag) {
215 c72688ef 2003-12-04 devnull case 0: /* brand new error */
216 c72688ef 2003-12-04 devnull yyerror("syntax error");
217 c72688ef 2003-12-04 devnull if(yydebug >= 1) {
218 c72688ef 2003-12-04 devnull fprint(2, "%s", yystatname(yystate));
219 c72688ef 2003-12-04 devnull fprint(2, "saw %s\n", yytokname(yychar));
221 53e2a4c6 2005-02-17 devnull goto yyerrlab;
222 53e2a4c6 2005-02-17 devnull yyerrlab:
223 cae9bfe9 2005-02-14 devnull yynerrs++;
226 c72688ef 2003-12-04 devnull case 2: /* incompletely recovered error ... try again */
227 c72688ef 2003-12-04 devnull yyerrflag = 3;
229 c72688ef 2003-12-04 devnull /* find a state where "error" is a legal shift action */
230 c72688ef 2003-12-04 devnull while(yyp >= yys) {
231 c72688ef 2003-12-04 devnull yyn = yypact[yyp->yys] + YYERRCODE;
232 c72688ef 2003-12-04 devnull if(yyn >= 0 && yyn < YYLAST) {
233 c72688ef 2003-12-04 devnull yystate = yyact[yyn]; /* simulate a shift of "error" */
234 c72688ef 2003-12-04 devnull if(yychk[yystate] == YYERRCODE)
235 c72688ef 2003-12-04 devnull goto yystack;
238 c72688ef 2003-12-04 devnull /* the current yyp has no shift onn "error", pop stack */
239 c72688ef 2003-12-04 devnull if(yydebug >= 2)
240 c72688ef 2003-12-04 devnull fprint(2, "error recovery pops state %d, uncovers %d\n",
241 c72688ef 2003-12-04 devnull yyp->yys, (yyp-1)->yys );
244 c72688ef 2003-12-04 devnull /* there is no state on the stack with an error shift ... abort */
245 c72688ef 2003-12-04 devnull goto ret1;
247 c72688ef 2003-12-04 devnull case 3: /* no shift yet; clobber input char */
248 c72688ef 2003-12-04 devnull if(yydebug >= 2)
249 c72688ef 2003-12-04 devnull fprint(2, "error recovery discards %s\n", yytokname(yychar));
250 c72688ef 2003-12-04 devnull if(yychar == YYEOFCODE)
251 c72688ef 2003-12-04 devnull goto ret1;
252 c72688ef 2003-12-04 devnull yychar = -1;
253 c72688ef 2003-12-04 devnull goto yynewstate; /* try again in the same state */
257 c72688ef 2003-12-04 devnull /* reduction by production yyn */
258 c72688ef 2003-12-04 devnull if(yydebug >= 2)
259 c72688ef 2003-12-04 devnull fprint(2, "reduce %d in:\n\t%s", yyn, yystatname(yystate));
261 c72688ef 2003-12-04 devnull yypt = yyp;
262 c72688ef 2003-12-04 devnull yyp -= yyr2[yyn];
263 c72688ef 2003-12-04 devnull yyval = (yyp+1)->yyv;
264 c72688ef 2003-12-04 devnull yym = yyn;
266 c72688ef 2003-12-04 devnull /* consult goto table to find next state */
267 c72688ef 2003-12-04 devnull yyn = yyr1[yyn];
268 c72688ef 2003-12-04 devnull yyg = yypgo[yyn];
269 c72688ef 2003-12-04 devnull yyj = yyg + yyp->yys + 1;
271 c72688ef 2003-12-04 devnull if(yyj >= YYLAST || yychk[yystate=yyact[yyj]] != -yyn)
272 c72688ef 2003-12-04 devnull yystate = yyact[yyg];
273 c72688ef 2003-12-04 devnull switch(yym) {
276 c72688ef 2003-12-04 devnull goto yystack; /* stack new state and value */