| 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 /** | 5 /** |
| 6 * A keyword in the Dart programming language. | 6 * A keyword in the Dart programming language. |
| 7 */ | 7 */ |
| 8 class Keyword implements SourceString { | 8 class Keyword implements SourceString { |
| 9 static final Keyword BREAK = const Keyword("break"); | 9 static final Keyword BREAK = const Keyword("break"); |
| 10 static final Keyword CASE = const Keyword("case"); | 10 static final Keyword CASE = const Keyword("case"); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 bool isEmpty() => false; | 153 bool isEmpty() => false; |
| 154 bool isPrivate() => false; | 154 bool isPrivate() => false; |
| 155 } | 155 } |
| 156 | 156 |
| 157 /** | 157 /** |
| 158 * Abstract state in a state machine for scanning keywords. | 158 * Abstract state in a state machine for scanning keywords. |
| 159 */ | 159 */ |
| 160 class KeywordState { | 160 class KeywordState { |
| 161 abstract bool isLeaf(); | 161 abstract bool isLeaf(); |
| 162 abstract KeywordState next(int c); | 162 abstract KeywordState next(int c); |
| 163 abstract Keyword get keyword(); | 163 abstract Keyword get keyword; |
| 164 | 164 |
| 165 static KeywordState _KEYWORD_STATE; | 165 static KeywordState _KEYWORD_STATE; |
| 166 static KeywordState get KEYWORD_STATE { | 166 static KeywordState get KEYWORD_STATE { |
| 167 if (_KEYWORD_STATE === null) { | 167 if (_KEYWORD_STATE === null) { |
| 168 List<String> strings = new List<String>(Keyword.values.length); | 168 List<String> strings = new List<String>(Keyword.values.length); |
| 169 for (int i = 0; i < Keyword.values.length; i++) { | 169 for (int i = 0; i < Keyword.values.length; i++) { |
| 170 strings[i] = Keyword.values[i].syntax; | 170 strings[i] = Keyword.values[i].syntax; |
| 171 } | 171 } |
| 172 strings.sort((a,b) => a.compareTo(b)); | 172 strings.sort((a,b) => a.compareTo(b)); |
| 173 _KEYWORD_STATE = computeKeywordStateTable(0, strings, 0, strings.length); | 173 _KEYWORD_STATE = computeKeywordStateTable(0, strings, 0, strings.length); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 final Keyword keyword; | 257 final Keyword keyword; |
| 258 | 258 |
| 259 LeafKeywordState(String syntax) : keyword = Keyword.keywords[syntax]; | 259 LeafKeywordState(String syntax) : keyword = Keyword.keywords[syntax]; |
| 260 | 260 |
| 261 bool isLeaf() => true; | 261 bool isLeaf() => true; |
| 262 | 262 |
| 263 KeywordState next(int c) => null; | 263 KeywordState next(int c) => null; |
| 264 | 264 |
| 265 String toString() => keyword.syntax; | 265 String toString() => keyword.syntax; |
| 266 } | 266 } |
| OLD | NEW |