| 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 part of scanner; | 5 part of scanner; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A keyword in the Dart programming language. | 8 * A keyword in the Dart programming language. |
| 9 */ | 9 */ |
| 10 class Keyword extends Iterable<int> implements SourceString { | 10 class Keyword extends Iterable<int> implements SourceString { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 int get hashCode => syntax.hashCode; | 100 int get hashCode => syntax.hashCode; |
| 101 | 101 |
| 102 bool operator ==(other) { | 102 bool operator ==(other) { |
| 103 return other is SourceString && toString() == other.slowToString(); | 103 return other is SourceString && toString() == other.slowToString(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 Iterator<int> get iterator => new StringCodeIterator(syntax); | 106 Iterator<int> get iterator => new StringCodeIterator(syntax); |
| 107 | 107 |
| 108 void printOn(StringBuffer sb) { | 108 void printOn(StringBuffer sb) { |
| 109 sb.add(syntax); | 109 sb.write(syntax); |
| 110 } | 110 } |
| 111 | 111 |
| 112 String toString() => syntax; | 112 String toString() => syntax; |
| 113 String slowToString() => syntax; | 113 String slowToString() => syntax; |
| 114 String get stringValue => syntax; | 114 String get stringValue => syntax; |
| 115 | 115 |
| 116 SourceString copyWithoutQuotes(int initial, int terminal) { | 116 SourceString copyWithoutQuotes(int initial, int terminal) { |
| 117 // TODO(lrn): consider remodelling to avoid having this method in keywords. | 117 // TODO(lrn): consider remodelling to avoid having this method in keywords. |
| 118 return this; | 118 return this; |
| 119 } | 119 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 196 |
| 197 ArrayKeywordState(List<KeywordState> this.table, String syntax) | 197 ArrayKeywordState(List<KeywordState> this.table, String syntax) |
| 198 : super((syntax == null) ? null : Keyword.keywords[syntax]); | 198 : super((syntax == null) ? null : Keyword.keywords[syntax]); |
| 199 | 199 |
| 200 bool isLeaf() => false; | 200 bool isLeaf() => false; |
| 201 | 201 |
| 202 KeywordState next(int c) => table[c - $a]; | 202 KeywordState next(int c) => table[c - $a]; |
| 203 | 203 |
| 204 String toString() { | 204 String toString() { |
| 205 StringBuffer sb = new StringBuffer(); | 205 StringBuffer sb = new StringBuffer(); |
| 206 sb.add("["); | 206 sb.write("["); |
| 207 if (keyword != null) { | 207 if (keyword != null) { |
| 208 sb.add("*"); | 208 sb.write("*"); |
| 209 sb.add(keyword); | 209 sb.write(keyword); |
| 210 sb.add(" "); | 210 sb.write(" "); |
| 211 } | 211 } |
| 212 List<KeywordState> foo = table; | 212 List<KeywordState> foo = table; |
| 213 for (int i = 0; i < foo.length; i++) { | 213 for (int i = 0; i < foo.length; i++) { |
| 214 if (foo[i] != null) { | 214 if (foo[i] != null) { |
| 215 sb.add("${new String.fromCharCodes([i + $a])}: ${foo[i]}; "); | 215 sb.write("${new String.fromCharCodes([i + $a])}: ${foo[i]}; "); |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 sb.add("]"); | 218 sb.write("]"); |
| 219 return sb.toString(); | 219 return sb.toString(); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 | 222 |
| 223 /** | 223 /** |
| 224 * A state that has no outgoing transitions. | 224 * A state that has no outgoing transitions. |
| 225 */ | 225 */ |
| 226 class LeafKeywordState extends KeywordState { | 226 class LeafKeywordState extends KeywordState { |
| 227 LeafKeywordState(String syntax) : super(Keyword.keywords[syntax]); | 227 LeafKeywordState(String syntax) : super(Keyword.keywords[syntax]); |
| 228 | 228 |
| 229 bool isLeaf() => true; | 229 bool isLeaf() => true; |
| 230 | 230 |
| 231 KeywordState next(int c) => null; | 231 KeywordState next(int c) => null; |
| 232 | 232 |
| 233 String toString() => keyword.syntax; | 233 String toString() => keyword.syntax; |
| 234 } | 234 } |
| OLD | NEW |