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 0cfb3760 2012-10-21 rsc yyp = &yys[0];
130 c72688ef 2003-12-04 devnull goto yystack;
133 c72688ef 2003-12-04 devnull yyn = 0;
134 c72688ef 2003-12-04 devnull goto ret;
137 c72688ef 2003-12-04 devnull yyn = 1;
138 c72688ef 2003-12-04 devnull goto 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;
147 c72688ef 2003-12-04 devnull return yyn;
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));
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;
159 c72688ef 2003-12-04 devnull yyp->yys = yystate;
160 c72688ef 2003-12-04 devnull yyp->yyv = yyval;
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);
170 c72688ef 2003-12-04 devnull yychar = yylex1();
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;
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);
193 cae9bfe9 2005-02-14 devnull yychar = yylex1();
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)
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)
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;
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));
218 53e2a4c6 2005-02-17 devnull goto yyerrlab;
219 53e2a4c6 2005-02-17 devnull yyerrlab:
220 c72688ef 2003-12-04 devnull yynerrs++;
223 c72688ef 2003-12-04 devnull case 2: /* incompletely recovered error ... try again */
224 c72688ef 2003-12-04 devnull yyerrflag = 3;
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;
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 );
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;
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 */
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));
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;
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;
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) {
273 c72688ef 2003-12-04 devnull goto yystack; /* stack new state and value */