Blame


1 c72688ef 2003-12-04 devnull #define YYFLAG -1000
2 c72688ef 2003-12-04 devnull #define YYERROR goto yyerrlab
3 c72688ef 2003-12-04 devnull #define YYACCEPT return(0)
4 c72688ef 2003-12-04 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 cae9bfe9 2005-02-14 devnull static const char*
28 c72688ef 2003-12-04 devnull yytokname(int yyc)
29 c72688ef 2003-12-04 devnull {
30 c72688ef 2003-12-04 devnull static char x[10];
31 c72688ef 2003-12-04 devnull
32 c72688ef 2003-12-04 devnull if(yyc > 0 && yyc <= sizeof(yytoknames)/sizeof(yytoknames[0]))
33 c72688ef 2003-12-04 devnull if(yytoknames[yyc-1])
34 c72688ef 2003-12-04 devnull return yytoknames[yyc-1];
35 c72688ef 2003-12-04 devnull sprintf(x, "<%d>", yyc);
36 c72688ef 2003-12-04 devnull return x;
37 c72688ef 2003-12-04 devnull }
38 c72688ef 2003-12-04 devnull
39 cae9bfe9 2005-02-14 devnull static const char*
40 c72688ef 2003-12-04 devnull yystatname(int yys)
41 c72688ef 2003-12-04 devnull {
42 c72688ef 2003-12-04 devnull static char x[10];
43 c72688ef 2003-12-04 devnull
44 c72688ef 2003-12-04 devnull if(yys >= 0 && yys < sizeof(yystates)/sizeof(yystates[0]))
45 c72688ef 2003-12-04 devnull if(yystates[yys])
46 c72688ef 2003-12-04 devnull return yystates[yys];
47 c72688ef 2003-12-04 devnull sprintf(x, "<%d>\n", yys);
48 c72688ef 2003-12-04 devnull return x;
49 c72688ef 2003-12-04 devnull }
50 c72688ef 2003-12-04 devnull
51 cae9bfe9 2005-02-14 devnull static long
52 cae9bfe9 2005-02-14 devnull #ifdef YYARG
53 cae9bfe9 2005-02-14 devnull yylex1(struct Yyarg *yyarg)
54 cae9bfe9 2005-02-14 devnull #else
55 c72688ef 2003-12-04 devnull yylex1(void)
56 cae9bfe9 2005-02-14 devnull #endif
57 c72688ef 2003-12-04 devnull {
58 c72688ef 2003-12-04 devnull long yychar;
59 cae9bfe9 2005-02-14 devnull const long *t3p;
60 c72688ef 2003-12-04 devnull int c;
61 c72688ef 2003-12-04 devnull
62 cae9bfe9 2005-02-14 devnull #ifdef YYARG
63 cae9bfe9 2005-02-14 devnull yychar = yylex(yyarg);
64 cae9bfe9 2005-02-14 devnull #else
65 c72688ef 2003-12-04 devnull yychar = yylex();
66 cae9bfe9 2005-02-14 devnull #endif
67 c72688ef 2003-12-04 devnull if(yychar <= 0) {
68 c72688ef 2003-12-04 devnull c = yytok1[0];
69 c72688ef 2003-12-04 devnull goto out;
70 c72688ef 2003-12-04 devnull }
71 c72688ef 2003-12-04 devnull if(yychar < sizeof(yytok1)/sizeof(yytok1[0])) {
72 c72688ef 2003-12-04 devnull c = yytok1[yychar];
73 c72688ef 2003-12-04 devnull goto out;
74 c72688ef 2003-12-04 devnull }
75 c72688ef 2003-12-04 devnull if(yychar >= YYPRIVATE)
76 c72688ef 2003-12-04 devnull if(yychar < YYPRIVATE+sizeof(yytok2)/sizeof(yytok2[0])) {
77 c72688ef 2003-12-04 devnull c = yytok2[yychar-YYPRIVATE];
78 c72688ef 2003-12-04 devnull goto out;
79 c72688ef 2003-12-04 devnull }
80 c72688ef 2003-12-04 devnull for(t3p=yytok3;; t3p+=2) {
81 c72688ef 2003-12-04 devnull c = t3p[0];
82 c72688ef 2003-12-04 devnull if(c == yychar) {
83 c72688ef 2003-12-04 devnull c = t3p[1];
84 c72688ef 2003-12-04 devnull goto out;
85 c72688ef 2003-12-04 devnull }
86 c72688ef 2003-12-04 devnull if(c == 0)
87 c72688ef 2003-12-04 devnull break;
88 c72688ef 2003-12-04 devnull }
89 c72688ef 2003-12-04 devnull c = 0;
90 c72688ef 2003-12-04 devnull
91 c72688ef 2003-12-04 devnull out:
92 c72688ef 2003-12-04 devnull if(c == 0)
93 c72688ef 2003-12-04 devnull c = yytok2[1]; /* unknown char */
94 c72688ef 2003-12-04 devnull if(yydebug >= 3)
95 c72688ef 2003-12-04 devnull printf("lex %.4lX %s\n", yychar, yytokname(c));
96 c72688ef 2003-12-04 devnull return c;
97 c72688ef 2003-12-04 devnull }
98 c72688ef 2003-12-04 devnull
99 c72688ef 2003-12-04 devnull int
100 cae9bfe9 2005-02-14 devnull #ifdef YYARG
101 cae9bfe9 2005-02-14 devnull yyparse(struct Yyarg *yyarg)
102 cae9bfe9 2005-02-14 devnull #else
103 c72688ef 2003-12-04 devnull yyparse(void)
104 cae9bfe9 2005-02-14 devnull #endif
105 c72688ef 2003-12-04 devnull {
106 c72688ef 2003-12-04 devnull struct
107 c72688ef 2003-12-04 devnull {
108 c72688ef 2003-12-04 devnull YYSTYPE yyv;
109 c72688ef 2003-12-04 devnull int yys;
110 c72688ef 2003-12-04 devnull } yys[YYMAXDEPTH], *yyp, *yypt;
111 cae9bfe9 2005-02-14 devnull const short *yyxi;
112 c72688ef 2003-12-04 devnull int yyj, yym, yystate, yyn, yyg;
113 cae9bfe9 2005-02-14 devnull long yychar;
114 cae9bfe9 2005-02-14 devnull #ifndef YYARG
115 c72688ef 2003-12-04 devnull YYSTYPE save1, save2;
116 c72688ef 2003-12-04 devnull int save3, save4;
117 c72688ef 2003-12-04 devnull
118 c72688ef 2003-12-04 devnull save1 = yylval;
119 c72688ef 2003-12-04 devnull save2 = yyval;
120 c72688ef 2003-12-04 devnull save3 = yynerrs;
121 c72688ef 2003-12-04 devnull save4 = yyerrflag;
122 cae9bfe9 2005-02-14 devnull #endif
123 c72688ef 2003-12-04 devnull
124 c72688ef 2003-12-04 devnull yystate = 0;
125 c72688ef 2003-12-04 devnull yychar = -1;
126 c72688ef 2003-12-04 devnull yynerrs = 0;
127 c72688ef 2003-12-04 devnull yyerrflag = 0;
128 0cfb3760 2012-10-21 rsc yyp = &yys[0];
129 0cfb3760 2012-10-21 rsc yyp--;
130 c72688ef 2003-12-04 devnull goto yystack;
131 c72688ef 2003-12-04 devnull
132 c72688ef 2003-12-04 devnull ret0:
133 c72688ef 2003-12-04 devnull yyn = 0;
134 c72688ef 2003-12-04 devnull goto ret;
135 c72688ef 2003-12-04 devnull
136 c72688ef 2003-12-04 devnull ret1:
137 c72688ef 2003-12-04 devnull yyn = 1;
138 c72688ef 2003-12-04 devnull goto ret;
139 c72688ef 2003-12-04 devnull
140 c72688ef 2003-12-04 devnull ret:
141 cae9bfe9 2005-02-14 devnull #ifndef YYARG
142 c72688ef 2003-12-04 devnull yylval = save1;
143 c72688ef 2003-12-04 devnull yyval = save2;
144 c72688ef 2003-12-04 devnull yynerrs = save3;
145 c72688ef 2003-12-04 devnull yyerrflag = save4;
146 cae9bfe9 2005-02-14 devnull #endif
147 c72688ef 2003-12-04 devnull return yyn;
148 c72688ef 2003-12-04 devnull
149 c72688ef 2003-12-04 devnull yystack:
150 c72688ef 2003-12-04 devnull /* put a state and value onto the stack */
151 c72688ef 2003-12-04 devnull if(yydebug >= 4)
152 c72688ef 2003-12-04 devnull printf("char %s in %s", yytokname(yychar), yystatname(yystate));
153 c72688ef 2003-12-04 devnull
154 c72688ef 2003-12-04 devnull yyp++;
155 c72688ef 2003-12-04 devnull if(yyp >= &yys[YYMAXDEPTH]) {
156 c72688ef 2003-12-04 devnull yyerror("yacc stack overflow");
157 c72688ef 2003-12-04 devnull goto ret1;
158 c72688ef 2003-12-04 devnull }
159 c72688ef 2003-12-04 devnull yyp->yys = yystate;
160 c72688ef 2003-12-04 devnull yyp->yyv = yyval;
161 c72688ef 2003-12-04 devnull
162 c72688ef 2003-12-04 devnull yynewstate:
163 c72688ef 2003-12-04 devnull yyn = yypact[yystate];
164 c72688ef 2003-12-04 devnull if(yyn <= YYFLAG)
165 c72688ef 2003-12-04 devnull goto yydefault; /* simple state */
166 c72688ef 2003-12-04 devnull if(yychar < 0)
167 cae9bfe9 2005-02-14 devnull #ifdef YYARG
168 cae9bfe9 2005-02-14 devnull yychar = yylex1(yyarg);
169 cae9bfe9 2005-02-14 devnull #else
170 c72688ef 2003-12-04 devnull yychar = yylex1();
171 cae9bfe9 2005-02-14 devnull #endif
172 c72688ef 2003-12-04 devnull yyn += yychar;
173 c72688ef 2003-12-04 devnull if(yyn < 0 || yyn >= YYLAST)
174 c72688ef 2003-12-04 devnull goto yydefault;
175 c72688ef 2003-12-04 devnull yyn = yyact[yyn];
176 c72688ef 2003-12-04 devnull if(yychk[yyn] == yychar) { /* valid shift */
177 c72688ef 2003-12-04 devnull yychar = -1;
178 c72688ef 2003-12-04 devnull yyval = yylval;
179 c72688ef 2003-12-04 devnull yystate = yyn;
180 c72688ef 2003-12-04 devnull if(yyerrflag > 0)
181 c72688ef 2003-12-04 devnull yyerrflag--;
182 c72688ef 2003-12-04 devnull goto yystack;
183 c72688ef 2003-12-04 devnull }
184 c72688ef 2003-12-04 devnull
185 c72688ef 2003-12-04 devnull yydefault:
186 c72688ef 2003-12-04 devnull /* default state action */
187 c72688ef 2003-12-04 devnull yyn = yydef[yystate];
188 c72688ef 2003-12-04 devnull if(yyn == -2) {
189 c72688ef 2003-12-04 devnull if(yychar < 0)
190 cae9bfe9 2005-02-14 devnull #ifdef YYARG
191 cae9bfe9 2005-02-14 devnull yychar = yylex1(yyarg);
192 cae9bfe9 2005-02-14 devnull #else
193 cae9bfe9 2005-02-14 devnull yychar = yylex1();
194 cae9bfe9 2005-02-14 devnull #endif
195 c72688ef 2003-12-04 devnull
196 c72688ef 2003-12-04 devnull /* look through exception table */
197 c72688ef 2003-12-04 devnull for(yyxi=yyexca;; yyxi+=2)
198 c72688ef 2003-12-04 devnull if(yyxi[0] == -1 && yyxi[1] == yystate)
199 c72688ef 2003-12-04 devnull break;
200 c72688ef 2003-12-04 devnull for(yyxi += 2;; yyxi += 2) {
201 c72688ef 2003-12-04 devnull yyn = yyxi[0];
202 c72688ef 2003-12-04 devnull if(yyn < 0 || yyn == yychar)
203 c72688ef 2003-12-04 devnull break;
204 c72688ef 2003-12-04 devnull }
205 c72688ef 2003-12-04 devnull yyn = yyxi[1];
206 c72688ef 2003-12-04 devnull if(yyn < 0)
207 c72688ef 2003-12-04 devnull goto ret0;
208 c72688ef 2003-12-04 devnull }
209 c72688ef 2003-12-04 devnull if(yyn == 0) {
210 c72688ef 2003-12-04 devnull /* error ... attempt to resume parsing */
211 c72688ef 2003-12-04 devnull switch(yyerrflag) {
212 c72688ef 2003-12-04 devnull case 0: /* brand new error */
213 c72688ef 2003-12-04 devnull yyerror("syntax error");
214 c72688ef 2003-12-04 devnull if(yydebug >= 1) {
215 c72688ef 2003-12-04 devnull printf("%s", yystatname(yystate));
216 c72688ef 2003-12-04 devnull printf("saw %s\n", yytokname(yychar));
217 c72688ef 2003-12-04 devnull }
218 53e2a4c6 2005-02-17 devnull goto yyerrlab;
219 53e2a4c6 2005-02-17 devnull yyerrlab:
220 c72688ef 2003-12-04 devnull yynerrs++;
221 c72688ef 2003-12-04 devnull
222 c72688ef 2003-12-04 devnull case 1:
223 c72688ef 2003-12-04 devnull case 2: /* incompletely recovered error ... try again */
224 c72688ef 2003-12-04 devnull yyerrflag = 3;
225 c72688ef 2003-12-04 devnull
226 c72688ef 2003-12-04 devnull /* find a state where "error" is a legal shift action */
227 c72688ef 2003-12-04 devnull while(yyp >= yys) {
228 c72688ef 2003-12-04 devnull yyn = yypact[yyp->yys] + YYERRCODE;
229 c72688ef 2003-12-04 devnull if(yyn >= 0 && yyn < YYLAST) {
230 c72688ef 2003-12-04 devnull yystate = yyact[yyn]; /* simulate a shift of "error" */
231 c72688ef 2003-12-04 devnull if(yychk[yystate] == YYERRCODE)
232 c72688ef 2003-12-04 devnull goto yystack;
233 c72688ef 2003-12-04 devnull }
234 c72688ef 2003-12-04 devnull
235 c72688ef 2003-12-04 devnull /* the current yyp has no shift onn "error", pop stack */
236 c72688ef 2003-12-04 devnull if(yydebug >= 2)
237 c72688ef 2003-12-04 devnull printf("error recovery pops state %d, uncovers %d\n",
238 c72688ef 2003-12-04 devnull yyp->yys, (yyp-1)->yys );
239 c72688ef 2003-12-04 devnull yyp--;
240 c72688ef 2003-12-04 devnull }
241 c72688ef 2003-12-04 devnull /* there is no state on the stack with an error shift ... abort */
242 c72688ef 2003-12-04 devnull goto ret1;
243 c72688ef 2003-12-04 devnull
244 c72688ef 2003-12-04 devnull case 3: /* no shift yet; clobber input char */
245 c72688ef 2003-12-04 devnull if(yydebug >= YYEOFCODE)
246 c72688ef 2003-12-04 devnull printf("error recovery discards %s\n", yytokname(yychar));
247 c72688ef 2003-12-04 devnull if(yychar == YYEOFCODE)
248 c72688ef 2003-12-04 devnull goto ret1;
249 c72688ef 2003-12-04 devnull yychar = -1;
250 c72688ef 2003-12-04 devnull goto yynewstate; /* try again in the same state */
251 c72688ef 2003-12-04 devnull }
252 c72688ef 2003-12-04 devnull }
253 c72688ef 2003-12-04 devnull
254 c72688ef 2003-12-04 devnull /* reduction by production yyn */
255 c72688ef 2003-12-04 devnull if(yydebug >= 2)
256 c72688ef 2003-12-04 devnull printf("reduce %d in:\n\t%s", yyn, yystatname(yystate));
257 c72688ef 2003-12-04 devnull
258 c72688ef 2003-12-04 devnull yypt = yyp;
259 c72688ef 2003-12-04 devnull yyp -= yyr2[yyn];
260 c72688ef 2003-12-04 devnull yyval = (yyp+1)->yyv;
261 c72688ef 2003-12-04 devnull yym = yyn;
262 c72688ef 2003-12-04 devnull
263 c72688ef 2003-12-04 devnull /* consult goto table to find next state */
264 c72688ef 2003-12-04 devnull yyn = yyr1[yyn];
265 c72688ef 2003-12-04 devnull yyg = yypgo[yyn];
266 c72688ef 2003-12-04 devnull yyj = yyg + yyp->yys + 1;
267 c72688ef 2003-12-04 devnull
268 c72688ef 2003-12-04 devnull if(yyj >= YYLAST || yychk[yystate=yyact[yyj]] != -yyn)
269 c72688ef 2003-12-04 devnull yystate = yyact[yyg];
270 c72688ef 2003-12-04 devnull switch(yym) {
271 c72688ef 2003-12-04 devnull $A
272 c72688ef 2003-12-04 devnull }
273 c72688ef 2003-12-04 devnull goto yystack; /* stack new state and value */
274 c72688ef 2003-12-04 devnull }