| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 | 3 |
| 4 library engine.scanner; | 4 library engine.scanner; |
| 5 | 5 |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'java_core.dart'; | 7 import 'java_core.dart'; |
| 8 import 'java_engine.dart'; | 8 import 'java_engine.dart'; |
| 9 import 'source.dart'; | 9 import 'source.dart'; |
| 10 import 'error.dart'; | 10 import 'error.dart'; |
| 11 import 'instrumentation.dart'; | 11 import 'instrumentation.dart'; |
| 12 | 12 |
| 13 |
| 13 /** | 14 /** |
| 14 * Instances of the abstract class {@code KeywordState} represent a state in a s
tate machine used to | 15 * Instances of the abstract class {@code KeywordState} represent a state in a s
tate machine used to |
| 15 * scan keywords. | 16 * scan keywords. |
| 16 * @coverage dart.engine.parser | 17 * @coverage dart.engine.parser |
| 17 */ | 18 */ |
| 18 class KeywordState { | 19 class KeywordState { |
| 20 |
| 19 /** | 21 /** |
| 20 * An empty transition table used by leaf states. | 22 * An empty transition table used by leaf states. |
| 21 */ | 23 */ |
| 22 static List<KeywordState> _EMPTY_TABLE = new List<KeywordState>(26); | 24 static List<KeywordState> _EMPTY_TABLE = new List<KeywordState>(26); |
| 25 |
| 23 /** | 26 /** |
| 24 * The initial state in the state machine. | 27 * The initial state in the state machine. |
| 25 */ | 28 */ |
| 26 static KeywordState KEYWORD_STATE = createKeywordStateTable(); | 29 static KeywordState KEYWORD_STATE = createKeywordStateTable(); |
| 30 |
| 27 /** | 31 /** |
| 28 * Create the next state in the state machine where we have already recognized
the subset of | 32 * Create the next state in the state machine where we have already recognized
the subset of |
| 29 * strings in the given array of strings starting at the given offset and havi
ng the given length. | 33 * strings in the given array of strings starting at the given offset and havi
ng the given length. |
| 30 * All of these strings have a common prefix and the next character is at the
given start index. | 34 * All of these strings have a common prefix and the next character is at the
given start index. |
| 31 * @param start the index of the character in the strings used to transition t
o a new state | 35 * @param start the index of the character in the strings used to transition t
o a new state |
| 32 * @param strings an array containing all of the strings that will be recogniz
ed by the state | 36 * @param strings an array containing all of the strings that will be recogniz
ed by the state |
| 33 * machine | 37 * machine |
| 34 * @param offset the offset of the first string in the array that has the pref
ix that is assumed | 38 * @param offset the offset of the first string in the array that has the pref
ix that is assumed |
| 35 * to have been recognized by the time we reach the state being built | 39 * to have been recognized by the time we reach the state being built |
| 36 * @param length the number of strings in the array that pass through the stat
e being built | 40 * @param length the number of strings in the array that pass through the stat
e being built |
| (...skipping 26 matching lines...) Expand all Loading... |
| 63 } else { | 67 } else { |
| 64 assert(length2 == 1); | 68 assert(length2 == 1); |
| 65 return new KeywordState(_EMPTY_TABLE, strings[offset]); | 69 return new KeywordState(_EMPTY_TABLE, strings[offset]); |
| 66 } | 70 } |
| 67 if (isLeaf) { | 71 if (isLeaf) { |
| 68 return new KeywordState(result, strings[offset]); | 72 return new KeywordState(result, strings[offset]); |
| 69 } else { | 73 } else { |
| 70 return new KeywordState(result, null); | 74 return new KeywordState(result, null); |
| 71 } | 75 } |
| 72 } | 76 } |
| 77 |
| 73 /** | 78 /** |
| 74 * Create the initial state in the state machine. | 79 * Create the initial state in the state machine. |
| 75 * @return the state that was created | 80 * @return the state that was created |
| 76 */ | 81 */ |
| 77 static KeywordState createKeywordStateTable() { | 82 static KeywordState createKeywordStateTable() { |
| 78 List<Keyword> values2 = Keyword.values; | 83 List<Keyword> values2 = Keyword.values; |
| 79 List<String> strings = new List<String>(values2.length); | 84 List<String> strings = new List<String>(values2.length); |
| 80 for (int i = 0; i < values2.length; i++) { | 85 for (int i = 0; i < values2.length; i++) { |
| 81 strings[i] = values2[i].syntax; | 86 strings[i] = values2[i].syntax; |
| 82 } | 87 } |
| 83 strings.sort(); | 88 strings.sort(); |
| 84 return computeKeywordStateTable(0, strings, 0, strings.length); | 89 return computeKeywordStateTable(0, strings, 0, strings.length); |
| 85 } | 90 } |
| 91 |
| 86 /** | 92 /** |
| 87 * A table mapping characters to the states to which those characters will tra
nsition. (The index | 93 * A table mapping characters to the states to which those characters will tra
nsition. (The index |
| 88 * into the array is the offset from the character {@code 'a'} to the transiti
oning character.) | 94 * into the array is the offset from the character {@code 'a'} to the transiti
oning character.) |
| 89 */ | 95 */ |
| 90 List<KeywordState> _table; | 96 List<KeywordState> _table; |
| 97 |
| 91 /** | 98 /** |
| 92 * The keyword that is recognized by this state, or {@code null} if this state
is not a terminal | 99 * The keyword that is recognized by this state, or {@code null} if this state
is not a terminal |
| 93 * state. | 100 * state. |
| 94 */ | 101 */ |
| 95 Keyword _keyword2; | 102 Keyword _keyword2; |
| 103 |
| 96 /** | 104 /** |
| 97 * Initialize a newly created state to have the given transitions and to recog
nize the keyword | 105 * Initialize a newly created state to have the given transitions and to recog
nize the keyword |
| 98 * with the given syntax. | 106 * with the given syntax. |
| 99 * @param table a table mapping characters to the states to which those charac
ters will transition | 107 * @param table a table mapping characters to the states to which those charac
ters will transition |
| 100 * @param syntax the syntax of the keyword that is recognized by the state | 108 * @param syntax the syntax of the keyword that is recognized by the state |
| 101 */ | 109 */ |
| 102 KeywordState(List<KeywordState> table, String syntax) { | 110 KeywordState(List<KeywordState> table, String syntax) { |
| 103 this._table = table; | 111 this._table = table; |
| 104 this._keyword2 = (syntax == null) ? null : Keyword.keywords[syntax]; | 112 this._keyword2 = (syntax == null) ? null : Keyword.keywords[syntax]; |
| 105 } | 113 } |
| 114 |
| 106 /** | 115 /** |
| 107 * Return the keyword that was recognized by this state, or {@code null} if th
is state does not | 116 * Return the keyword that was recognized by this state, or {@code null} if th
is state does not |
| 108 * recognized a keyword. | 117 * recognized a keyword. |
| 109 * @return the keyword that was matched by reaching this state | 118 * @return the keyword that was matched by reaching this state |
| 110 */ | 119 */ |
| 111 Keyword keyword() => _keyword2; | 120 Keyword keyword() => _keyword2; |
| 121 |
| 112 /** | 122 /** |
| 113 * Return the state that follows this state on a transition of the given chara
cter, or{@code null} if there is no valid state reachable from this state with s
uch a transition. | 123 * Return the state that follows this state on a transition of the given chara
cter, or{@code null} if there is no valid state reachable from this state with s
uch a transition. |
| 114 * @param c the character used to transition from this state to another state | 124 * @param c the character used to transition from this state to another state |
| 115 * @return the state that follows this state on a transition of the given char
acter | 125 * @return the state that follows this state on a transition of the given char
acter |
| 116 */ | 126 */ |
| 117 KeywordState next(int c) => _table[c - 0x61]; | 127 KeywordState next(int c) => _table[c - 0x61]; |
| 118 } | 128 } |
| 129 |
| 119 /** | 130 /** |
| 120 * The enumeration {@code ScannerErrorCode} defines the error codes used for err
ors detected by the | 131 * The enumeration {@code ScannerErrorCode} defines the error codes used for err
ors detected by the |
| 121 * scanner. | 132 * scanner. |
| 122 * @coverage dart.engine.parser | 133 * @coverage dart.engine.parser |
| 123 */ | 134 */ |
| 124 class ScannerErrorCode implements Comparable<ScannerErrorCode>, ErrorCode { | 135 class ScannerErrorCode implements Comparable<ScannerErrorCode>, ErrorCode { |
| 125 static final ScannerErrorCode ILLEGAL_CHARACTER = new ScannerErrorCode('ILLEGA
L_CHARACTER', 0, "Illegal character %x"); | 136 static final ScannerErrorCode ILLEGAL_CHARACTER = new ScannerErrorCode('ILLEGA
L_CHARACTER', 0, "Illegal character %x"); |
| 126 static final ScannerErrorCode MISSING_DIGIT = new ScannerErrorCode('MISSING_DI
GIT', 1, "Decimal digit expected"); | 137 static final ScannerErrorCode MISSING_DIGIT = new ScannerErrorCode('MISSING_DI
GIT', 1, "Decimal digit expected"); |
| 127 static final ScannerErrorCode MISSING_HEX_DIGIT = new ScannerErrorCode('MISSIN
G_HEX_DIGIT', 2, "Hexidecimal digit expected"); | 138 static final ScannerErrorCode MISSING_HEX_DIGIT = new ScannerErrorCode('MISSIN
G_HEX_DIGIT', 2, "Hexidecimal digit expected"); |
| 128 static final ScannerErrorCode MISSING_QUOTE = new ScannerErrorCode('MISSING_QU
OTE', 3, "Expected quote (' or \")"); | 139 static final ScannerErrorCode MISSING_QUOTE = new ScannerErrorCode('MISSING_QU
OTE', 3, "Expected quote (' or \")"); |
| 129 static final ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT = new ScannerErr
orCode('UNTERMINATED_MULTI_LINE_COMMENT', 4, "Unterminated multi-line comment"); | 140 static final ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT = new ScannerErr
orCode('UNTERMINATED_MULTI_LINE_COMMENT', 4, "Unterminated multi-line comment"); |
| 130 static final ScannerErrorCode UNTERMINATED_STRING_LITERAL = new ScannerErrorCo
de('UNTERMINATED_STRING_LITERAL', 5, "Unterminated string literal"); | 141 static final ScannerErrorCode UNTERMINATED_STRING_LITERAL = new ScannerErrorCo
de('UNTERMINATED_STRING_LITERAL', 5, "Unterminated string literal"); |
| 131 static final List<ScannerErrorCode> values = [ILLEGAL_CHARACTER, MISSING_DIGIT
, MISSING_HEX_DIGIT, MISSING_QUOTE, UNTERMINATED_MULTI_LINE_COMMENT, UNTERMINATE
D_STRING_LITERAL]; | 142 static final List<ScannerErrorCode> values = [ILLEGAL_CHARACTER, MISSING_DIGIT
, MISSING_HEX_DIGIT, MISSING_QUOTE, UNTERMINATED_MULTI_LINE_COMMENT, UNTERMINATE
D_STRING_LITERAL]; |
| 132 final String __name; | 143 |
| 133 final int __ordinal; | 144 /// The name of this enum constant, as declared in the enum declaration. |
| 134 int get ordinal => __ordinal; | 145 final String name; |
| 146 |
| 147 /// The position in the enum declaration. |
| 148 final int ordinal; |
| 149 |
| 135 /** | 150 /** |
| 136 * The message template used to create the message to be displayed for this er
ror. | 151 * The message template used to create the message to be displayed for this er
ror. |
| 137 */ | 152 */ |
| 138 String _message; | 153 String _message; |
| 154 |
| 139 /** | 155 /** |
| 140 * Initialize a newly created error code to have the given message. | 156 * Initialize a newly created error code to have the given message. |
| 141 * @param message the message template used to create the message to be displa
yed for this error | 157 * @param message the message template used to create the message to be displa
yed for this error |
| 142 */ | 158 */ |
| 143 ScannerErrorCode(this.__name, this.__ordinal, String message) { | 159 ScannerErrorCode(this.name, this.ordinal, String message) { |
| 144 this._message = message; | 160 this._message = message; |
| 145 } | 161 } |
| 146 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; | 162 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; |
| 147 String get message => _message; | 163 String get message => _message; |
| 148 ErrorType get type => ErrorType.SYNTACTIC_ERROR; | 164 ErrorType get type => ErrorType.SYNTACTIC_ERROR; |
| 149 bool needsRecompilation() => true; | 165 int compareTo(ScannerErrorCode other) => ordinal - other.ordinal; |
| 150 int compareTo(ScannerErrorCode other) => __ordinal - other.__ordinal; | 166 String toString() => name; |
| 151 String toString() => __name; | |
| 152 } | 167 } |
| 168 |
| 153 /** | 169 /** |
| 154 * Instances of the class {@code TokenWithComment} represent a string token that
is preceded by | 170 * Instances of the class {@code TokenWithComment} represent a string token that
is preceded by |
| 155 * comments. | 171 * comments. |
| 156 * @coverage dart.engine.parser | 172 * @coverage dart.engine.parser |
| 157 */ | 173 */ |
| 158 class StringTokenWithComment extends StringToken { | 174 class StringTokenWithComment extends StringToken { |
| 175 |
| 159 /** | 176 /** |
| 160 * The first comment in the list of comments that precede this token. | 177 * The first comment in the list of comments that precede this token. |
| 161 */ | 178 */ |
| 162 Token _precedingComment; | 179 Token _precedingComment; |
| 180 |
| 163 /** | 181 /** |
| 164 * Initialize a newly created token to have the given type and offset and to b
e preceded by the | 182 * Initialize a newly created token to have the given type and offset and to b
e preceded by the |
| 165 * comments reachable from the given comment. | 183 * comments reachable from the given comment. |
| 166 * @param type the type of the token | 184 * @param type the type of the token |
| 167 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 185 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 168 * @param precedingComment the first comment in the list of comments that prec
ede this token | 186 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 169 */ | 187 */ |
| 170 StringTokenWithComment(TokenType type, String value, int offset, Token precedi
ngComment) : super(type, value, offset) { | 188 StringTokenWithComment(TokenType type, String value, int offset, Token precedi
ngComment) : super(type, value, offset) { |
| 171 this._precedingComment = precedingComment; | 189 this._precedingComment = precedingComment; |
| 172 } | 190 } |
| 173 Token get precedingComments => _precedingComment; | 191 Token get precedingComments => _precedingComment; |
| 174 } | 192 } |
| 193 |
| 175 /** | 194 /** |
| 176 * The enumeration {@code Keyword} defines the keywords in the Dart programming
language. | 195 * The enumeration {@code Keyword} defines the keywords in the Dart programming
language. |
| 177 * @coverage dart.engine.parser | 196 * @coverage dart.engine.parser |
| 178 */ | 197 */ |
| 179 class Keyword implements Comparable<Keyword> { | 198 class Keyword implements Comparable<Keyword> { |
| 180 static final Keyword ASSERT = new Keyword.con1('ASSERT', 0, "assert"); | 199 static final Keyword ASSERT = new Keyword.con1('ASSERT', 0, "assert"); |
| 181 static final Keyword BREAK = new Keyword.con1('BREAK', 1, "break"); | 200 static final Keyword BREAK = new Keyword.con1('BREAK', 1, "break"); |
| 182 static final Keyword CASE = new Keyword.con1('CASE', 2, "case"); | 201 static final Keyword CASE = new Keyword.con1('CASE', 2, "case"); |
| 183 static final Keyword CATCH = new Keyword.con1('CATCH', 3, "catch"); | 202 static final Keyword CATCH = new Keyword.con1('CATCH', 3, "catch"); |
| 184 static final Keyword CLASS = new Keyword.con1('CLASS', 4, "class"); | 203 static final Keyword CLASS = new Keyword.con1('CLASS', 4, "class"); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 static final Keyword GET = new Keyword.con2('GET', 39, "get", true); | 238 static final Keyword GET = new Keyword.con2('GET', 39, "get", true); |
| 220 static final Keyword IMPLEMENTS = new Keyword.con2('IMPLEMENTS', 40, "implemen
ts", true); | 239 static final Keyword IMPLEMENTS = new Keyword.con2('IMPLEMENTS', 40, "implemen
ts", true); |
| 221 static final Keyword IMPORT = new Keyword.con2('IMPORT', 41, "import", true); | 240 static final Keyword IMPORT = new Keyword.con2('IMPORT', 41, "import", true); |
| 222 static final Keyword LIBRARY = new Keyword.con2('LIBRARY', 42, "library", true
); | 241 static final Keyword LIBRARY = new Keyword.con2('LIBRARY', 42, "library", true
); |
| 223 static final Keyword OPERATOR = new Keyword.con2('OPERATOR', 43, "operator", t
rue); | 242 static final Keyword OPERATOR = new Keyword.con2('OPERATOR', 43, "operator", t
rue); |
| 224 static final Keyword PART = new Keyword.con2('PART', 44, "part", true); | 243 static final Keyword PART = new Keyword.con2('PART', 44, "part", true); |
| 225 static final Keyword SET = new Keyword.con2('SET', 45, "set", true); | 244 static final Keyword SET = new Keyword.con2('SET', 45, "set", true); |
| 226 static final Keyword STATIC = new Keyword.con2('STATIC', 46, "static", true); | 245 static final Keyword STATIC = new Keyword.con2('STATIC', 46, "static", true); |
| 227 static final Keyword TYPEDEF = new Keyword.con2('TYPEDEF', 47, "typedef", true
); | 246 static final Keyword TYPEDEF = new Keyword.con2('TYPEDEF', 47, "typedef", true
); |
| 228 static final List<Keyword> values = [ASSERT, BREAK, CASE, CATCH, CLASS, CONST,
CONTINUE, DEFAULT, DO, ELSE, ENUM, EXTENDS, FALSE, FINAL, FINALLY, FOR, IF, IN,
IS, NEW, NULL, RETHROW, RETURN, SUPER, SWITCH, THIS, THROW, TRUE, TRY, VAR, VOI
D, WHILE, WITH, ABSTRACT, AS, DYNAMIC, EXPORT, EXTERNAL, FACTORY, GET, IMPLEMENT
S, IMPORT, LIBRARY, OPERATOR, PART, SET, STATIC, TYPEDEF]; | 247 static final List<Keyword> values = [ASSERT, BREAK, CASE, CATCH, CLASS, CONST,
CONTINUE, DEFAULT, DO, ELSE, ENUM, EXTENDS, FALSE, FINAL, FINALLY, FOR, IF, IN,
IS, NEW, NULL, RETHROW, RETURN, SUPER, SWITCH, THIS, THROW, TRUE, TRY, VAR, VOI
D, WHILE, WITH, ABSTRACT, AS, DYNAMIC, EXPORT, EXTERNAL, FACTORY, GET, IMPLEMENT
S, IMPORT, LIBRARY, OPERATOR, PART, SET, STATIC, TYPEDEF]; |
| 229 String __name; | 248 |
| 230 int __ordinal = 0; | 249 /// The name of this enum constant, as declared in the enum declaration. |
| 231 int get ordinal => __ordinal; | 250 final String name; |
| 251 |
| 252 /// The position in the enum declaration. |
| 253 final int ordinal; |
| 254 |
| 232 /** | 255 /** |
| 233 * The lexeme for the keyword. | 256 * The lexeme for the keyword. |
| 234 */ | 257 */ |
| 235 String _syntax; | 258 String _syntax; |
| 259 |
| 236 /** | 260 /** |
| 237 * A flag indicating whether the keyword is a pseudo-keyword. Pseudo keywords
can be used as | 261 * A flag indicating whether the keyword is a pseudo-keyword. Pseudo keywords
can be used as |
| 238 * identifiers. | 262 * identifiers. |
| 239 */ | 263 */ |
| 240 bool _isPseudoKeyword2 = false; | 264 bool _isPseudoKeyword2 = false; |
| 265 |
| 241 /** | 266 /** |
| 242 * A table mapping the lexemes of keywords to the corresponding keyword. | 267 * A table mapping the lexemes of keywords to the corresponding keyword. |
| 243 */ | 268 */ |
| 244 static Map<String, Keyword> keywords = createKeywordMap(); | 269 static Map<String, Keyword> keywords = createKeywordMap(); |
| 270 |
| 245 /** | 271 /** |
| 246 * Create a table mapping the lexemes of keywords to the corresponding keyword
. | 272 * Create a table mapping the lexemes of keywords to the corresponding keyword
. |
| 247 * @return the table that was created | 273 * @return the table that was created |
| 248 */ | 274 */ |
| 249 static Map<String, Keyword> createKeywordMap() { | 275 static Map<String, Keyword> createKeywordMap() { |
| 250 LinkedHashMap<String, Keyword> result = new LinkedHashMap<String, Keyword>()
; | 276 LinkedHashMap<String, Keyword> result = new LinkedHashMap<String, Keyword>()
; |
| 251 for (Keyword keyword in values) { | 277 for (Keyword keyword in values) { |
| 252 result[keyword._syntax] = keyword; | 278 result[keyword._syntax] = keyword; |
| 253 } | 279 } |
| 254 return result; | 280 return result; |
| 255 } | 281 } |
| 282 |
| 256 /** | 283 /** |
| 257 * Initialize a newly created keyword to have the given syntax. The keyword is
not a | 284 * Initialize a newly created keyword to have the given syntax. The keyword is
not a |
| 258 * pseudo-keyword. | 285 * pseudo-keyword. |
| 259 * @param syntax the lexeme for the keyword | 286 * @param syntax the lexeme for the keyword |
| 260 */ | 287 */ |
| 261 Keyword.con1(String ___name, int ___ordinal, String syntax) { | 288 Keyword.con1(this.name, this.ordinal, String syntax) { |
| 262 _jtd_constructor_309_impl(___name, ___ordinal, syntax); | 289 _jtd_constructor_316_impl(syntax); |
| 263 } | 290 } |
| 264 _jtd_constructor_309_impl(String ___name, int ___ordinal, String syntax) { | 291 _jtd_constructor_316_impl(String syntax) { |
| 265 _jtd_constructor_310_impl(___name, ___ordinal, syntax, false); | 292 _jtd_constructor_317_impl(syntax, false); |
| 266 } | 293 } |
| 294 |
| 267 /** | 295 /** |
| 268 * Initialize a newly created keyword to have the given syntax. The keyword is
a pseudo-keyword if | 296 * Initialize a newly created keyword to have the given syntax. The keyword is
a pseudo-keyword if |
| 269 * the given flag is {@code true}. | 297 * the given flag is {@code true}. |
| 270 * @param syntax the lexeme for the keyword | 298 * @param syntax the lexeme for the keyword |
| 271 * @param isPseudoKeyword {@code true} if this keyword is a pseudo-keyword | 299 * @param isPseudoKeyword {@code true} if this keyword is a pseudo-keyword |
| 272 */ | 300 */ |
| 273 Keyword.con2(String ___name, int ___ordinal, String syntax2, bool isPseudoKeyw
ord) { | 301 Keyword.con2(this.name, this.ordinal, String syntax2, bool isPseudoKeyword) { |
| 274 _jtd_constructor_310_impl(___name, ___ordinal, syntax2, isPseudoKeyword); | 302 _jtd_constructor_317_impl(syntax2, isPseudoKeyword); |
| 275 } | 303 } |
| 276 _jtd_constructor_310_impl(String ___name, int ___ordinal, String syntax2, bool
isPseudoKeyword) { | 304 _jtd_constructor_317_impl(String syntax2, bool isPseudoKeyword) { |
| 277 __name = ___name; | |
| 278 __ordinal = ___ordinal; | |
| 279 this._syntax = syntax2; | 305 this._syntax = syntax2; |
| 280 this._isPseudoKeyword2 = isPseudoKeyword; | 306 this._isPseudoKeyword2 = isPseudoKeyword; |
| 281 } | 307 } |
| 308 |
| 282 /** | 309 /** |
| 283 * Return the lexeme for the keyword. | 310 * Return the lexeme for the keyword. |
| 284 * @return the lexeme for the keyword | 311 * @return the lexeme for the keyword |
| 285 */ | 312 */ |
| 286 String get syntax => _syntax; | 313 String get syntax => _syntax; |
| 314 |
| 287 /** | 315 /** |
| 288 * Return {@code true} if this keyword is a pseudo-keyword. Pseudo keywords ca
n be used as | 316 * Return {@code true} if this keyword is a pseudo-keyword. Pseudo keywords ca
n be used as |
| 289 * identifiers. | 317 * identifiers. |
| 290 * @return {@code true} if this keyword is a pseudo-keyword | 318 * @return {@code true} if this keyword is a pseudo-keyword |
| 291 */ | 319 */ |
| 292 bool isPseudoKeyword() => _isPseudoKeyword2; | 320 bool isPseudoKeyword() => _isPseudoKeyword2; |
| 293 int compareTo(Keyword other) => __ordinal - other.__ordinal; | 321 int compareTo(Keyword other) => ordinal - other.ordinal; |
| 294 String toString() => __name; | 322 String toString() => name; |
| 295 } | 323 } |
| 324 |
| 296 /** | 325 /** |
| 297 * The abstract class {@code AbstractScanner} implements a scanner for Dart code
. Subclasses are | 326 * The abstract class {@code AbstractScanner} implements a scanner for Dart code
. Subclasses are |
| 298 * required to implement the interface used to access the characters being scann
ed. | 327 * required to implement the interface used to access the characters being scann
ed. |
| 299 * <p> | 328 * <p> |
| 300 * The lexical structure of Dart is ambiguous without knowledge of the context i
n which a token is | 329 * The lexical structure of Dart is ambiguous without knowledge of the context i
n which a token is |
| 301 * being scanned. For example, without context we cannot determine whether sourc
e of the form "<<" | 330 * being scanned. For example, without context we cannot determine whether sourc
e of the form "<<" |
| 302 * should be scanned as a single left-shift operator or as two left angle bracke
ts. This scanner | 331 * should be scanned as a single left-shift operator or as two left angle bracke
ts. This scanner |
| 303 * does not have any context, so it always resolves such conflicts by scanning t
he longest possible | 332 * does not have any context, so it always resolves such conflicts by scanning t
he longest possible |
| 304 * token. | 333 * token. |
| 305 * @coverage dart.engine.parser | 334 * @coverage dart.engine.parser |
| 306 */ | 335 */ |
| 307 abstract class AbstractScanner { | 336 abstract class AbstractScanner { |
| 337 |
| 308 /** | 338 /** |
| 309 * The source being scanned. | 339 * The source being scanned. |
| 310 */ | 340 */ |
| 311 Source _source; | 341 Source _source; |
| 342 |
| 312 /** | 343 /** |
| 313 * The error listener that will be informed of any errors that are found durin
g the scan. | 344 * The error listener that will be informed of any errors that are found durin
g the scan. |
| 314 */ | 345 */ |
| 315 AnalysisErrorListener _errorListener; | 346 AnalysisErrorListener _errorListener; |
| 347 |
| 316 /** | 348 /** |
| 317 * The token pointing to the head of the linked list of tokens. | 349 * The token pointing to the head of the linked list of tokens. |
| 318 */ | 350 */ |
| 319 Token _tokens; | 351 Token _tokens; |
| 352 |
| 320 /** | 353 /** |
| 321 * The last token that was scanned. | 354 * The last token that was scanned. |
| 322 */ | 355 */ |
| 323 Token _tail; | 356 Token _tail; |
| 357 |
| 324 /** | 358 /** |
| 325 * The first token in the list of comment tokens found since the last non-comm
ent token. | 359 * The first token in the list of comment tokens found since the last non-comm
ent token. |
| 326 */ | 360 */ |
| 327 Token _firstComment; | 361 Token _firstComment; |
| 362 |
| 328 /** | 363 /** |
| 329 * The last token in the list of comment tokens found since the last non-comme
nt token. | 364 * The last token in the list of comment tokens found since the last non-comme
nt token. |
| 330 */ | 365 */ |
| 331 Token _lastComment; | 366 Token _lastComment; |
| 367 |
| 332 /** | 368 /** |
| 333 * The index of the first character of the current token. | 369 * The index of the first character of the current token. |
| 334 */ | 370 */ |
| 335 int _tokenStart = 0; | 371 int _tokenStart = 0; |
| 372 |
| 336 /** | 373 /** |
| 337 * A list containing the offsets of the first character of each line in the so
urce code. | 374 * A list containing the offsets of the first character of each line in the so
urce code. |
| 338 */ | 375 */ |
| 339 List<int> _lineStarts = new List<int>(); | 376 List<int> _lineStarts = new List<int>(); |
| 377 |
| 340 /** | 378 /** |
| 341 * A list, treated something like a stack, of tokens representing the beginnin
g of a matched pair. | 379 * A list, treated something like a stack, of tokens representing the beginnin
g of a matched pair. |
| 342 * It is used to pair the end tokens with the begin tokens. | 380 * It is used to pair the end tokens with the begin tokens. |
| 343 */ | 381 */ |
| 344 List<BeginToken> _groupingStack = new List<BeginToken>(); | 382 List<BeginToken> _groupingStack = new List<BeginToken>(); |
| 383 |
| 345 /** | 384 /** |
| 346 * A flag indicating whether any unmatched groups were found during the parse. | 385 * A flag indicating whether any unmatched groups were found during the parse. |
| 347 */ | 386 */ |
| 348 bool _hasUnmatchedGroups2 = false; | 387 bool _hasUnmatchedGroups2 = false; |
| 388 |
| 349 /** | 389 /** |
| 350 * A non-breaking space, which is allowed by this scanner as a white-space cha
racter. | 390 * A non-breaking space, which is allowed by this scanner as a white-space cha
racter. |
| 351 */ | 391 */ |
| 352 static int _$NBSP = 160; | 392 static int _$NBSP = 160; |
| 393 |
| 353 /** | 394 /** |
| 354 * Initialize a newly created scanner. | 395 * Initialize a newly created scanner. |
| 355 * @param source the source being scanned | 396 * @param source the source being scanned |
| 356 * @param errorListener the error listener that will be informed of any errors
that are found | 397 * @param errorListener the error listener that will be informed of any errors
that are found |
| 357 */ | 398 */ |
| 358 AbstractScanner(Source source, AnalysisErrorListener errorListener) { | 399 AbstractScanner(Source source, AnalysisErrorListener errorListener) { |
| 359 this._source = source; | 400 this._source = source; |
| 360 this._errorListener = errorListener; | 401 this._errorListener = errorListener; |
| 361 _tokens = new Token(TokenType.EOF, -1); | 402 _tokens = new Token(TokenType.EOF, -1); |
| 362 _tokens.setNext(_tokens); | 403 _tokens.setNext(_tokens); |
| 363 _tail = _tokens; | 404 _tail = _tokens; |
| 364 _tokenStart = -1; | 405 _tokenStart = -1; |
| 365 _lineStarts.add(0); | 406 _lineStarts.add(0); |
| 366 } | 407 } |
| 408 |
| 367 /** | 409 /** |
| 368 * Return an array containing the offsets of the first character of each line
in the source code. | 410 * Return an array containing the offsets of the first character of each line
in the source code. |
| 369 * @return an array containing the offsets of the first character of each line
in the source code | 411 * @return an array containing the offsets of the first character of each line
in the source code |
| 370 */ | 412 */ |
| 371 List<int> get lineStarts => _lineStarts; | 413 List<int> get lineStarts => _lineStarts; |
| 414 |
| 372 /** | 415 /** |
| 373 * Return the current offset relative to the beginning of the file. Return the
initial offset if | 416 * Return the current offset relative to the beginning of the file. Return the
initial offset if |
| 374 * the scanner has not yet scanned the source code, and one (1) past the end o
f the source code if | 417 * the scanner has not yet scanned the source code, and one (1) past the end o
f the source code if |
| 375 * the source code has been scanned. | 418 * the source code has been scanned. |
| 376 * @return the current offset of the scanner in the source | 419 * @return the current offset of the scanner in the source |
| 377 */ | 420 */ |
| 378 int get offset; | 421 int get offset; |
| 422 |
| 379 /** | 423 /** |
| 380 * Return {@code true} if any unmatched groups were found during the parse. | 424 * Return {@code true} if any unmatched groups were found during the parse. |
| 381 * @return {@code true} if any unmatched groups were found during the parse | 425 * @return {@code true} if any unmatched groups were found during the parse |
| 382 */ | 426 */ |
| 383 bool hasUnmatchedGroups() => _hasUnmatchedGroups2; | 427 bool hasUnmatchedGroups() => _hasUnmatchedGroups2; |
| 428 |
| 384 /** | 429 /** |
| 385 * Scan the source code to produce a list of tokens representing the source. | 430 * Scan the source code to produce a list of tokens representing the source. |
| 386 * @return the first token in the list of tokens that were produced | 431 * @return the first token in the list of tokens that were produced |
| 387 */ | 432 */ |
| 388 Token tokenize() { | 433 Token tokenize() { |
| 389 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi
ne.AbstractScanner.tokenize"); | 434 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi
ne.AbstractScanner.tokenize"); |
| 390 int tokenCounter = 0; | 435 int tokenCounter = 0; |
| 391 try { | 436 try { |
| 392 int next = advance(); | 437 int next = advance(); |
| 393 while (next != -1) { | 438 while (next != -1) { |
| 394 tokenCounter++; | 439 tokenCounter++; |
| 395 next = bigSwitch(next); | 440 next = bigSwitch(next); |
| 396 } | 441 } |
| 397 appendEofToken(); | 442 appendEofToken(); |
| 398 instrumentation.metric2("tokensCount", tokenCounter); | 443 instrumentation.metric2("tokensCount", tokenCounter); |
| 399 return firstToken(); | 444 return firstToken(); |
| 400 } finally { | 445 } finally { |
| 401 instrumentation.log(); | 446 instrumentation.log(); |
| 402 } | 447 } |
| 403 } | 448 } |
| 449 |
| 404 /** | 450 /** |
| 405 * Advance the current position and return the character at the new current po
sition. | 451 * Advance the current position and return the character at the new current po
sition. |
| 406 * @return the character at the new current position | 452 * @return the character at the new current position |
| 407 */ | 453 */ |
| 408 int advance(); | 454 int advance(); |
| 455 |
| 409 /** | 456 /** |
| 410 * Return the substring of the source code between the start offset and the mo
dified current | 457 * Return the substring of the source code between the start offset and the mo
dified current |
| 411 * position. The current position is modified by adding the end delta. | 458 * position. The current position is modified by adding the end delta. |
| 412 * @param start the offset to the beginning of the string, relative to the sta
rt of the file | 459 * @param start the offset to the beginning of the string, relative to the sta
rt of the file |
| 413 * @param endDelta the number of character after the current location to be in
cluded in the | 460 * @param endDelta the number of character after the current location to be in
cluded in the |
| 414 * string, or the number of characters before the current location to be exclu
ded if the | 461 * string, or the number of characters before the current location to be exclu
ded if the |
| 415 * offset is negative | 462 * offset is negative |
| 416 * @return the specified substring of the source code | 463 * @return the specified substring of the source code |
| 417 */ | 464 */ |
| 418 String getString(int start, int endDelta); | 465 String getString(int start, int endDelta); |
| 466 |
| 419 /** | 467 /** |
| 420 * Return the character at the current position without changing the current p
osition. | 468 * Return the character at the current position without changing the current p
osition. |
| 421 * @return the character at the current position | 469 * @return the character at the current position |
| 422 */ | 470 */ |
| 423 int peek(); | 471 int peek(); |
| 472 |
| 424 /** | 473 /** |
| 425 * Record the fact that we are at the beginning of a new line in the source. | 474 * Record the fact that we are at the beginning of a new line in the source. |
| 426 */ | 475 */ |
| 427 void recordStartOfLine() { | 476 void recordStartOfLine() { |
| 428 _lineStarts.add(offset); | 477 _lineStarts.add(offset); |
| 429 } | 478 } |
| 430 void appendBeginToken(TokenType type) { | 479 void appendBeginToken(TokenType type) { |
| 431 BeginToken token; | 480 BeginToken token; |
| 432 if (_firstComment == null) { | 481 if (_firstComment == null) { |
| 433 token = new BeginToken(type, _tokenStart); | 482 token = new BeginToken(type, _tokenStart); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 int bigSwitch(int next) { | 581 int bigSwitch(int next) { |
| 533 beginToken(); | 582 beginToken(); |
| 534 if (next == 0xD) { | 583 if (next == 0xD) { |
| 535 next = advance(); | 584 next = advance(); |
| 536 if (next == 0xA) { | 585 if (next == 0xA) { |
| 537 next = advance(); | 586 next = advance(); |
| 538 } | 587 } |
| 539 recordStartOfLine(); | 588 recordStartOfLine(); |
| 540 return next; | 589 return next; |
| 541 } else if (next == 0xA) { | 590 } else if (next == 0xA) { |
| 591 next = advance(); |
| 542 recordStartOfLine(); | 592 recordStartOfLine(); |
| 543 return advance(); | 593 return next; |
| 544 } else if (next == 0x9 || next == 0x20) { | 594 } else if (next == 0x9 || next == 0x20) { |
| 545 return advance(); | 595 return advance(); |
| 546 } | 596 } |
| 547 if (next == 0x72) { | 597 if (next == 0x72) { |
| 548 int peek2 = peek(); | 598 int peek2 = peek(); |
| 549 if (peek2 == 0x22 || peek2 == 0x27) { | 599 if (peek2 == 0x22 || peek2 == 0x27) { |
| 550 int start = offset; | 600 int start = offset; |
| 551 return tokenizeString(advance(), start, true); | 601 return tokenizeString(advance(), start, true); |
| 552 } | 602 } |
| 553 } | 603 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 } | 717 } |
| 668 if (Character.isLetter(next)) { | 718 if (Character.isLetter(next)) { |
| 669 return tokenizeIdentifier(next, offset, true); | 719 return tokenizeIdentifier(next, offset, true); |
| 670 } | 720 } |
| 671 if (next == _$NBSP) { | 721 if (next == _$NBSP) { |
| 672 return advance(); | 722 return advance(); |
| 673 } | 723 } |
| 674 reportError(ScannerErrorCode.ILLEGAL_CHARACTER, [next]); | 724 reportError(ScannerErrorCode.ILLEGAL_CHARACTER, [next]); |
| 675 return advance(); | 725 return advance(); |
| 676 } | 726 } |
| 727 |
| 677 /** | 728 /** |
| 678 * Return the beginning token corresponding to a closing brace that was found
while scanning | 729 * Return the beginning token corresponding to a closing brace that was found
while scanning |
| 679 * inside a string interpolation expression. Tokens that cannot be matched wit
h the closing brace | 730 * inside a string interpolation expression. Tokens that cannot be matched wit
h the closing brace |
| 680 * will be dropped from the stack. | 731 * will be dropped from the stack. |
| 681 * @return the token to be paired with the closing brace | 732 * @return the token to be paired with the closing brace |
| 682 */ | 733 */ |
| 683 BeginToken findTokenMatchingClosingBraceInInterpolationExpression() { | 734 BeginToken findTokenMatchingClosingBraceInInterpolationExpression() { |
| 684 int last = _groupingStack.length - 1; | 735 int last = _groupingStack.length - 1; |
| 685 while (last >= 0) { | 736 while (last >= 0) { |
| 686 BeginToken begin = _groupingStack[last]; | 737 BeginToken begin = _groupingStack[last]; |
| 687 if (identical(begin.type, TokenType.OPEN_CURLY_BRACKET) || identical(begin
.type, TokenType.STRING_INTERPOLATION_EXPRESSION)) { | 738 if (identical(begin.type, TokenType.OPEN_CURLY_BRACKET) || identical(begin
.type, TokenType.STRING_INTERPOLATION_EXPRESSION)) { |
| 688 return begin; | 739 return begin; |
| 689 } | 740 } |
| 690 _hasUnmatchedGroups2 = true; | 741 _hasUnmatchedGroups2 = true; |
| 691 _groupingStack.removeAt(last); | 742 _groupingStack.removeAt(last); |
| 692 last--; | 743 last--; |
| 693 } | 744 } |
| 694 return null; | 745 return null; |
| 695 } | 746 } |
| 696 Token firstToken() => _tokens.next; | 747 Token firstToken() => _tokens.next; |
| 748 |
| 697 /** | 749 /** |
| 698 * Return the source being scanned. | 750 * Return the source being scanned. |
| 699 * @return the source being scanned | 751 * @return the source being scanned |
| 700 */ | 752 */ |
| 701 Source get source => _source; | 753 Source get source => _source; |
| 754 |
| 702 /** | 755 /** |
| 703 * Report an error at the current offset. | 756 * Report an error at the current offset. |
| 704 * @param errorCode the error code indicating the nature of the error | 757 * @param errorCode the error code indicating the nature of the error |
| 705 * @param arguments any arguments needed to complete the error message | 758 * @param arguments any arguments needed to complete the error message |
| 706 */ | 759 */ |
| 707 void reportError(ScannerErrorCode errorCode, List<Object> arguments) { | 760 void reportError(ScannerErrorCode errorCode, List<Object> arguments) { |
| 708 _errorListener.onError(new AnalysisError.con2(source, offset, 1, errorCode,
arguments)); | 761 _errorListener.onError(new AnalysisError.con2(source, offset, 1, errorCode,
arguments)); |
| 709 } | 762 } |
| 710 int select(int choice, TokenType yesType, TokenType noType) { | 763 int select(int choice, TokenType yesType, TokenType noType) { |
| 711 int next = advance(); | 764 int next = advance(); |
| 712 if (next == choice) { | 765 if (next == choice) { |
| 713 appendToken(yesType); | 766 appendToken(yesType); |
| 714 return advance(); | 767 return advance(); |
| 715 } else { | 768 } else { |
| 716 appendToken(noType); | 769 appendToken(noType); |
| 717 return next; | 770 return next; |
| 718 } | 771 } |
| 719 } | 772 } |
| 720 int select2(int choice, TokenType yesType, TokenType noType, int offset) { | 773 int select4(int choice, TokenType yesType, TokenType noType, int offset) { |
| 721 int next = advance(); | 774 int next = advance(); |
| 722 if (next == choice) { | 775 if (next == choice) { |
| 723 appendToken2(yesType, offset); | 776 appendToken2(yesType, offset); |
| 724 return advance(); | 777 return advance(); |
| 725 } else { | 778 } else { |
| 726 appendToken2(noType, offset); | 779 appendToken2(noType, offset); |
| 727 return next; | 780 return next; |
| 728 } | 781 } |
| 729 } | 782 } |
| 730 int tokenizeAmpersand(int next) { | 783 int tokenizeAmpersand(int next) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 continue LOOP; | 870 continue LOOP; |
| 818 } else { | 871 } else { |
| 819 done = true; | 872 done = true; |
| 820 continue LOOP; | 873 continue LOOP; |
| 821 } | 874 } |
| 822 next = advance(); | 875 next = advance(); |
| 823 } | 876 } |
| 824 if (!hasDigit) { | 877 if (!hasDigit) { |
| 825 appendStringToken(TokenType.INT, getString(start, -2)); | 878 appendStringToken(TokenType.INT, getString(start, -2)); |
| 826 if (0x2E == next) { | 879 if (0x2E == next) { |
| 827 return select2(0x2E, TokenType.PERIOD_PERIOD_PERIOD, TokenType.PERIOD_PE
RIOD, offset - 1); | 880 return select4(0x2E, TokenType.PERIOD_PERIOD_PERIOD, TokenType.PERIOD_PE
RIOD, offset - 1); |
| 828 } | 881 } |
| 829 appendToken2(TokenType.PERIOD, offset - 1); | 882 appendToken2(TokenType.PERIOD, offset - 1); |
| 830 return bigSwitch(next); | 883 return bigSwitch(next); |
| 831 } | 884 } |
| 832 if (next == 0x64 || next == 0x44) { | 885 if (next == 0x64 || next == 0x44) { |
| 833 next = advance(); | 886 next = advance(); |
| 834 } | 887 } |
| 835 appendStringToken(TokenType.DOUBLE, getString(start, next < 0 ? 0 : -1)); | 888 appendStringToken(TokenType.DOUBLE, getString(start, next < 0 ? 0 : -1)); |
| 836 return next; | 889 return next; |
| 837 } | 890 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 } | 968 } |
| 916 if (next == -1) { | 969 if (next == -1) { |
| 917 return next; | 970 return next; |
| 918 } | 971 } |
| 919 next = advance(); | 972 next = advance(); |
| 920 beginToken(); | 973 beginToken(); |
| 921 return next; | 974 return next; |
| 922 } | 975 } |
| 923 int tokenizeInterpolatedIdentifier(int next, int start) { | 976 int tokenizeInterpolatedIdentifier(int next, int start) { |
| 924 appendStringToken2(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 0); | 977 appendStringToken2(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 0); |
| 925 beginToken(); | 978 if (((0x41 <= next && next <= 0x5A) || (0x61 <= next && next <= 0x7A) || nex
t == 0x5F)) { |
| 926 next = tokenizeKeywordOrIdentifier(next, false); | 979 beginToken(); |
| 980 next = tokenizeKeywordOrIdentifier(next, false); |
| 981 } |
| 927 beginToken(); | 982 beginToken(); |
| 928 return next; | 983 return next; |
| 929 } | 984 } |
| 930 int tokenizeKeywordOrIdentifier(int next2, bool allowDollar) { | 985 int tokenizeKeywordOrIdentifier(int next2, bool allowDollar) { |
| 931 KeywordState state = KeywordState.KEYWORD_STATE; | 986 KeywordState state = KeywordState.KEYWORD_STATE; |
| 932 int start = offset; | 987 int start = offset; |
| 933 while (state != null && 0x61 <= next2 && next2 <= 0x7A) { | 988 while (state != null && 0x61 <= next2 && next2 <= 0x7A) { |
| 934 state = state.next((next2 as int)); | 989 state = state.next((next2 as int)); |
| 935 next2 = advance(); | 990 next2 = advance(); |
| 936 } | 991 } |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 int tokenizeTilde(int next) { | 1270 int tokenizeTilde(int next) { |
| 1216 next = advance(); | 1271 next = advance(); |
| 1217 if (next == 0x2F) { | 1272 if (next == 0x2F) { |
| 1218 return select(0x3D, TokenType.TILDE_SLASH_EQ, TokenType.TILDE_SLASH); | 1273 return select(0x3D, TokenType.TILDE_SLASH_EQ, TokenType.TILDE_SLASH); |
| 1219 } else { | 1274 } else { |
| 1220 appendToken(TokenType.TILDE); | 1275 appendToken(TokenType.TILDE); |
| 1221 return next; | 1276 return next; |
| 1222 } | 1277 } |
| 1223 } | 1278 } |
| 1224 } | 1279 } |
| 1280 |
| 1225 /** | 1281 /** |
| 1226 * Instances of the class {@code StringToken} represent a token whose value is i
ndependent of it's | 1282 * Instances of the class {@code StringToken} represent a token whose value is i
ndependent of it's |
| 1227 * type. | 1283 * type. |
| 1228 * @coverage dart.engine.parser | 1284 * @coverage dart.engine.parser |
| 1229 */ | 1285 */ |
| 1230 class StringToken extends Token { | 1286 class StringToken extends Token { |
| 1287 |
| 1231 /** | 1288 /** |
| 1232 * The lexeme represented by this token. | 1289 * The lexeme represented by this token. |
| 1233 */ | 1290 */ |
| 1234 String _value2; | 1291 String _value2; |
| 1292 |
| 1235 /** | 1293 /** |
| 1236 * Initialize a newly created token to represent a token of the given type wit
h the given value. | 1294 * Initialize a newly created token to represent a token of the given type wit
h the given value. |
| 1237 * @param type the type of the token | 1295 * @param type the type of the token |
| 1238 * @param value the lexeme represented by this token | 1296 * @param value the lexeme represented by this token |
| 1239 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1297 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1240 */ | 1298 */ |
| 1241 StringToken(TokenType type, String value, int offset) : super(type, offset) { | 1299 StringToken(TokenType type, String value, int offset) : super(type, offset) { |
| 1242 this._value2 = StringUtilities.intern(value); | 1300 this._value2 = StringUtilities.intern(value); |
| 1243 } | 1301 } |
| 1244 String get lexeme => _value2; | 1302 String get lexeme => _value2; |
| 1245 String value() => _value2; | 1303 String value() => _value2; |
| 1246 } | 1304 } |
| 1305 |
| 1247 /** | 1306 /** |
| 1248 * Instances of the class {@code CharBufferScanner} implement a scanner that rea
ds from a character | 1307 * Instances of the class {@code CharBufferScanner} implement a scanner that rea
ds from a character |
| 1249 * buffer. The scanning logic is in the superclass. | 1308 * buffer. The scanning logic is in the superclass. |
| 1250 * @coverage dart.engine.parser | 1309 * @coverage dart.engine.parser |
| 1251 */ | 1310 */ |
| 1252 class CharBufferScanner extends AbstractScanner { | 1311 class CharBufferScanner extends AbstractScanner { |
| 1312 |
| 1253 /** | 1313 /** |
| 1254 * The buffer from which characters will be read. | 1314 * The buffer from which characters will be read. |
| 1255 */ | 1315 */ |
| 1256 CharBuffer _buffer; | 1316 CharBuffer _buffer; |
| 1317 |
| 1257 /** | 1318 /** |
| 1258 * The number of characters in the buffer. | 1319 * The number of characters in the buffer. |
| 1259 */ | 1320 */ |
| 1260 int _bufferLength = 0; | 1321 int _bufferLength = 0; |
| 1322 |
| 1261 /** | 1323 /** |
| 1262 * The index of the last character that was read. | 1324 * The index of the last character that was read. |
| 1263 */ | 1325 */ |
| 1264 int _charOffset = 0; | 1326 int _charOffset = 0; |
| 1327 |
| 1265 /** | 1328 /** |
| 1266 * Initialize a newly created scanner to scan the characters in the given char
acter buffer. | 1329 * Initialize a newly created scanner to scan the characters in the given char
acter buffer. |
| 1267 * @param source the source being scanned | 1330 * @param source the source being scanned |
| 1268 * @param buffer the buffer from which characters will be read | 1331 * @param buffer the buffer from which characters will be read |
| 1269 * @param errorListener the error listener that will be informed of any errors
that are found | 1332 * @param errorListener the error listener that will be informed of any errors
that are found |
| 1270 */ | 1333 */ |
| 1271 CharBufferScanner(Source source, CharBuffer buffer, AnalysisErrorListener erro
rListener) : super(source, errorListener) { | 1334 CharBufferScanner(Source source, CharBuffer buffer, AnalysisErrorListener erro
rListener) : super(source, errorListener) { |
| 1272 this._buffer = buffer; | 1335 this._buffer = buffer; |
| 1273 this._bufferLength = buffer.length(); | 1336 this._bufferLength = buffer.length(); |
| 1274 this._charOffset = -1; | 1337 this._charOffset = -1; |
| 1275 } | 1338 } |
| 1276 int get offset => _charOffset; | 1339 int get offset => _charOffset; |
| 1277 int advance() { | 1340 int advance() { |
| 1278 if (_charOffset + 1 >= _bufferLength) { | 1341 if (_charOffset + 1 >= _bufferLength) { |
| 1279 return -1; | 1342 return -1; |
| 1280 } | 1343 } |
| 1281 return _buffer.charAt(++_charOffset); | 1344 return _buffer.charAt(++_charOffset); |
| 1282 } | 1345 } |
| 1283 String getString(int start, int endDelta) => ((_buffer as CharSequence)).subSe
quence(start, _charOffset + 1 + endDelta).toString(); | 1346 String getString(int start, int endDelta) => ((_buffer as CharSequence)).subSe
quence(start, _charOffset + 1 + endDelta).toString(); |
| 1284 int peek() { | 1347 int peek() { |
| 1285 if (_charOffset + 1 >= _buffer.length()) { | 1348 if (_charOffset + 1 >= _buffer.length()) { |
| 1286 return -1; | 1349 return -1; |
| 1287 } | 1350 } |
| 1288 return _buffer.charAt(_charOffset + 1); | 1351 return _buffer.charAt(_charOffset + 1); |
| 1289 } | 1352 } |
| 1290 } | 1353 } |
| 1354 |
| 1291 /** | 1355 /** |
| 1292 * Instances of the class {@code TokenWithComment} represent a normal token that
is preceded by | 1356 * Instances of the class {@code TokenWithComment} represent a normal token that
is preceded by |
| 1293 * comments. | 1357 * comments. |
| 1294 * @coverage dart.engine.parser | 1358 * @coverage dart.engine.parser |
| 1295 */ | 1359 */ |
| 1296 class TokenWithComment extends Token { | 1360 class TokenWithComment extends Token { |
| 1361 |
| 1297 /** | 1362 /** |
| 1298 * The first comment in the list of comments that precede this token. | 1363 * The first comment in the list of comments that precede this token. |
| 1299 */ | 1364 */ |
| 1300 Token _precedingComment; | 1365 Token _precedingComment; |
| 1366 |
| 1301 /** | 1367 /** |
| 1302 * Initialize a newly created token to have the given type and offset and to b
e preceded by the | 1368 * Initialize a newly created token to have the given type and offset and to b
e preceded by the |
| 1303 * comments reachable from the given comment. | 1369 * comments reachable from the given comment. |
| 1304 * @param type the type of the token | 1370 * @param type the type of the token |
| 1305 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1371 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1306 * @param precedingComment the first comment in the list of comments that prec
ede this token | 1372 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 1307 */ | 1373 */ |
| 1308 TokenWithComment(TokenType type, int offset, Token precedingComment) : super(t
ype, offset) { | 1374 TokenWithComment(TokenType type, int offset, Token precedingComment) : super(t
ype, offset) { |
| 1309 this._precedingComment = precedingComment; | 1375 this._precedingComment = precedingComment; |
| 1310 } | 1376 } |
| 1311 Token get precedingComments => _precedingComment; | 1377 Token get precedingComments => _precedingComment; |
| 1312 } | 1378 } |
| 1379 |
| 1313 /** | 1380 /** |
| 1314 * Instances of the class {@code Token} represent a token that was scanned from
the input. Each | 1381 * Instances of the class {@code Token} represent a token that was scanned from
the input. Each |
| 1315 * token knows which token follows it, acting as the head of a linked list of to
kens. | 1382 * token knows which token follows it, acting as the head of a linked list of to
kens. |
| 1316 * @coverage dart.engine.parser | 1383 * @coverage dart.engine.parser |
| 1317 */ | 1384 */ |
| 1318 class Token { | 1385 class Token { |
| 1386 |
| 1319 /** | 1387 /** |
| 1320 * The type of the token. | 1388 * The type of the token. |
| 1321 */ | 1389 */ |
| 1322 TokenType _type; | 1390 TokenType _type; |
| 1391 |
| 1323 /** | 1392 /** |
| 1324 * The offset from the beginning of the file to the first character in the tok
en. | 1393 * The offset from the beginning of the file to the first character in the tok
en. |
| 1325 */ | 1394 */ |
| 1326 int _offset = 0; | 1395 int _offset = 0; |
| 1396 |
| 1327 /** | 1397 /** |
| 1328 * The previous token in the token stream. | 1398 * The previous token in the token stream. |
| 1329 */ | 1399 */ |
| 1330 Token _previous; | 1400 Token _previous; |
| 1401 |
| 1331 /** | 1402 /** |
| 1332 * The next token in the token stream. | 1403 * The next token in the token stream. |
| 1333 */ | 1404 */ |
| 1334 Token _next; | 1405 Token _next; |
| 1406 |
| 1335 /** | 1407 /** |
| 1336 * Initialize a newly created token to have the given type and offset. | 1408 * Initialize a newly created token to have the given type and offset. |
| 1337 * @param type the type of the token | 1409 * @param type the type of the token |
| 1338 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1410 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1339 */ | 1411 */ |
| 1340 Token(TokenType type, int offset) { | 1412 Token(TokenType type, int offset) { |
| 1341 this._type = type; | 1413 this._type = type; |
| 1342 this._offset = offset; | 1414 this._offset = offset; |
| 1343 } | 1415 } |
| 1416 |
| 1344 /** | 1417 /** |
| 1345 * Return the offset from the beginning of the file to the character after las
t character of the | 1418 * Return the offset from the beginning of the file to the character after las
t character of the |
| 1346 * token. | 1419 * token. |
| 1347 * @return the offset from the beginning of the file to the first character af
ter last character | 1420 * @return the offset from the beginning of the file to the first character af
ter last character |
| 1348 * of the token | 1421 * of the token |
| 1349 */ | 1422 */ |
| 1350 int get end => _offset + length; | 1423 int get end => _offset + length; |
| 1424 |
| 1351 /** | 1425 /** |
| 1352 * Return the number of characters in the node's source range. | 1426 * Return the number of characters in the node's source range. |
| 1353 * @return the number of characters in the node's source range | 1427 * @return the number of characters in the node's source range |
| 1354 */ | 1428 */ |
| 1355 int get length => lexeme.length; | 1429 int get length => lexeme.length; |
| 1430 |
| 1356 /** | 1431 /** |
| 1357 * Return the lexeme that represents this token. | 1432 * Return the lexeme that represents this token. |
| 1358 * @return the lexeme that represents this token | 1433 * @return the lexeme that represents this token |
| 1359 */ | 1434 */ |
| 1360 String get lexeme => _type.lexeme; | 1435 String get lexeme => _type.lexeme; |
| 1436 |
| 1361 /** | 1437 /** |
| 1362 * Return the next token in the token stream. | 1438 * Return the next token in the token stream. |
| 1363 * @return the next token in the token stream | 1439 * @return the next token in the token stream |
| 1364 */ | 1440 */ |
| 1365 Token get next => _next; | 1441 Token get next => _next; |
| 1442 |
| 1366 /** | 1443 /** |
| 1367 * Return the offset from the beginning of the file to the first character in
the token. | 1444 * Return the offset from the beginning of the file to the first character in
the token. |
| 1368 * @return the offset from the beginning of the file to the first character in
the token | 1445 * @return the offset from the beginning of the file to the first character in
the token |
| 1369 */ | 1446 */ |
| 1370 int get offset => _offset; | 1447 int get offset => _offset; |
| 1448 |
| 1371 /** | 1449 /** |
| 1372 * Return the first comment in the list of comments that precede this token, o
r {@code null} if | 1450 * Return the first comment in the list of comments that precede this token, o
r {@code null} if |
| 1373 * there are no comments preceding this token. Additional comments can be reac
hed by following the | 1451 * there are no comments preceding this token. Additional comments can be reac
hed by following the |
| 1374 * token stream using {@link #getNext()} until {@code null} is returned. | 1452 * token stream using {@link #getNext()} until {@code null} is returned. |
| 1375 * @return the first comment in the list of comments that precede this token | 1453 * @return the first comment in the list of comments that precede this token |
| 1376 */ | 1454 */ |
| 1377 Token get precedingComments => null; | 1455 Token get precedingComments => null; |
| 1456 |
| 1378 /** | 1457 /** |
| 1379 * Return the previous token in the token stream. | 1458 * Return the previous token in the token stream. |
| 1380 * @return the previous token in the token stream | 1459 * @return the previous token in the token stream |
| 1381 */ | 1460 */ |
| 1382 Token get previous => _previous; | 1461 Token get previous => _previous; |
| 1462 |
| 1383 /** | 1463 /** |
| 1384 * Return the type of the token. | 1464 * Return the type of the token. |
| 1385 * @return the type of the token | 1465 * @return the type of the token |
| 1386 */ | 1466 */ |
| 1387 TokenType get type => _type; | 1467 TokenType get type => _type; |
| 1468 |
| 1388 /** | 1469 /** |
| 1389 * Return {@code true} if this token represents an operator. | 1470 * Return {@code true} if this token represents an operator. |
| 1390 * @return {@code true} if this token represents an operator | 1471 * @return {@code true} if this token represents an operator |
| 1391 */ | 1472 */ |
| 1392 bool isOperator() => _type.isOperator(); | 1473 bool isOperator() => _type.isOperator(); |
| 1474 |
| 1393 /** | 1475 /** |
| 1394 * Return {@code true} if this token is a synthetic token. A synthetic token i
s a token that was | 1476 * Return {@code true} if this token is a synthetic token. A synthetic token i
s a token that was |
| 1395 * introduced by the parser in order to recover from an error in the code. Syn
thetic tokens always | 1477 * introduced by the parser in order to recover from an error in the code. Syn
thetic tokens always |
| 1396 * have a length of zero ({@code 0}). | 1478 * have a length of zero ({@code 0}). |
| 1397 * @return {@code true} if this token is a synthetic token | 1479 * @return {@code true} if this token is a synthetic token |
| 1398 */ | 1480 */ |
| 1399 bool isSynthetic() => length == 0; | 1481 bool isSynthetic() => length == 0; |
| 1482 |
| 1400 /** | 1483 /** |
| 1401 * Return {@code true} if this token represents an operator that can be define
d by users. | 1484 * Return {@code true} if this token represents an operator that can be define
d by users. |
| 1402 * @return {@code true} if this token represents an operator that can be defin
ed by users | 1485 * @return {@code true} if this token represents an operator that can be defin
ed by users |
| 1403 */ | 1486 */ |
| 1404 bool isUserDefinableOperator() => _type.isUserDefinableOperator(); | 1487 bool isUserDefinableOperator() => _type.isUserDefinableOperator(); |
| 1488 |
| 1405 /** | 1489 /** |
| 1406 * Set the next token in the token stream to the given token. This has the sid
e-effect of setting | 1490 * Set the next token in the token stream to the given token. This has the sid
e-effect of setting |
| 1407 * this token to be the previous token for the given token. | 1491 * this token to be the previous token for the given token. |
| 1408 * @param token the next token in the token stream | 1492 * @param token the next token in the token stream |
| 1409 * @return the token that was passed in | 1493 * @return the token that was passed in |
| 1410 */ | 1494 */ |
| 1411 Token setNext(Token token) { | 1495 Token setNext(Token token) { |
| 1412 _next = token; | 1496 _next = token; |
| 1413 token.previous = this; | 1497 token.previous = this; |
| 1414 return token; | 1498 return token; |
| 1415 } | 1499 } |
| 1500 |
| 1416 /** | 1501 /** |
| 1417 * Set the next token in the token stream to the given token without changing
which token is the | 1502 * Set the next token in the token stream to the given token without changing
which token is the |
| 1418 * previous token for the given token. | 1503 * previous token for the given token. |
| 1419 * @param token the next token in the token stream | 1504 * @param token the next token in the token stream |
| 1420 * @return the token that was passed in | 1505 * @return the token that was passed in |
| 1421 */ | 1506 */ |
| 1422 Token setNextWithoutSettingPrevious(Token token) { | 1507 Token setNextWithoutSettingPrevious(Token token) { |
| 1423 _next = token; | 1508 _next = token; |
| 1424 return token; | 1509 return token; |
| 1425 } | 1510 } |
| 1511 |
| 1426 /** | 1512 /** |
| 1427 * Set the offset from the beginning of the file to the first character in the
token to the given | 1513 * Set the offset from the beginning of the file to the first character in the
token to the given |
| 1428 * offset. | 1514 * offset. |
| 1429 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1515 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1430 */ | 1516 */ |
| 1431 void set offset(int offset2) { | 1517 void set offset(int offset2) { |
| 1432 this._offset = offset2; | 1518 this._offset = offset2; |
| 1433 } | 1519 } |
| 1434 String toString() => lexeme; | 1520 String toString() => lexeme; |
| 1521 |
| 1435 /** | 1522 /** |
| 1436 * Return the value of this token. For keyword tokens, this is the keyword ass
ociated with the | 1523 * Return the value of this token. For keyword tokens, this is the keyword ass
ociated with the |
| 1437 * token, for other tokens it is the lexeme associated with the token. | 1524 * token, for other tokens it is the lexeme associated with the token. |
| 1438 * @return the value of this token | 1525 * @return the value of this token |
| 1439 */ | 1526 */ |
| 1440 Object value() => _type.lexeme; | 1527 Object value() => _type.lexeme; |
| 1528 |
| 1441 /** | 1529 /** |
| 1442 * Set the previous token in the token stream to the given token. | 1530 * Set the previous token in the token stream to the given token. |
| 1443 * @param previous the previous token in the token stream | 1531 * @param previous the previous token in the token stream |
| 1444 */ | 1532 */ |
| 1445 void set previous(Token previous2) { | 1533 void set previous(Token previous2) { |
| 1446 this._previous = previous2; | 1534 this._previous = previous2; |
| 1447 } | 1535 } |
| 1448 } | 1536 } |
| 1537 |
| 1449 /** | 1538 /** |
| 1450 * Instances of the class {@code StringScanner} implement a scanner that reads f
rom a string. The | 1539 * Instances of the class {@code StringScanner} implement a scanner that reads f
rom a string. The |
| 1451 * scanning logic is in the superclass. | 1540 * scanning logic is in the superclass. |
| 1452 * @coverage dart.engine.parser | 1541 * @coverage dart.engine.parser |
| 1453 */ | 1542 */ |
| 1454 class StringScanner extends AbstractScanner { | 1543 class StringScanner extends AbstractScanner { |
| 1544 |
| 1455 /** | 1545 /** |
| 1456 * The offset from the beginning of the file to the beginning of the source be
ing scanned. | 1546 * The offset from the beginning of the file to the beginning of the source be
ing scanned. |
| 1457 */ | 1547 */ |
| 1458 int _offsetDelta = 0; | 1548 int _offsetDelta = 0; |
| 1549 |
| 1459 /** | 1550 /** |
| 1460 * The string from which characters will be read. | 1551 * The string from which characters will be read. |
| 1461 */ | 1552 */ |
| 1462 String _string; | 1553 String _string; |
| 1554 |
| 1463 /** | 1555 /** |
| 1464 * The number of characters in the string. | 1556 * The number of characters in the string. |
| 1465 */ | 1557 */ |
| 1466 int _stringLength = 0; | 1558 int _stringLength = 0; |
| 1559 |
| 1467 /** | 1560 /** |
| 1468 * The index, relative to the string, of the last character that was read. | 1561 * The index, relative to the string, of the last character that was read. |
| 1469 */ | 1562 */ |
| 1470 int _charOffset = 0; | 1563 int _charOffset = 0; |
| 1564 |
| 1471 /** | 1565 /** |
| 1472 * Initialize a newly created scanner to scan the characters in the given stri
ng. | 1566 * Initialize a newly created scanner to scan the characters in the given stri
ng. |
| 1473 * @param source the source being scanned | 1567 * @param source the source being scanned |
| 1474 * @param string the string from which characters will be read | 1568 * @param string the string from which characters will be read |
| 1475 * @param errorListener the error listener that will be informed of any errors
that are found | 1569 * @param errorListener the error listener that will be informed of any errors
that are found |
| 1476 */ | 1570 */ |
| 1477 StringScanner(Source source, String string, AnalysisErrorListener errorListene
r) : super(source, errorListener) { | 1571 StringScanner(Source source, String string, AnalysisErrorListener errorListene
r) : super(source, errorListener) { |
| 1478 this._offsetDelta = 0; | 1572 this._offsetDelta = 0; |
| 1479 this._string = string; | 1573 this._string = string; |
| 1480 this._stringLength = string.length; | 1574 this._stringLength = string.length; |
| 1481 this._charOffset = -1; | 1575 this._charOffset = -1; |
| 1482 } | 1576 } |
| 1483 int get offset => _offsetDelta + _charOffset; | 1577 int get offset => _offsetDelta + _charOffset; |
| 1578 |
| 1484 /** | 1579 /** |
| 1485 * Record that the source begins on the given line and column at the given off
set. The line starts | 1580 * Record that the source begins on the given line and column at the given off
set. The line starts |
| 1486 * for lines before the given line will not be correct. | 1581 * for lines before the given line will not be correct. |
| 1487 * <p> | 1582 * <p> |
| 1488 * This method must be invoked at most one time and must be invoked before sca
nning begins. The | 1583 * This method must be invoked at most one time and must be invoked before sca
nning begins. The |
| 1489 * values provided must be sensible. The results are undefined if these condit
ions are violated. | 1584 * values provided must be sensible. The results are undefined if these condit
ions are violated. |
| 1490 * @param line the one-based index of the line containing the first character
of the source | 1585 * @param line the one-based index of the line containing the first character
of the source |
| 1491 * @param column the one-based index of the column in which the first characte
r of the source | 1586 * @param column the one-based index of the column in which the first characte
r of the source |
| 1492 * occurs | 1587 * occurs |
| 1493 * @param offset the zero-based offset from the beginning of the larger contex
t to the first | 1588 * @param offset the zero-based offset from the beginning of the larger contex
t to the first |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1512 return _string.codeUnitAt(++_charOffset); | 1607 return _string.codeUnitAt(++_charOffset); |
| 1513 } | 1608 } |
| 1514 String getString(int start, int endDelta) => _string.substring(start - _offset
Delta, _charOffset + 1 + endDelta); | 1609 String getString(int start, int endDelta) => _string.substring(start - _offset
Delta, _charOffset + 1 + endDelta); |
| 1515 int peek() { | 1610 int peek() { |
| 1516 if (_charOffset + 1 >= _string.length) { | 1611 if (_charOffset + 1 >= _string.length) { |
| 1517 return -1; | 1612 return -1; |
| 1518 } | 1613 } |
| 1519 return _string.codeUnitAt(_charOffset + 1); | 1614 return _string.codeUnitAt(_charOffset + 1); |
| 1520 } | 1615 } |
| 1521 } | 1616 } |
| 1617 |
| 1522 /** | 1618 /** |
| 1523 * Instances of the class {@code BeginTokenWithComment} represent a begin token
that is preceded by | 1619 * Instances of the class {@code BeginTokenWithComment} represent a begin token
that is preceded by |
| 1524 * comments. | 1620 * comments. |
| 1525 * @coverage dart.engine.parser | 1621 * @coverage dart.engine.parser |
| 1526 */ | 1622 */ |
| 1527 class BeginTokenWithComment extends BeginToken { | 1623 class BeginTokenWithComment extends BeginToken { |
| 1624 |
| 1528 /** | 1625 /** |
| 1529 * The first comment in the list of comments that precede this token. | 1626 * The first comment in the list of comments that precede this token. |
| 1530 */ | 1627 */ |
| 1531 Token _precedingComment; | 1628 Token _precedingComment; |
| 1629 |
| 1532 /** | 1630 /** |
| 1533 * Initialize a newly created token to have the given type and offset and to b
e preceded by the | 1631 * Initialize a newly created token to have the given type and offset and to b
e preceded by the |
| 1534 * comments reachable from the given comment. | 1632 * comments reachable from the given comment. |
| 1535 * @param type the type of the token | 1633 * @param type the type of the token |
| 1536 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1634 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1537 * @param precedingComment the first comment in the list of comments that prec
ede this token | 1635 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 1538 */ | 1636 */ |
| 1539 BeginTokenWithComment(TokenType type, int offset, Token precedingComment) : su
per(type, offset) { | 1637 BeginTokenWithComment(TokenType type, int offset, Token precedingComment) : su
per(type, offset) { |
| 1540 this._precedingComment = precedingComment; | 1638 this._precedingComment = precedingComment; |
| 1541 } | 1639 } |
| 1542 Token get precedingComments => _precedingComment; | 1640 Token get precedingComments => _precedingComment; |
| 1543 } | 1641 } |
| 1642 |
| 1544 /** | 1643 /** |
| 1545 * Instances of the class {@code KeywordToken} represent a keyword in the langua
ge. | 1644 * Instances of the class {@code KeywordToken} represent a keyword in the langua
ge. |
| 1546 * @coverage dart.engine.parser | 1645 * @coverage dart.engine.parser |
| 1547 */ | 1646 */ |
| 1548 class KeywordToken extends Token { | 1647 class KeywordToken extends Token { |
| 1648 |
| 1549 /** | 1649 /** |
| 1550 * The keyword being represented by this token. | 1650 * The keyword being represented by this token. |
| 1551 */ | 1651 */ |
| 1552 Keyword _keyword; | 1652 Keyword _keyword; |
| 1653 |
| 1553 /** | 1654 /** |
| 1554 * Initialize a newly created token to represent the given keyword. | 1655 * Initialize a newly created token to represent the given keyword. |
| 1555 * @param keyword the keyword being represented by this token | 1656 * @param keyword the keyword being represented by this token |
| 1556 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1657 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1557 */ | 1658 */ |
| 1558 KeywordToken(Keyword keyword, int offset) : super(TokenType.KEYWORD, offset) { | 1659 KeywordToken(Keyword keyword, int offset) : super(TokenType.KEYWORD, offset) { |
| 1559 this._keyword = keyword; | 1660 this._keyword = keyword; |
| 1560 } | 1661 } |
| 1662 |
| 1561 /** | 1663 /** |
| 1562 * Return the keyword being represented by this token. | 1664 * Return the keyword being represented by this token. |
| 1563 * @return the keyword being represented by this token | 1665 * @return the keyword being represented by this token |
| 1564 */ | 1666 */ |
| 1565 Keyword get keyword => _keyword; | 1667 Keyword get keyword => _keyword; |
| 1566 String get lexeme => _keyword.syntax; | 1668 String get lexeme => _keyword.syntax; |
| 1567 Keyword value() => _keyword; | 1669 Keyword value() => _keyword; |
| 1568 } | 1670 } |
| 1671 |
| 1569 /** | 1672 /** |
| 1570 * Instances of the class {@code BeginToken} represent the opening half of a gro
uping pair of | 1673 * Instances of the class {@code BeginToken} represent the opening half of a gro
uping pair of |
| 1571 * tokens. This is used for curly brackets ('{'), parentheses ('('), and square
brackets ('\['). | 1674 * tokens. This is used for curly brackets ('{'), parentheses ('('), and square
brackets ('\['). |
| 1572 * @coverage dart.engine.parser | 1675 * @coverage dart.engine.parser |
| 1573 */ | 1676 */ |
| 1574 class BeginToken extends Token { | 1677 class BeginToken extends Token { |
| 1678 |
| 1575 /** | 1679 /** |
| 1576 * The token that corresponds to this token. | 1680 * The token that corresponds to this token. |
| 1577 */ | 1681 */ |
| 1578 Token _endToken; | 1682 Token _endToken; |
| 1683 |
| 1579 /** | 1684 /** |
| 1580 * Initialize a newly created token representing the opening half of a groupin
g pair of tokens. | 1685 * Initialize a newly created token representing the opening half of a groupin
g pair of tokens. |
| 1581 * @param type the type of the token | 1686 * @param type the type of the token |
| 1582 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1687 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1583 */ | 1688 */ |
| 1584 BeginToken(TokenType type, int offset) : super(type, offset) { | 1689 BeginToken(TokenType type, int offset) : super(type, offset) { |
| 1585 assert((identical(type, TokenType.OPEN_CURLY_BRACKET) || identical(type, Tok
enType.OPEN_PAREN) || identical(type, TokenType.OPEN_SQUARE_BRACKET) || identica
l(type, TokenType.STRING_INTERPOLATION_EXPRESSION))); | 1690 assert((identical(type, TokenType.OPEN_CURLY_BRACKET) || identical(type, Tok
enType.OPEN_PAREN) || identical(type, TokenType.OPEN_SQUARE_BRACKET) || identica
l(type, TokenType.STRING_INTERPOLATION_EXPRESSION))); |
| 1586 } | 1691 } |
| 1692 |
| 1587 /** | 1693 /** |
| 1588 * Return the token that corresponds to this token. | 1694 * Return the token that corresponds to this token. |
| 1589 * @return the token that corresponds to this token | 1695 * @return the token that corresponds to this token |
| 1590 */ | 1696 */ |
| 1591 Token get endToken => _endToken; | 1697 Token get endToken => _endToken; |
| 1698 |
| 1592 /** | 1699 /** |
| 1593 * Set the token that corresponds to this token to the given token. | 1700 * Set the token that corresponds to this token to the given token. |
| 1594 * @param token the token that corresponds to this token | 1701 * @param token the token that corresponds to this token |
| 1595 */ | 1702 */ |
| 1596 void set endToken(Token token) { | 1703 void set endToken(Token token) { |
| 1597 this._endToken = token; | 1704 this._endToken = token; |
| 1598 } | 1705 } |
| 1599 } | 1706 } |
| 1707 |
| 1600 /** | 1708 /** |
| 1601 * The enumeration {@code TokenClass} represents classes (or groups) of tokens w
ith a similar use. | 1709 * The enumeration {@code TokenClass} represents classes (or groups) of tokens w
ith a similar use. |
| 1602 * @coverage dart.engine.parser | 1710 * @coverage dart.engine.parser |
| 1603 */ | 1711 */ |
| 1604 class TokenClass implements Comparable<TokenClass> { | 1712 class TokenClass implements Comparable<TokenClass> { |
| 1713 |
| 1605 /** | 1714 /** |
| 1606 * A value used to indicate that the token type is not part of any specific cl
ass of token. | 1715 * A value used to indicate that the token type is not part of any specific cl
ass of token. |
| 1607 */ | 1716 */ |
| 1608 static final TokenClass NO_CLASS = new TokenClass.con1('NO_CLASS', 0); | 1717 static final TokenClass NO_CLASS = new TokenClass.con1('NO_CLASS', 0); |
| 1718 |
| 1609 /** | 1719 /** |
| 1610 * A value used to indicate that the token type is an additive operator. | 1720 * A value used to indicate that the token type is an additive operator. |
| 1611 */ | 1721 */ |
| 1612 static final TokenClass ADDITIVE_OPERATOR = new TokenClass.con2('ADDITIVE_OPER
ATOR', 1, 12); | 1722 static final TokenClass ADDITIVE_OPERATOR = new TokenClass.con2('ADDITIVE_OPER
ATOR', 1, 12); |
| 1723 |
| 1613 /** | 1724 /** |
| 1614 * A value used to indicate that the token type is an assignment operator. | 1725 * A value used to indicate that the token type is an assignment operator. |
| 1615 */ | 1726 */ |
| 1616 static final TokenClass ASSIGNMENT_OPERATOR = new TokenClass.con2('ASSIGNMENT_
OPERATOR', 2, 1); | 1727 static final TokenClass ASSIGNMENT_OPERATOR = new TokenClass.con2('ASSIGNMENT_
OPERATOR', 2, 1); |
| 1728 |
| 1617 /** | 1729 /** |
| 1618 * A value used to indicate that the token type is a bitwise-and operator. | 1730 * A value used to indicate that the token type is a bitwise-and operator. |
| 1619 */ | 1731 */ |
| 1620 static final TokenClass BITWISE_AND_OPERATOR = new TokenClass.con2('BITWISE_AN
D_OPERATOR', 3, 8); | 1732 static final TokenClass BITWISE_AND_OPERATOR = new TokenClass.con2('BITWISE_AN
D_OPERATOR', 3, 8); |
| 1733 |
| 1621 /** | 1734 /** |
| 1622 * A value used to indicate that the token type is a bitwise-or operator. | 1735 * A value used to indicate that the token type is a bitwise-or operator. |
| 1623 */ | 1736 */ |
| 1624 static final TokenClass BITWISE_OR_OPERATOR = new TokenClass.con2('BITWISE_OR_
OPERATOR', 4, 6); | 1737 static final TokenClass BITWISE_OR_OPERATOR = new TokenClass.con2('BITWISE_OR_
OPERATOR', 4, 6); |
| 1738 |
| 1625 /** | 1739 /** |
| 1626 * A value used to indicate that the token type is a bitwise-xor operator. | 1740 * A value used to indicate that the token type is a bitwise-xor operator. |
| 1627 */ | 1741 */ |
| 1628 static final TokenClass BITWISE_XOR_OPERATOR = new TokenClass.con2('BITWISE_XO
R_OPERATOR', 5, 7); | 1742 static final TokenClass BITWISE_XOR_OPERATOR = new TokenClass.con2('BITWISE_XO
R_OPERATOR', 5, 7); |
| 1743 |
| 1629 /** | 1744 /** |
| 1630 * A value used to indicate that the token type is a cascade operator. | 1745 * A value used to indicate that the token type is a cascade operator. |
| 1631 */ | 1746 */ |
| 1632 static final TokenClass CASCADE_OPERATOR = new TokenClass.con2('CASCADE_OPERAT
OR', 6, 2); | 1747 static final TokenClass CASCADE_OPERATOR = new TokenClass.con2('CASCADE_OPERAT
OR', 6, 2); |
| 1748 |
| 1633 /** | 1749 /** |
| 1634 * A value used to indicate that the token type is a conditional operator. | 1750 * A value used to indicate that the token type is a conditional operator. |
| 1635 */ | 1751 */ |
| 1636 static final TokenClass CONDITIONAL_OPERATOR = new TokenClass.con2('CONDITIONA
L_OPERATOR', 7, 3); | 1752 static final TokenClass CONDITIONAL_OPERATOR = new TokenClass.con2('CONDITIONA
L_OPERATOR', 7, 3); |
| 1753 |
| 1637 /** | 1754 /** |
| 1638 * A value used to indicate that the token type is an equality operator. | 1755 * A value used to indicate that the token type is an equality operator. |
| 1639 */ | 1756 */ |
| 1640 static final TokenClass EQUALITY_OPERATOR = new TokenClass.con2('EQUALITY_OPER
ATOR', 8, 9); | 1757 static final TokenClass EQUALITY_OPERATOR = new TokenClass.con2('EQUALITY_OPER
ATOR', 8, 9); |
| 1758 |
| 1641 /** | 1759 /** |
| 1642 * A value used to indicate that the token type is a logical-and operator. | 1760 * A value used to indicate that the token type is a logical-and operator. |
| 1643 */ | 1761 */ |
| 1644 static final TokenClass LOGICAL_AND_OPERATOR = new TokenClass.con2('LOGICAL_AN
D_OPERATOR', 9, 5); | 1762 static final TokenClass LOGICAL_AND_OPERATOR = new TokenClass.con2('LOGICAL_AN
D_OPERATOR', 9, 5); |
| 1763 |
| 1645 /** | 1764 /** |
| 1646 * A value used to indicate that the token type is a logical-or operator. | 1765 * A value used to indicate that the token type is a logical-or operator. |
| 1647 */ | 1766 */ |
| 1648 static final TokenClass LOGICAL_OR_OPERATOR = new TokenClass.con2('LOGICAL_OR_
OPERATOR', 10, 4); | 1767 static final TokenClass LOGICAL_OR_OPERATOR = new TokenClass.con2('LOGICAL_OR_
OPERATOR', 10, 4); |
| 1768 |
| 1649 /** | 1769 /** |
| 1650 * A value used to indicate that the token type is a multiplicative operator. | 1770 * A value used to indicate that the token type is a multiplicative operator. |
| 1651 */ | 1771 */ |
| 1652 static final TokenClass MULTIPLICATIVE_OPERATOR = new TokenClass.con2('MULTIPL
ICATIVE_OPERATOR', 11, 13); | 1772 static final TokenClass MULTIPLICATIVE_OPERATOR = new TokenClass.con2('MULTIPL
ICATIVE_OPERATOR', 11, 13); |
| 1773 |
| 1653 /** | 1774 /** |
| 1654 * A value used to indicate that the token type is a relational operator. | 1775 * A value used to indicate that the token type is a relational operator. |
| 1655 */ | 1776 */ |
| 1656 static final TokenClass RELATIONAL_OPERATOR = new TokenClass.con2('RELATIONAL_
OPERATOR', 12, 10); | 1777 static final TokenClass RELATIONAL_OPERATOR = new TokenClass.con2('RELATIONAL_
OPERATOR', 12, 10); |
| 1778 |
| 1657 /** | 1779 /** |
| 1658 * A value used to indicate that the token type is a shift operator. | 1780 * A value used to indicate that the token type is a shift operator. |
| 1659 */ | 1781 */ |
| 1660 static final TokenClass SHIFT_OPERATOR = new TokenClass.con2('SHIFT_OPERATOR',
13, 11); | 1782 static final TokenClass SHIFT_OPERATOR = new TokenClass.con2('SHIFT_OPERATOR',
13, 11); |
| 1783 |
| 1661 /** | 1784 /** |
| 1662 * A value used to indicate that the token type is a unary operator. | 1785 * A value used to indicate that the token type is a unary operator. |
| 1663 */ | 1786 */ |
| 1664 static final TokenClass UNARY_POSTFIX_OPERATOR = new TokenClass.con2('UNARY_PO
STFIX_OPERATOR', 14, 15); | 1787 static final TokenClass UNARY_POSTFIX_OPERATOR = new TokenClass.con2('UNARY_PO
STFIX_OPERATOR', 14, 15); |
| 1788 |
| 1665 /** | 1789 /** |
| 1666 * A value used to indicate that the token type is a unary operator. | 1790 * A value used to indicate that the token type is a unary operator. |
| 1667 */ | 1791 */ |
| 1668 static final TokenClass UNARY_PREFIX_OPERATOR = new TokenClass.con2('UNARY_PRE
FIX_OPERATOR', 15, 14); | 1792 static final TokenClass UNARY_PREFIX_OPERATOR = new TokenClass.con2('UNARY_PRE
FIX_OPERATOR', 15, 14); |
| 1669 static final List<TokenClass> values = [NO_CLASS, ADDITIVE_OPERATOR, ASSIGNMEN
T_OPERATOR, BITWISE_AND_OPERATOR, BITWISE_OR_OPERATOR, BITWISE_XOR_OPERATOR, CAS
CADE_OPERATOR, CONDITIONAL_OPERATOR, EQUALITY_OPERATOR, LOGICAL_AND_OPERATOR, LO
GICAL_OR_OPERATOR, MULTIPLICATIVE_OPERATOR, RELATIONAL_OPERATOR, SHIFT_OPERATOR,
UNARY_POSTFIX_OPERATOR, UNARY_PREFIX_OPERATOR]; | 1793 static final List<TokenClass> values = [NO_CLASS, ADDITIVE_OPERATOR, ASSIGNMEN
T_OPERATOR, BITWISE_AND_OPERATOR, BITWISE_OR_OPERATOR, BITWISE_XOR_OPERATOR, CAS
CADE_OPERATOR, CONDITIONAL_OPERATOR, EQUALITY_OPERATOR, LOGICAL_AND_OPERATOR, LO
GICAL_OR_OPERATOR, MULTIPLICATIVE_OPERATOR, RELATIONAL_OPERATOR, SHIFT_OPERATOR,
UNARY_POSTFIX_OPERATOR, UNARY_PREFIX_OPERATOR]; |
| 1670 String __name; | 1794 |
| 1671 int __ordinal = 0; | 1795 /// The name of this enum constant, as declared in the enum declaration. |
| 1672 int get ordinal => __ordinal; | 1796 final String name; |
| 1797 |
| 1798 /// The position in the enum declaration. |
| 1799 final int ordinal; |
| 1800 |
| 1673 /** | 1801 /** |
| 1674 * The precedence of tokens of this class, or {@code 0} if the such tokens do
not represent an | 1802 * The precedence of tokens of this class, or {@code 0} if the such tokens do
not represent an |
| 1675 * operator. | 1803 * operator. |
| 1676 */ | 1804 */ |
| 1677 int _precedence = 0; | 1805 int _precedence = 0; |
| 1678 TokenClass.con1(String ___name, int ___ordinal) { | 1806 TokenClass.con1(this.name, this.ordinal) { |
| 1679 _jtd_constructor_319_impl(___name, ___ordinal); | 1807 _jtd_constructor_326_impl(); |
| 1680 } | 1808 } |
| 1681 _jtd_constructor_319_impl(String ___name, int ___ordinal) { | 1809 _jtd_constructor_326_impl() { |
| 1682 _jtd_constructor_320_impl(___name, ___ordinal, 0); | 1810 _jtd_constructor_327_impl(0); |
| 1683 } | 1811 } |
| 1684 TokenClass.con2(String ___name, int ___ordinal, int precedence2) { | 1812 TokenClass.con2(this.name, this.ordinal, int precedence2) { |
| 1685 _jtd_constructor_320_impl(___name, ___ordinal, precedence2); | 1813 _jtd_constructor_327_impl(precedence2); |
| 1686 } | 1814 } |
| 1687 _jtd_constructor_320_impl(String ___name, int ___ordinal, int precedence2) { | 1815 _jtd_constructor_327_impl(int precedence2) { |
| 1688 __name = ___name; | |
| 1689 __ordinal = ___ordinal; | |
| 1690 this._precedence = precedence2; | 1816 this._precedence = precedence2; |
| 1691 } | 1817 } |
| 1818 |
| 1692 /** | 1819 /** |
| 1693 * Return the precedence of tokens of this class, or {@code 0} if the such tok
ens do not represent | 1820 * Return the precedence of tokens of this class, or {@code 0} if the such tok
ens do not represent |
| 1694 * an operator. | 1821 * an operator. |
| 1695 * @return the precedence of tokens of this class | 1822 * @return the precedence of tokens of this class |
| 1696 */ | 1823 */ |
| 1697 int get precedence => _precedence; | 1824 int get precedence => _precedence; |
| 1698 int compareTo(TokenClass other) => __ordinal - other.__ordinal; | 1825 int compareTo(TokenClass other) => ordinal - other.ordinal; |
| 1699 String toString() => __name; | 1826 String toString() => name; |
| 1700 } | 1827 } |
| 1828 |
| 1701 /** | 1829 /** |
| 1702 * Instances of the class {@code KeywordTokenWithComment} implement a keyword to
ken that is preceded | 1830 * Instances of the class {@code KeywordTokenWithComment} implement a keyword to
ken that is preceded |
| 1703 * by comments. | 1831 * by comments. |
| 1704 * @coverage dart.engine.parser | 1832 * @coverage dart.engine.parser |
| 1705 */ | 1833 */ |
| 1706 class KeywordTokenWithComment extends KeywordToken { | 1834 class KeywordTokenWithComment extends KeywordToken { |
| 1835 |
| 1707 /** | 1836 /** |
| 1708 * The first comment in the list of comments that precede this token. | 1837 * The first comment in the list of comments that precede this token. |
| 1709 */ | 1838 */ |
| 1710 Token _precedingComment; | 1839 Token _precedingComment; |
| 1840 |
| 1711 /** | 1841 /** |
| 1712 * Initialize a newly created token to to represent the given keyword and to b
e preceded by the | 1842 * Initialize a newly created token to to represent the given keyword and to b
e preceded by the |
| 1713 * comments reachable from the given comment. | 1843 * comments reachable from the given comment. |
| 1714 * @param keyword the keyword being represented by this token | 1844 * @param keyword the keyword being represented by this token |
| 1715 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1845 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1716 * @param precedingComment the first comment in the list of comments that prec
ede this token | 1846 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 1717 */ | 1847 */ |
| 1718 KeywordTokenWithComment(Keyword keyword, int offset, Token precedingComment) :
super(keyword, offset) { | 1848 KeywordTokenWithComment(Keyword keyword, int offset, Token precedingComment) :
super(keyword, offset) { |
| 1719 this._precedingComment = precedingComment; | 1849 this._precedingComment = precedingComment; |
| 1720 } | 1850 } |
| 1721 Token get precedingComments => _precedingComment; | 1851 Token get precedingComments => _precedingComment; |
| 1722 } | 1852 } |
| 1853 |
| 1723 /** | 1854 /** |
| 1724 * The enumeration {@code TokenType} defines the types of tokens that can be ret
urned by the | 1855 * The enumeration {@code TokenType} defines the types of tokens that can be ret
urned by the |
| 1725 * scanner. | 1856 * scanner. |
| 1726 * @coverage dart.engine.parser | 1857 * @coverage dart.engine.parser |
| 1727 */ | 1858 */ |
| 1728 class TokenType implements Comparable<TokenType> { | 1859 class TokenType implements Comparable<TokenType> { |
| 1860 |
| 1729 /** | 1861 /** |
| 1730 * The type of the token that marks the end of the input. | 1862 * The type of the token that marks the end of the input. |
| 1731 */ | 1863 */ |
| 1732 static final TokenType EOF = new TokenType_EOF('EOF', 0, null, ""); | 1864 static final TokenType EOF = new TokenType_EOF('EOF', 0, null, ""); |
| 1733 static final TokenType DOUBLE = new TokenType.con1('DOUBLE', 1); | 1865 static final TokenType DOUBLE = new TokenType.con1('DOUBLE', 1); |
| 1734 static final TokenType HEXADECIMAL = new TokenType.con1('HEXADECIMAL', 2); | 1866 static final TokenType HEXADECIMAL = new TokenType.con1('HEXADECIMAL', 2); |
| 1735 static final TokenType IDENTIFIER = new TokenType.con1('IDENTIFIER', 3); | 1867 static final TokenType IDENTIFIER = new TokenType.con1('IDENTIFIER', 3); |
| 1736 static final TokenType INT = new TokenType.con1('INT', 4); | 1868 static final TokenType INT = new TokenType.con1('INT', 4); |
| 1737 static final TokenType KEYWORD = new TokenType.con1('KEYWORD', 5); | 1869 static final TokenType KEYWORD = new TokenType.con1('KEYWORD', 5); |
| 1738 static final TokenType MULTI_LINE_COMMENT = new TokenType.con1('MULTI_LINE_COM
MENT', 6); | 1870 static final TokenType MULTI_LINE_COMMENT = new TokenType.con1('MULTI_LINE_COM
MENT', 6); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 static final TokenType STAR_EQ = new TokenType.con2('STAR_EQ', 59, TokenClass.
ASSIGNMENT_OPERATOR, "*="); | 1923 static final TokenType STAR_EQ = new TokenType.con2('STAR_EQ', 59, TokenClass.
ASSIGNMENT_OPERATOR, "*="); |
| 1792 static final TokenType STRING_INTERPOLATION_EXPRESSION = new TokenType.con2('S
TRING_INTERPOLATION_EXPRESSION', 60, null, "\${"); | 1924 static final TokenType STRING_INTERPOLATION_EXPRESSION = new TokenType.con2('S
TRING_INTERPOLATION_EXPRESSION', 60, null, "\${"); |
| 1793 static final TokenType STRING_INTERPOLATION_IDENTIFIER = new TokenType.con2('S
TRING_INTERPOLATION_IDENTIFIER', 61, null, "\$"); | 1925 static final TokenType STRING_INTERPOLATION_IDENTIFIER = new TokenType.con2('S
TRING_INTERPOLATION_IDENTIFIER', 61, null, "\$"); |
| 1794 static final TokenType TILDE = new TokenType.con2('TILDE', 62, TokenClass.UNAR
Y_PREFIX_OPERATOR, "~"); | 1926 static final TokenType TILDE = new TokenType.con2('TILDE', 62, TokenClass.UNAR
Y_PREFIX_OPERATOR, "~"); |
| 1795 static final TokenType TILDE_SLASH = new TokenType.con2('TILDE_SLASH', 63, Tok
enClass.MULTIPLICATIVE_OPERATOR, "~/"); | 1927 static final TokenType TILDE_SLASH = new TokenType.con2('TILDE_SLASH', 63, Tok
enClass.MULTIPLICATIVE_OPERATOR, "~/"); |
| 1796 static final TokenType TILDE_SLASH_EQ = new TokenType.con2('TILDE_SLASH_EQ', 6
4, TokenClass.ASSIGNMENT_OPERATOR, "~/="); | 1928 static final TokenType TILDE_SLASH_EQ = new TokenType.con2('TILDE_SLASH_EQ', 6
4, TokenClass.ASSIGNMENT_OPERATOR, "~/="); |
| 1797 static final TokenType BACKPING = new TokenType.con2('BACKPING', 65, null, "`"
); | 1929 static final TokenType BACKPING = new TokenType.con2('BACKPING', 65, null, "`"
); |
| 1798 static final TokenType BACKSLASH = new TokenType.con2('BACKSLASH', 66, null, "
\\"); | 1930 static final TokenType BACKSLASH = new TokenType.con2('BACKSLASH', 66, null, "
\\"); |
| 1799 static final TokenType PERIOD_PERIOD_PERIOD = new TokenType.con2('PERIOD_PERIO
D_PERIOD', 67, null, "..."); | 1931 static final TokenType PERIOD_PERIOD_PERIOD = new TokenType.con2('PERIOD_PERIO
D_PERIOD', 67, null, "..."); |
| 1800 static final List<TokenType> values = [EOF, DOUBLE, HEXADECIMAL, IDENTIFIER, I
NT, KEYWORD, MULTI_LINE_COMMENT, SCRIPT_TAG, SINGLE_LINE_COMMENT, STRING, AMPERS
AND, AMPERSAND_AMPERSAND, AMPERSAND_EQ, AT, BANG, BANG_EQ, BAR, BAR_BAR, BAR_EQ,
COLON, COMMA, CARET, CARET_EQ, CLOSE_CURLY_BRACKET, CLOSE_PAREN, CLOSE_SQUARE_B
RACKET, EQ, EQ_EQ, FUNCTION, GT, GT_EQ, GT_GT, GT_GT_EQ, HASH, INDEX, INDEX_EQ,
IS, LT, LT_EQ, LT_LT, LT_LT_EQ, MINUS, MINUS_EQ, MINUS_MINUS, OPEN_CURLY_BRACKET
, OPEN_PAREN, OPEN_SQUARE_BRACKET, PERCENT, PERCENT_EQ, PERIOD, PERIOD_PERIOD, P
LUS, PLUS_EQ, PLUS_PLUS, QUESTION, SEMICOLON, SLASH, SLASH_EQ, STAR, STAR_EQ, ST
RING_INTERPOLATION_EXPRESSION, STRING_INTERPOLATION_IDENTIFIER, TILDE, TILDE_SLA
SH, TILDE_SLASH_EQ, BACKPING, BACKSLASH, PERIOD_PERIOD_PERIOD]; | 1932 static final List<TokenType> values = [EOF, DOUBLE, HEXADECIMAL, IDENTIFIER, I
NT, KEYWORD, MULTI_LINE_COMMENT, SCRIPT_TAG, SINGLE_LINE_COMMENT, STRING, AMPERS
AND, AMPERSAND_AMPERSAND, AMPERSAND_EQ, AT, BANG, BANG_EQ, BAR, BAR_BAR, BAR_EQ,
COLON, COMMA, CARET, CARET_EQ, CLOSE_CURLY_BRACKET, CLOSE_PAREN, CLOSE_SQUARE_B
RACKET, EQ, EQ_EQ, FUNCTION, GT, GT_EQ, GT_GT, GT_GT_EQ, HASH, INDEX, INDEX_EQ,
IS, LT, LT_EQ, LT_LT, LT_LT_EQ, MINUS, MINUS_EQ, MINUS_MINUS, OPEN_CURLY_BRACKET
, OPEN_PAREN, OPEN_SQUARE_BRACKET, PERCENT, PERCENT_EQ, PERIOD, PERIOD_PERIOD, P
LUS, PLUS_EQ, PLUS_PLUS, QUESTION, SEMICOLON, SLASH, SLASH_EQ, STAR, STAR_EQ, ST
RING_INTERPOLATION_EXPRESSION, STRING_INTERPOLATION_IDENTIFIER, TILDE, TILDE_SLA
SH, TILDE_SLASH_EQ, BACKPING, BACKSLASH, PERIOD_PERIOD_PERIOD]; |
| 1801 String __name; | 1933 |
| 1802 int __ordinal = 0; | 1934 /// The name of this enum constant, as declared in the enum declaration. |
| 1803 int get ordinal => __ordinal; | 1935 final String name; |
| 1936 |
| 1937 /// The position in the enum declaration. |
| 1938 final int ordinal; |
| 1939 |
| 1804 /** | 1940 /** |
| 1805 * The class of the token. | 1941 * The class of the token. |
| 1806 */ | 1942 */ |
| 1807 TokenClass _tokenClass; | 1943 TokenClass _tokenClass; |
| 1944 |
| 1808 /** | 1945 /** |
| 1809 * The lexeme that defines this type of token, or {@code null} if there is mor
e than one possible | 1946 * The lexeme that defines this type of token, or {@code null} if there is mor
e than one possible |
| 1810 * lexeme for this type of token. | 1947 * lexeme for this type of token. |
| 1811 */ | 1948 */ |
| 1812 String _lexeme; | 1949 String _lexeme; |
| 1813 TokenType.con1(String ___name, int ___ordinal) { | 1950 TokenType.con1(this.name, this.ordinal) { |
| 1814 _jtd_constructor_321_impl(___name, ___ordinal); | 1951 _jtd_constructor_328_impl(); |
| 1815 } | 1952 } |
| 1816 _jtd_constructor_321_impl(String ___name, int ___ordinal) { | 1953 _jtd_constructor_328_impl() { |
| 1817 _jtd_constructor_322_impl(___name, ___ordinal, TokenClass.NO_CLASS, null); | 1954 _jtd_constructor_329_impl(TokenClass.NO_CLASS, null); |
| 1818 } | 1955 } |
| 1819 TokenType.con2(String ___name, int ___ordinal, TokenClass tokenClass2, String
lexeme2) { | 1956 TokenType.con2(this.name, this.ordinal, TokenClass tokenClass2, String lexeme2
) { |
| 1820 _jtd_constructor_322_impl(___name, ___ordinal, tokenClass2, lexeme2); | 1957 _jtd_constructor_329_impl(tokenClass2, lexeme2); |
| 1821 } | 1958 } |
| 1822 _jtd_constructor_322_impl(String ___name, int ___ordinal, TokenClass tokenClas
s2, String lexeme2) { | 1959 _jtd_constructor_329_impl(TokenClass tokenClass2, String lexeme2) { |
| 1823 __name = ___name; | |
| 1824 __ordinal = ___ordinal; | |
| 1825 this._tokenClass = tokenClass2 == null ? TokenClass.NO_CLASS : tokenClass2; | 1960 this._tokenClass = tokenClass2 == null ? TokenClass.NO_CLASS : tokenClass2; |
| 1826 this._lexeme = lexeme2; | 1961 this._lexeme = lexeme2; |
| 1827 } | 1962 } |
| 1963 |
| 1828 /** | 1964 /** |
| 1829 * Return the lexeme that defines this type of token, or {@code null} if there
is more than one | 1965 * Return the lexeme that defines this type of token, or {@code null} if there
is more than one |
| 1830 * possible lexeme for this type of token. | 1966 * possible lexeme for this type of token. |
| 1831 * @return the lexeme that defines this type of token | 1967 * @return the lexeme that defines this type of token |
| 1832 */ | 1968 */ |
| 1833 String get lexeme => _lexeme; | 1969 String get lexeme => _lexeme; |
| 1970 |
| 1834 /** | 1971 /** |
| 1835 * Return the precedence of the token, or {@code 0} if the token does not repr
esent an operator. | 1972 * Return the precedence of the token, or {@code 0} if the token does not repr
esent an operator. |
| 1836 * @return the precedence of the token | 1973 * @return the precedence of the token |
| 1837 */ | 1974 */ |
| 1838 int get precedence => _tokenClass.precedence; | 1975 int get precedence => _tokenClass.precedence; |
| 1976 |
| 1839 /** | 1977 /** |
| 1840 * Return {@code true} if this type of token represents an additive operator. | 1978 * Return {@code true} if this type of token represents an additive operator. |
| 1841 * @return {@code true} if this type of token represents an additive operator | 1979 * @return {@code true} if this type of token represents an additive operator |
| 1842 */ | 1980 */ |
| 1843 bool isAdditiveOperator() => identical(_tokenClass, TokenClass.ADDITIVE_OPERAT
OR); | 1981 bool isAdditiveOperator() => identical(_tokenClass, TokenClass.ADDITIVE_OPERAT
OR); |
| 1982 |
| 1844 /** | 1983 /** |
| 1845 * Return {@code true} if this type of token represents an assignment operator
. | 1984 * Return {@code true} if this type of token represents an assignment operator
. |
| 1846 * @return {@code true} if this type of token represents an assignment operato
r | 1985 * @return {@code true} if this type of token represents an assignment operato
r |
| 1847 */ | 1986 */ |
| 1848 bool isAssignmentOperator() => identical(_tokenClass, TokenClass.ASSIGNMENT_OP
ERATOR); | 1987 bool isAssignmentOperator() => identical(_tokenClass, TokenClass.ASSIGNMENT_OP
ERATOR); |
| 1988 |
| 1849 /** | 1989 /** |
| 1850 * Return {@code true} if this type of token represents an associative operato
r. An associative | 1990 * Return {@code true} if this type of token represents an associative operato
r. An associative |
| 1851 * operator is an operator for which the following equality is true:{@code (a
* b) * c == a * (b * c)}. In other words, if the result of applying the operator
to | 1991 * operator is an operator for which the following equality is true:{@code (a
* b) * c == a * (b * c)}. In other words, if the result of applying the operator
to |
| 1852 * multiple operands does not depend on the order in which those applications
occur. | 1992 * multiple operands does not depend on the order in which those applications
occur. |
| 1853 * <p> | 1993 * <p> |
| 1854 * Note: This method considers the logical-and and logical-or operators to be
associative, even | 1994 * Note: This method considers the logical-and and logical-or operators to be
associative, even |
| 1855 * though the order in which the application of those operators can have an ef
fect because | 1995 * though the order in which the application of those operators can have an ef
fect because |
| 1856 * evaluation of the right-hand operand is conditional. | 1996 * evaluation of the right-hand operand is conditional. |
| 1857 * @return {@code true} if this type of token represents an associative operat
or | 1997 * @return {@code true} if this type of token represents an associative operat
or |
| 1858 */ | 1998 */ |
| 1859 bool isAssociativeOperator() => identical(this, AMPERSAND) || identical(this,
AMPERSAND_AMPERSAND) || identical(this, BAR) || identical(this, BAR_BAR) || iden
tical(this, CARET) || identical(this, PLUS) || identical(this, STAR); | 1999 bool isAssociativeOperator() => identical(this, AMPERSAND) || identical(this,
AMPERSAND_AMPERSAND) || identical(this, BAR) || identical(this, BAR_BAR) || iden
tical(this, CARET) || identical(this, PLUS) || identical(this, STAR); |
| 2000 |
| 1860 /** | 2001 /** |
| 1861 * Return {@code true} if this type of token represents an equality operator. | 2002 * Return {@code true} if this type of token represents an equality operator. |
| 1862 * @return {@code true} if this type of token represents an equality operator | 2003 * @return {@code true} if this type of token represents an equality operator |
| 1863 */ | 2004 */ |
| 1864 bool isEqualityOperator() => identical(_tokenClass, TokenClass.EQUALITY_OPERAT
OR); | 2005 bool isEqualityOperator() => identical(_tokenClass, TokenClass.EQUALITY_OPERAT
OR); |
| 2006 |
| 1865 /** | 2007 /** |
| 1866 * Return {@code true} if this type of token represents an increment operator. | 2008 * Return {@code true} if this type of token represents an increment operator. |
| 1867 * @return {@code true} if this type of token represents an increment operator | 2009 * @return {@code true} if this type of token represents an increment operator |
| 1868 */ | 2010 */ |
| 1869 bool isIncrementOperator() => identical(_lexeme, "++") || identical(_lexeme, "
--"); | 2011 bool isIncrementOperator() => identical(_lexeme, "++") || identical(_lexeme, "
--"); |
| 2012 |
| 1870 /** | 2013 /** |
| 1871 * Return {@code true} if this type of token represents a multiplicative opera
tor. | 2014 * Return {@code true} if this type of token represents a multiplicative opera
tor. |
| 1872 * @return {@code true} if this type of token represents a multiplicative oper
ator | 2015 * @return {@code true} if this type of token represents a multiplicative oper
ator |
| 1873 */ | 2016 */ |
| 1874 bool isMultiplicativeOperator() => identical(_tokenClass, TokenClass.MULTIPLIC
ATIVE_OPERATOR); | 2017 bool isMultiplicativeOperator() => identical(_tokenClass, TokenClass.MULTIPLIC
ATIVE_OPERATOR); |
| 2018 |
| 1875 /** | 2019 /** |
| 1876 * Return {@code true} if this token type represents an operator. | 2020 * Return {@code true} if this token type represents an operator. |
| 1877 * @return {@code true} if this token type represents an operator | 2021 * @return {@code true} if this token type represents an operator |
| 1878 */ | 2022 */ |
| 1879 bool isOperator() => _tokenClass != TokenClass.NO_CLASS && this != OPEN_PAREN
&& this != OPEN_SQUARE_BRACKET && this != PERIOD; | 2023 bool isOperator() => _tokenClass != TokenClass.NO_CLASS && this != OPEN_PAREN
&& this != OPEN_SQUARE_BRACKET && this != PERIOD; |
| 2024 |
| 1880 /** | 2025 /** |
| 1881 * Return {@code true} if this type of token represents a relational operator. | 2026 * Return {@code true} if this type of token represents a relational operator. |
| 1882 * @return {@code true} if this type of token represents a relational operator | 2027 * @return {@code true} if this type of token represents a relational operator |
| 1883 */ | 2028 */ |
| 1884 bool isRelationalOperator() => identical(_tokenClass, TokenClass.RELATIONAL_OP
ERATOR); | 2029 bool isRelationalOperator() => identical(_tokenClass, TokenClass.RELATIONAL_OP
ERATOR); |
| 2030 |
| 1885 /** | 2031 /** |
| 1886 * Return {@code true} if this type of token represents a shift operator. | 2032 * Return {@code true} if this type of token represents a shift operator. |
| 1887 * @return {@code true} if this type of token represents a shift operator | 2033 * @return {@code true} if this type of token represents a shift operator |
| 1888 */ | 2034 */ |
| 1889 bool isShiftOperator() => identical(_tokenClass, TokenClass.SHIFT_OPERATOR); | 2035 bool isShiftOperator() => identical(_tokenClass, TokenClass.SHIFT_OPERATOR); |
| 2036 |
| 1890 /** | 2037 /** |
| 1891 * Return {@code true} if this type of token represents a unary postfix operat
or. | 2038 * Return {@code true} if this type of token represents a unary postfix operat
or. |
| 1892 * @return {@code true} if this type of token represents a unary postfix opera
tor | 2039 * @return {@code true} if this type of token represents a unary postfix opera
tor |
| 1893 */ | 2040 */ |
| 1894 bool isUnaryPostfixOperator() => identical(_tokenClass, TokenClass.UNARY_POSTF
IX_OPERATOR); | 2041 bool isUnaryPostfixOperator() => identical(_tokenClass, TokenClass.UNARY_POSTF
IX_OPERATOR); |
| 2042 |
| 1895 /** | 2043 /** |
| 1896 * Return {@code true} if this type of token represents a unary prefix operato
r. | 2044 * Return {@code true} if this type of token represents a unary prefix operato
r. |
| 1897 * @return {@code true} if this type of token represents a unary prefix operat
or | 2045 * @return {@code true} if this type of token represents a unary prefix operat
or |
| 1898 */ | 2046 */ |
| 1899 bool isUnaryPrefixOperator() => identical(_tokenClass, TokenClass.UNARY_PREFIX
_OPERATOR); | 2047 bool isUnaryPrefixOperator() => identical(_tokenClass, TokenClass.UNARY_PREFIX
_OPERATOR); |
| 2048 |
| 1900 /** | 2049 /** |
| 1901 * Return {@code true} if this token type represents an operator that can be d
efined by users. | 2050 * Return {@code true} if this token type represents an operator that can be d
efined by users. |
| 1902 * @return {@code true} if this token type represents an operator that can be
defined by users | 2051 * @return {@code true} if this token type represents an operator that can be
defined by users |
| 1903 */ | 2052 */ |
| 1904 bool isUserDefinableOperator() => identical(_lexeme, "==") || identical(_lexem
e, "~") || identical(_lexeme, "[]") || identical(_lexeme, "[]=") || identical(_l
exeme, "*") || identical(_lexeme, "/") || identical(_lexeme, "%") || identical(_
lexeme, "~/") || identical(_lexeme, "+") || identical(_lexeme, "-") || identical
(_lexeme, "<<") || identical(_lexeme, ">>") || identical(_lexeme, ">=") || ident
ical(_lexeme, ">") || identical(_lexeme, "<=") || identical(_lexeme, "<") || ide
ntical(_lexeme, "&") || identical(_lexeme, "^") || identical(_lexeme, "|"); | 2053 bool isUserDefinableOperator() => identical(_lexeme, "==") || identical(_lexem
e, "~") || identical(_lexeme, "[]") || identical(_lexeme, "[]=") || identical(_l
exeme, "*") || identical(_lexeme, "/") || identical(_lexeme, "%") || identical(_
lexeme, "~/") || identical(_lexeme, "+") || identical(_lexeme, "-") || identical
(_lexeme, "<<") || identical(_lexeme, ">>") || identical(_lexeme, ">=") || ident
ical(_lexeme, ">") || identical(_lexeme, "<=") || identical(_lexeme, "<") || ide
ntical(_lexeme, "&") || identical(_lexeme, "^") || identical(_lexeme, "|"); |
| 1905 int compareTo(TokenType other) => __ordinal - other.__ordinal; | 2054 int compareTo(TokenType other) => ordinal - other.ordinal; |
| 1906 String toString() => __name; | 2055 String toString() => name; |
| 1907 } | 2056 } |
| 1908 class TokenType_EOF extends TokenType { | 2057 class TokenType_EOF extends TokenType { |
| 1909 TokenType_EOF(String ___name, int ___ordinal, TokenClass arg0, String arg1) :
super.con2(___name, ___ordinal, arg0, arg1); | 2058 TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) : super.
con2(name, ordinal, arg0, arg1); |
| 1910 String toString() => "-eof-"; | 2059 String toString() => "-eof-"; |
| 1911 } | 2060 } |
| OLD | NEW |