Blame


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
7 c72688ef 2003-12-04 devnull
8 c72688ef 2003-12-04 devnull #ifdef yydebug
9 c72688ef 2003-12-04 devnull #include "y.debug"
10 c72688ef 2003-12-04 devnull #else
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 */
14 c72688ef 2003-12-04 devnull #endif
15 c72688ef 2003-12-04 devnull
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
22 cae9bfe9 2005-02-14 devnull #else
23 c72688ef 2003-12-04 devnull int yynerrs = 0; /* number of errors */
24 c72688ef 2003-12-04 devnull int yyerrflag = 0; /* error recovery flag */
25 cae9bfe9 2005-02-14 devnull #endif
26 c72688ef 2003-12-04 devnull
27 c72688ef 2003-12-04 devnull extern int fprint(int, char*, ...);
28 c72688ef 2003-12-04 devnull extern int sprint(char*, char*, ...);
29 c72688ef 2003-12-04 devnull
30 cae9bfe9 2005-02-14 devnull static const char*
31 c72688ef 2003-12-04 devnull yytokname(int yyc)
32 c72688ef 2003-12-04 devnull {
33 c72688ef 2003-12-04 devnull static char x[10];
34 c72688ef 2003-12-04 devnull
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;
40 c72688ef 2003-12-04 devnull }
41 c72688ef 2003-12-04 devnull
42 cae9bfe9 2005-02-14 devnull static const char*
43 c72688ef 2003-12-04 devnull yystatname(int yys)
44 c72688ef 2003-12-04 devnull {
45 c72688ef 2003-12-04 devnull static char x[10];
46 c72688ef 2003-12-04 devnull
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;
52 c72688ef 2003-12-04 devnull }
53 c72688ef 2003-12-04 devnull
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)
57 cae9bfe9 2005-02-14 devnull #else
58 c72688ef 2003-12-04 devnull yylex1(void)
59 cae9bfe9 2005-02-14 devnull #endif
60 c72688ef 2003-12-04 devnull {
61 c72688ef 2003-12-04 devnull long yychar;
62 cae9bfe9 2005-02-14 devnull const long *t3p;
63 c72688ef 2003-12-04 devnull int c;
64 c72688ef 2003-12-04 devnull
65 cae9bfe9 2005-02-14 devnull #ifdef YYARG
66 cae9bfe9 2005-02-14 devnull yychar = yylex(yyarg);
67 cae9bfe9 2005-02-14 devnull #else
68 c72688ef 2003-12-04 devnull yychar = yylex();
69 cae9bfe9 2005-02-14 devnull #endif
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;
73 c72688ef 2003-12-04 devnull }
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;
77 c72688ef 2003-12-04 devnull }
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;
82 c72688ef 2003-12-04 devnull }
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;
88 c72688ef 2003-12-04 devnull }
89 c72688ef 2003-12-04 devnull if(c == 0)
90 c72688ef 2003-12-04 devnull break;
91 c72688ef 2003-12-04 devnull }
92 c72688ef 2003-12-04 devnull c = 0;
93 c72688ef 2003-12-04 devnull
94 c72688ef 2003-12-04 devnull out:
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;
100 c72688ef 2003-12-04 devnull }
101 c72688ef 2003-12-04 devnull
102 c72688ef 2003-12-04 devnull int
103 cae9bfe9 2005-02-14 devnull #ifdef YYARG
104 cae9bfe9 2005-02-14 devnull yyparse(struct Yyarg *yyarg)
105 cae9bfe9 2005-02-14 devnull #else
106 c72688ef 2003-12-04 devnull yyparse(void)
107 cae9bfe9 2005-02-14 devnull #endif
108 c72688ef 2003-12-04 devnull {
109 c72688ef 2003-12-04 devnull struct
110 c72688ef 2003-12-04 devnull {
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;
120 c72688ef 2003-12-04 devnull
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;
125 cae9bfe9 2005-02-14 devnull #endif
126 c72688ef 2003-12-04 devnull
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];
132 310ae033 2017-01-06 rsc yyp--;
133 c72688ef 2003-12-04 devnull goto yystack;
134 c72688ef 2003-12-04 devnull
135 c72688ef 2003-12-04 devnull ret0:
136 c72688ef 2003-12-04 devnull yyn = 0;
137 c72688ef 2003-12-04 devnull goto ret;
138 c72688ef 2003-12-04 devnull
139 c72688ef 2003-12-04 devnull ret1:
140 c72688ef 2003-12-04 devnull yyn = 1;
141 c72688ef 2003-12-04 devnull goto ret;
142 c72688ef 2003-12-04 devnull
143 c72688ef 2003-12-04 devnull 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;
149 cae9bfe9 2005-02-14 devnull #endif
150 c72688ef 2003-12-04 devnull return yyn;
151 c72688ef 2003-12-04 devnull
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));
156 c72688ef 2003-12-04 devnull
157 c72688ef 2003-12-04 devnull yyp++;
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;
161 c72688ef 2003-12-04 devnull }
162 c72688ef 2003-12-04 devnull yyp->yys = yystate;
163 c72688ef 2003-12-04 devnull yyp->yyv = yyval;
164 c72688ef 2003-12-04 devnull
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);
172 cae9bfe9 2005-02-14 devnull #else
173 c72688ef 2003-12-04 devnull yychar = yylex1();
174 cae9bfe9 2005-02-14 devnull #endif
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;
186 c72688ef 2003-12-04 devnull }
187 c72688ef 2003-12-04 devnull
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);
195 cae9bfe9 2005-02-14 devnull #else
196 cae9bfe9 2005-02-14 devnull yychar = yylex1();
197 cae9bfe9 2005-02-14 devnull #endif
198 c72688ef 2003-12-04 devnull
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)
202 c72688ef 2003-12-04 devnull break;
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)
206 c72688ef 2003-12-04 devnull break;
207 c72688ef 2003-12-04 devnull }
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;
211 c72688ef 2003-12-04 devnull }
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));
220 c72688ef 2003-12-04 devnull }
221 53e2a4c6 2005-02-17 devnull goto yyerrlab;
222 53e2a4c6 2005-02-17 devnull yyerrlab:
223 cae9bfe9 2005-02-14 devnull yynerrs++;
224 c72688ef 2003-12-04 devnull
225 c72688ef 2003-12-04 devnull case 1:
226 c72688ef 2003-12-04 devnull case 2: /* incompletely recovered error ... try again */
227 c72688ef 2003-12-04 devnull yyerrflag = 3;
228 c72688ef 2003-12-04 devnull
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;
236 c72688ef 2003-12-04 devnull }
237 c72688ef 2003-12-04 devnull
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 );
242 c72688ef 2003-12-04 devnull yyp--;
243 c72688ef 2003-12-04 devnull }
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;
246 c72688ef 2003-12-04 devnull
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 */
254 c72688ef 2003-12-04 devnull }
255 c72688ef 2003-12-04 devnull }
256 c72688ef 2003-12-04 devnull
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));
260 c72688ef 2003-12-04 devnull
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;
265 c72688ef 2003-12-04 devnull
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;
270 c72688ef 2003-12-04 devnull
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) {
274 c72688ef 2003-12-04 devnull $A
275 c72688ef 2003-12-04 devnull }
276 c72688ef 2003-12-04 devnull goto yystack; /* stack new state and value */
277 c72688ef 2003-12-04 devnull }