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
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 cae9bfe9 2005-02-14 devnull static const char*
28 c72688ef 2003-12-04 devnull yytokname(int yyc)
30 c72688ef 2003-12-04 devnull static char x[10];
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;
39 cae9bfe9 2005-02-14 devnull static const char*
40 c72688ef 2003-12-04 devnull yystatname(int yys)
42 c72688ef 2003-12-04 devnull static char x[10];
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;
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)
55 c72688ef 2003-12-04 devnull yylex1(void)
58 c72688ef 2003-12-04 devnull long yychar;
59 cae9bfe9 2005-02-14 devnull const long *t3p;
62 cae9bfe9 2005-02-14 devnull #ifdef YYARG
63 cae9bfe9 2005-02-14 devnull yychar = yylex(yyarg);
65 c72688ef 2003-12-04 devnull yychar = yylex();
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;
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;
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;
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;
86 c72688ef 2003-12-04 devnull if(c == 0)
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;
100 cae9bfe9 2005-02-14 devnull #ifdef YYARG
101 cae9bfe9 2005-02-14 devnull yyparse(struct Yyarg *yyarg)
103 c72688ef 2003-12-04 devnull yyparse(void)
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;
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;
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 c72688ef 2003-12-04 devnull yyp = &yys[-1];
129 c72688ef 2003-12-04 devnull goto yystack;
132 c72688ef 2003-12-04 devnull yyn = 0;
133 c72688ef 2003-12-04 devnull goto ret;
136 c72688ef 2003-12-04 devnull yyn = 1;
137 c72688ef 2003-12-04 devnull goto ret;
140 cae9bfe9 2005-02-14 devnull #ifndef YYARG
141 c72688ef 2003-12-04 devnull yylval = save1;
142 c72688ef 2003-12-04 devnull yyval = save2;
143 c72688ef 2003-12-04 devnull yynerrs = save3;
144 c72688ef 2003-12-04 devnull yyerrflag = save4;
146 c72688ef 2003-12-04 devnull return yyn;
148 c72688ef 2003-12-04 devnull yystack:
149 c72688ef 2003-12-04 devnull /* put a state and value onto the stack */
150 c72688ef 2003-12-04 devnull if(yydebug >= 4)
151 c72688ef 2003-12-04 devnull printf("char %s in %s", yytokname(yychar), yystatname(yystate));
154 c72688ef 2003-12-04 devnull if(yyp >= &yys[YYMAXDEPTH]) {
155 c72688ef 2003-12-04 devnull yyerror("yacc stack overflow");
156 c72688ef 2003-12-04 devnull goto ret1;
158 c72688ef 2003-12-04 devnull yyp->yys = yystate;
159 c72688ef 2003-12-04 devnull yyp->yyv = yyval;
161 c72688ef 2003-12-04 devnull yynewstate:
162 c72688ef 2003-12-04 devnull yyn = yypact[yystate];
163 c72688ef 2003-12-04 devnull if(yyn <= YYFLAG)
164 c72688ef 2003-12-04 devnull goto yydefault; /* simple state */
165 c72688ef 2003-12-04 devnull if(yychar < 0)
166 cae9bfe9 2005-02-14 devnull #ifdef YYARG
167 cae9bfe9 2005-02-14 devnull yychar = yylex1(yyarg);
169 c72688ef 2003-12-04 devnull yychar = yylex1();
171 c72688ef 2003-12-04 devnull yyn += yychar;
172 c72688ef 2003-12-04 devnull if(yyn < 0 || yyn >= YYLAST)
173 c72688ef 2003-12-04 devnull goto yydefault;
174 c72688ef 2003-12-04 devnull yyn = yyact[yyn];
175 c72688ef 2003-12-04 devnull if(yychk[yyn] == yychar) { /* valid shift */
176 c72688ef 2003-12-04 devnull yychar = -1;
177 c72688ef 2003-12-04 devnull yyval = yylval;
178 c72688ef 2003-12-04 devnull yystate = yyn;
179 c72688ef 2003-12-04 devnull if(yyerrflag > 0)
180 c72688ef 2003-12-04 devnull yyerrflag--;
181 c72688ef 2003-12-04 devnull goto yystack;
184 c72688ef 2003-12-04 devnull yydefault:
185 c72688ef 2003-12-04 devnull /* default state action */
186 c72688ef 2003-12-04 devnull yyn = yydef[yystate];
187 c72688ef 2003-12-04 devnull if(yyn == -2) {
188 c72688ef 2003-12-04 devnull if(yychar < 0)
189 cae9bfe9 2005-02-14 devnull #ifdef YYARG
190 cae9bfe9 2005-02-14 devnull yychar = yylex1(yyarg);
192 cae9bfe9 2005-02-14 devnull yychar = yylex1();
195 c72688ef 2003-12-04 devnull /* look through exception table */
196 c72688ef 2003-12-04 devnull for(yyxi=yyexca;; yyxi+=2)
197 c72688ef 2003-12-04 devnull if(yyxi[0] == -1 && yyxi[1] == yystate)
199 c72688ef 2003-12-04 devnull for(yyxi += 2;; yyxi += 2) {
200 c72688ef 2003-12-04 devnull yyn = yyxi[0];
201 c72688ef 2003-12-04 devnull if(yyn < 0 || yyn == yychar)
204 c72688ef 2003-12-04 devnull yyn = yyxi[1];
205 c72688ef 2003-12-04 devnull if(yyn < 0)
206 c72688ef 2003-12-04 devnull goto ret0;
208 c72688ef 2003-12-04 devnull if(yyn == 0) {
209 c72688ef 2003-12-04 devnull /* error ... attempt to resume parsing */
210 c72688ef 2003-12-04 devnull switch(yyerrflag) {
211 c72688ef 2003-12-04 devnull case 0: /* brand new error */
212 c72688ef 2003-12-04 devnull yyerror("syntax error");
213 c72688ef 2003-12-04 devnull if(yydebug >= 1) {
214 c72688ef 2003-12-04 devnull printf("%s", yystatname(yystate));
215 c72688ef 2003-12-04 devnull printf("saw %s\n", yytokname(yychar));
217 53e2a4c6 2005-02-17 devnull goto yyerrlab;
218 53e2a4c6 2005-02-17 devnull yyerrlab:
219 c72688ef 2003-12-04 devnull yynerrs++;
222 c72688ef 2003-12-04 devnull case 2: /* incompletely recovered error ... try again */
223 c72688ef 2003-12-04 devnull yyerrflag = 3;
225 c72688ef 2003-12-04 devnull /* find a state where "error" is a legal shift action */
226 c72688ef 2003-12-04 devnull while(yyp >= yys) {
227 c72688ef 2003-12-04 devnull yyn = yypact[yyp->yys] + YYERRCODE;
228 c72688ef 2003-12-04 devnull if(yyn >= 0 && yyn < YYLAST) {
229 c72688ef 2003-12-04 devnull yystate = yyact[yyn]; /* simulate a shift of "error" */
230 c72688ef 2003-12-04 devnull if(yychk[yystate] == YYERRCODE)
231 c72688ef 2003-12-04 devnull goto yystack;
234 c72688ef 2003-12-04 devnull /* the current yyp has no shift onn "error", pop stack */
235 c72688ef 2003-12-04 devnull if(yydebug >= 2)
236 c72688ef 2003-12-04 devnull printf("error recovery pops state %d, uncovers %d\n",
237 c72688ef 2003-12-04 devnull yyp->yys, (yyp-1)->yys );
240 c72688ef 2003-12-04 devnull /* there is no state on the stack with an error shift ... abort */
241 c72688ef 2003-12-04 devnull goto ret1;
243 c72688ef 2003-12-04 devnull case 3: /* no shift yet; clobber input char */
244 c72688ef 2003-12-04 devnull if(yydebug >= YYEOFCODE)
245 c72688ef 2003-12-04 devnull printf("error recovery discards %s\n", yytokname(yychar));
246 c72688ef 2003-12-04 devnull if(yychar == YYEOFCODE)
247 c72688ef 2003-12-04 devnull goto ret1;
248 c72688ef 2003-12-04 devnull yychar = -1;
249 c72688ef 2003-12-04 devnull goto yynewstate; /* try again in the same state */
253 c72688ef 2003-12-04 devnull /* reduction by production yyn */
254 c72688ef 2003-12-04 devnull if(yydebug >= 2)
255 c72688ef 2003-12-04 devnull printf("reduce %d in:\n\t%s", yyn, yystatname(yystate));
257 c72688ef 2003-12-04 devnull yypt = yyp;
258 c72688ef 2003-12-04 devnull yyp -= yyr2[yyn];
259 c72688ef 2003-12-04 devnull yyval = (yyp+1)->yyv;
260 c72688ef 2003-12-04 devnull yym = yyn;
262 c72688ef 2003-12-04 devnull /* consult goto table to find next state */
263 c72688ef 2003-12-04 devnull yyn = yyr1[yyn];
264 c72688ef 2003-12-04 devnull yyg = yypgo[yyn];
265 c72688ef 2003-12-04 devnull yyj = yyg + yyp->yys + 1;
267 c72688ef 2003-12-04 devnull if(yyj >= YYLAST || yychk[yystate=yyact[yyj]] != -yyn)
268 c72688ef 2003-12-04 devnull yystate = yyact[yyg];
269 c72688ef 2003-12-04 devnull switch(yym) {
272 c72688ef 2003-12-04 devnull goto yystack; /* stack new state and value */