Chromium Code Reviews| 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 class ArrayBasedScanner<S extends SourceString> extends AbstractScanner<S> { | 5 class ArrayBasedScanner<S extends SourceString> extends AbstractScanner<S> { |
| 6 int get charOffset() => byteOffset + extraCharOffset; | 6 int get charOffset() => byteOffset + extraCharOffset; |
| 7 final Token tokens; | 7 final Token tokens; |
| 8 Token tail; | 8 Token tail; |
| 9 int tokenStart; | 9 int tokenStart; |
| 10 int byteOffset; | 10 int byteOffset; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 tail.next = new Token(info, tokenStart); | 42 tail.next = new Token(info, tokenStart); |
| 43 tail = tail.next; | 43 tail = tail.next; |
| 44 } | 44 } |
| 45 | 45 |
| 46 void appendStringToken(PrecedenceInfo info, String value) { | 46 void appendStringToken(PrecedenceInfo info, String value) { |
| 47 tail.next = new StringToken(info, value, tokenStart); | 47 tail.next = new StringToken(info, value, tokenStart); |
| 48 tail = tail.next; | 48 tail = tail.next; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void appendKeywordToken(Keyword keyword) { | 51 void appendKeywordToken(Keyword keyword) { |
| 52 final syntax = keyword.syntax; | |
|
Lasse Reichstein Nielsen
2012/06/15 11:51:13
Please write the type of the variable. In this cas
ahe
2012/06/15 13:12:34
Good point.
Please be aware that when I'm writing
| |
| 53 if (syntax === 'this' || syntax === 'super') discardOpenLt(); | |
| 52 tail.next = new KeywordToken(keyword, tokenStart); | 54 tail.next = new KeywordToken(keyword, tokenStart); |
| 53 tail = tail.next; | 55 tail = tail.next; |
| 54 } | 56 } |
| 55 | 57 |
| 56 void appendEofToken() { | 58 void appendEofToken() { |
| 57 tail.next = new Token(EOF_INFO, charOffset); | 59 tail.next = new Token(EOF_INFO, charOffset); |
| 58 tail = tail.next; | 60 tail = tail.next; |
| 59 // EOF points to itself so there's always infinite look-ahead. | 61 // EOF points to itself so there's always infinite look-ahead. |
| 60 tail.next = tail; | 62 tail.next = tail; |
| 61 discardOpenLt(); | 63 discardOpenLt(); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 83 } | 85 } |
| 84 | 86 |
| 85 void appendWhiteSpace(int next) { | 87 void appendWhiteSpace(int next) { |
| 86 // Do nothing, we don't collect white space. | 88 // Do nothing, we don't collect white space. |
| 87 } | 89 } |
| 88 | 90 |
| 89 void appendBeginGroup(PrecedenceInfo info, String value) { | 91 void appendBeginGroup(PrecedenceInfo info, String value) { |
| 90 Token token = new BeginGroupToken(info, value, tokenStart); | 92 Token token = new BeginGroupToken(info, value, tokenStart); |
| 91 tail.next = token; | 93 tail.next = token; |
| 92 tail = tail.next; | 94 tail = tail.next; |
| 93 while (info.kind !== LT_TOKEN && | 95 if (info.kind !== LT_TOKEN) discardOpenLt(); |
| 94 !groupingStack.isEmpty() && | |
| 95 groupingStack.head.kind === LT_TOKEN) { | |
| 96 groupingStack = groupingStack.tail; | |
| 97 } | |
| 98 groupingStack = groupingStack.prepend(token); | 96 groupingStack = groupingStack.prepend(token); |
| 99 } | 97 } |
| 100 | 98 |
| 101 int appendEndGroup(PrecedenceInfo info, String value, int openKind) { | 99 int appendEndGroup(PrecedenceInfo info, String value, int openKind) { |
| 102 assert(openKind !== LT_TOKEN); | 100 assert(openKind !== LT_TOKEN); |
| 103 appendStringToken(info, value); | 101 appendStringToken(info, value); |
| 104 discardOpenLt(); | 102 discardOpenLt(); |
| 105 if (groupingStack.isEmpty()) { | 103 if (groupingStack.isEmpty()) { |
| 106 return advance(); | 104 return advance(); |
| 107 } | 105 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 | 164 |
| 167 void discardOpenLt() { | 165 void discardOpenLt() { |
| 168 while (!groupingStack.isEmpty() && groupingStack.head.kind === LT_TOKEN) { | 166 while (!groupingStack.isEmpty() && groupingStack.head.kind === LT_TOKEN) { |
| 169 groupingStack = groupingStack.tail; | 167 groupingStack = groupingStack.tail; |
| 170 } | 168 } |
| 171 } | 169 } |
| 172 | 170 |
| 173 // TODO(ahe): make class abstract instead of adding an abstract method. | 171 // TODO(ahe): make class abstract instead of adding an abstract method. |
| 174 abstract peek(); | 172 abstract peek(); |
| 175 } | 173 } |
| OLD | NEW |