1 2 3 4 import ro.infoiasi.donald.compiler.cfg.*; 5 import ro.infoiasi.donald.compiler.parser.*; 6 7 8 14 public class TestLexer6 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, 0, 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, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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\1\3\1\4\1\5"; 46 47 private static int [] yy_unpack_YY_ACTION() { 48 int [] result = new int[7]; 49 int offset = 0; 50 offset = yy_unpack_YY_ACTION(YY_ACTION_packed0, offset, result); 51 return result; 52 } 53 54 private static int yy_unpack_YY_ACTION(String packed, int offset, int [] result) { 55 int i = 0; 56 int j = offset; 57 int l = packed.length(); 58 while (i < l) { 59 int count = packed.charAt(i++); 60 int value = packed.charAt(i++); 61 do result[j++] = value; while (--count > 0); 62 } 63 return j; 64 } 65 66 67 70 private static final int [] yy_rowMap = yy_unpack_yy_rowMap(); 71 72 private static final String yy_rowMap_packed0 = 73 "\0\0\0\7\0\16\0\7\0\7\0\7\0\7"; 74 75 private static int [] yy_unpack_yy_rowMap() { 76 int [] result = new int[7]; 77 int offset = 0; 78 offset = yy_unpack_yy_rowMap(yy_rowMap_packed0, offset, result); 79 return result; 80 } 81 82 private static int yy_unpack_yy_rowMap(String packed, int offset, int [] result) { 83 int i = 0; 84 int j = offset; 85 int l = packed.length(); 86 while (i < l) { 87 int high = ((int) packed.charAt(i++)) << 16; 88 result[j++] = high | packed.charAt(i++); 89 } 90 return j; 91 } 92 93 96 private static final int [] yytrans = yy_unpack_yytrans(); 97 98 private static final String yytrans_packed0 = 99 "\1\2\1\3\2\4\1\5\1\6\1\7\11\0\1\4"+ 100 "\4\0"; 101 102 private static int [] yy_unpack_yytrans() { 103 int [] result = new int[21]; 104 int offset = 0; 105 offset = yy_unpack_yytrans(yytrans_packed0, offset, result); 106 return result; 107 } 108 109 private static int yy_unpack_yytrans(String packed, int offset, int [] result) { 110 int i = 0; 111 int j = offset; 112 int l = packed.length(); 113 while (i < l) { 114 int count = packed.charAt(i++); 115 int value = packed.charAt(i++); 116 value--; 117 do result[j++] = value; while (--count > 0); 118 } 119 return j; 120 } 121 122 123 124 private static final int YY_UNKNOWN_ERROR = 0; 125 private static final int YY_NO_MATCH = 1; 126 private static final int YY_PUSHBACK_2BIG = 2; 127 128 129 private static final String YY_ERROR_MSG[] = { 130 "Unkown internal scanner error", 131 "Error: could not match input", 132 "Error: pushback value was too large" 133 }; 134 135 138 private static final int [] YY_ATTRIBUTE = yy_unpack_YY_ATTRIBUTE(); 139 140 private static final String YY_ATTRIBUTE_packed0 = 141 "\1\0\1\11\1\1\4\11"; 142 143 private static int [] yy_unpack_YY_ATTRIBUTE() { 144 int [] result = new int[7]; 145 int offset = 0; 146 offset = yy_unpack_YY_ATTRIBUTE(YY_ATTRIBUTE_packed0, offset, result); 147 return result; 148 } 149 150 private static int yy_unpack_YY_ATTRIBUTE(String packed, int offset, int [] result) { 151 int i = 0; 152 int j = offset; 153 int l = packed.length(); 154 while (i < l) { 155 int count = packed.charAt(i++); 156 int value = packed.charAt(i++); 157 do result[j++] = value; while (--count > 0); 158 } 159 return j; 160 } 161 162 163 private java.io.Reader yy_reader; 164 165 166 private int yy_state; 167 168 169 private int yy_lexical_state = YYINITIAL; 170 171 173 private char yy_buffer[] = new char[YY_BUFFERSIZE]; 174 175 176 private int yy_markedPos; 177 178 179 private int yy_pushbackPos; 180 181 182 private int yy_currentPos; 183 184 185 private int yy_startRead; 186 187 189 private int yy_endRead; 190 191 192 private int yyline; 193 194 195 private int yychar; 196 197 201 private int yycolumn; 202 203 206 private boolean yy_atBOL = true; 207 208 209 private boolean yy_atEOF; 210 211 212 private boolean yy_eof_done; 213 214 215 private Terminals t; 216 public void setTerminals(Terminals t) { 217 this.t = t; 218 } 219 220 221 227 public TestLexer6(java.io.Reader in) { 228 this.yy_reader = in; 229 } 230 231 237 public TestLexer6(java.io.InputStream in) { 238 this(new java.io.InputStreamReader (in)); 239 } 240 241 242 249 private boolean yy_refill() throws java.io.IOException { 250 251 252 if (yy_startRead > 0) { 253 System.arraycopy(yy_buffer, yy_startRead, 254 yy_buffer, 0, 255 yy_endRead-yy_startRead); 256 257 258 yy_endRead-= yy_startRead; 259 yy_currentPos-= yy_startRead; 260 yy_markedPos-= yy_startRead; 261 yy_pushbackPos-= yy_startRead; 262 yy_startRead = 0; 263 } 264 265 266 if (yy_currentPos >= yy_buffer.length) { 267 268 char newBuffer[] = new char[yy_currentPos*2]; 269 System.arraycopy(yy_buffer, 0, newBuffer, 0, yy_buffer.length); 270 yy_buffer = newBuffer; 271 } 272 273 274 int numRead = yy_reader.read(yy_buffer, yy_endRead, 275 yy_buffer.length-yy_endRead); 276 277 if (numRead < 0) { 278 return true; 279 } 280 else { 281 yy_endRead+= numRead; 282 return false; 283 } 284 } 285 286 287 290 public final void yyclose() throws java.io.IOException { 291 yy_atEOF = true; 292 yy_endRead = yy_startRead; 293 294 if (yy_reader != null) 295 yy_reader.close(); 296 } 297 298 299 309 public final void yyreset(java.io.Reader reader) throws java.io.IOException { 310 yy_reader = reader; 311 yy_atBOL = true; 312 yy_atEOF = false; 313 yy_endRead = yy_startRead = 0; 314 yy_currentPos = yy_markedPos = yy_pushbackPos = 0; 315 yyline = yychar = yycolumn = 0; 316 yy_lexical_state = YYINITIAL; 317 } 318 319 320 323 public final int yystate() { 324 return yy_lexical_state; 325 } 326 327 328 333 public final void yybegin(int newState) { 334 yy_lexical_state = newState; 335 } 336 337 338 341 public final String yytext() { 342 return new String ( yy_buffer, yy_startRead, yy_markedPos-yy_startRead ); 343 } 344 345 346 357 public final char yycharat(int pos) { 358 return yy_buffer[yy_startRead+pos]; 359 } 360 361 362 365 public final int yylength() { 366 return yy_markedPos-yy_startRead; 367 } 368 369 370 384 private void yy_ScanError(int errorCode) { 385 String message; 386 try { 387 message = YY_ERROR_MSG[errorCode]; 388 } 389 catch (ArrayIndexOutOfBoundsException e) { 390 message = YY_ERROR_MSG[YY_UNKNOWN_ERROR]; 391 } 392 393 throw new Error (message); 394 } 395 396 397 405 public void yypushback(int number) { 406 if ( number > yylength() ) 407 yy_ScanError(YY_PUSHBACK_2BIG); 408 409 yy_markedPos -= number; 410 } 411 412 413 417 private void yy_do_eof() throws java.io.IOException { 418 if (!yy_eof_done) { 419 yy_eof_done = true; 420 yyclose(); 421 } 422 } 423 424 425 432 public Terminal nextToken() throws java.io.IOException { 433 int yy_input; 434 int yy_action; 435 436 int yy_currentPos_l; 438 int yy_markedPos_l; 439 int yy_endRead_l = yy_endRead; 440 char [] yy_buffer_l = yy_buffer; 441 char [] yycmap_l = yycmap; 442 443 int [] yytrans_l = yytrans; 444 int [] yy_rowMap_l = yy_rowMap; 445 int [] yy_attr_l = YY_ATTRIBUTE; 446 447 while (true) { 448 yy_markedPos_l = yy_markedPos; 449 450 boolean yy_r = false; 451 for (yy_currentPos_l = yy_startRead; yy_currentPos_l < yy_markedPos_l; 452 yy_currentPos_l++) { 453 switch (yy_buffer_l[yy_currentPos_l]) { 454 case '\u000B': 455 case '\u000C': 456 case '\u0085': 457 case '\u2028': 458 case '\u2029': 459 yyline++; 460 yycolumn = 0; 461 yy_r = false; 462 break; 463 case '\r': 464 yyline++; 465 yycolumn = 0; 466 yy_r = true; 467 break; 468 case '\n': 469 if (yy_r) 470 yy_r = false; 471 else { 472 yyline++; 473 yycolumn = 0; 474 } 475 break; 476 default: 477 yy_r = false; 478 yycolumn++; 479 } 480 } 481 482 if (yy_r) { 483 boolean yy_peek; 485 if (yy_markedPos_l < yy_endRead_l) 486 yy_peek = yy_buffer_l[yy_markedPos_l] == '\n'; 487 else if (yy_atEOF) 488 yy_peek = false; 489 else { 490 boolean eof = yy_refill(); 491 yy_markedPos_l = yy_markedPos; 492 yy_buffer_l = yy_buffer; 493 if (eof) 494 yy_peek = false; 495 else 496 yy_peek = yy_buffer_l[yy_markedPos_l] == '\n'; 497 } 498 if (yy_peek) yyline--; 499 } 500 yy_action = -1; 501 502 yy_currentPos_l = yy_currentPos = yy_startRead = yy_markedPos_l; 503 504 yy_state = yy_lexical_state; 505 506 507 yy_forAction: { 508 while (true) { 509 510 if (yy_currentPos_l < yy_endRead_l) 511 yy_input = yy_buffer_l[yy_currentPos_l++]; 512 else if (yy_atEOF) { 513 yy_input = YYEOF; 514 break yy_forAction; 515 } 516 else { 517 yy_currentPos = yy_currentPos_l; 519 yy_markedPos = yy_markedPos_l; 520 boolean eof = yy_refill(); 521 yy_currentPos_l = yy_currentPos; 523 yy_markedPos_l = yy_markedPos; 524 yy_buffer_l = yy_buffer; 525 yy_endRead_l = yy_endRead; 526 if (eof) { 527 yy_input = YYEOF; 528 break yy_forAction; 529 } 530 else { 531 yy_input = yy_buffer_l[yy_currentPos_l++]; 532 } 533 } 534 int yy_next = yytrans_l[ yy_rowMap_l[yy_state] + yycmap_l[yy_input] ]; 535 if (yy_next == -1) break yy_forAction; 536 yy_state = yy_next; 537 538 int yy_attributes = yy_attr_l[yy_state]; 539 if ( (yy_attributes & 1) == 1 ) { 540 yy_action = yy_state; 541 yy_markedPos_l = yy_currentPos_l; 542 if ( (yy_attributes & 8) == 8 ) break yy_forAction; 543 } 544 545 } 546 } 547 548 yy_markedPos = yy_markedPos_l; 550 551 switch (yy_action < 0 ? yy_action : YY_ACTION[yy_action]) { 552 case 1: 553 { throw new RuntimeException ("illegal character \""+yytext()+"\""); } 554 case 6: break; 555 case 3: 556 { return t.find("a"); } 557 case 7: break; 558 case 5: 559 { return t.find("c"); } 560 case 8: break; 561 case 4: 562 { return t.find("b"); } 563 case 9: break; 564 case 2: 565 { } 566 case 10: break; 567 default: 568 if (yy_input == YYEOF && yy_startRead == yy_currentPos) { 569 yy_atEOF = true; 570 yy_do_eof(); 571 { return t.EOF; 572 } 573 } 574 else { 575 yy_ScanError(YY_NO_MATCH); 576 } 577 } 578 } 579 } 580 581 582 } 583 | Popular Tags |