| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 interface Visitor<R> { | 5 interface Visitor<R> { |
| 6 R visitBlock(Block node); | 6 R visitBlock(Block node); |
| 7 R visitBreakStatement(BreakStatement node); | 7 R visitBreakStatement(BreakStatement node); |
| 8 R visitCatchBlock(CatchBlock node); | 8 R visitCatchBlock(CatchBlock node); |
| 9 R visitClassNode(ClassNode node); | 9 R visitClassNode(ClassNode node); |
| 10 R visitConditional(Conditional node); | 10 R visitConditional(Conditional node); |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 (this.handler)(token, "not a bool ${token.value}"); | 613 (this.handler)(token, "not a bool ${token.value}"); |
| 614 } | 614 } |
| 615 } | 615 } |
| 616 | 616 |
| 617 accept(Visitor visitor) => visitor.visitLiteralBool(this); | 617 accept(Visitor visitor) => visitor.visitLiteralBool(this); |
| 618 } | 618 } |
| 619 | 619 |
| 620 | 620 |
| 621 class StringQuoting { | 621 class StringQuoting { |
| 622 static final StringQuoting SINGLELINE_DQ = | 622 static final StringQuoting SINGLELINE_DQ = |
| 623 const StringQuoting($DQ, raw: false, multiline: false); | 623 const StringQuoting($DQ, raw: false, leftQuoteLength: 1); |
| 624 static final StringQuoting RAW_SINGLELINE_DQ = | 624 static final StringQuoting RAW_SINGLELINE_DQ = |
| 625 const StringQuoting($DQ, raw: true, multiline: false); | 625 const StringQuoting($DQ, raw: true, leftQuoteLength: 1); |
| 626 static final StringQuoting MULTILINE_DQ = | 626 static final StringQuoting MULTILINE_DQ = |
| 627 const StringQuoting($DQ, raw: false, multiline: true); | 627 const StringQuoting($DQ, raw: false, leftQuoteLength: 3); |
| 628 static final StringQuoting RAW_MULTILINE_DQ = | 628 static final StringQuoting RAW_MULTILINE_DQ = |
| 629 const StringQuoting($DQ, raw: true, multiline: true); | 629 const StringQuoting($DQ, raw: true, leftQuoteLength: 3); |
| 630 static final StringQuoting MULTILINE_NL_DQ = |
| 631 const StringQuoting($DQ, raw: false, leftQuoteLength: 4); |
| 632 static final StringQuoting RAW_MULTILINE_NL_DQ = |
| 633 const StringQuoting($DQ, raw: true, leftQuoteLength: 4); |
| 634 static final StringQuoting MULTILINE_NL2_DQ = |
| 635 const StringQuoting($DQ, raw: false, leftQuoteLength: 5); |
| 636 static final StringQuoting RAW_MULTILINE_NL2_DQ = |
| 637 const StringQuoting($DQ, raw: true, leftQuoteLength: 5); |
| 630 static final StringQuoting SINGLELINE_SQ = | 638 static final StringQuoting SINGLELINE_SQ = |
| 631 const StringQuoting($SQ, raw: false, multiline: false); | 639 const StringQuoting($SQ, raw: false, leftQuoteLength: 1); |
| 632 static final StringQuoting RAW_SINGLELINE_SQ = | 640 static final StringQuoting RAW_SINGLELINE_SQ = |
| 633 const StringQuoting($SQ, raw: true, multiline: false); | 641 const StringQuoting($SQ, raw: true, leftQuoteLength: 1); |
| 634 static final StringQuoting MULTILINE_SQ = | 642 static final StringQuoting MULTILINE_SQ = |
| 635 const StringQuoting($SQ, raw: false, multiline: true); | 643 const StringQuoting($SQ, raw: false, leftQuoteLength: 3); |
| 636 static final StringQuoting RAW_MULTILINE_SQ = | 644 static final StringQuoting RAW_MULTILINE_SQ = |
| 637 const StringQuoting($SQ, raw: true, multiline: true); | 645 const StringQuoting($SQ, raw: true, leftQuoteLength: 3); |
| 646 static final StringQuoting MULTILINE_NL_SQ = |
| 647 const StringQuoting($SQ, raw: false, leftQuoteLength: 4); |
| 648 static final StringQuoting RAW_MULTILINE_NL_SQ = |
| 649 const StringQuoting($SQ, raw: true, leftQuoteLength: 4); |
| 650 static final StringQuoting MULTILINE_NL2_SQ = |
| 651 const StringQuoting($SQ, raw: false, leftQuoteLength: 5); |
| 652 static final StringQuoting RAW_MULTILINE_NL2_SQ = |
| 653 const StringQuoting($SQ, raw: true, leftQuoteLength: 5); |
| 654 |
| 655 |
| 638 static final List<StringQuoting> mapping = const <StringQuoting>[ | 656 static final List<StringQuoting> mapping = const <StringQuoting>[ |
| 639 SINGLELINE_DQ, | 657 SINGLELINE_DQ, |
| 640 RAW_SINGLELINE_DQ, | 658 RAW_SINGLELINE_DQ, |
| 641 MULTILINE_DQ, | 659 MULTILINE_DQ, |
| 642 RAW_MULTILINE_DQ, | 660 RAW_MULTILINE_DQ, |
| 661 MULTILINE_NL_DQ, |
| 662 RAW_MULTILINE_NL_DQ, |
| 663 MULTILINE_NL2_DQ, |
| 664 RAW_MULTILINE_NL2_DQ, |
| 643 SINGLELINE_SQ, | 665 SINGLELINE_SQ, |
| 644 RAW_SINGLELINE_SQ, | 666 RAW_SINGLELINE_SQ, |
| 645 MULTILINE_DQ, | 667 MULTILINE_SQ, |
| 646 RAW_MULTILINE_SQ | 668 RAW_MULTILINE_SQ, |
| 669 MULTILINE_NL_SQ, |
| 670 RAW_MULTILINE_NL_SQ, |
| 671 MULTILINE_NL2_SQ, |
| 672 RAW_MULTILINE_NL2_SQ |
| 647 ]; | 673 ]; |
| 648 final bool raw; | 674 final bool raw; |
| 649 final bool multiline; | 675 final int leftQuoteCharCount; |
| 650 final int quote; | 676 final int quote; |
| 651 const StringQuoting(this.quote, [bool raw, bool multiline]) | 677 const StringQuoting(this.quote, [bool raw, int leftQuoteLength]) |
| 652 : this.raw = raw, this.multiline = multiline; | 678 : this.raw = raw, this.leftQuoteCharCount = leftQuoteLength; |
| 653 String get quoteChar() => quote === $DQ ? '"' : "'"; | 679 String get quoteChar() => quote === $DQ ? '"' : "'"; |
| 654 | 680 |
| 655 int get leftQuoteLength() => (raw ? 1 : 0) + (multiline ? 3 : 1); | 681 int get leftQuoteLength() => (raw ? 1 : 0) + leftQuoteCharCount; |
| 656 int get rightQuoteLength() => multiline ? 3 : 1; | 682 int get rightQuoteLength() => (leftQuoteCharCount > 2) ? 3 : 1; |
| 657 static StringQuoting get(int quote, bool raw, bool multiline) => | 683 static StringQuoting get(int quote, bool raw, int quoteLength) { |
| 658 mapping[(raw ? 1 : 0) + (multiline ? 2 : 0) + (quote === $SQ ? 4 : 0)]; | 684 int index = quoteLength - 1; |
| 685 if (quoteLength > 2) index -= 1; |
| 686 return mapping[(raw ? 1 : 0) + index * 2 + (quote === $SQ ? 8 : 0)]; |
| 687 } |
| 659 } | 688 } |
| 660 | 689 |
| 661 | 690 |
| 662 class DartString implements Iterable<int> { | 691 class DartString implements Iterable<int> { |
| 663 factory DartString.literal(String string) => new LiteralDartString(string); | 692 factory DartString.literal(String string) => new LiteralDartString(string); |
| 664 factory DartString.rawString(SourceString source, int length) => | 693 factory DartString.rawString(SourceString source, int length) => |
| 665 new RawSourceDartString(source, length); | 694 new RawSourceDartString(source, length); |
| 666 factory DartString.escapedString(SourceString source, int length) => | 695 factory DartString.escapedString(SourceString source, int length) => |
| 667 new EscapedSourceDartString(source, length); | 696 new EscapedSourceDartString(source, length); |
| 668 DartString(); | 697 DartString(); |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 | 1443 |
| 1415 visitChildren(Visitor visitor) { | 1444 visitChildren(Visitor visitor) { |
| 1416 formals.accept(visitor); | 1445 formals.accept(visitor); |
| 1417 block.accept(visitor); | 1446 block.accept(visitor); |
| 1418 } | 1447 } |
| 1419 | 1448 |
| 1420 Token getBeginToken() => catchKeyword; | 1449 Token getBeginToken() => catchKeyword; |
| 1421 | 1450 |
| 1422 Token getEndToken() => block.getEndToken(); | 1451 Token getEndToken() => block.getEndToken(); |
| 1423 } | 1452 } |
| OLD | NEW |