1 2 3 4 import ro.infoiasi.donald.compiler.cfg.*; 5 import ro.infoiasi.donald.compiler.parser.*; 6 7 8 14 public class TestLexer5 implements Lexer { 15 16 17 public static final int YYEOF = -1; 18 19 20 private static final int YY_BUFFERSIZE = 16384; 21 22 23 public static final int YYINITIAL = 0; 24 25 28 private static final char [] yycmap = { 29 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 0, 3, 1, 0, 0, 30 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 33 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35 0, 11, 4, 0, 9, 5, 0, 6, 0, 7, 0, 0, 0, 0, 8, 0, 36 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 37 }; 38 39 42 private static final int [] YY_ACTION = yy_unpack_YY_ACTION(); 43 44 private static final String YY_ACTION_packed0 = 45 "\1\0\1\1\2\2\2\1\1\3\1\4\1\5\3\0"+ 46 "\1\6\1\0\1\7"; 47 48 private static int [] yy_unpack_YY_ACTION() { 49 int [] result = new int[15]; 50 int offset = 0; 51 offset = yy_unpack_YY_ACTION(YY_ACTION_packed0, offset, result); 52 return result; 53 } 54 55 private static int yy_unpack_YY_ACTION(String packed, int offset, int [] result) { 56 int i = 0; 57 int j = offset; 58 int l = packed.length(); 59 while (i < l) { 60 int count = packed.charAt(i++); 61 int value = packed.charAt(i++); 62 do result[j++] = value; while (--count > 0); 63 } 64 return j; 65 } 66 67 68 71 private static final int [] yy_rowMap = yy_unpack_yy_rowMap(); 72 73 private static final String yy_rowMap_packed0 = 74 "\0\0\0\14\0\30\0\14\0\44\0\60\0\14\0\14"+ 75 "\0\14\0\74\0\110\0\124\0\14\0\140\0\14"; 76 77 private static int [] yy_unpack_yy_rowMap() { 78 int [] result = new int[15]; 79 int offset = 0; 80 offset = yy_unpack_yy_rowMap(yy_rowMap_packed0, offset, result); 81 return result; 82 } 83 84 private static int yy_unpack_yy_rowMap(String packed, int offset, int [] result) { 85 int i = 0; 86 int j = offset; 87 int l = packed.length(); 88 while (i < l) { 89 int high = ((int) packed.charAt(i++)) << 16; 90 result[j++] = high | packed.charAt(i++); 91 } 92 return j; 93 } 94 95 98 private static final int [] yytrans = yy_unpack_yytrans(); 99 100 private static final String yytrans_packed0 = 101 "\1\2\1\3\2\4\1\5\1\6\3\2\1\7\1\10"+ 102 "\1\11\16\0\1\4\16\0\1\12\16\0\1\13\11\0"+ 103 "\1\14\16\0\1\15\11\0\1\16\14\0\1\17\3\0"; 104 105 private static int [] yy_unpack_yytrans() { 106 int [] result = new int[108]; 107 int offset = 0; 108 offset = yy_unpack_yytrans(yytrans_packed0, offset, result); 109 return result; 110 } 111 112 private static int yy_unpack_yytrans(String packed, int offset, int [] result) { 113 int i = 0; 114 int j = offset; 115 int l = packed.length(); 116 while (i < l) { 117 int count = packed.charAt(i++); 118 int value = packed.charAt(i++); 119 value--; 120 do result[j++] = value; while (--count > 0); 121 } 122 return j; 123 } 124 125 126 127 private static final int YY_UNKNOWN_ERROR = 0; 128 private static final int YY_NO_MATCH = 1; 129 private static final int YY_PUSHBACK_2BIG = 2; 130 131 132 private static final String YY_ERROR_MSG[] = { 133 "Unkown internal scanner error", 134 "Error: could not match input", 135 "Error: pushback value was too large" 136 }; 137 138 141 private static final int [] YY_ATTRIBUTE = yy_unpack_YY_ATTRIBUTE(); 142 143 private static final String YY_ATTRIBUTE_packed0 = 144 "\1\0\1\11\1\1\1\11\2\1\3\11\3\0\1\11"+ 145 "\1\0\1\11"; 146 147 private static int [] yy_unpack_YY_ATTRIBUTE() { 148 int [] result = new int[15]; 149 int offset = 0; 150 offset = yy_unpack_YY_ATTRIBUTE(YY_ATTRIBUTE_packed0, offset, result); 151 return result; 152 } 153 154 private static int yy_unpack_YY_ATTRIBUTE(String packed, int offset, int [] result) { 155 int i = 0; 156 int j = offset; 157 int l = packed.length(); 158 while (i < l) { 159 int count = packed.charAt(i++); 160 int value = packed.charAt(i++); 161 do result[j++] = value; while (--count > 0); 162 } 163 return j; 164 } 165 166 167 private java.io.Reader yy_reader; 168 169 170 private int yy_state; 171 172 173 private int yy_lexical_state = YYINITIAL; 174 175 177 private char yy_buffer[] = new char[YY_BUFFERSIZE]; 178 179 180 private int yy_markedPos; 181 182 183 private int yy_pushbackPos; 184 185 186 private int yy_currentPos; 187 188 189 private int yy_startRead; 190 191 193 private int yy_endRead; 194 195 196 private int yyline; 197 198 199 private int yychar; 200 201 205 private int yycolumn; 206 207 210 private boolean yy_atBOL = true; 211 212 213 private boolean yy_atEOF; 214 215 216 private boolean yy_eof_done; 217 218 219 private Terminals t; 220 public void setTerminals(Terminals t) { 221 this.t = t; 222 } 223 224 225 231 public TestLexer5(java.io.Reader in) { 232 this.yy_reader = in; 233 } 234 235 241 public TestLexer5(java.io.InputStream in) { 242 this(new java.io.InputStreamReader (in)); 243 } 244 245 246 253 private boolean yy_refill() throws java.io.IOException { 254 255 256 if (yy_startRead > 0) { 257 System.arraycopy(yy_buffer, yy_startRead, 258 yy_buffer, 0, 259 yy_endRead-yy_startRead); 260 261 262 yy_endRead-= yy_startRead; 263 yy_currentPos-= yy_startRead; 264 yy_markedPos-= yy_startRead; 265 yy_pushbackPos-= yy_startRead; 266 yy_startRead = 0; 267 } 268 269 270 if (yy_currentPos >= yy_buffer.length) { 271 272 char newBuffer[] = new char[yy_currentPos*2]; 273 System.arraycopy(yy_buffer, 0, newBuffer, 0, yy_buffer.length); 274 yy_buffer = newBuffer; 275 } 276 277 278 int numRead = yy_reader.read(yy_buffer, yy_endRead, 279 yy_buffer.length-yy_endRead); 280 281 if (numRead < 0) { 282 return true; 283 } 284 else { 285 yy_endRead+= numRead; 286 return false; 287 } 288 } 289 290 291 294 public final void yyclose() throws java.io.IOException { 295 yy_atEOF = true; 296 yy_endRead = yy_startRead; 297 298 if (yy_reader != null) 299 yy_reader.close(); 300 } 301 302 303 313 public final void yyreset(java.io.Reader reader) throws java.io.IOException { 314 yy_reader = reader; 315 yy_atBOL = true; 316 yy_atEOF = false; 317 yy_endRead = yy_startRead = 0; 318 yy_currentPos = yy_markedPos = yy_pushbackPos = 0; 319 yyline = yychar = yycolumn = 0; 320 yy_lexical_state = YYINITIAL; 321 } 322 323 324 327 public final int yystate() { 328 return yy_lexical_state; 329 } 330 331 332 337 public final void yybegin(int newState) { 338 yy_lexical_state = newState; 339 } 340 341 342 345 public final String yytext() { 346 return new String ( yy_buffer, yy_startRead, yy_markedPos-yy_startRead ); 347 } 348 349 350 361 public final char yycharat(int pos) { 362 return yy_buffer[yy_startRead+pos]; 363 } 364 365 366 369 public final int yylength() { 370 return yy_markedPos-yy_startRead; 371 } 372 373 374 388 private void yy_ScanError(int errorCode) { 389 String message; 390 try { 391 message = YY_ERROR_MSG[errorCode]; 392 } 393 catch (ArrayIndexOutOfBoundsException e) { 394 message = YY_ERROR_MSG[YY_UNKNOWN_ERROR]; 395 } 396 397 throw new Error (message); 398 } 399 400 401 409 public void yypushback(int number) { 410 if ( number > yylength() ) 411 yy_ScanError(YY_PUSHBACK_2BIG); 412 413 yy_markedPos -= number; 414 } 415 416 417 421 private void yy_do_eof() throws java.io.IOException { 422 if (!yy_eof_done) { 423 yy_eof_done = true; 424 yyclose(); 425 } 426 } 427 428 429 436 public Terminal nextToken() throws java.io.IOException { 437 int yy_input; 438 int yy_action; 439 440 int yy_currentPos_l; 442 int yy_markedPos_l; 443 int yy_endRead_l = yy_endRead; 444 char [] yy_buffer_l = yy_buffer; 445 char [] yycmap_l = yycmap; 446 447 int [] yytrans_l = yytrans; 448 int [] yy_rowMap_l = yy_rowMap; 449 int [] yy_attr_l = YY_ATTRIBUTE; 450 451 while (true) { 452 yy_markedPos_l = yy_markedPos; 453 454 boolean yy_r = false; 455 for (yy_currentPos_l = yy_startRead; yy_currentPos_l < yy_markedPos_l; 456 yy_currentPos_l++) { 457 switch (yy_buffer_l[yy_currentPos_l]) { 458 case '\u000B': 459 case '\u000C': 460 case '\u0085': 461 case '\u2028': 462 case '\u2029': 463 yyline++; 464 yycolumn = 0; 465 yy_r = false; 466 break; 467 case '\r': 468 yyline++; 469 yycolumn = 0; 470 yy_r = true; 471 break; 472 case '\n': 473 if (yy_r) 474 yy_r = false; 475 else { 476 yyline++; 477 yycolumn = 0; 478 } 479 break; 480 default: 481 yy_r = false; 482 yycolumn++; 483 } 484 } 485 486 if (yy_r) { 487 boolean yy_peek; 489 if (yy_markedPos_l < yy_endRead_l) 490 yy_peek = yy_buffer_l[yy_markedPos_l] == '\n'; 491 else if (yy_atEOF) 492 yy_peek = false; 493 else { 494 boolean eof = yy_refill(); 495 yy_markedPos_l = yy_markedPos; 496 yy_buffer_l = yy_buffer; 497 if (eof) 498 yy_peek = false; 499 else 500 yy_peek = yy_buffer_l[yy_markedPos_l] == '\n'; 501 } 502 if (yy_peek) yyline--; 503 } 504 yy_action = -1; 505 506 yy_currentPos_l = yy_currentPos = yy_startRead = yy_markedPos_l; 507 508 yy_state = yy_lexical_state; 509 510 511 yy_forAction: { 512 while (true) { 513 514 if (yy_currentPos_l < yy_endRead_l) 515 yy_input = yy_buffer_l[yy_currentPos_l++]; 516 else if (yy_atEOF) { 517 yy_input = YYEOF; 518 break yy_forAction; 519 } 520 else { 521 yy_currentPos = yy_currentPos_l; 523 yy_markedPos = yy_markedPos_l; 524 boolean eof = yy_refill(); 525 yy_currentPos_l = yy_currentPos; 527 yy_markedPos_l = yy_markedPos; 528 yy_buffer_l = yy_buffer; 529 yy_endRead_l = yy_endRead; 530 if (eof) { 531 yy_input = YYEOF; 532 break yy_forAction; 533 } 534 else { 535 yy_input = yy_buffer_l[yy_currentPos_l++]; 536 } 537 } 538 int yy_next = yytrans_l[ yy_rowMap_l[yy_state] + yycmap_l[yy_input] ]; 539 if (yy_next == -1) break yy_forAction; 540 yy_state = yy_next; 541 542 int yy_attributes = yy_attr_l[yy_state]; 543 if ( (yy_attributes & 1) == 1 ) { 544 yy_action = yy_state; 545 yy_markedPos_l = yy_currentPos_l; 546 if ( (yy_attributes & 8) == 8 ) break yy_forAction; 547 } 548 549 } 550 } 551 552 yy_markedPos = yy_markedPos_l; 554 555 switch (yy_action < 0 ? yy_action : YY_ACTION[yy_action]) { 556 case 1: 557 { throw new RuntimeException ("illegal character \""+yytext()+"\""); } 558 case 8: break; 559 case 7: 560 { return t.find("begin"); } 561 case 9: break; 562 case 5: 563 { return t.find("a"); } 564 case 10: break; 565 case 4: 566 { return t.find("semicolon"); } 567 case 11: break; 568 case 3: 569 { return t.find("d"); } 570 case 12: break; 571 case 6: 572 { return t.find("end"); } 573 case 13: break; 574 case 2: 575 { } 576 case 14: break; 577 default: 578 if (yy_input == YYEOF && yy_startRead == yy_currentPos) { 579 yy_atEOF = true; 580 yy_do_eof(); 581 { return t.EOF; 582 } 583 } 584 else { 585 yy_ScanError(YY_NO_MATCH); 586 } 587 } 588 } 589 } 590 591 592 } 593 | Popular Tags |