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 const List<Keyword> values = const <Keyword> [ | 9 static const List<Keyword> values = const <Keyword> [ |
10 const Keyword("break"), | 10 const Keyword("break"), |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 static Map<String, Keyword> _keywords; | 75 static Map<String, Keyword> _keywords; |
76 static Map<String, Keyword> get keywords { | 76 static Map<String, Keyword> get keywords { |
77 if (_keywords === null) { | 77 if (_keywords === null) { |
78 _keywords = computeKeywordMap(); | 78 _keywords = computeKeywordMap(); |
79 } | 79 } |
80 return _keywords; | 80 return _keywords; |
81 } | 81 } |
82 | 82 |
83 const Keyword(String this.syntax, | 83 const Keyword(String this.syntax, |
84 [bool this.isPseudo = false, | 84 {bool this.isPseudo: false, |
85 bool this.isBuiltIn = false, | 85 bool this.isBuiltIn: false, |
86 PrecedenceInfo this.info = KEYWORD_INFO]); | 86 PrecedenceInfo this.info: KEYWORD_INFO}); |
87 | 87 |
88 static Map<String, Keyword> computeKeywordMap() { | 88 static Map<String, Keyword> computeKeywordMap() { |
89 Map<String, Keyword> result = new LinkedHashMap<String, Keyword>(); | 89 Map<String, Keyword> result = new LinkedHashMap<String, Keyword>(); |
90 for (Keyword keyword in values) { | 90 for (Keyword keyword in values) { |
91 result[keyword.syntax] = keyword; | 91 result[keyword.syntax] = keyword; |
92 } | 92 } |
93 return result; | 93 return result; |
94 } | 94 } |
95 | 95 |
96 int hashCode() => syntax.hashCode(); | 96 int hashCode() => syntax.hashCode(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 final Keyword keyword; | 221 final Keyword keyword; |
222 | 222 |
223 LeafKeywordState(String syntax) : keyword = Keyword.keywords[syntax]; | 223 LeafKeywordState(String syntax) : keyword = Keyword.keywords[syntax]; |
224 | 224 |
225 bool isLeaf() => true; | 225 bool isLeaf() => true; |
226 | 226 |
227 KeywordState next(int c) => null; | 227 KeywordState next(int c) => null; |
228 | 228 |
229 String toString() => keyword.syntax; | 229 String toString() => keyword.syntax; |
230 } | 230 } |
OLD | NEW |