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 c72688ef 2003-12-04 devnull yyp = &yys[-1];
132 c72688ef 2003-12-04 devnull goto yystack;
133 c72688ef 2003-12-04 devnull
134 c72688ef 2003-12-04 devnull ret0:
135 c72688ef 2003-12-04 devnull yyn = 0;
136 c72688ef 2003-12-04 devnull goto ret;
137 c72688ef 2003-12-04 devnull
138 c72688ef 2003-12-04 devnull ret1:
139 c72688ef 2003-12-04 devnull yyn = 1;
140 c72688ef 2003-12-04 devnull goto ret;
141 c72688ef 2003-12-04 devnull
142 c72688ef 2003-12-04 devnull ret:
143 cae9bfe9 2005-02-14 devnull #ifndef YYARG
144 c72688ef 2003-12-04 devnull yylval = save1;
145 c72688ef 2003-12-04 devnull yyval = save2;
146 c72688ef 2003-12-04 devnull yynerrs = save3;
147 c72688ef 2003-12-04 devnull yyerrflag = save4;
148 cae9bfe9 2005-02-14 devnull #endif
149 c72688ef 2003-12-04 devnull return yyn;
150 c72688ef 2003-12-04 devnull
151 c72688ef 2003-12-04 devnull yystack:
152 c72688ef 2003-12-04 devnull /* put a state and value onto the stack */
153 c72688ef 2003-12-04 devnull if(yydebug >= 4)
154 c72688ef 2003-12-04 devnull fprint(2, "char %s in %s", yytokname(yychar), yystatname(yystate));
155 c72688ef 2003-12-04 devnull
156 c72688ef 2003-12-04 devnull yyp++;
157 c72688ef 2003-12-04 devnull if(yyp >= &yys[YYMAXDEPTH]) {
158 c72688ef 2003-12-04 devnull yyerror("yacc stack overflow");
159 c72688ef 2003-12-04 devnull goto ret1;
160 c72688ef 2003-12-04 devnull }
161 c72688ef 2003-12-04 devnull yyp->yys = yystate;
162 c72688ef 2003-12-04 devnull yyp->yyv = yyval;
163 c72688ef 2003-12-04 devnull
164 c72688ef 2003-12-04 devnull yynewstate:
165 c72688ef 2003-12-04 devnull yyn = yypact[yystate];
166 c72688ef 2003-12-04 devnull if(yyn <= YYFLAG)
167 c72688ef 2003-12-04 devnull goto yydefault; /* simple state */
168 c72688ef 2003-12-04 devnull if(yychar < 0)
169 cae9bfe9 2005-02-14 devnull #ifdef YYARG
170 cae9bfe9 2005-02-14 devnull yychar = yylex1(yyarg);
171 cae9bfe9 2005-02-14 devnull #else
172 c72688ef 2003-12-04 devnull yychar = yylex1();
173 cae9bfe9 2005-02-14 devnull #endif
174 c72688ef 2003-12-04 devnull yyn += yychar;
175 c72688ef 2003-12-04 devnull if(yyn < 0 || yyn >= YYLAST)
176 c72688ef 2003-12-04 devnull goto yydefault;
177 c72688ef 2003-12-04 devnull yyn = yyact[yyn];
178 c72688ef 2003-12-04 devnull if(yychk[yyn] == yychar) { /* valid shift */
179 c72688ef 2003-12-04 devnull yychar = -1;
180 c72688ef 2003-12-04 devnull yyval = yylval;
181 c72688ef 2003-12-04 devnull yystate = yyn;
182 c72688ef 2003-12-04 devnull if(yyerrflag > 0)
183 c72688ef 2003-12-04 devnull yyerrflag--;
184 c72688ef 2003-12-04 devnull goto yystack;
185 c72688ef 2003-12-04 devnull }
186 c72688ef 2003-12-04 devnull
187 c72688ef 2003-12-04 devnull yydefault:
188 c72688ef 2003-12-04 devnull /* default state action */
189 c72688ef 2003-12-04 devnull yyn = yydef[yystate];
190 c72688ef 2003-12-04 devnull if(yyn == -2) {
191 c72688ef 2003-12-04 devnull if(yychar < 0)
192 cae9bfe9 2005-02-14 devnull #ifdef YYARG
193 cae9bfe9 2005-02-14 devnull yychar = yylex1(yyarg);
194 cae9bfe9 2005-02-14 devnull #else
195 cae9bfe9 2005-02-14 devnull yychar = yylex1();
196 cae9bfe9 2005-02-14 devnull #endif
197 c72688ef 2003-12-04 devnull
198 c72688ef 2003-12-04 devnull /* look through exception table */
199 c72688ef 2003-12-04 devnull for(yyxi=yyexca;; yyxi+=2)
200 c72688ef 2003-12-04 devnull if(yyxi[0] == -1 && yyxi[1] == yystate)
201 c72688ef 2003-12-04 devnull break;
202 c72688ef 2003-12-04 devnull for(yyxi += 2;; yyxi += 2) {
203 c72688ef 2003-12-04 devnull yyn = yyxi[0];
204 c72688ef 2003-12-04 devnull if(yyn < 0 || yyn == yychar)
205 c72688ef 2003-12-04 devnull break;
206 c72688ef 2003-12-04 devnull }
207 c72688ef 2003-12-04 devnull yyn = yyxi[1];
208 c72688ef 2003-12-04 devnull if(yyn < 0)
209 c72688ef 2003-12-04 devnull goto ret0;
210 c72688ef 2003-12-04 devnull }
211 c72688ef 2003-12-04 devnull if(yyn == 0) {
212 c72688ef 2003-12-04 devnull /* error ... attempt to resume parsing */
213 c72688ef 2003-12-04 devnull switch(yyerrflag) {
214 c72688ef 2003-12-04 devnull case 0: /* brand new error */
215 c72688ef 2003-12-04 devnull yyerror("syntax error");
216 c72688ef 2003-12-04 devnull if(yydebug >= 1) {
217 c72688ef 2003-12-04 devnull fprint(2, "%s", yystatname(yystate));
218 c72688ef 2003-12-04 devnull fprint(2, "saw %s\n", yytokname(yychar));
219 c72688ef 2003-12-04 devnull }
220 53e2a4c6 2005-02-17 devnull goto yyerrlab;
221 53e2a4c6 2005-02-17 devnull yyerrlab:
222 cae9bfe9 2005-02-14 devnull yynerrs++;
223 c72688ef 2003-12-04 devnull
224 c72688ef 2003-12-04 devnull case 1:
225 c72688ef 2003-12-04 devnull case 2: /* incompletely recovered error ... try again */
226 c72688ef 2003-12-04 devnull yyerrflag = 3;
227 c72688ef 2003-12-04 devnull
228 c72688ef 2003-12-04 devnull /* find a state where "error" is a legal shift action */
229 c72688ef 2003-12-04 devnull while(yyp >= yys) {
230 c72688ef 2003-12-04 devnull yyn = yypact[yyp->yys] + YYERRCODE;
231 c72688ef 2003-12-04 devnull if(yyn >= 0 && yyn < YYLAST) {
232 c72688ef 2003-12-04 devnull yystate = yyact[yyn]; /* simulate a shift of "error" */
233 c72688ef 2003-12-04 devnull if(yychk[yystate] == YYERRCODE)
234 c72688ef 2003-12-04 devnull goto yystack;
235 c72688ef 2003-12-04 devnull }
236 c72688ef 2003-12-04 devnull
237 c72688ef 2003-12-04 devnull /* the current yyp has no shift onn "error", pop stack */
238 c72688ef 2003-12-04 devnull if(yydebug >= 2)
239 c72688ef 2003-12-04 devnull fprint(2, "error recovery pops state %d, uncovers %d\n",
240 c72688ef 2003-12-04 devnull yyp->yys, (yyp-1)->yys );
241 c72688ef 2003-12-04 devnull yyp--;
242 c72688ef 2003-12-04 devnull }
243 c72688ef 2003-12-04 devnull /* there is no state on the stack with an error shift ... abort */
244 c72688ef 2003-12-04 devnull goto ret1;
245 c72688ef 2003-12-04 devnull
246 c72688ef 2003-12-04 devnull case 3: /* no shift yet; clobber input char */
247 c72688ef 2003-12-04 devnull if(yydebug >= 2)
248 c72688ef 2003-12-04 devnull fprint(2, "error recovery discards %s\n", yytokname(yychar));
249 c72688ef 2003-12-04 devnull if(yychar == YYEOFCODE)
250 c72688ef 2003-12-04 devnull goto ret1;
251 c72688ef 2003-12-04 devnull yychar = -1;
252 c72688ef 2003-12-04 devnull goto yynewstate; /* try again in the same state */
253 c72688ef 2003-12-04 devnull }
254 c72688ef 2003-12-04 devnull }
255 c72688ef 2003-12-04 devnull
256 c72688ef 2003-12-04 devnull /* reduction by production yyn */
257 c72688ef 2003-12-04 devnull if(yydebug >= 2)
258 c72688ef 2003-12-04 devnull fprint(2, "reduce %d in:\n\t%s", yyn, yystatname(yystate));
259 c72688ef 2003-12-04 devnull
260 c72688ef 2003-12-04 devnull yypt = yyp;
261 c72688ef 2003-12-04 devnull yyp -= yyr2[yyn];
262 c72688ef 2003-12-04 devnull yyval = (yyp+1)->yyv;
263 c72688ef 2003-12-04 devnull yym = yyn;
264 c72688ef 2003-12-04 devnull
265 c72688ef 2003-12-04 devnull /* consult goto table to find next state */
266 c72688ef 2003-12-04 devnull yyn = yyr1[yyn];
267 c72688ef 2003-12-04 devnull yyg = yypgo[yyn];
268 c72688ef 2003-12-04 devnull yyj = yyg + yyp->yys + 1;
269 c72688ef 2003-12-04 devnull
270 c72688ef 2003-12-04 devnull if(yyj >= YYLAST || yychk[yystate=yyact[yyj]] != -yyn)
271 c72688ef 2003-12-04 devnull yystate = yyact[yyg];
272 c72688ef 2003-12-04 devnull switch(yym) {
273 c72688ef 2003-12-04 devnull $A
274 c72688ef 2003-12-04 devnull }
275 c72688ef 2003-12-04 devnull goto yystack; /* stack new state and value */
276 c72688ef 2003-12-04 devnull }