00001 #ifndef lint
00002 static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
00003 #endif
00004 #define YYBYACC 1
00005 #define YYMAJOR 1
00006 #define YYMINOR 9
00007 #define yyclearin (yychar=(-1))
00008 #define yyerrok (yyerrflag=0)
00009 #define YYRECOVERING (yyerrflag!=0)
00010 #define YYPREFIX "yy"
00011 #line 2 "rowo.y"
00012 #include <string>
00013 #include <stdio.h>
00014 #include <stdlib.h>
00015 #include <vector>
00016 #include <map>
00017 #include "robotworld.h"
00018
00019 #define C the_str[the_ptr]
00020 #define C1 the_str[the_ptr+1]
00021
00022
00023 static char the_str[1000];
00024 static int the_ptr;
00025 static int line;
00026 static FILE *fil;
00027 static int uniq;
00028 static std::vector<VARIABLE *> variables;
00029 static std::string codestr;
00030 static std::map<std::string, int> codemap;
00031 static bool failed;
00032 static int x_ptr;
00033
00034 const std::string& GetCodestr() { return codestr; }
00035 std::map<std::string, int>& GetCodemap() { return codemap; }
00036 std::vector<VARIABLE *>& GetVariables() { return variables; }
00037 bool GetFailed() { return failed; }
00038
00039
00040 int yyparse();
00041 short reg_variable(const std::string& ,int type = 0);
00042 void check_property(const std::string& , const std::string& );
00043 void check_method(const std::string& , const std::string& );
00044 void add_bytecode(char *, int opcode);
00045 void add_bytecode(char *, int opcode, short val);
00046 void add_bytecode(char *, int opcode, long val);
00047 void add_bytecode(char *, int opcode, const std::string& object, const std::string& property_or_method);
00048 #line 40 "rowo.y"
00049 typedef union {
00050 long l;
00051 char str[1000];
00052 struct codestruct {
00053 char code[10000];
00054 char bytecode[10000];
00055 } code;
00056 } YYSTYPE;
00057 #line 58 "y.tab.c"
00058 #define INT 257
00059 #define IDENTIFIER 258
00060 #define COMMENT 259
00061 #define Object 260
00062 #define EnumObjectType 261
00063 #define Cos 262
00064 #define Sin 263
00065 #define If 264
00066 #define Loop 265
00067 #define EQ 266
00068 #define NEQ 267
00069 #define AND 268
00070 #define OR 269
00071 #define YYERRCODE 256
00072 short yylhs[] = { -1,
00073 0, 10, 10, 11, 12, 12, 4, 4, 5, 5,
00074 5, 5, 5, 6, 7, 7, 8, 8, 9, 2,
00075 2, 2, 3, 1, 1, 1, 1, 1, 1, 1,
00076 1, 1, 1, 1, 1, 1, 1, 1, 1,
00077 };
00078 short yylen[] = { 2,
00079 1, 1, 2, 2, 2, 3, 1, 2, 1, 1,
00080 1, 1, 1, 5, 3, 5, 7, 7, 6, 0,
00081 1, 3, 1, 1, 1, 3, 1, 3, 3, 3,
00082 3, 3, 3, 5, 3, 2, 3, 3, 3,
00083 };
00084 short yydefred[] = { 0,
00085 0, 0, 0, 2, 0, 4, 3, 0, 13, 0,
00086 0, 5, 0, 7, 9, 10, 11, 12, 0, 0,
00087 0, 6, 8, 24, 0, 0, 25, 0, 0, 0,
00088 0, 0, 0, 0, 0, 0, 0, 36, 0, 0,
00089 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00090 0, 28, 26, 0, 0, 35, 0, 0, 0, 0,
00091 0, 0, 0, 31, 32, 0, 0, 21, 0, 14,
00092 0, 0, 0, 19, 0, 18, 17, 0, 22,
00093 };
00094 short yydgoto[] = { 2,
00095 66, 67, 68, 13, 14, 15, 16, 17, 18, 3,
00096 4, 6,
00097 };
00098 short yysindex[] = { -257,
00099 -121, 0, -257, 0, -106, 0, 0, -53, 0, -26,
00100 -19, 0, -103, 0, 0, 0, 0, 0, -33, -233,
00101 75, 0, 0, 0, -14, -11, 0, -249, 75, 75,
00102 86, -34, 58, -227, -222, -9, -8, 0, 71, 75,
00103 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
00104 -121, 0, 0, -219, -213, 0, 4, 4, 97, 97,
00105 80, -32, -32, 0, 0, 86, -37, 0, 86, 0,
00106 -121, -121, 75, 0, 75, 0, 0, 86, 0,
00107 };
00108 short yyrindex[] = { 0,
00109 0, 0, 50, 0, 0, 0, 0, 0, 0, 0,
00110 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00111 0, 0, 0, 0, -29, 0, 0, 0, 0, 0,
00112 -92, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00113 0, 0, 0, 0, 0, 0, 0, 0, -36, 0,
00114 0, 0, 0, 0, 0, 0, 12, 25, 39, 46,
00115 0, -15, -1, 0, 0, -24, 0, 0, -84, 0,
00116 0, 0, 0, 0, 0, 0, 0, 53, 0,
00117 };
00118 short yygindex[] = { 0,
00119 163, 0, -23, 0, 41, 0, 0, 0, 0, 0,
00120 52, -48,
00121 };
00122 #define YYTABLESIZE 364
00123 short yytable[] = { 29,
00124 1, 5, 70, 74, 20, 49, 30, 19, 36, 47,
00125 37, 27, 27, 27, 48, 27, 23, 27, 12, 20,
00126 21, 22, 76, 77, 32, 30, 50, 30, 27, 30,
00127 52, 34, 15, 27, 35, 53, 54, 55, 71, 29,
00128 16, 29, 30, 29, 72, 47, 46, 30, 45, 1,
00129 48, 79, 33, 23, 7, 0, 29, 0, 0, 0,
00130 0, 29, 0, 0, 0, 37, 44, 0, 0, 33,
00131 0, 0, 0, 0, 0, 0, 0, 0, 0, 38,
00132 0, 0, 37, 0, 0, 0, 39, 0, 0, 0,
00133 0, 0, 0, 34, 0, 27, 38, 0, 51, 47,
00134 46, 0, 45, 39, 48, 0, 0, 29, 0, 30,
00135 34, 56, 47, 46, 30, 45, 0, 48, 0, 0,
00136 44, 47, 46, 29, 45, 0, 48, 47, 46, 0,
00137 45, 0, 48, 44, 0, 0, 33, 73, 47, 46,
00138 0, 45, 44, 48, 0, 0, 0, 0, 44, 37,
00139 0, 8, 9, 10, 8, 9, 10, 11, 0, 44,
00140 11, 0, 0, 38, 0, 15, 15, 15, 0, 0,
00141 39, 15, 0, 16, 16, 16, 0, 34, 0, 16,
00142 0, 31, 0, 33, 0, 0, 0, 0, 0, 0,
00143 0, 38, 39, 0, 0, 0, 0, 0, 0, 0,
00144 0, 0, 57, 58, 59, 60, 61, 62, 63, 64,
00145 65, 0, 69, 0, 0, 0, 0, 0, 0, 0,
00146 0, 0, 0, 24, 25, 0, 26, 27, 27, 27,
00147 27, 28, 75, 20, 27, 78, 27, 27, 27, 27,
00148 27, 0, 30, 30, 30, 23, 0, 0, 30, 0,
00149 30, 30, 30, 30, 30, 0, 29, 29, 29, 0,
00150 0, 0, 29, 0, 29, 29, 29, 29, 29, 33,
00151 33, 33, 0, 0, 0, 33, 0, 33, 33, 33,
00152 33, 33, 37, 37, 37, 0, 0, 0, 37, 0,
00153 37, 37, 37, 37, 37, 0, 38, 38, 38, 0,
00154 0, 0, 38, 39, 39, 39, 38, 38, 38, 39,
00155 34, 34, 34, 39, 39, 39, 34, 0, 0, 0,
00156 0, 0, 34, 40, 41, 42, 43, 0, 0, 0,
00157 0, 24, 25, 0, 26, 27, 40, 41, 42, 43,
00158 0, 0, 0, 0, 0, 40, 41, 42, 43, 0,
00159 0, 40, 41, 42, 43, 0, 0, 0, 0, 0,
00160 0, 0, 40, 41,
00161 };
00162 short yycheck[] = { 33,
00163 258, 123, 51, 41, 41, 40, 40, 61, 258, 42,
00164 260, 41, 42, 43, 47, 45, 41, 47, 125, 46,
00165 40, 125, 71, 72, 258, 41, 61, 43, 58, 45,
00166 258, 46, 125, 63, 46, 258, 46, 46, 258, 41,
00167 125, 43, 58, 45, 258, 42, 43, 63, 45, 0,
00168 47, 75, 41, 13, 3, -1, 58, -1, -1, -1,
00169 -1, 63, -1, -1, -1, 41, 63, -1, -1, 58,
00170 -1, -1, -1, -1, -1, -1, -1, -1, -1, 41,
00171 -1, -1, 58, -1, -1, -1, 41, -1, -1, -1,
00172 -1, -1, -1, 41, -1, 125, 58, -1, 41, 42,
00173 43, -1, 45, 58, 47, -1, -1, 33, -1, 125,
00174 58, 41, 42, 43, 40, 45, -1, 47, -1, -1,
00175 63, 42, 43, 125, 45, -1, 47, 42, 43, -1,
00176 45, -1, 47, 63, -1, -1, 125, 58, 42, 43,
00177 -1, 45, 63, 47, -1, -1, -1, -1, 63, 125,
00178 -1, 258, 259, 260, 258, 259, 260, 264, -1, 63,
00179 264, -1, -1, 125, -1, 258, 259, 260, -1, -1,
00180 125, 264, -1, 258, 259, 260, -1, 125, -1, 264,
00181 -1, 19, -1, 21, -1, -1, -1, -1, -1, -1,
00182 -1, 29, 30, -1, -1, -1, -1, -1, -1, -1,
00183 -1, -1, 40, 41, 42, 43, 44, 45, 46, 47,
00184 48, -1, 50, -1, -1, -1, -1, -1, -1, -1,
00185 -1, -1, -1, 257, 258, -1, 260, 261, 258, 259,
00186 260, 265, 270, 270, 264, 73, 266, 267, 268, 269,
00187 270, -1, 258, 259, 260, 270, -1, -1, 264, -1,
00188 266, 267, 268, 269, 270, -1, 258, 259, 260, -1,
00189 -1, -1, 264, -1, 266, 267, 268, 269, 270, 258,
00190 259, 260, -1, -1, -1, 264, -1, 266, 267, 268,
00191 269, 270, 258, 259, 260, -1, -1, -1, 264, -1,
00192 266, 267, 268, 269, 270, -1, 258, 259, 260, -1,
00193 -1, -1, 264, 258, 259, 260, 268, 269, 270, 264,
00194 258, 259, 260, 268, 269, 270, 264, -1, -1, -1,
00195 -1, -1, 270, 266, 267, 268, 269, -1, -1, -1,
00196 -1, 257, 258, -1, 260, 261, 266, 267, 268, 269,
00197 -1, -1, -1, -1, -1, 266, 267, 268, 269, -1,
00198 -1, 266, 267, 268, 269, -1, -1, -1, -1, -1,
00199 -1, -1, 266, 267,
00200 };
00201 #define YYFINAL 2
00202 #ifndef YYDEBUG
00203 #define YYDEBUG 0
00204 #endif
00205 #define YYMAXTOKEN 270
00206 #if YYDEBUG
00207 char *yyname[] = {
00208 "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00209 "'!'",0,0,0,0,0,0,"'('","')'","'*'","'+'",0,"'-'","'.'","'/'",0,0,0,0,0,0,0,0,0,
00210 0,"':'",0,0,"'='",0,"'?'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00211 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,
00212 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00213 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00214 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00215 0,0,0,0,0,0,0,0,0,0,"INT","IDENTIFIER","COMMENT","Object","EnumObjectType",
00216 "Cos","Sin","If","Loop","EQ","NEQ","AND","OR","\", \"",
00217 };
00218 char *yyrule[] = {
00219 "$accept : program",
00220 "program : methods",
00221 "methods : method",
00222 "methods : methods method",
00223 "method : IDENTIFIER scope",
00224 "scope : '{' '}'",
00225 "scope : '{' statements '}'",
00226 "statements : statement",
00227 "statements : statements statement",
00228 "statement : if_statement",
00229 "statement : assign_statement",
00230 "statement : loop_statement",
00231 "statement : object_statement",
00232 "statement : COMMENT",
00233 "if_statement : If '(' expr ')' scope",
00234 "assign_statement : IDENTIFIER '=' expr",
00235 "assign_statement : Object '.' IDENTIFIER '=' expr",
00236 "loop_statement : IDENTIFIER '=' Loop Object '.' IDENTIFIER scope",
00237 "loop_statement : IDENTIFIER '=' Loop IDENTIFIER '.' IDENTIFIER scope",
00238 "object_statement : Object '.' IDENTIFIER '(' parameters ')'",
00239 "parameters :",
00240 "parameters : parameter",
00241 "parameters : parameters \", \" parameter",
00242 "parameter : expr",
00243 "expr : INT",
00244 "expr : EnumObjectType",
00245 "expr : Object '.' IDENTIFIER",
00246 "expr : IDENTIFIER",
00247 "expr : IDENTIFIER '.' IDENTIFIER",
00248 "expr : expr '+' expr",
00249 "expr : expr '-' expr",
00250 "expr : expr '*' expr",
00251 "expr : expr '/' expr",
00252 "expr : expr EQ expr",
00253 "expr : expr '?' expr ':' expr",
00254 "expr : '(' expr ')'",
00255 "expr : '!' expr",
00256 "expr : expr NEQ expr",
00257 "expr : expr AND expr",
00258 "expr : expr OR expr",
00259 };
00260 #endif
00261 #ifdef YYSTACKSIZE
00262 #undef YYMAXDEPTH
00263 #define YYMAXDEPTH YYSTACKSIZE
00264 #else
00265 #ifdef YYMAXDEPTH
00266 #define YYSTACKSIZE YYMAXDEPTH
00267 #else
00268 #define YYSTACKSIZE 500
00269 #define YYMAXDEPTH 500
00270 #endif
00271 #endif
00272 int yydebug;
00273 int yynerrs;
00274 int yyerrflag;
00275 int yychar;
00276 short *yyssp;
00277 YYSTYPE *yyvsp;
00278 YYSTYPE yyval;
00279 YYSTYPE yylval;
00280 short yyss[YYSTACKSIZE];
00281 YYSTYPE yyvs[YYSTACKSIZE];
00282 #define yystacksize YYSTACKSIZE
00283 #line 420 "rowo.y"
00284
00285
00286 int yyerror(char *s)
00287 {
00288 int i;
00289
00290 printf("%d>%s\n", line, the_str);
00291 printf("%d ", line);
00292 for (i = 1; i < x_ptr; i++)
00293 printf(" ");
00294 printf("^ yyerror '%s'\n", s);
00295 failed = true;
00296 return 0;
00297 }
00298
00299
00300 int yylex()
00301 {
00302 size_t x;
00303
00304 while (C == ' ' || C == 9)
00305 {
00306 the_ptr++;
00307 }
00308 while (!C && !feof(fil))
00309 {
00310 fgets(the_str, 1000, fil);
00311 the_str[strlen(the_str) - 1] = 0;
00312 for (size_t i = 0; i < strlen(the_str); i++)
00313 if (the_str[i] == 9)
00314 the_str[i] = ' ';
00315 the_ptr = 0;
00316 line++;
00317 while (C == ' ' || C == 9)
00318 {
00319 the_ptr++;
00320 }
00321 }
00322 if (feof(fil))
00323 {
00324 return 0;
00325 }
00326 x_ptr = the_ptr;
00327 if (C == '=' && C1 == '=')
00328 {
00329 the_ptr += 2;
00330 return EQ;
00331 }
00332 if (C == '!' && C1 == '=')
00333 {
00334 the_ptr += 2;
00335 return NEQ;
00336 }
00337 if (C == '&' && C1 == '&')
00338 {
00339 the_ptr += 2;
00340 return AND;
00341 }
00342 if (C == '|' && C1 == '|')
00343 {
00344 the_ptr += 2;
00345 return OR;
00346 }
00347 if (C == '/' && C1 == '/')
00348 {
00349 strcpy(yylval.str, the_str + the_ptr);
00350 C = 0;
00351 return COMMENT;
00352 }
00353 if (isalpha(C))
00354 {
00355 x = the_ptr++;
00356 while (isalnum(C) || C == '_')
00357 {
00358 the_ptr++;
00359 }
00360 std::string ord = static_cast<std::string>(the_str).substr(x, the_ptr - x);
00361 strcpy(yylval.str, ord.c_str());
00362 if (ord == "if")
00363 return If;
00364 if (ord == "radar" || ord == "turret" || ord == "gun" || ord == "robot" || ord == "shields" )
00365 {
00366 return Object;
00367 }
00368 if (ord == "Robot")
00369 {
00370 yylval.l = MAPOBJECT_ROBOT;
00371 return EnumObjectType;
00372 }
00373 if (ord == "Portal")
00374 {
00375 yylval.l = MAPOBJECT_PORTAL;
00376 return EnumObjectType;
00377 }
00378 if (ord == "Powerup")
00379 {
00380 yylval.l = MAPOBJECT_POWERUP_UNKNOWN;
00381 return EnumObjectType;
00382 }
00383 if (ord == "Base")
00384 {
00385 yylval.l = MAPOBJECT_BASE;
00386 return EnumObjectType;
00387 }
00388 if (ord == "Item")
00389 {
00390 yylval.l = MAPOBJECT_ITEM;
00391 return EnumObjectType;
00392 }
00393 if (ord == "Nothing")
00394 {
00395 yylval.l = MAPOBJECT_NOTHING;
00396 return EnumObjectType;
00397 }
00398 if (ord == "loop")
00399 return Loop;
00400 return IDENTIFIER;
00401 }
00402 if (isdigit(C))
00403 {
00404 bool f = false;
00405 x = the_ptr;
00406 while (isdigit(C))
00407 {
00408 if (!isdigit(C))
00409 f = true;
00410 the_ptr++;
00411 }
00412 std::string ord = static_cast<std::string>(the_str).substr(x, the_ptr - x);
00413
00414
00415
00416
00417
00418
00419
00420 yylval.l = atol(ord.c_str());
00421 return INT;
00422 }
00423 return the_str[the_ptr++];
00424 }
00425
00426
00427 void parse_file(const std::string& filename)
00428 {
00429 *the_str = 0;
00430 the_ptr = 0;
00431 line = 0;
00432 uniq = 1;
00433 codestr = "";
00434 failed = false;
00435 while (codemap.size())
00436 {
00437 codemap.erase(codemap.begin());
00438 }
00439 while (variables.size())
00440 {
00441 variables.erase(variables.begin());
00442 }
00443 if ((fil = fopen(filename.c_str(), "rt")) != NULL)
00444 {
00445 yyparse();
00446 fclose(fil);
00447 }
00448 else
00449 {
00450 fprintf(stderr, "Couldn't open '%s'...\n", filename.c_str());
00451 failed = true;
00452 }
00453 }
00454
00455
00456 short reg_variable(const std::string& name,int type)
00457 {
00458 for (std::vector<VARIABLE *>::iterator it = variables.begin(); it != variables.end(); it++)
00459 {
00460 VARIABLE *p = *it;
00461 if (name == p -> name)
00462 {
00463 if (type && !p -> type)
00464 p -> type = type;
00465 if (type && p -> type && type != p -> type)
00466 fprintf(stderr,"Variable type mismatch: '%s'\n",name.c_str());
00467 return p -> nr;
00468 }
00469 }
00470 VARIABLE *p = new VARIABLE(name, type, variables.size());
00471 variables.push_back(p);
00472 return p -> nr;
00473 }
00474
00475
00476 void check_property(const std::string& object, const std::string& property)
00477 {
00478 }
00479
00480
00481 void check_method(const std::string& object, const std::string& method)
00482 {
00483 }
00484
00485
00486 void add_bytecode(char *s, int opcode)
00487 {
00488 sprintf(s + strlen(s), "%02x", opcode);
00489 }
00490
00491
00492 void add_bytecode(char *s, int opcode, short valx)
00493 {
00494 unsigned short val;
00495 if (valx < 0)
00496 {
00497 val = -valx;
00498 val |= 0x8000;
00499 }
00500 else
00501 {
00502 val = valx;
00503 }
00504 sprintf(s + strlen(s), "%02x%04x", opcode, val);
00505 }
00506
00507
00508 void add_bytecode(char *s, int opcode, long val)
00509 {
00510 sprintf(s + strlen(s), "%02x%08lx", opcode, val);
00511 }
00512
00513
00514 void add_bytecode(char *s, int opcode, const std::string& object, const std::string& property_or_method)
00515 {
00516 int objectcode = 0;
00517 int val = 0;
00518 {
00519
00520 if (!strcmp(object.c_str(), "robot"))
00521 {
00522 objectcode = ROBOTOBJECT_ROBOT;
00523 if (property_or_method == "ok")
00524 val = 1;
00525 if (property_or_method == "damage")
00526 val = 2;
00527 if (property_or_method == "repair_rate")
00528 val = 3;
00529 if (property_or_method == "inventory")
00530 val = 4;
00531 if (property_or_method == "power")
00532 val = 5;
00533 if (property_or_method == "charging")
00534 val = 6;
00535 }
00536 else
00537 if (!strcmp(object.c_str(), "radar"))
00538 {
00539 objectcode = ROBOTOBJECT_RADAR;
00540 if (property_or_method == "ok")
00541 val = 1;
00542 if (property_or_method == "damage")
00543 val = 2;
00544 if (property_or_method == "repair_rate")
00545 val = 3;
00546 }
00547 else
00548 if (!strcmp(object.c_str(), "turret"))
00549 {
00550 objectcode = ROBOTOBJECT_TURRET;
00551 if (property_or_method == "ok")
00552 val = 1;
00553 if (property_or_method == "damage")
00554 val = 2;
00555 if (property_or_method == "repair_rate")
00556 val = 3;
00557 }
00558 else
00559 if (!strcmp(object.c_str(), "gun"))
00560 {
00561 objectcode = ROBOTOBJECT_GUN;
00562 if (property_or_method == "ok")
00563 val = 1;
00564 if (property_or_method == "damage")
00565 val = 2;
00566 if (property_or_method == "repair_rate")
00567 val = 3;
00568 }
00569 else
00570 if (!strcmp(object.c_str(), "shields"))
00571 {
00572 objectcode = ROBOTOBJECT_SHIELDS;
00573 if (property_or_method == "ok")
00574 val = 1;
00575 if (property_or_method == "damage")
00576 val = 2;
00577 if (property_or_method == "repair_rate")
00578 val = 3;
00579 }
00580 else
00581 {
00582 printf("Unknown object: %s\n", object.c_str() );
00583 failed = true;
00584 }
00585 }
00586 sprintf(s + strlen(s), "%02x%02x%02x", opcode, objectcode, val);
00587 }
00588
00589
00590 #line 591 "y.tab.c"
00591 #define YYABORT goto yyabort
00592 #define YYREJECT goto yyabort
00593 #define YYACCEPT goto yyaccept
00594 #define YYERROR goto yyerrlab
00595 int
00596 yyparse()
00597 {
00598 register int yym, yyn, yystate;
00599 #if YYDEBUG
00600 register char *yys;
00601 extern char *getenv();
00602
00603 if (yys = getenv("YYDEBUG"))
00604 {
00605 yyn = *yys;
00606 if (yyn >= '0' && yyn <= '9')
00607 yydebug = yyn - '0';
00608 }
00609 #endif
00610
00611 yynerrs = 0;
00612 yyerrflag = 0;
00613 yychar = (-1);
00614
00615 yyssp = yyss;
00616 yyvsp = yyvs;
00617 *yyssp = yystate = 0;
00618
00619 yyloop:
00620 if (yyn = yydefred[yystate]) goto yyreduce;
00621 if (yychar < 0)
00622 {
00623 if ((yychar = yylex()) < 0) yychar = 0;
00624 #if YYDEBUG
00625 if (yydebug)
00626 {
00627 yys = 0;
00628 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
00629 if (!yys) yys = "illegal-symbol";
00630 printf("%sdebug: state %d, reading %d (%s)\n",
00631 YYPREFIX, yystate, yychar, yys);
00632 }
00633 #endif
00634 }
00635 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
00636 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
00637 {
00638 #if YYDEBUG
00639 if (yydebug)
00640 printf("%sdebug: state %d, shifting to state %d\n",
00641 YYPREFIX, yystate, yytable[yyn]);
00642 #endif
00643 if (yyssp >= yyss + yystacksize - 1)
00644 {
00645 goto yyoverflow;
00646 }
00647 *++yyssp = yystate = yytable[yyn];
00648 *++yyvsp = yylval;
00649 yychar = (-1);
00650 if (yyerrflag > 0) --yyerrflag;
00651 goto yyloop;
00652 }
00653 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
00654 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
00655 {
00656 yyn = yytable[yyn];
00657 goto yyreduce;
00658 }
00659 if (yyerrflag) goto yyinrecovery;
00660 #ifdef lint
00661 goto yynewerror;
00662 #endif
00663 yynewerror:
00664 yyerror("syntax error");
00665 #ifdef lint
00666 goto yyerrlab;
00667 #endif
00668 yyerrlab:
00669 ++yynerrs;
00670 yyinrecovery:
00671 if (yyerrflag < 3)
00672 {
00673 yyerrflag = 3;
00674 for (;;)
00675 {
00676 if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
00677 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
00678 {
00679 #if YYDEBUG
00680 if (yydebug)
00681 printf("%sdebug: state %d, error recovery shifting\
00682 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
00683 #endif
00684 if (yyssp >= yyss + yystacksize - 1)
00685 {
00686 goto yyoverflow;
00687 }
00688 *++yyssp = yystate = yytable[yyn];
00689 *++yyvsp = yylval;
00690 goto yyloop;
00691 }
00692 else
00693 {
00694 #if YYDEBUG
00695 if (yydebug)
00696 printf("%sdebug: error recovery discarding state %d\n",
00697 YYPREFIX, *yyssp);
00698 #endif
00699 if (yyssp <= yyss) goto yyabort;
00700 --yyssp;
00701 --yyvsp;
00702 }
00703 }
00704 }
00705 else
00706 {
00707 if (yychar == 0) goto yyabort;
00708 #if YYDEBUG
00709 if (yydebug)
00710 {
00711 yys = 0;
00712 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
00713 if (!yys) yys = "illegal-symbol";
00714 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
00715 YYPREFIX, yystate, yychar, yys);
00716 }
00717 #endif
00718 yychar = (-1);
00719 goto yyloop;
00720 }
00721 yyreduce:
00722 #if YYDEBUG
00723 if (yydebug)
00724 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
00725 YYPREFIX, yystate, yyn, yyrule[yyn]);
00726 #endif
00727 yym = yylen[yyn];
00728 yyval = yyvsp[1-yym];
00729 switch (yyn)
00730 {
00731 case 4:
00732 #line 80 "rowo.y"
00733 {
00734
00735 add_bytecode(yyvsp[0].code.bytecode, 0x84);
00736
00737 codemap[yyvsp[-1].str] = codestr.size() / 2;
00738 codestr += yyvsp[0].code.bytecode;
00739 }
00740 break;
00741 case 5:
00742 #line 88 "rowo.y"
00743 {
00744 *yyval.code.code = 0;
00745 *yyval.code.bytecode = 0;
00746 }
00747 break;
00748 case 6:
00749 #line 92 "rowo.y"
00750 {
00751 strcpy(yyval.code.code, yyvsp[-1].code.code);
00752
00753 strcpy(yyval.code.bytecode, yyvsp[-1].code.bytecode);
00754 }
00755 break;
00756 case 7:
00757 #line 98 "rowo.y"
00758 {
00759 strcpy(yyval.code.code, yyvsp[0].code.code);
00760
00761 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
00762 }
00763 break;
00764 case 8:
00765 #line 103 "rowo.y"
00766 {
00767 strcpy(yyval.code.code, yyvsp[-1].code.code);
00768 strcat(yyval.code.code, yyvsp[0].code.code);
00769
00770 strcpy(yyval.code.bytecode, yyvsp[-1].code.bytecode);
00771 strcat(yyval.code.bytecode, yyvsp[0].code.bytecode);
00772 }
00773 break;
00774 case 9:
00775 #line 111 "rowo.y"
00776 {
00777 strcpy(yyval.code.code, yyvsp[0].code.code);
00778
00779 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
00780 }
00781 break;
00782 case 10:
00783 #line 116 "rowo.y"
00784 {
00785 strcpy(yyval.code.code, yyvsp[0].code.code);
00786
00787 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
00788 }
00789 break;
00790 case 11:
00791 #line 121 "rowo.y"
00792 {
00793 strcpy(yyval.code.code, yyvsp[0].code.code);
00794
00795 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
00796 }
00797 break;
00798 case 12:
00799 #line 126 "rowo.y"
00800 {
00801 strcpy(yyval.code.code, yyvsp[0].code.code);
00802
00803 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
00804 }
00805 break;
00806 case 13:
00807 #line 131 "rowo.y"
00808 { *yyval.code.code = 0;
00809 *yyval.code.bytecode = 0;
00810 }
00811 break;
00812 case 14:
00813 #line 135 "rowo.y"
00814 {
00815
00816 int x = uniq++;
00817 *yyval.code.code = 0;
00818 strcat(yyval.code.code, " // if_statement\n");
00819 strcat(yyval.code.code, yyvsp[-2].code.code);
00820 sprintf(yyval.code.code + strlen(yyval.code.code), " jz label_%d\n", x);
00821 strcat(yyval.code.code, yyvsp[0].code.code);
00822 sprintf(yyval.code.code + strlen(yyval.code.code), "label_%d:\n", x);
00823
00824 strcpy(yyval.code.bytecode, yyvsp[-2].code.bytecode);
00825 short len = strlen(yyvsp[0].code.bytecode) / 2;
00826 add_bytecode(yyval.code.bytecode, 0x0a, len);
00827 strcat(yyval.code.bytecode, yyvsp[0].code.bytecode);
00828 }
00829 break;
00830 case 15:
00831 #line 151 "rowo.y"
00832 {
00833 *yyval.code.code = 0;
00834 strcat(yyval.code.code, " // assign_statement\n");
00835 strcat(yyval.code.code, yyvsp[0].code.code);
00836 sprintf(yyval.code.code + strlen(yyval.code.code), " ld $%s, a\n", yyvsp[-2].str);
00837
00838 short var = reg_variable(yyvsp[-2].str, 1);
00839
00840 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
00841 add_bytecode(yyval.code.bytecode, 0x0d, var);
00842 }
00843 break;
00844 case 16:
00845 #line 162 "rowo.y"
00846 {
00847 *yyval.code.code = 0;
00848 strcat(yyval.code.code, " // assign_statement\n");
00849 strcat(yyval.code.code, yyvsp[0].code.code);
00850 sprintf(yyval.code.code + strlen(yyval.code.code), " ld $%s.%s, a\n", yyvsp[-4].str, yyvsp[-2].str);
00851
00852 check_property(yyvsp[-4].str, yyvsp[-2].str);
00853
00854 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
00855 add_bytecode(yyval.code.bytecode, 0x0f, yyvsp[-4].str, yyvsp[-2].str);
00856 }
00857 break;
00858 case 17:
00859 #line 174 "rowo.y"
00860 {
00861 short var = reg_variable(yyvsp[-6].str, 2);
00862 check_property(yyvsp[-3].str, yyvsp[-1].str);
00863
00864 *yyval.code.bytecode = 0;
00865 add_bytecode(yyval.code.bytecode, 0x82, yyvsp[-3].str, yyvsp[-1].str);
00866 strcat(yyval.code.bytecode, "0000");
00867 size_t x = strlen(yyval.code.bytecode);
00868 add_bytecode(yyval.code.bytecode, 0x83, var);
00869 short len = strlen(yyvsp[0].code.bytecode) / 2 + 3;
00870 add_bytecode(yyval.code.bytecode, 0x0a, len);
00871 strcat(yyval.code.bytecode, yyvsp[0].code.bytecode);
00872 len = strlen(yyvsp[0].code.bytecode) / 2 + 6;
00873 len = -len;
00874 add_bytecode(yyval.code.bytecode, 0x81, len);
00875
00876 size_t body = (strlen(yyval.code.bytecode) - x) / 2;
00877 char slask[100];
00878 sprintf(slask, "%04x", body);
00879 memcpy(yyval.code.bytecode + x - 4, slask, 4);
00880 }
00881 break;
00882 case 18:
00883 #line 195 "rowo.y"
00884 {
00885 short var1 = reg_variable(yyvsp[-6].str, 2);
00886 short var2 = reg_variable(yyvsp[-3].str);
00887 short len = strlen(yyvsp[-1].str);
00888 *yyval.code.bytecode = 0;
00889 add_bytecode(yyval.code.bytecode, 0x11, var2);
00890 sprintf(yyval.code.bytecode + strlen(yyval.code.bytecode), "%02x", len);
00891 for (int i = 0; i < len; i++)
00892 {
00893 sprintf(yyval.code.bytecode + strlen(yyval.code.bytecode), "%02x", yyvsp[-1].str[i]);
00894 }
00895 strcat(yyval.code.bytecode, "0000");
00896 size_t x = strlen(yyval.code.bytecode);
00897 add_bytecode(yyval.code.bytecode, 0x83, var1);
00898 len = strlen(yyvsp[0].code.bytecode) / 2 + 3;
00899 add_bytecode(yyval.code.bytecode, 0x0a, len);
00900 strcat(yyval.code.bytecode, yyvsp[0].code.bytecode);
00901 len = strlen(yyvsp[0].code.bytecode) / 2 + 6;
00902 len = -len;
00903 add_bytecode(yyval.code.bytecode, 0x81, len);
00904
00905 size_t body = (strlen(yyval.code.bytecode) - x) / 2;
00906 char slask[100];
00907 sprintf(slask, "%04x", body);
00908 memcpy(yyval.code.bytecode + x - 4, slask, 4);
00909 }
00910 break;
00911 case 19:
00912 #line 222 "rowo.y"
00913 {
00914 *yyval.code.code = 0;
00915 strcat(yyval.code.code, " // object_statement\n");
00916 strcat(yyval.code.code, yyvsp[-1].code.code);
00917 sprintf(yyval.code.code + strlen(yyval.code.code), " call $%s.%s\n", yyvsp[-5].str, yyvsp[-3].str);
00918 strcat(yyval.code.code, " pop a // ? - call returns with value in a, not on stack perhaps?\n");
00919
00920 check_method(yyvsp[-5].str, yyvsp[-3].str);
00921
00922 *yyval.code.bytecode = 0;
00923 strcpy(yyval.code.bytecode, yyvsp[-1].code.bytecode);
00924 add_bytecode(yyval.code.bytecode, 0x0e, yyvsp[-5].str, yyvsp[-3].str);
00925 }
00926 break;
00927 case 20:
00928 #line 236 "rowo.y"
00929 {
00930 *yyval.code.code = 0;
00931 *yyval.code.bytecode = 0;
00932 }
00933 break;
00934 case 21:
00935 #line 240 "rowo.y"
00936 {
00937 strcpy(yyval.code.code, yyvsp[0].code.code);
00938
00939 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
00940 }
00941 break;
00942 case 22:
00943 #line 245 "rowo.y"
00944 {
00945 strcpy(yyval.code.code, yyvsp[-2].code.code);
00946 strcat(yyval.code.code, yyvsp[0].code.code);
00947
00948 strcpy(yyval.code.bytecode, yyvsp[-2].code.bytecode);
00949 strcat(yyval.code.bytecode, yyvsp[0].code.bytecode);
00950 }
00951 break;
00952 case 23:
00953 #line 253 "rowo.y"
00954 {
00955 strcpy(yyval.code.code, yyvsp[0].code.code);
00956 strcat(yyval.code.code, " push a\n");
00957
00958 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
00959 add_bytecode(yyval.code.bytecode, 0x02);
00960 }
00961 break;
00962 case 24:
00963 #line 261 "rowo.y"
00964 { sprintf(yyval.code.code, " ld a, %ld\n", yyvsp[0].l);
00965
00966 *yyval.code.bytecode = 0;
00967 add_bytecode(yyval.code.bytecode, 0x03, yyvsp[0].l);
00968 }
00969 break;
00970 case 25:
00971 #line 266 "rowo.y"
00972 {
00973 sprintf(yyval.code.code, " ld a, %ld\n", yyvsp[0].l);
00974
00975 *yyval.code.bytecode = 0;
00976 add_bytecode(yyval.code.bytecode, 0x03, yyvsp[0].l);
00977 }
00978 break;
00979 case 26:
00980 #line 272 "rowo.y"
00981 {
00982 sprintf(yyval.code.code, " ld a, $%s.%s\n", yyvsp[-2].str, yyvsp[0].str);
00983
00984 check_property(yyvsp[-2].str, yyvsp[0].str);
00985
00986 *yyval.code.bytecode = 0;
00987 add_bytecode(yyval.code.bytecode, 0x01, yyvsp[-2].str, yyvsp[0].str);
00988 }
00989 break;
00990 case 27:
00991 #line 280 "rowo.y"
00992 { sprintf(yyval.code.code, " ld a, $%s\n", yyvsp[0].str);
00993
00994 short var = reg_variable(yyvsp[0].str);
00995
00996 *yyval.code.bytecode = 0;
00997 add_bytecode(yyval.code.bytecode, 0x0c, var);
00998 }
00999 break;
01000 case 28:
01001 #line 287 "rowo.y"
01002 {
01003 sprintf(yyval.code.code, " ld a, $%s.%s\n", yyvsp[-2].str, yyvsp[0].str);
01004
01005 short var = reg_variable(yyvsp[-2].str);
01006 short len = strlen(yyvsp[0].str);
01007 check_property(yyvsp[-2].str, yyvsp[0].str);
01008
01009 *yyval.code.bytecode = 0;
01010 add_bytecode(yyval.code.bytecode, 0x10, var);
01011 sprintf(yyval.code.bytecode + strlen(yyval.code.bytecode), "%02x", len);
01012 for (int i = 0; i < len; i++)
01013 {
01014 sprintf(yyval.code.bytecode + strlen(yyval.code.bytecode), "%02x", yyvsp[0].str[i]);
01015 }
01016 }
01017 break;
01018 case 29:
01019 #line 302 "rowo.y"
01020 {
01021 strcpy(yyval.code.code, yyvsp[0].code.code);
01022 strcat(yyval.code.code, " push a\n");
01023 strcat(yyval.code.code, yyvsp[-2].code.code);
01024 strcat(yyval.code.code, " pop b\n");
01025 strcat(yyval.code.code, " add b\n");
01026
01027 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
01028 add_bytecode(yyval.code.bytecode, 0x02);
01029 strcat(yyval.code.bytecode, yyvsp[-2].code.bytecode);
01030 add_bytecode(yyval.code.bytecode, 0x24);
01031 add_bytecode(yyval.code.bytecode, 0x25);
01032 }
01033 break;
01034 case 30:
01035 #line 315 "rowo.y"
01036 {
01037 strcpy(yyval.code.code, yyvsp[0].code.code);
01038 strcat(yyval.code.code, " push a\n");
01039 strcat(yyval.code.code, yyvsp[-2].code.code);
01040 strcat(yyval.code.code, " pop b\n");
01041 strcat(yyval.code.code, " sub b\n");
01042
01043 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
01044 add_bytecode(yyval.code.bytecode, 0x02);
01045 strcat(yyval.code.bytecode, yyvsp[-2].code.bytecode);
01046 add_bytecode(yyval.code.bytecode, 0x24);
01047 add_bytecode(yyval.code.bytecode, 0x26);
01048 }
01049 break;
01050 case 31:
01051 #line 328 "rowo.y"
01052 {
01053 strcpy(yyval.code.code, yyvsp[0].code.code);
01054 strcat(yyval.code.code, " push a\n");
01055 strcat(yyval.code.code, yyvsp[-2].code.code);
01056 strcat(yyval.code.code, " pop b\n");
01057 strcat(yyval.code.code, " mul b\n");
01058
01059 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
01060 add_bytecode(yyval.code.bytecode, 0x02);
01061 strcat(yyval.code.bytecode, yyvsp[-2].code.bytecode);
01062 add_bytecode(yyval.code.bytecode, 0x24);
01063 add_bytecode(yyval.code.bytecode, 0x27);
01064 }
01065 break;
01066 case 32:
01067 #line 341 "rowo.y"
01068 {
01069 strcpy(yyval.code.code, yyvsp[0].code.code);
01070 strcat(yyval.code.code, " push a\n");
01071 strcat(yyval.code.code, yyvsp[-2].code.code);
01072 strcat(yyval.code.code, " pop b\n");
01073 strcat(yyval.code.code, " div b\n");
01074
01075 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
01076 add_bytecode(yyval.code.bytecode, 0x02);
01077 strcat(yyval.code.bytecode, yyvsp[-2].code.bytecode);
01078 add_bytecode(yyval.code.bytecode, 0x24);
01079 add_bytecode(yyval.code.bytecode, 0x28);
01080 }
01081 break;
01082 case 33:
01083 #line 354 "rowo.y"
01084 {
01085 strcpy(yyval.code.code, yyvsp[-2].code.code);
01086 strcat(yyval.code.code, " push a\n");
01087 strcat(yyval.code.code, yyvsp[0].code.code);
01088 strcat(yyval.code.code, " pop b\n");
01089 strcat(yyval.code.code, " eq b // a=0 if a!=b, a=1 if a==b\n");
01090
01091 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
01092 add_bytecode(yyval.code.bytecode, 0x02);
01093 strcat(yyval.code.bytecode, yyvsp[-2].code.bytecode);
01094 add_bytecode(yyval.code.bytecode, 0x24);
01095 add_bytecode(yyval.code.bytecode, 0x29);
01096 }
01097 break;
01098 case 34:
01099 #line 367 "rowo.y"
01100 {
01101 int x = uniq++;
01102 strcpy(yyval.code.code, yyvsp[-4].code.code);
01103 sprintf(yyval.code.code + strlen(yyval.code.code), " jz label_second_%d\n", x);
01104 strcat(yyval.code.code, yyvsp[-2].code.code);
01105 sprintf(yyval.code.code + strlen(yyval.code.code), " jmp label_%d\n", x);
01106 sprintf(yyval.code.code + strlen(yyval.code.code), "label_second_%d:\n", x);
01107 strcat(yyval.code.code, yyvsp[0].code.code);
01108 sprintf(yyval.code.code + strlen(yyval.code.code), "label_%d:\n", x);
01109
01110 strcpy(yyval.code.bytecode, yyvsp[-4].code.bytecode);
01111 short len = strlen(yyvsp[-2].code.bytecode) / 2 + 3;
01112 add_bytecode(yyval.code.bytecode, 0x0a, len);
01113 strcat(yyval.code.bytecode, yyvsp[-2].code.bytecode);
01114 len = strlen(yyvsp[0].code.bytecode) / 2;
01115 add_bytecode(yyval.code.bytecode, 0x81, len);
01116 strcat(yyval.code.bytecode, yyvsp[0].code.bytecode);
01117 }
01118 break;
01119 case 35:
01120 #line 385 "rowo.y"
01121 {
01122 strcpy(yyval.code.code, yyvsp[-1].code.code);
01123
01124 strcpy(yyval.code.bytecode, yyvsp[-1].code.bytecode);
01125 }
01126 break;
01127 case 36:
01128 #line 390 "rowo.y"
01129 {
01130 *yyval.code.bytecode = 0;
01131 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
01132 add_bytecode(yyval.code.bytecode, 0x12);
01133 }
01134 break;
01135 case 37:
01136 #line 395 "rowo.y"
01137 {
01138 *yyval.code.bytecode = 0;
01139 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
01140 add_bytecode(yyval.code.bytecode, 0x02);
01141 strcat(yyval.code.bytecode, yyvsp[-2].code.bytecode);
01142 add_bytecode(yyval.code.bytecode, 0x24);
01143 add_bytecode(yyval.code.bytecode, 0x33);
01144 }
01145 break;
01146 case 38:
01147 #line 403 "rowo.y"
01148 {
01149 *yyval.code.bytecode = 0;
01150 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
01151 add_bytecode(yyval.code.bytecode, 0x02);
01152 strcat(yyval.code.bytecode, yyvsp[-2].code.bytecode);
01153 add_bytecode(yyval.code.bytecode, 0x24);
01154 add_bytecode(yyval.code.bytecode, 0x34);
01155 }
01156 break;
01157 case 39:
01158 #line 411 "rowo.y"
01159 {
01160 *yyval.code.bytecode = 0;
01161 strcpy(yyval.code.bytecode, yyvsp[0].code.bytecode);
01162 add_bytecode(yyval.code.bytecode, 0x02);
01163 strcat(yyval.code.bytecode, yyvsp[-2].code.bytecode);
01164 add_bytecode(yyval.code.bytecode, 0x24);
01165 add_bytecode(yyval.code.bytecode, 0x35);
01166 }
01167 break;
01168 #line 1169 "y.tab.c"
01169 }
01170 yyssp -= yym;
01171 yystate = *yyssp;
01172 yyvsp -= yym;
01173 yym = yylhs[yyn];
01174 if (yystate == 0 && yym == 0)
01175 {
01176 #if YYDEBUG
01177 if (yydebug)
01178 printf("%sdebug: after reduction, shifting from state 0 to\
01179 state %d\n", YYPREFIX, YYFINAL);
01180 #endif
01181 yystate = YYFINAL;
01182 *++yyssp = YYFINAL;
01183 *++yyvsp = yyval;
01184 if (yychar < 0)
01185 {
01186 if ((yychar = yylex()) < 0) yychar = 0;
01187 #if YYDEBUG
01188 if (yydebug)
01189 {
01190 yys = 0;
01191 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
01192 if (!yys) yys = "illegal-symbol";
01193 printf("%sdebug: state %d, reading %d (%s)\n",
01194 YYPREFIX, YYFINAL, yychar, yys);
01195 }
01196 #endif
01197 }
01198 if (yychar == 0) goto yyaccept;
01199 goto yyloop;
01200 }
01201 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
01202 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
01203 yystate = yytable[yyn];
01204 else
01205 yystate = yydgoto[yym];
01206 #if YYDEBUG
01207 if (yydebug)
01208 printf("%sdebug: after reduction, shifting from state %d \
01209 to state %d\n", YYPREFIX, *yyssp, yystate);
01210 #endif
01211 if (yyssp >= yyss + yystacksize - 1)
01212 {
01213 goto yyoverflow;
01214 }
01215 *++yyssp = yystate;
01216 *++yyvsp = yyval;
01217 goto yyloop;
01218 yyoverflow:
01219 yyerror("yacc stack overflow");
01220 yyabort:
01221 return (1);
01222 yyaccept:
01223 return (0);
01224 }