(Object reader, Object doublequote, Object opts, Object pendingForms)
| 562 | |
| 563 | public static class StringReader extends AFn{ |
| 564 | public Object invoke(Object reader, Object doublequote, Object opts, Object pendingForms) { |
| 565 | StringBuilder sb = new StringBuilder(); |
| 566 | Reader r = (Reader) reader; |
| 567 | |
| 568 | for(int ch = read1(r); ch != '"'; ch = read1(r)) |
| 569 | { |
| 570 | if(ch == -1) |
| 571 | throw Util.runtimeException("EOF while reading string"); |
| 572 | if(ch == '\\') //escape |
| 573 | { |
| 574 | ch = read1(r); |
| 575 | if(ch == -1) |
| 576 | throw Util.runtimeException("EOF while reading string"); |
| 577 | switch(ch) |
| 578 | { |
| 579 | case 't': |
| 580 | ch = '\t'; |
| 581 | break; |
| 582 | case 'r': |
| 583 | ch = '\r'; |
| 584 | break; |
| 585 | case 'n': |
| 586 | ch = '\n'; |
| 587 | break; |
| 588 | case '\\': |
| 589 | break; |
| 590 | case '"': |
| 591 | break; |
| 592 | case 'b': |
| 593 | ch = '\b'; |
| 594 | break; |
| 595 | case 'f': |
| 596 | ch = '\f'; |
| 597 | break; |
| 598 | case 'u': |
| 599 | { |
| 600 | ch = read1(r); |
| 601 | if (Character.digit(ch, 16) == -1) |
| 602 | throw Util.runtimeException("Invalid unicode escape: \\u" + (char) ch); |
| 603 | ch = readUnicodeChar((PushbackReader) r, ch, 16, 4, true); |
| 604 | break; |
| 605 | } |
| 606 | default: |
| 607 | { |
| 608 | if(Character.isDigit(ch)) |
| 609 | { |
| 610 | ch = readUnicodeChar((PushbackReader) r, ch, 8, 3, false); |
| 611 | if(ch > 0377) |
| 612 | throw Util.runtimeException("Octal escape sequence must be in range [0, 377]."); |
| 613 | } |
| 614 | else |
| 615 | throw Util.runtimeException("Unsupported escape character: \\" + (char) ch); |
| 616 | } |
| 617 | } |
| 618 | } |
| 619 | sb.append((char) ch); |
| 620 | } |
| 621 | return sb.toString(); |
nothing calls this directly
no test coverage detected