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 c72688ef 2003-12-04 devnull yyp = &yys[-1];
132 c72688ef 2003-12-04 devnull goto yystack;
135 c72688ef 2003-12-04 devnull yyn = 0;
136 c72688ef 2003-12-04 devnull goto ret;
139 c72688ef 2003-12-04 devnull yyn = 1;
140 c72688ef 2003-12-04 devnull goto 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;
149 c72688ef 2003-12-04 devnull return yyn;
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));
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;
161 c72688ef 2003-12-04 devnull yyp->yys = yystate;
162 c72688ef 2003-12-04 devnull yyp->yyv = yyval;
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);
172 c72688ef 2003-12-04 devnull yychar = yylex1();
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;
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);
195 cae9bfe9 2005-02-14 devnull yychar = yylex1();
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)
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)
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;
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));
220 53e2a4c6 2005-02-17 devnull goto yyerrlab;
221 53e2a4c6 2005-02-17 devnull yyerrlab:
222 cae9bfe9 2005-02-14 devnull yynerrs++;
225 c72688ef 2003-12-04 devnull case 2: /* incompletely recovered error ... try again */
226 c72688ef 2003-12-04 devnull yyerrflag = 3;
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;
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 );
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;
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 */
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));
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;
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;
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) {
275 c72688ef 2003-12-04 devnull goto yystack; /* stack new state and value */