| 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 library engine.scanner; | 4 library engine.scanner; |
| 5 |
| 4 import 'dart:collection'; | 6 import 'dart:collection'; |
| 5 import 'java_core.dart'; | 7 import 'java_core.dart'; |
| 6 import 'java_engine.dart'; | 8 import 'java_engine.dart'; |
| 7 import 'source.dart'; | 9 import 'source.dart'; |
| 8 import 'error.dart'; | 10 import 'error.dart'; |
| 9 import 'instrumentation.dart'; | 11 import 'instrumentation.dart'; |
| 10 import 'utilities_collection.dart' show TokenMap; | 12 import 'utilities_collection.dart' show TokenMap; |
| 13 |
| 11 /** | 14 /** |
| 12 * Instances of the abstract class `KeywordState` represent a state in a state m
achine used to | 15 * Instances of the abstract class `KeywordState` represent a state in a state m
achine used to |
| 13 * scan keywords. | 16 * scan keywords. |
| 14 * | 17 * |
| 15 * @coverage dart.engine.parser | 18 * @coverage dart.engine.parser |
| 16 */ | 19 */ |
| 17 class KeywordState { | 20 class KeywordState { |
| 18 | |
| 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); |
| 23 | 25 |
| 24 /** | 26 /** |
| 25 * The initial state in the state machine. | 27 * The initial state in the state machine. |
| 26 */ | 28 */ |
| 27 static KeywordState KEYWORD_STATE = createKeywordStateTable(); | 29 static KeywordState KEYWORD_STATE = createKeywordStateTable(); |
| 28 | 30 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 125 |
| 124 /** | 126 /** |
| 125 * Return the state that follows this state on a transition of the given chara
cter, or | 127 * Return the state that follows this state on a transition of the given chara
cter, or |
| 126 * `null` if there is no valid state reachable from this state with such a tra
nsition. | 128 * `null` if there is no valid state reachable from this state with such a tra
nsition. |
| 127 * | 129 * |
| 128 * @param c the character used to transition from this state to another state | 130 * @param c the character used to transition from this state to another state |
| 129 * @return the state that follows this state on a transition of the given char
acter | 131 * @return the state that follows this state on a transition of the given char
acter |
| 130 */ | 132 */ |
| 131 KeywordState next(int c) => _table[c - 0x61]; | 133 KeywordState next(int c) => _table[c - 0x61]; |
| 132 } | 134 } |
| 135 |
| 133 /** | 136 /** |
| 134 * The enumeration `ScannerErrorCode` defines the error codes used for errors de
tected by the | 137 * The enumeration `ScannerErrorCode` defines the error codes used for errors de
tected by the |
| 135 * scanner. | 138 * scanner. |
| 136 * | 139 * |
| 137 * @coverage dart.engine.parser | 140 * @coverage dart.engine.parser |
| 138 */ | 141 */ |
| 139 class ScannerErrorCode extends Enum<ScannerErrorCode> implements ErrorCode { | 142 class ScannerErrorCode extends Enum<ScannerErrorCode> implements ErrorCode { |
| 140 static final ScannerErrorCode ILLEGAL_CHARACTER = new ScannerErrorCode.con1('I
LLEGAL_CHARACTER', 0, "Illegal character %x"); | 143 static final ScannerErrorCode ILLEGAL_CHARACTER = new ScannerErrorCode.con1('I
LLEGAL_CHARACTER', 0, "Illegal character %x"); |
| 144 |
| 141 static final ScannerErrorCode MISSING_DIGIT = new ScannerErrorCode.con1('MISSI
NG_DIGIT', 1, "Decimal digit expected"); | 145 static final ScannerErrorCode MISSING_DIGIT = new ScannerErrorCode.con1('MISSI
NG_DIGIT', 1, "Decimal digit expected"); |
| 146 |
| 142 static final ScannerErrorCode MISSING_HEX_DIGIT = new ScannerErrorCode.con1('M
ISSING_HEX_DIGIT', 2, "Hexidecimal digit expected"); | 147 static final ScannerErrorCode MISSING_HEX_DIGIT = new ScannerErrorCode.con1('M
ISSING_HEX_DIGIT', 2, "Hexidecimal digit expected"); |
| 148 |
| 143 static final ScannerErrorCode MISSING_QUOTE = new ScannerErrorCode.con1('MISSI
NG_QUOTE', 3, "Expected quote (' or \")"); | 149 static final ScannerErrorCode MISSING_QUOTE = new ScannerErrorCode.con1('MISSI
NG_QUOTE', 3, "Expected quote (' or \")"); |
| 150 |
| 144 static final ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT = new ScannerErr
orCode.con1('UNTERMINATED_MULTI_LINE_COMMENT', 4, "Unterminated multi-line comme
nt"); | 151 static final ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT = new ScannerErr
orCode.con1('UNTERMINATED_MULTI_LINE_COMMENT', 4, "Unterminated multi-line comme
nt"); |
| 152 |
| 145 static final ScannerErrorCode UNTERMINATED_STRING_LITERAL = new ScannerErrorCo
de.con1('UNTERMINATED_STRING_LITERAL', 5, "Unterminated string literal"); | 153 static final ScannerErrorCode UNTERMINATED_STRING_LITERAL = new ScannerErrorCo
de.con1('UNTERMINATED_STRING_LITERAL', 5, "Unterminated string literal"); |
| 154 |
| 146 static final List<ScannerErrorCode> values = [ | 155 static final List<ScannerErrorCode> values = [ |
| 147 ILLEGAL_CHARACTER, | 156 ILLEGAL_CHARACTER, |
| 148 MISSING_DIGIT, | 157 MISSING_DIGIT, |
| 149 MISSING_HEX_DIGIT, | 158 MISSING_HEX_DIGIT, |
| 150 MISSING_QUOTE, | 159 MISSING_QUOTE, |
| 151 UNTERMINATED_MULTI_LINE_COMMENT, | 160 UNTERMINATED_MULTI_LINE_COMMENT, |
| 152 UNTERMINATED_STRING_LITERAL]; | 161 UNTERMINATED_STRING_LITERAL]; |
| 153 | 162 |
| 154 /** | 163 /** |
| 155 * The template used to create the message to be displayed for this error. | 164 * The template used to create the message to be displayed for this error. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 174 /** | 183 /** |
| 175 * Initialize a newly created error code to have the given message and correct
ion. | 184 * Initialize a newly created error code to have the given message and correct
ion. |
| 176 * | 185 * |
| 177 * @param message the template used to create the message to be displayed for
the error | 186 * @param message the template used to create the message to be displayed for
the error |
| 178 * @param correction the template used to create the correction to be displaye
d for the error | 187 * @param correction the template used to create the correction to be displaye
d for the error |
| 179 */ | 188 */ |
| 180 ScannerErrorCode.con2(String name, int ordinal, String message, String correct
ion) : super(name, ordinal) { | 189 ScannerErrorCode.con2(String name, int ordinal, String message, String correct
ion) : super(name, ordinal) { |
| 181 this._message = message; | 190 this._message = message; |
| 182 this.correction10 = correction; | 191 this.correction10 = correction; |
| 183 } | 192 } |
| 193 |
| 184 String get correction => correction10; | 194 String get correction => correction10; |
| 195 |
| 185 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; | 196 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; |
| 197 |
| 186 String get message => _message; | 198 String get message => _message; |
| 199 |
| 187 ErrorType get type => ErrorType.SYNTACTIC_ERROR; | 200 ErrorType get type => ErrorType.SYNTACTIC_ERROR; |
| 188 } | 201 } |
| 202 |
| 189 /** | 203 /** |
| 190 * Instances of the class `SubSequenceReader` implement a [CharacterReader] that
reads | 204 * Instances of the class `SubSequenceReader` implement a [CharacterReader] that
reads |
| 191 * characters from a character sequence, but adds a delta when reporting the cur
rent character | 205 * characters from a character sequence, but adds a delta when reporting the cur
rent character |
| 192 * offset so that the character sequence can be a subsequence from a larger sequ
ence. | 206 * offset so that the character sequence can be a subsequence from a larger sequ
ence. |
| 193 */ | 207 */ |
| 194 class SubSequenceReader extends CharSequenceReader { | 208 class SubSequenceReader extends CharSequenceReader { |
| 195 | |
| 196 /** | 209 /** |
| 197 * The offset from the beginning of the file to the beginning of the source be
ing scanned. | 210 * The offset from the beginning of the file to the beginning of the source be
ing scanned. |
| 198 */ | 211 */ |
| 199 int _offsetDelta = 0; | 212 int _offsetDelta = 0; |
| 200 | 213 |
| 201 /** | 214 /** |
| 202 * Initialize a newly created reader to read the characters in the given seque
nce. | 215 * Initialize a newly created reader to read the characters in the given seque
nce. |
| 203 * | 216 * |
| 204 * @param sequence the sequence from which characters will be read | 217 * @param sequence the sequence from which characters will be read |
| 205 * @param offsetDelta the offset from the beginning of the file to the beginni
ng of the source | 218 * @param offsetDelta the offset from the beginning of the file to the beginni
ng of the source |
| 206 * being scanned | 219 * being scanned |
| 207 */ | 220 */ |
| 208 SubSequenceReader(CharSequence sequence, int offsetDelta) : super(sequence) { | 221 SubSequenceReader(CharSequence sequence, int offsetDelta) : super(sequence) { |
| 209 this._offsetDelta = offsetDelta; | 222 this._offsetDelta = offsetDelta; |
| 210 } | 223 } |
| 224 |
| 211 int get offset => _offsetDelta + super.offset; | 225 int get offset => _offsetDelta + super.offset; |
| 226 |
| 212 String getString(int start, int endDelta) => super.getString(start - _offsetDe
lta, endDelta); | 227 String getString(int start, int endDelta) => super.getString(start - _offsetDe
lta, endDelta); |
| 228 |
| 213 void set offset(int offset) { | 229 void set offset(int offset) { |
| 214 super.offset = offset - _offsetDelta; | 230 super.offset = offset - _offsetDelta; |
| 215 } | 231 } |
| 216 } | 232 } |
| 233 |
| 217 /** | 234 /** |
| 218 * Instances of the class `TokenWithComment` represent a string token that is pr
eceded by | 235 * Instances of the class `TokenWithComment` represent a string token that is pr
eceded by |
| 219 * comments. | 236 * comments. |
| 220 * | 237 * |
| 221 * @coverage dart.engine.parser | 238 * @coverage dart.engine.parser |
| 222 */ | 239 */ |
| 223 class StringTokenWithComment extends StringToken { | 240 class StringTokenWithComment extends StringToken { |
| 224 | |
| 225 /** | 241 /** |
| 226 * The first comment in the list of comments that precede this token. | 242 * The first comment in the list of comments that precede this token. |
| 227 */ | 243 */ |
| 228 Token _precedingComment; | 244 Token _precedingComment; |
| 229 | 245 |
| 230 /** | 246 /** |
| 231 * Initialize a newly created token to have the given type and offset and to b
e preceded by the | 247 * Initialize a newly created token to have the given type and offset and to b
e preceded by the |
| 232 * comments reachable from the given comment. | 248 * comments reachable from the given comment. |
| 233 * | 249 * |
| 234 * @param type the type of the token | 250 * @param type the type of the token |
| 235 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 251 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 236 * @param precedingComment the first comment in the list of comments that prec
ede this token | 252 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 237 */ | 253 */ |
| 238 StringTokenWithComment(TokenType type, String value, int offset, Token precedi
ngComment) : super(type, value, offset) { | 254 StringTokenWithComment(TokenType type, String value, int offset, Token precedi
ngComment) : super(type, value, offset) { |
| 239 this._precedingComment = precedingComment; | 255 this._precedingComment = precedingComment; |
| 240 } | 256 } |
| 257 |
| 241 Token copy() => new StringTokenWithComment(type, lexeme, offset, copyComments(
_precedingComment)); | 258 Token copy() => new StringTokenWithComment(type, lexeme, offset, copyComments(
_precedingComment)); |
| 259 |
| 242 Token get precedingComments => _precedingComment; | 260 Token get precedingComments => _precedingComment; |
| 261 |
| 243 void applyDelta(int delta) { | 262 void applyDelta(int delta) { |
| 244 super.applyDelta(delta); | 263 super.applyDelta(delta); |
| 245 Token token = _precedingComment; | 264 Token token = _precedingComment; |
| 246 while (token != null) { | 265 while (token != null) { |
| 247 token.applyDelta(delta); | 266 token.applyDelta(delta); |
| 248 token = token.next; | 267 token = token.next; |
| 249 } | 268 } |
| 250 } | 269 } |
| 251 } | 270 } |
| 271 |
| 252 /** | 272 /** |
| 253 * The enumeration `Keyword` defines the keywords in the Dart programming langua
ge. | 273 * The enumeration `Keyword` defines the keywords in the Dart programming langua
ge. |
| 254 * | 274 * |
| 255 * @coverage dart.engine.parser | 275 * @coverage dart.engine.parser |
| 256 */ | 276 */ |
| 257 class Keyword extends Enum<Keyword> { | 277 class Keyword extends Enum<Keyword> { |
| 258 static final Keyword ASSERT = new Keyword.con1('ASSERT', 0, "assert"); | 278 static final Keyword ASSERT = new Keyword.con1('ASSERT', 0, "assert"); |
| 279 |
| 259 static final Keyword BREAK = new Keyword.con1('BREAK', 1, "break"); | 280 static final Keyword BREAK = new Keyword.con1('BREAK', 1, "break"); |
| 281 |
| 260 static final Keyword CASE = new Keyword.con1('CASE', 2, "case"); | 282 static final Keyword CASE = new Keyword.con1('CASE', 2, "case"); |
| 283 |
| 261 static final Keyword CATCH = new Keyword.con1('CATCH', 3, "catch"); | 284 static final Keyword CATCH = new Keyword.con1('CATCH', 3, "catch"); |
| 285 |
| 262 static final Keyword CLASS = new Keyword.con1('CLASS', 4, "class"); | 286 static final Keyword CLASS = new Keyword.con1('CLASS', 4, "class"); |
| 287 |
| 263 static final Keyword CONST = new Keyword.con1('CONST', 5, "const"); | 288 static final Keyword CONST = new Keyword.con1('CONST', 5, "const"); |
| 289 |
| 264 static final Keyword CONTINUE = new Keyword.con1('CONTINUE', 6, "continue"); | 290 static final Keyword CONTINUE = new Keyword.con1('CONTINUE', 6, "continue"); |
| 291 |
| 265 static final Keyword DEFAULT = new Keyword.con1('DEFAULT', 7, "default"); | 292 static final Keyword DEFAULT = new Keyword.con1('DEFAULT', 7, "default"); |
| 293 |
| 266 static final Keyword DO = new Keyword.con1('DO', 8, "do"); | 294 static final Keyword DO = new Keyword.con1('DO', 8, "do"); |
| 295 |
| 267 static final Keyword ELSE = new Keyword.con1('ELSE', 9, "else"); | 296 static final Keyword ELSE = new Keyword.con1('ELSE', 9, "else"); |
| 297 |
| 268 static final Keyword ENUM = new Keyword.con1('ENUM', 10, "enum"); | 298 static final Keyword ENUM = new Keyword.con1('ENUM', 10, "enum"); |
| 299 |
| 269 static final Keyword EXTENDS = new Keyword.con1('EXTENDS', 11, "extends"); | 300 static final Keyword EXTENDS = new Keyword.con1('EXTENDS', 11, "extends"); |
| 301 |
| 270 static final Keyword FALSE = new Keyword.con1('FALSE', 12, "false"); | 302 static final Keyword FALSE = new Keyword.con1('FALSE', 12, "false"); |
| 303 |
| 271 static final Keyword FINAL = new Keyword.con1('FINAL', 13, "final"); | 304 static final Keyword FINAL = new Keyword.con1('FINAL', 13, "final"); |
| 305 |
| 272 static final Keyword FINALLY = new Keyword.con1('FINALLY', 14, "finally"); | 306 static final Keyword FINALLY = new Keyword.con1('FINALLY', 14, "finally"); |
| 307 |
| 273 static final Keyword FOR = new Keyword.con1('FOR', 15, "for"); | 308 static final Keyword FOR = new Keyword.con1('FOR', 15, "for"); |
| 309 |
| 274 static final Keyword IF = new Keyword.con1('IF', 16, "if"); | 310 static final Keyword IF = new Keyword.con1('IF', 16, "if"); |
| 311 |
| 275 static final Keyword IN = new Keyword.con1('IN', 17, "in"); | 312 static final Keyword IN = new Keyword.con1('IN', 17, "in"); |
| 313 |
| 276 static final Keyword IS = new Keyword.con1('IS', 18, "is"); | 314 static final Keyword IS = new Keyword.con1('IS', 18, "is"); |
| 315 |
| 277 static final Keyword NEW = new Keyword.con1('NEW', 19, "new"); | 316 static final Keyword NEW = new Keyword.con1('NEW', 19, "new"); |
| 317 |
| 278 static final Keyword NULL = new Keyword.con1('NULL', 20, "null"); | 318 static final Keyword NULL = new Keyword.con1('NULL', 20, "null"); |
| 319 |
| 279 static final Keyword RETHROW = new Keyword.con1('RETHROW', 21, "rethrow"); | 320 static final Keyword RETHROW = new Keyword.con1('RETHROW', 21, "rethrow"); |
| 321 |
| 280 static final Keyword RETURN = new Keyword.con1('RETURN', 22, "return"); | 322 static final Keyword RETURN = new Keyword.con1('RETURN', 22, "return"); |
| 323 |
| 281 static final Keyword SUPER = new Keyword.con1('SUPER', 23, "super"); | 324 static final Keyword SUPER = new Keyword.con1('SUPER', 23, "super"); |
| 325 |
| 282 static final Keyword SWITCH = new Keyword.con1('SWITCH', 24, "switch"); | 326 static final Keyword SWITCH = new Keyword.con1('SWITCH', 24, "switch"); |
| 327 |
| 283 static final Keyword THIS = new Keyword.con1('THIS', 25, "this"); | 328 static final Keyword THIS = new Keyword.con1('THIS', 25, "this"); |
| 329 |
| 284 static final Keyword THROW = new Keyword.con1('THROW', 26, "throw"); | 330 static final Keyword THROW = new Keyword.con1('THROW', 26, "throw"); |
| 331 |
| 285 static final Keyword TRUE = new Keyword.con1('TRUE', 27, "true"); | 332 static final Keyword TRUE = new Keyword.con1('TRUE', 27, "true"); |
| 333 |
| 286 static final Keyword TRY = new Keyword.con1('TRY', 28, "try"); | 334 static final Keyword TRY = new Keyword.con1('TRY', 28, "try"); |
| 335 |
| 287 static final Keyword VAR = new Keyword.con1('VAR', 29, "var"); | 336 static final Keyword VAR = new Keyword.con1('VAR', 29, "var"); |
| 337 |
| 288 static final Keyword VOID = new Keyword.con1('VOID', 30, "void"); | 338 static final Keyword VOID = new Keyword.con1('VOID', 30, "void"); |
| 339 |
| 289 static final Keyword WHILE = new Keyword.con1('WHILE', 31, "while"); | 340 static final Keyword WHILE = new Keyword.con1('WHILE', 31, "while"); |
| 341 |
| 290 static final Keyword WITH = new Keyword.con1('WITH', 32, "with"); | 342 static final Keyword WITH = new Keyword.con1('WITH', 32, "with"); |
| 343 |
| 291 static final Keyword ABSTRACT = new Keyword.con2('ABSTRACT', 33, "abstract", t
rue); | 344 static final Keyword ABSTRACT = new Keyword.con2('ABSTRACT', 33, "abstract", t
rue); |
| 345 |
| 292 static final Keyword AS = new Keyword.con2('AS', 34, "as", true); | 346 static final Keyword AS = new Keyword.con2('AS', 34, "as", true); |
| 347 |
| 293 static final Keyword DYNAMIC = new Keyword.con2('DYNAMIC', 35, "dynamic", true
); | 348 static final Keyword DYNAMIC = new Keyword.con2('DYNAMIC', 35, "dynamic", true
); |
| 349 |
| 294 static final Keyword EXPORT = new Keyword.con2('EXPORT', 36, "export", true); | 350 static final Keyword EXPORT = new Keyword.con2('EXPORT', 36, "export", true); |
| 351 |
| 295 static final Keyword EXTERNAL = new Keyword.con2('EXTERNAL', 37, "external", t
rue); | 352 static final Keyword EXTERNAL = new Keyword.con2('EXTERNAL', 37, "external", t
rue); |
| 353 |
| 296 static final Keyword FACTORY = new Keyword.con2('FACTORY', 38, "factory", true
); | 354 static final Keyword FACTORY = new Keyword.con2('FACTORY', 38, "factory", true
); |
| 355 |
| 297 static final Keyword GET = new Keyword.con2('GET', 39, "get", true); | 356 static final Keyword GET = new Keyword.con2('GET', 39, "get", true); |
| 357 |
| 298 static final Keyword IMPLEMENTS = new Keyword.con2('IMPLEMENTS', 40, "implemen
ts", true); | 358 static final Keyword IMPLEMENTS = new Keyword.con2('IMPLEMENTS', 40, "implemen
ts", true); |
| 359 |
| 299 static final Keyword IMPORT = new Keyword.con2('IMPORT', 41, "import", true); | 360 static final Keyword IMPORT = new Keyword.con2('IMPORT', 41, "import", true); |
| 361 |
| 300 static final Keyword LIBRARY = new Keyword.con2('LIBRARY', 42, "library", true
); | 362 static final Keyword LIBRARY = new Keyword.con2('LIBRARY', 42, "library", true
); |
| 363 |
| 301 static final Keyword OPERATOR = new Keyword.con2('OPERATOR', 43, "operator", t
rue); | 364 static final Keyword OPERATOR = new Keyword.con2('OPERATOR', 43, "operator", t
rue); |
| 365 |
| 302 static final Keyword PART = new Keyword.con2('PART', 44, "part", true); | 366 static final Keyword PART = new Keyword.con2('PART', 44, "part", true); |
| 367 |
| 303 static final Keyword SET = new Keyword.con2('SET', 45, "set", true); | 368 static final Keyword SET = new Keyword.con2('SET', 45, "set", true); |
| 369 |
| 304 static final Keyword STATIC = new Keyword.con2('STATIC', 46, "static", true); | 370 static final Keyword STATIC = new Keyword.con2('STATIC', 46, "static", true); |
| 371 |
| 305 static final Keyword TYPEDEF = new Keyword.con2('TYPEDEF', 47, "typedef", true
); | 372 static final Keyword TYPEDEF = new Keyword.con2('TYPEDEF', 47, "typedef", true
); |
| 373 |
| 306 static final List<Keyword> values = [ | 374 static final List<Keyword> values = [ |
| 307 ASSERT, | 375 ASSERT, |
| 308 BREAK, | 376 BREAK, |
| 309 CASE, | 377 CASE, |
| 310 CATCH, | 378 CATCH, |
| 311 CLASS, | 379 CLASS, |
| 312 CONST, | 380 CONST, |
| 313 CONTINUE, | 381 CONTINUE, |
| 314 DEFAULT, | 382 DEFAULT, |
| 315 DO, | 383 DO, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 * the given flag is `true`. | 463 * the given flag is `true`. |
| 396 * | 464 * |
| 397 * @param syntax the lexeme for the keyword | 465 * @param syntax the lexeme for the keyword |
| 398 * @param isPseudoKeyword `true` if this keyword is a pseudo-keyword | 466 * @param isPseudoKeyword `true` if this keyword is a pseudo-keyword |
| 399 */ | 467 */ |
| 400 Keyword.con2(String name, int ordinal, String syntax, bool isPseudoKeyword) :
super(name, ordinal) { | 468 Keyword.con2(String name, int ordinal, String syntax, bool isPseudoKeyword) :
super(name, ordinal) { |
| 401 this.syntax = syntax; | 469 this.syntax = syntax; |
| 402 this.isPseudoKeyword = isPseudoKeyword; | 470 this.isPseudoKeyword = isPseudoKeyword; |
| 403 } | 471 } |
| 404 } | 472 } |
| 473 |
| 405 /** | 474 /** |
| 406 * Instances of the class `CharSequenceReader` implement a [CharacterReader] tha
t reads | 475 * Instances of the class `CharSequenceReader` implement a [CharacterReader] tha
t reads |
| 407 * characters from a character sequence. | 476 * characters from a character sequence. |
| 408 */ | 477 */ |
| 409 class CharSequenceReader implements CharacterReader { | 478 class CharSequenceReader implements CharacterReader { |
| 410 | |
| 411 /** | 479 /** |
| 412 * The sequence from which characters will be read. | 480 * The sequence from which characters will be read. |
| 413 */ | 481 */ |
| 414 CharSequence _sequence; | 482 CharSequence _sequence; |
| 415 | 483 |
| 416 /** | 484 /** |
| 417 * The number of characters in the string. | 485 * The number of characters in the string. |
| 418 */ | 486 */ |
| 419 int _stringLength = 0; | 487 int _stringLength = 0; |
| 420 | 488 |
| 421 /** | 489 /** |
| 422 * The index, relative to the string, of the last character that was read. | 490 * The index, relative to the string, of the last character that was read. |
| 423 */ | 491 */ |
| 424 int _charOffset = 0; | 492 int _charOffset = 0; |
| 425 | 493 |
| 426 /** | 494 /** |
| 427 * Initialize a newly created reader to read the characters in the given seque
nce. | 495 * Initialize a newly created reader to read the characters in the given seque
nce. |
| 428 * | 496 * |
| 429 * @param sequence the sequence from which characters will be read | 497 * @param sequence the sequence from which characters will be read |
| 430 */ | 498 */ |
| 431 CharSequenceReader(CharSequence sequence) { | 499 CharSequenceReader(CharSequence sequence) { |
| 432 this._sequence = sequence; | 500 this._sequence = sequence; |
| 433 this._stringLength = sequence.length(); | 501 this._stringLength = sequence.length(); |
| 434 this._charOffset = -1; | 502 this._charOffset = -1; |
| 435 } | 503 } |
| 504 |
| 436 int advance() { | 505 int advance() { |
| 437 if (_charOffset + 1 >= _stringLength) { | 506 if (_charOffset + 1 >= _stringLength) { |
| 438 return -1; | 507 return -1; |
| 439 } | 508 } |
| 440 return _sequence.charAt(++_charOffset); | 509 return _sequence.charAt(++_charOffset); |
| 441 } | 510 } |
| 511 |
| 442 int get offset => _charOffset; | 512 int get offset => _charOffset; |
| 513 |
| 443 String getString(int start, int endDelta) => _sequence.subSequence(start, _cha
rOffset + 1 + endDelta).toString(); | 514 String getString(int start, int endDelta) => _sequence.subSequence(start, _cha
rOffset + 1 + endDelta).toString(); |
| 515 |
| 444 int peek() { | 516 int peek() { |
| 445 if (_charOffset + 1 >= _sequence.length()) { | 517 if (_charOffset + 1 >= _sequence.length()) { |
| 446 return -1; | 518 return -1; |
| 447 } | 519 } |
| 448 return _sequence.charAt(_charOffset + 1); | 520 return _sequence.charAt(_charOffset + 1); |
| 449 } | 521 } |
| 522 |
| 450 void set offset(int offset) { | 523 void set offset(int offset) { |
| 451 _charOffset = offset; | 524 _charOffset = offset; |
| 452 } | 525 } |
| 453 } | 526 } |
| 527 |
| 454 /** | 528 /** |
| 455 * Instances of the class `IncrementalScanner` implement a scanner that scans a
subset of a | 529 * Instances of the class `IncrementalScanner` implement a scanner that scans a
subset of a |
| 456 * string and inserts the resulting tokens into the middle of an existing token
stream. | 530 * string and inserts the resulting tokens into the middle of an existing token
stream. |
| 457 * | 531 * |
| 458 * @coverage dart.engine.parser | 532 * @coverage dart.engine.parser |
| 459 */ | 533 */ |
| 460 class IncrementalScanner extends Scanner { | 534 class IncrementalScanner extends Scanner { |
| 461 | |
| 462 /** | 535 /** |
| 463 * The reader used to access the characters in the source. | 536 * The reader used to access the characters in the source. |
| 464 */ | 537 */ |
| 465 CharacterReader _reader; | 538 CharacterReader _reader; |
| 466 | 539 |
| 467 /** | 540 /** |
| 468 * A map from tokens that were copied to the copies of the tokens. | 541 * A map from tokens that were copied to the copies of the tokens. |
| 469 */ | 542 */ |
| 470 final TokenMap tokenMap = new TokenMap(); | 543 final TokenMap tokenMap = new TokenMap(); |
| 471 | 544 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 originalStream = originalStream.next; | 617 originalStream = originalStream.next; |
| 545 } | 618 } |
| 546 int delta = insertedLength - removedLength; | 619 int delta = insertedLength - removedLength; |
| 547 while (originalStream.type != TokenType.EOF) { | 620 while (originalStream.type != TokenType.EOF) { |
| 548 originalStream = copyAndAdvance(originalStream, delta); | 621 originalStream = copyAndAdvance(originalStream, delta); |
| 549 } | 622 } |
| 550 Token eof = copyAndAdvance(originalStream, delta); | 623 Token eof = copyAndAdvance(originalStream, delta); |
| 551 eof.setNextWithoutSettingPrevious(eof); | 624 eof.setNextWithoutSettingPrevious(eof); |
| 552 return super.firstToken; | 625 return super.firstToken; |
| 553 } | 626 } |
| 627 |
| 554 Token copyAndAdvance(Token originalToken, int delta) { | 628 Token copyAndAdvance(Token originalToken, int delta) { |
| 555 Token copiedToken = originalToken.copy(); | 629 Token copiedToken = originalToken.copy(); |
| 556 tokenMap.put(originalToken, copiedToken); | 630 tokenMap.put(originalToken, copiedToken); |
| 557 copiedToken.applyDelta(delta); | 631 copiedToken.applyDelta(delta); |
| 558 appendToken(copiedToken); | 632 appendToken(copiedToken); |
| 559 Token originalComment = originalToken.precedingComments; | 633 Token originalComment = originalToken.precedingComments; |
| 560 Token copiedComment = originalToken.precedingComments; | 634 Token copiedComment = originalToken.precedingComments; |
| 561 while (originalComment != null) { | 635 while (originalComment != null) { |
| 562 tokenMap.put(originalComment, copiedComment); | 636 tokenMap.put(originalComment, copiedComment); |
| 563 originalComment = originalComment.next; | 637 originalComment = originalComment.next; |
| 564 copiedComment = copiedComment.next; | 638 copiedComment = copiedComment.next; |
| 565 } | 639 } |
| 566 return originalToken.next; | 640 return originalToken.next; |
| 567 } | 641 } |
| 568 } | 642 } |
| 643 |
| 569 /** | 644 /** |
| 570 * The class `Scanner` implements a scanner for Dart code. | 645 * The class `Scanner` implements a scanner for Dart code. |
| 571 * | 646 * |
| 572 * The lexical structure of Dart is ambiguous without knowledge of the context i
n which a token is | 647 * The lexical structure of Dart is ambiguous without knowledge of the context i
n which a token is |
| 573 * being scanned. For example, without context we cannot determine whether sourc
e of the form "<<" | 648 * being scanned. For example, without context we cannot determine whether sourc
e of the form "<<" |
| 574 * should be scanned as a single left-shift operator or as two left angle bracke
ts. This scanner | 649 * should be scanned as a single left-shift operator or as two left angle bracke
ts. This scanner |
| 575 * does not have any context, so it always resolves such conflicts by scanning t
he longest possible | 650 * does not have any context, so it always resolves such conflicts by scanning t
he longest possible |
| 576 * token. | 651 * token. |
| 577 * | 652 * |
| 578 * @coverage dart.engine.parser | 653 * @coverage dart.engine.parser |
| 579 */ | 654 */ |
| 580 class Scanner { | 655 class Scanner { |
| 581 | |
| 582 /** | 656 /** |
| 583 * The source being scanned. | 657 * The source being scanned. |
| 584 */ | 658 */ |
| 585 Source source; | 659 Source source; |
| 586 | 660 |
| 587 /** | 661 /** |
| 588 * The reader used to access the characters in the source. | 662 * The reader used to access the characters in the source. |
| 589 */ | 663 */ |
| 590 CharacterReader _reader; | 664 CharacterReader _reader; |
| 591 | 665 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 /** | 793 /** |
| 720 * Append the given token to the end of the token stream being scanned. This m
ethod is intended to | 794 * Append the given token to the end of the token stream being scanned. This m
ethod is intended to |
| 721 * be used by subclasses that copy existing tokens and should not normally be
used because it will | 795 * be used by subclasses that copy existing tokens and should not normally be
used because it will |
| 722 * fail to correctly associate any comments with the token being passed in. | 796 * fail to correctly associate any comments with the token being passed in. |
| 723 * | 797 * |
| 724 * @param token the token to be appended | 798 * @param token the token to be appended |
| 725 */ | 799 */ |
| 726 void appendToken(Token token) { | 800 void appendToken(Token token) { |
| 727 tail = tail.setNext(token); | 801 tail = tail.setNext(token); |
| 728 } | 802 } |
| 803 |
| 729 int bigSwitch(int next) { | 804 int bigSwitch(int next) { |
| 730 beginToken(); | 805 beginToken(); |
| 731 if (next == 0xD) { | 806 if (next == 0xD) { |
| 732 next = _reader.advance(); | 807 next = _reader.advance(); |
| 733 if (next == 0xA) { | 808 if (next == 0xA) { |
| 734 next = _reader.advance(); | 809 next = _reader.advance(); |
| 735 } | 810 } |
| 736 recordStartOfLine(); | 811 recordStartOfLine(); |
| 737 return next; | 812 return next; |
| 738 } else if (next == 0xA) { | 813 } else if (next == 0xA) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 * @return the first token in the token stream that was scanned | 948 * @return the first token in the token stream that was scanned |
| 874 */ | 949 */ |
| 875 Token get firstToken => _tokens.next; | 950 Token get firstToken => _tokens.next; |
| 876 | 951 |
| 877 /** | 952 /** |
| 878 * Record the fact that we are at the beginning of a new line in the source. | 953 * Record the fact that we are at the beginning of a new line in the source. |
| 879 */ | 954 */ |
| 880 void recordStartOfLine() { | 955 void recordStartOfLine() { |
| 881 _lineStarts.add(_reader.offset); | 956 _lineStarts.add(_reader.offset); |
| 882 } | 957 } |
| 958 |
| 883 void appendBeginToken(TokenType type) { | 959 void appendBeginToken(TokenType type) { |
| 884 BeginToken token; | 960 BeginToken token; |
| 885 if (_firstComment == null) { | 961 if (_firstComment == null) { |
| 886 token = new BeginToken(type, _tokenStart); | 962 token = new BeginToken(type, _tokenStart); |
| 887 } else { | 963 } else { |
| 888 token = new BeginTokenWithComment(type, _tokenStart, _firstComment); | 964 token = new BeginTokenWithComment(type, _tokenStart, _firstComment); |
| 889 _firstComment = null; | 965 _firstComment = null; |
| 890 _lastComment = null; | 966 _lastComment = null; |
| 891 } | 967 } |
| 892 tail = tail.setNext(token); | 968 tail = tail.setNext(token); |
| 893 _groupingStack.add(token); | 969 _groupingStack.add(token); |
| 894 _stackEnd++; | 970 _stackEnd++; |
| 895 } | 971 } |
| 972 |
| 896 void appendCommentToken(TokenType type, String value) { | 973 void appendCommentToken(TokenType type, String value) { |
| 897 if (_firstComment == null) { | 974 if (_firstComment == null) { |
| 898 _firstComment = new StringToken(type, value, _tokenStart); | 975 _firstComment = new StringToken(type, value, _tokenStart); |
| 899 _lastComment = _firstComment; | 976 _lastComment = _firstComment; |
| 900 } else { | 977 } else { |
| 901 _lastComment = _lastComment.setNext(new StringToken(type, value, _tokenSta
rt)); | 978 _lastComment = _lastComment.setNext(new StringToken(type, value, _tokenSta
rt)); |
| 902 } | 979 } |
| 903 } | 980 } |
| 981 |
| 904 void appendEndToken(TokenType type, TokenType beginType) { | 982 void appendEndToken(TokenType type, TokenType beginType) { |
| 905 Token token; | 983 Token token; |
| 906 if (_firstComment == null) { | 984 if (_firstComment == null) { |
| 907 token = new Token(type, _tokenStart); | 985 token = new Token(type, _tokenStart); |
| 908 } else { | 986 } else { |
| 909 token = new TokenWithComment(type, _tokenStart, _firstComment); | 987 token = new TokenWithComment(type, _tokenStart, _firstComment); |
| 910 _firstComment = null; | 988 _firstComment = null; |
| 911 _lastComment = null; | 989 _lastComment = null; |
| 912 } | 990 } |
| 913 tail = tail.setNext(token); | 991 tail = tail.setNext(token); |
| 914 if (_stackEnd >= 0) { | 992 if (_stackEnd >= 0) { |
| 915 BeginToken begin = _groupingStack[_stackEnd]; | 993 BeginToken begin = _groupingStack[_stackEnd]; |
| 916 if (identical(begin.type, beginType)) { | 994 if (identical(begin.type, beginType)) { |
| 917 begin.endToken = token; | 995 begin.endToken = token; |
| 918 _groupingStack.removeAt(_stackEnd--); | 996 _groupingStack.removeAt(_stackEnd--); |
| 919 } | 997 } |
| 920 } | 998 } |
| 921 } | 999 } |
| 1000 |
| 922 void appendEofToken() { | 1001 void appendEofToken() { |
| 923 Token eofToken; | 1002 Token eofToken; |
| 924 if (_firstComment == null) { | 1003 if (_firstComment == null) { |
| 925 eofToken = new Token(TokenType.EOF, _reader.offset + 1); | 1004 eofToken = new Token(TokenType.EOF, _reader.offset + 1); |
| 926 } else { | 1005 } else { |
| 927 eofToken = new TokenWithComment(TokenType.EOF, _reader.offset + 1, _firstC
omment); | 1006 eofToken = new TokenWithComment(TokenType.EOF, _reader.offset + 1, _firstC
omment); |
| 928 _firstComment = null; | 1007 _firstComment = null; |
| 929 _lastComment = null; | 1008 _lastComment = null; |
| 930 } | 1009 } |
| 931 eofToken.setNext(eofToken); | 1010 eofToken.setNext(eofToken); |
| 932 tail = tail.setNext(eofToken); | 1011 tail = tail.setNext(eofToken); |
| 933 if (_stackEnd >= 0) { | 1012 if (_stackEnd >= 0) { |
| 934 _hasUnmatchedGroups2 = true; | 1013 _hasUnmatchedGroups2 = true; |
| 935 } | 1014 } |
| 936 } | 1015 } |
| 1016 |
| 937 void appendKeywordToken(Keyword keyword) { | 1017 void appendKeywordToken(Keyword keyword) { |
| 938 if (_firstComment == null) { | 1018 if (_firstComment == null) { |
| 939 tail = tail.setNext(new KeywordToken(keyword, _tokenStart)); | 1019 tail = tail.setNext(new KeywordToken(keyword, _tokenStart)); |
| 940 } else { | 1020 } else { |
| 941 tail = tail.setNext(new KeywordTokenWithComment(keyword, _tokenStart, _fir
stComment)); | 1021 tail = tail.setNext(new KeywordTokenWithComment(keyword, _tokenStart, _fir
stComment)); |
| 942 _firstComment = null; | 1022 _firstComment = null; |
| 943 _lastComment = null; | 1023 _lastComment = null; |
| 944 } | 1024 } |
| 945 } | 1025 } |
| 1026 |
| 946 void appendStringToken(TokenType type, String value) { | 1027 void appendStringToken(TokenType type, String value) { |
| 947 if (_firstComment == null) { | 1028 if (_firstComment == null) { |
| 948 tail = tail.setNext(new StringToken(type, value, _tokenStart)); | 1029 tail = tail.setNext(new StringToken(type, value, _tokenStart)); |
| 949 } else { | 1030 } else { |
| 950 tail = tail.setNext(new StringTokenWithComment(type, value, _tokenStart, _
firstComment)); | 1031 tail = tail.setNext(new StringTokenWithComment(type, value, _tokenStart, _
firstComment)); |
| 951 _firstComment = null; | 1032 _firstComment = null; |
| 952 _lastComment = null; | 1033 _lastComment = null; |
| 953 } | 1034 } |
| 954 } | 1035 } |
| 1036 |
| 955 void appendStringToken2(TokenType type, String value, int offset) { | 1037 void appendStringToken2(TokenType type, String value, int offset) { |
| 956 if (_firstComment == null) { | 1038 if (_firstComment == null) { |
| 957 tail = tail.setNext(new StringToken(type, value, _tokenStart + offset)); | 1039 tail = tail.setNext(new StringToken(type, value, _tokenStart + offset)); |
| 958 } else { | 1040 } else { |
| 959 tail = tail.setNext(new StringTokenWithComment(type, value, _tokenStart +
offset, _firstComment)); | 1041 tail = tail.setNext(new StringTokenWithComment(type, value, _tokenStart +
offset, _firstComment)); |
| 960 _firstComment = null; | 1042 _firstComment = null; |
| 961 _lastComment = null; | 1043 _lastComment = null; |
| 962 } | 1044 } |
| 963 } | 1045 } |
| 1046 |
| 964 void appendToken2(TokenType type) { | 1047 void appendToken2(TokenType type) { |
| 965 if (_firstComment == null) { | 1048 if (_firstComment == null) { |
| 966 tail = tail.setNext(new Token(type, _tokenStart)); | 1049 tail = tail.setNext(new Token(type, _tokenStart)); |
| 967 } else { | 1050 } else { |
| 968 tail = tail.setNext(new TokenWithComment(type, _tokenStart, _firstComment)
); | 1051 tail = tail.setNext(new TokenWithComment(type, _tokenStart, _firstComment)
); |
| 969 _firstComment = null; | 1052 _firstComment = null; |
| 970 _lastComment = null; | 1053 _lastComment = null; |
| 971 } | 1054 } |
| 972 } | 1055 } |
| 1056 |
| 973 void appendToken3(TokenType type, int offset) { | 1057 void appendToken3(TokenType type, int offset) { |
| 974 if (_firstComment == null) { | 1058 if (_firstComment == null) { |
| 975 tail = tail.setNext(new Token(type, offset)); | 1059 tail = tail.setNext(new Token(type, offset)); |
| 976 } else { | 1060 } else { |
| 977 tail = tail.setNext(new TokenWithComment(type, offset, _firstComment)); | 1061 tail = tail.setNext(new TokenWithComment(type, offset, _firstComment)); |
| 978 _firstComment = null; | 1062 _firstComment = null; |
| 979 _lastComment = null; | 1063 _lastComment = null; |
| 980 } | 1064 } |
| 981 } | 1065 } |
| 1066 |
| 982 void beginToken() { | 1067 void beginToken() { |
| 983 _tokenStart = _reader.offset; | 1068 _tokenStart = _reader.offset; |
| 984 } | 1069 } |
| 985 | 1070 |
| 986 /** | 1071 /** |
| 987 * Return the beginning token corresponding to a closing brace that was found
while scanning | 1072 * Return the beginning token corresponding to a closing brace that was found
while scanning |
| 988 * inside a string interpolation expression. Tokens that cannot be matched wit
h the closing brace | 1073 * inside a string interpolation expression. Tokens that cannot be matched wit
h the closing brace |
| 989 * will be dropped from the stack. | 1074 * will be dropped from the stack. |
| 990 * | 1075 * |
| 991 * @return the token to be paired with the closing brace | 1076 * @return the token to be paired with the closing brace |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1004 | 1089 |
| 1005 /** | 1090 /** |
| 1006 * Report an error at the current offset. | 1091 * Report an error at the current offset. |
| 1007 * | 1092 * |
| 1008 * @param errorCode the error code indicating the nature of the error | 1093 * @param errorCode the error code indicating the nature of the error |
| 1009 * @param arguments any arguments needed to complete the error message | 1094 * @param arguments any arguments needed to complete the error message |
| 1010 */ | 1095 */ |
| 1011 void reportError(ScannerErrorCode errorCode, List<Object> arguments) { | 1096 void reportError(ScannerErrorCode errorCode, List<Object> arguments) { |
| 1012 _errorListener.onError(new AnalysisError.con2(source, _reader.offset, 1, err
orCode, arguments)); | 1097 _errorListener.onError(new AnalysisError.con2(source, _reader.offset, 1, err
orCode, arguments)); |
| 1013 } | 1098 } |
| 1099 |
| 1014 int select(int choice, TokenType yesType, TokenType noType) { | 1100 int select(int choice, TokenType yesType, TokenType noType) { |
| 1015 int next = _reader.advance(); | 1101 int next = _reader.advance(); |
| 1016 if (next == choice) { | 1102 if (next == choice) { |
| 1017 appendToken2(yesType); | 1103 appendToken2(yesType); |
| 1018 return _reader.advance(); | 1104 return _reader.advance(); |
| 1019 } else { | 1105 } else { |
| 1020 appendToken2(noType); | 1106 appendToken2(noType); |
| 1021 return next; | 1107 return next; |
| 1022 } | 1108 } |
| 1023 } | 1109 } |
| 1110 |
| 1024 int select2(int choice, TokenType yesType, TokenType noType, int offset) { | 1111 int select2(int choice, TokenType yesType, TokenType noType, int offset) { |
| 1025 int next = _reader.advance(); | 1112 int next = _reader.advance(); |
| 1026 if (next == choice) { | 1113 if (next == choice) { |
| 1027 appendToken3(yesType, offset); | 1114 appendToken3(yesType, offset); |
| 1028 return _reader.advance(); | 1115 return _reader.advance(); |
| 1029 } else { | 1116 } else { |
| 1030 appendToken3(noType, offset); | 1117 appendToken3(noType, offset); |
| 1031 return next; | 1118 return next; |
| 1032 } | 1119 } |
| 1033 } | 1120 } |
| 1121 |
| 1034 int tokenizeAmpersand(int next) { | 1122 int tokenizeAmpersand(int next) { |
| 1035 next = _reader.advance(); | 1123 next = _reader.advance(); |
| 1036 if (next == 0x26) { | 1124 if (next == 0x26) { |
| 1037 appendToken2(TokenType.AMPERSAND_AMPERSAND); | 1125 appendToken2(TokenType.AMPERSAND_AMPERSAND); |
| 1038 return _reader.advance(); | 1126 return _reader.advance(); |
| 1039 } else if (next == 0x3D) { | 1127 } else if (next == 0x3D) { |
| 1040 appendToken2(TokenType.AMPERSAND_EQ); | 1128 appendToken2(TokenType.AMPERSAND_EQ); |
| 1041 return _reader.advance(); | 1129 return _reader.advance(); |
| 1042 } else { | 1130 } else { |
| 1043 appendToken2(TokenType.AMPERSAND); | 1131 appendToken2(TokenType.AMPERSAND); |
| 1044 return next; | 1132 return next; |
| 1045 } | 1133 } |
| 1046 } | 1134 } |
| 1135 |
| 1047 int tokenizeBar(int next) { | 1136 int tokenizeBar(int next) { |
| 1048 next = _reader.advance(); | 1137 next = _reader.advance(); |
| 1049 if (next == 0x7C) { | 1138 if (next == 0x7C) { |
| 1050 appendToken2(TokenType.BAR_BAR); | 1139 appendToken2(TokenType.BAR_BAR); |
| 1051 return _reader.advance(); | 1140 return _reader.advance(); |
| 1052 } else if (next == 0x3D) { | 1141 } else if (next == 0x3D) { |
| 1053 appendToken2(TokenType.BAR_EQ); | 1142 appendToken2(TokenType.BAR_EQ); |
| 1054 return _reader.advance(); | 1143 return _reader.advance(); |
| 1055 } else { | 1144 } else { |
| 1056 appendToken2(TokenType.BAR); | 1145 appendToken2(TokenType.BAR); |
| 1057 return next; | 1146 return next; |
| 1058 } | 1147 } |
| 1059 } | 1148 } |
| 1149 |
| 1060 int tokenizeCaret(int next) => select(0x3D, TokenType.CARET_EQ, TokenType.CARE
T); | 1150 int tokenizeCaret(int next) => select(0x3D, TokenType.CARET_EQ, TokenType.CARE
T); |
| 1151 |
| 1061 int tokenizeDotOrNumber(int next) { | 1152 int tokenizeDotOrNumber(int next) { |
| 1062 int start = _reader.offset; | 1153 int start = _reader.offset; |
| 1063 next = _reader.advance(); | 1154 next = _reader.advance(); |
| 1064 if (0x30 <= next && next <= 0x39) { | 1155 if (0x30 <= next && next <= 0x39) { |
| 1065 return tokenizeFractionPart(next, start); | 1156 return tokenizeFractionPart(next, start); |
| 1066 } else if (0x2E == next) { | 1157 } else if (0x2E == next) { |
| 1067 return select(0x2E, TokenType.PERIOD_PERIOD_PERIOD, TokenType.PERIOD_PERIO
D); | 1158 return select(0x2E, TokenType.PERIOD_PERIOD_PERIOD, TokenType.PERIOD_PERIO
D); |
| 1068 } else { | 1159 } else { |
| 1069 appendToken2(TokenType.PERIOD); | 1160 appendToken2(TokenType.PERIOD); |
| 1070 return next; | 1161 return next; |
| 1071 } | 1162 } |
| 1072 } | 1163 } |
| 1164 |
| 1073 int tokenizeEquals(int next) { | 1165 int tokenizeEquals(int next) { |
| 1074 next = _reader.advance(); | 1166 next = _reader.advance(); |
| 1075 if (next == 0x3D) { | 1167 if (next == 0x3D) { |
| 1076 appendToken2(TokenType.EQ_EQ); | 1168 appendToken2(TokenType.EQ_EQ); |
| 1077 return _reader.advance(); | 1169 return _reader.advance(); |
| 1078 } else if (next == 0x3E) { | 1170 } else if (next == 0x3E) { |
| 1079 appendToken2(TokenType.FUNCTION); | 1171 appendToken2(TokenType.FUNCTION); |
| 1080 return _reader.advance(); | 1172 return _reader.advance(); |
| 1081 } | 1173 } |
| 1082 appendToken2(TokenType.EQ); | 1174 appendToken2(TokenType.EQ); |
| 1083 return next; | 1175 return next; |
| 1084 } | 1176 } |
| 1177 |
| 1085 int tokenizeExclamation(int next) { | 1178 int tokenizeExclamation(int next) { |
| 1086 next = _reader.advance(); | 1179 next = _reader.advance(); |
| 1087 if (next == 0x3D) { | 1180 if (next == 0x3D) { |
| 1088 appendToken2(TokenType.BANG_EQ); | 1181 appendToken2(TokenType.BANG_EQ); |
| 1089 return _reader.advance(); | 1182 return _reader.advance(); |
| 1090 } | 1183 } |
| 1091 appendToken2(TokenType.BANG); | 1184 appendToken2(TokenType.BANG); |
| 1092 return next; | 1185 return next; |
| 1093 } | 1186 } |
| 1187 |
| 1094 int tokenizeExponent(int next) { | 1188 int tokenizeExponent(int next) { |
| 1095 if (next == 0x2B || next == 0x2D) { | 1189 if (next == 0x2B || next == 0x2D) { |
| 1096 next = _reader.advance(); | 1190 next = _reader.advance(); |
| 1097 } | 1191 } |
| 1098 bool hasDigits = false; | 1192 bool hasDigits = false; |
| 1099 while (true) { | 1193 while (true) { |
| 1100 if (0x30 <= next && next <= 0x39) { | 1194 if (0x30 <= next && next <= 0x39) { |
| 1101 hasDigits = true; | 1195 hasDigits = true; |
| 1102 } else { | 1196 } else { |
| 1103 if (!hasDigits) { | 1197 if (!hasDigits) { |
| 1104 reportError(ScannerErrorCode.MISSING_DIGIT, []); | 1198 reportError(ScannerErrorCode.MISSING_DIGIT, []); |
| 1105 } | 1199 } |
| 1106 return next; | 1200 return next; |
| 1107 } | 1201 } |
| 1108 next = _reader.advance(); | 1202 next = _reader.advance(); |
| 1109 } | 1203 } |
| 1110 } | 1204 } |
| 1205 |
| 1111 int tokenizeFractionPart(int next, int start) { | 1206 int tokenizeFractionPart(int next, int start) { |
| 1112 bool done = false; | 1207 bool done = false; |
| 1113 bool hasDigit = false; | 1208 bool hasDigit = false; |
| 1114 LOOP: while (!done) { | 1209 LOOP: while (!done) { |
| 1115 if (0x30 <= next && next <= 0x39) { | 1210 if (0x30 <= next && next <= 0x39) { |
| 1116 hasDigit = true; | 1211 hasDigit = true; |
| 1117 } else if (0x65 == next || 0x45 == next) { | 1212 } else if (0x65 == next || 0x45 == next) { |
| 1118 hasDigit = true; | 1213 hasDigit = true; |
| 1119 next = tokenizeExponent(_reader.advance()); | 1214 next = tokenizeExponent(_reader.advance()); |
| 1120 done = true; | 1215 done = true; |
| 1121 continue LOOP; | 1216 continue LOOP; |
| 1122 } else { | 1217 } else { |
| 1123 done = true; | 1218 done = true; |
| 1124 continue LOOP; | 1219 continue LOOP; |
| 1125 } | 1220 } |
| 1126 next = _reader.advance(); | 1221 next = _reader.advance(); |
| 1127 } | 1222 } |
| 1128 if (!hasDigit) { | 1223 if (!hasDigit) { |
| 1129 appendStringToken(TokenType.INT, _reader.getString(start, -2)); | 1224 appendStringToken(TokenType.INT, _reader.getString(start, -2)); |
| 1130 if (0x2E == next) { | 1225 if (0x2E == next) { |
| 1131 return select2(0x2E, TokenType.PERIOD_PERIOD_PERIOD, TokenType.PERIOD_PE
RIOD, _reader.offset - 1); | 1226 return select2(0x2E, TokenType.PERIOD_PERIOD_PERIOD, TokenType.PERIOD_PE
RIOD, _reader.offset - 1); |
| 1132 } | 1227 } |
| 1133 appendToken3(TokenType.PERIOD, _reader.offset - 1); | 1228 appendToken3(TokenType.PERIOD, _reader.offset - 1); |
| 1134 return bigSwitch(next); | 1229 return bigSwitch(next); |
| 1135 } | 1230 } |
| 1136 appendStringToken(TokenType.DOUBLE, _reader.getString(start, next < 0 ? 0 :
-1)); | 1231 appendStringToken(TokenType.DOUBLE, _reader.getString(start, next < 0 ? 0 :
-1)); |
| 1137 return next; | 1232 return next; |
| 1138 } | 1233 } |
| 1234 |
| 1139 int tokenizeGreaterThan(int next) { | 1235 int tokenizeGreaterThan(int next) { |
| 1140 next = _reader.advance(); | 1236 next = _reader.advance(); |
| 1141 if (0x3D == next) { | 1237 if (0x3D == next) { |
| 1142 appendToken2(TokenType.GT_EQ); | 1238 appendToken2(TokenType.GT_EQ); |
| 1143 return _reader.advance(); | 1239 return _reader.advance(); |
| 1144 } else if (0x3E == next) { | 1240 } else if (0x3E == next) { |
| 1145 next = _reader.advance(); | 1241 next = _reader.advance(); |
| 1146 if (0x3D == next) { | 1242 if (0x3D == next) { |
| 1147 appendToken2(TokenType.GT_GT_EQ); | 1243 appendToken2(TokenType.GT_GT_EQ); |
| 1148 return _reader.advance(); | 1244 return _reader.advance(); |
| 1149 } else { | 1245 } else { |
| 1150 appendToken2(TokenType.GT_GT); | 1246 appendToken2(TokenType.GT_GT); |
| 1151 return next; | 1247 return next; |
| 1152 } | 1248 } |
| 1153 } else { | 1249 } else { |
| 1154 appendToken2(TokenType.GT); | 1250 appendToken2(TokenType.GT); |
| 1155 return next; | 1251 return next; |
| 1156 } | 1252 } |
| 1157 } | 1253 } |
| 1254 |
| 1158 int tokenizeHex(int next) { | 1255 int tokenizeHex(int next) { |
| 1159 int start = _reader.offset - 1; | 1256 int start = _reader.offset - 1; |
| 1160 bool hasDigits = false; | 1257 bool hasDigits = false; |
| 1161 while (true) { | 1258 while (true) { |
| 1162 next = _reader.advance(); | 1259 next = _reader.advance(); |
| 1163 if ((0x30 <= next && next <= 0x39) || (0x41 <= next && next <= 0x46) || (0
x61 <= next && next <= 0x66)) { | 1260 if ((0x30 <= next && next <= 0x39) || (0x41 <= next && next <= 0x46) || (0
x61 <= next && next <= 0x66)) { |
| 1164 hasDigits = true; | 1261 hasDigits = true; |
| 1165 } else { | 1262 } else { |
| 1166 if (!hasDigits) { | 1263 if (!hasDigits) { |
| 1167 reportError(ScannerErrorCode.MISSING_HEX_DIGIT, []); | 1264 reportError(ScannerErrorCode.MISSING_HEX_DIGIT, []); |
| 1168 } | 1265 } |
| 1169 appendStringToken(TokenType.HEXADECIMAL, _reader.getString(start, next <
0 ? 0 : -1)); | 1266 appendStringToken(TokenType.HEXADECIMAL, _reader.getString(start, next <
0 ? 0 : -1)); |
| 1170 return next; | 1267 return next; |
| 1171 } | 1268 } |
| 1172 } | 1269 } |
| 1173 } | 1270 } |
| 1271 |
| 1174 int tokenizeHexOrNumber(int next) { | 1272 int tokenizeHexOrNumber(int next) { |
| 1175 int x = _reader.peek(); | 1273 int x = _reader.peek(); |
| 1176 if (x == 0x78 || x == 0x58) { | 1274 if (x == 0x78 || x == 0x58) { |
| 1177 _reader.advance(); | 1275 _reader.advance(); |
| 1178 return tokenizeHex(x); | 1276 return tokenizeHex(x); |
| 1179 } | 1277 } |
| 1180 return tokenizeNumber(next); | 1278 return tokenizeNumber(next); |
| 1181 } | 1279 } |
| 1280 |
| 1182 int tokenizeIdentifier(int next, int start, bool allowDollar) { | 1281 int tokenizeIdentifier(int next, int start, bool allowDollar) { |
| 1183 while ((0x61 <= next && next <= 0x7A) || (0x41 <= next && next <= 0x5A) || (
0x30 <= next && next <= 0x39) || next == 0x5F || (next == 0x24 && allowDollar))
{ | 1282 while ((0x61 <= next && next <= 0x7A) || (0x41 <= next && next <= 0x5A) || (
0x30 <= next && next <= 0x39) || next == 0x5F || (next == 0x24 && allowDollar))
{ |
| 1184 next = _reader.advance(); | 1283 next = _reader.advance(); |
| 1185 } | 1284 } |
| 1186 appendStringToken(TokenType.IDENTIFIER, _reader.getString(start, next < 0 ?
0 : -1)); | 1285 appendStringToken(TokenType.IDENTIFIER, _reader.getString(start, next < 0 ?
0 : -1)); |
| 1187 return next; | 1286 return next; |
| 1188 } | 1287 } |
| 1288 |
| 1189 int tokenizeInterpolatedExpression(int next, int start) { | 1289 int tokenizeInterpolatedExpression(int next, int start) { |
| 1190 appendBeginToken(TokenType.STRING_INTERPOLATION_EXPRESSION); | 1290 appendBeginToken(TokenType.STRING_INTERPOLATION_EXPRESSION); |
| 1191 next = _reader.advance(); | 1291 next = _reader.advance(); |
| 1192 while (next != -1) { | 1292 while (next != -1) { |
| 1193 if (next == 0x7D) { | 1293 if (next == 0x7D) { |
| 1194 BeginToken begin = findTokenMatchingClosingBraceInInterpolationExpressio
n(); | 1294 BeginToken begin = findTokenMatchingClosingBraceInInterpolationExpressio
n(); |
| 1195 if (begin == null) { | 1295 if (begin == null) { |
| 1196 beginToken(); | 1296 beginToken(); |
| 1197 appendToken2(TokenType.CLOSE_CURLY_BRACKET); | 1297 appendToken2(TokenType.CLOSE_CURLY_BRACKET); |
| 1198 next = _reader.advance(); | 1298 next = _reader.advance(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1214 next = bigSwitch(next); | 1314 next = bigSwitch(next); |
| 1215 } | 1315 } |
| 1216 } | 1316 } |
| 1217 if (next == -1) { | 1317 if (next == -1) { |
| 1218 return next; | 1318 return next; |
| 1219 } | 1319 } |
| 1220 next = _reader.advance(); | 1320 next = _reader.advance(); |
| 1221 beginToken(); | 1321 beginToken(); |
| 1222 return next; | 1322 return next; |
| 1223 } | 1323 } |
| 1324 |
| 1224 int tokenizeInterpolatedIdentifier(int next, int start) { | 1325 int tokenizeInterpolatedIdentifier(int next, int start) { |
| 1225 appendStringToken2(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 0); | 1326 appendStringToken2(TokenType.STRING_INTERPOLATION_IDENTIFIER, "\$", 0); |
| 1226 if ((0x41 <= next && next <= 0x5A) || (0x61 <= next && next <= 0x7A) || next
== 0x5F) { | 1327 if ((0x41 <= next && next <= 0x5A) || (0x61 <= next && next <= 0x7A) || next
== 0x5F) { |
| 1227 beginToken(); | 1328 beginToken(); |
| 1228 next = tokenizeKeywordOrIdentifier(next, false); | 1329 next = tokenizeKeywordOrIdentifier(next, false); |
| 1229 } | 1330 } |
| 1230 beginToken(); | 1331 beginToken(); |
| 1231 return next; | 1332 return next; |
| 1232 } | 1333 } |
| 1334 |
| 1233 int tokenizeKeywordOrIdentifier(int next, bool allowDollar) { | 1335 int tokenizeKeywordOrIdentifier(int next, bool allowDollar) { |
| 1234 KeywordState state = KeywordState.KEYWORD_STATE; | 1336 KeywordState state = KeywordState.KEYWORD_STATE; |
| 1235 int start = _reader.offset; | 1337 int start = _reader.offset; |
| 1236 while (state != null && 0x61 <= next && next <= 0x7A) { | 1338 while (state != null && 0x61 <= next && next <= 0x7A) { |
| 1237 state = state.next(next as int); | 1339 state = state.next(next as int); |
| 1238 next = _reader.advance(); | 1340 next = _reader.advance(); |
| 1239 } | 1341 } |
| 1240 if (state == null || state.keyword() == null) { | 1342 if (state == null || state.keyword() == null) { |
| 1241 return tokenizeIdentifier(next, start, allowDollar); | 1343 return tokenizeIdentifier(next, start, allowDollar); |
| 1242 } | 1344 } |
| 1243 if ((0x41 <= next && next <= 0x5A) || (0x30 <= next && next <= 0x39) || next
== 0x5F || next == 0x24) { | 1345 if ((0x41 <= next && next <= 0x5A) || (0x30 <= next && next <= 0x39) || next
== 0x5F || next == 0x24) { |
| 1244 return tokenizeIdentifier(next, start, allowDollar); | 1346 return tokenizeIdentifier(next, start, allowDollar); |
| 1245 } else if (next < 128) { | 1347 } else if (next < 128) { |
| 1246 appendKeywordToken(state.keyword()); | 1348 appendKeywordToken(state.keyword()); |
| 1247 return next; | 1349 return next; |
| 1248 } else { | 1350 } else { |
| 1249 return tokenizeIdentifier(next, start, allowDollar); | 1351 return tokenizeIdentifier(next, start, allowDollar); |
| 1250 } | 1352 } |
| 1251 } | 1353 } |
| 1354 |
| 1252 int tokenizeLessThan(int next) { | 1355 int tokenizeLessThan(int next) { |
| 1253 next = _reader.advance(); | 1356 next = _reader.advance(); |
| 1254 if (0x3D == next) { | 1357 if (0x3D == next) { |
| 1255 appendToken2(TokenType.LT_EQ); | 1358 appendToken2(TokenType.LT_EQ); |
| 1256 return _reader.advance(); | 1359 return _reader.advance(); |
| 1257 } else if (0x3C == next) { | 1360 } else if (0x3C == next) { |
| 1258 return select(0x3D, TokenType.LT_LT_EQ, TokenType.LT_LT); | 1361 return select(0x3D, TokenType.LT_LT_EQ, TokenType.LT_LT); |
| 1259 } else { | 1362 } else { |
| 1260 appendToken2(TokenType.LT); | 1363 appendToken2(TokenType.LT); |
| 1261 return next; | 1364 return next; |
| 1262 } | 1365 } |
| 1263 } | 1366 } |
| 1367 |
| 1264 int tokenizeMinus(int next) { | 1368 int tokenizeMinus(int next) { |
| 1265 next = _reader.advance(); | 1369 next = _reader.advance(); |
| 1266 if (next == 0x2D) { | 1370 if (next == 0x2D) { |
| 1267 appendToken2(TokenType.MINUS_MINUS); | 1371 appendToken2(TokenType.MINUS_MINUS); |
| 1268 return _reader.advance(); | 1372 return _reader.advance(); |
| 1269 } else if (next == 0x3D) { | 1373 } else if (next == 0x3D) { |
| 1270 appendToken2(TokenType.MINUS_EQ); | 1374 appendToken2(TokenType.MINUS_EQ); |
| 1271 return _reader.advance(); | 1375 return _reader.advance(); |
| 1272 } else { | 1376 } else { |
| 1273 appendToken2(TokenType.MINUS); | 1377 appendToken2(TokenType.MINUS); |
| 1274 return next; | 1378 return next; |
| 1275 } | 1379 } |
| 1276 } | 1380 } |
| 1381 |
| 1277 int tokenizeMultiLineComment(int next) { | 1382 int tokenizeMultiLineComment(int next) { |
| 1278 int nesting = 1; | 1383 int nesting = 1; |
| 1279 next = _reader.advance(); | 1384 next = _reader.advance(); |
| 1280 while (true) { | 1385 while (true) { |
| 1281 if (-1 == next) { | 1386 if (-1 == next) { |
| 1282 reportError(ScannerErrorCode.UNTERMINATED_MULTI_LINE_COMMENT, []); | 1387 reportError(ScannerErrorCode.UNTERMINATED_MULTI_LINE_COMMENT, []); |
| 1283 appendCommentToken(TokenType.MULTI_LINE_COMMENT, _reader.getString(_toke
nStart, 0)); | 1388 appendCommentToken(TokenType.MULTI_LINE_COMMENT, _reader.getString(_toke
nStart, 0)); |
| 1284 return next; | 1389 return next; |
| 1285 } else if (0x2A == next) { | 1390 } else if (0x2A == next) { |
| 1286 next = _reader.advance(); | 1391 next = _reader.advance(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1306 } | 1411 } |
| 1307 recordStartOfLine(); | 1412 recordStartOfLine(); |
| 1308 } else if (next == 0xA) { | 1413 } else if (next == 0xA) { |
| 1309 recordStartOfLine(); | 1414 recordStartOfLine(); |
| 1310 next = _reader.advance(); | 1415 next = _reader.advance(); |
| 1311 } else { | 1416 } else { |
| 1312 next = _reader.advance(); | 1417 next = _reader.advance(); |
| 1313 } | 1418 } |
| 1314 } | 1419 } |
| 1315 } | 1420 } |
| 1421 |
| 1316 int tokenizeMultiLineRawString(int quoteChar, int start) { | 1422 int tokenizeMultiLineRawString(int quoteChar, int start) { |
| 1317 int next = _reader.advance(); | 1423 int next = _reader.advance(); |
| 1318 outer: while (next != -1) { | 1424 outer: while (next != -1) { |
| 1319 while (next != quoteChar) { | 1425 while (next != quoteChar) { |
| 1320 next = _reader.advance(); | 1426 next = _reader.advance(); |
| 1321 if (next == -1) { | 1427 if (next == -1) { |
| 1322 break outer; | 1428 break outer; |
| 1323 } else if (next == 0xD) { | 1429 } else if (next == 0xD) { |
| 1324 next = _reader.advance(); | 1430 next = _reader.advance(); |
| 1325 if (next == 0xA) { | 1431 if (next == 0xA) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1337 if (next == quoteChar) { | 1443 if (next == quoteChar) { |
| 1338 appendStringToken(TokenType.STRING, _reader.getString(start, 0)); | 1444 appendStringToken(TokenType.STRING, _reader.getString(start, 0)); |
| 1339 return _reader.advance(); | 1445 return _reader.advance(); |
| 1340 } | 1446 } |
| 1341 } | 1447 } |
| 1342 } | 1448 } |
| 1343 reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, []); | 1449 reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, []); |
| 1344 appendStringToken(TokenType.STRING, _reader.getString(start, 0)); | 1450 appendStringToken(TokenType.STRING, _reader.getString(start, 0)); |
| 1345 return _reader.advance(); | 1451 return _reader.advance(); |
| 1346 } | 1452 } |
| 1453 |
| 1347 int tokenizeMultiLineString(int quoteChar, int start, bool raw) { | 1454 int tokenizeMultiLineString(int quoteChar, int start, bool raw) { |
| 1348 if (raw) { | 1455 if (raw) { |
| 1349 return tokenizeMultiLineRawString(quoteChar, start); | 1456 return tokenizeMultiLineRawString(quoteChar, start); |
| 1350 } | 1457 } |
| 1351 int next = _reader.advance(); | 1458 int next = _reader.advance(); |
| 1352 while (next != -1) { | 1459 while (next != -1) { |
| 1353 if (next == 0x24) { | 1460 if (next == 0x24) { |
| 1354 appendStringToken(TokenType.STRING, _reader.getString(start, -1)); | 1461 appendStringToken(TokenType.STRING, _reader.getString(start, -1)); |
| 1355 beginToken(); | 1462 beginToken(); |
| 1356 next = tokenizeStringInterpolation(start); | 1463 next = tokenizeStringInterpolation(start); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 recordStartOfLine(); | 1502 recordStartOfLine(); |
| 1396 next = _reader.advance(); | 1503 next = _reader.advance(); |
| 1397 } else { | 1504 } else { |
| 1398 next = _reader.advance(); | 1505 next = _reader.advance(); |
| 1399 } | 1506 } |
| 1400 } | 1507 } |
| 1401 reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, []); | 1508 reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, []); |
| 1402 appendStringToken(TokenType.STRING, _reader.getString(start, 0)); | 1509 appendStringToken(TokenType.STRING, _reader.getString(start, 0)); |
| 1403 return _reader.advance(); | 1510 return _reader.advance(); |
| 1404 } | 1511 } |
| 1512 |
| 1405 int tokenizeMultiply(int next) => select(0x3D, TokenType.STAR_EQ, TokenType.ST
AR); | 1513 int tokenizeMultiply(int next) => select(0x3D, TokenType.STAR_EQ, TokenType.ST
AR); |
| 1514 |
| 1406 int tokenizeNumber(int next) { | 1515 int tokenizeNumber(int next) { |
| 1407 int start = _reader.offset; | 1516 int start = _reader.offset; |
| 1408 while (true) { | 1517 while (true) { |
| 1409 next = _reader.advance(); | 1518 next = _reader.advance(); |
| 1410 if (0x30 <= next && next <= 0x39) { | 1519 if (0x30 <= next && next <= 0x39) { |
| 1411 continue; | 1520 continue; |
| 1412 } else if (next == 0x2E) { | 1521 } else if (next == 0x2E) { |
| 1413 return tokenizeFractionPart(_reader.advance(), start); | 1522 return tokenizeFractionPart(_reader.advance(), start); |
| 1414 } else if (next == 0x65 || next == 0x45) { | 1523 } else if (next == 0x65 || next == 0x45) { |
| 1415 return tokenizeFractionPart(next, start); | 1524 return tokenizeFractionPart(next, start); |
| 1416 } else { | 1525 } else { |
| 1417 appendStringToken(TokenType.INT, _reader.getString(start, next < 0 ? 0 :
-1)); | 1526 appendStringToken(TokenType.INT, _reader.getString(start, next < 0 ? 0 :
-1)); |
| 1418 return next; | 1527 return next; |
| 1419 } | 1528 } |
| 1420 } | 1529 } |
| 1421 } | 1530 } |
| 1531 |
| 1422 int tokenizeOpenSquareBracket(int next) { | 1532 int tokenizeOpenSquareBracket(int next) { |
| 1423 next = _reader.advance(); | 1533 next = _reader.advance(); |
| 1424 if (next == 0x5D) { | 1534 if (next == 0x5D) { |
| 1425 return select(0x3D, TokenType.INDEX_EQ, TokenType.INDEX); | 1535 return select(0x3D, TokenType.INDEX_EQ, TokenType.INDEX); |
| 1426 } else { | 1536 } else { |
| 1427 appendBeginToken(TokenType.OPEN_SQUARE_BRACKET); | 1537 appendBeginToken(TokenType.OPEN_SQUARE_BRACKET); |
| 1428 return next; | 1538 return next; |
| 1429 } | 1539 } |
| 1430 } | 1540 } |
| 1541 |
| 1431 int tokenizePercent(int next) => select(0x3D, TokenType.PERCENT_EQ, TokenType.
PERCENT); | 1542 int tokenizePercent(int next) => select(0x3D, TokenType.PERCENT_EQ, TokenType.
PERCENT); |
| 1543 |
| 1432 int tokenizePlus(int next) { | 1544 int tokenizePlus(int next) { |
| 1433 next = _reader.advance(); | 1545 next = _reader.advance(); |
| 1434 if (0x2B == next) { | 1546 if (0x2B == next) { |
| 1435 appendToken2(TokenType.PLUS_PLUS); | 1547 appendToken2(TokenType.PLUS_PLUS); |
| 1436 return _reader.advance(); | 1548 return _reader.advance(); |
| 1437 } else if (0x3D == next) { | 1549 } else if (0x3D == next) { |
| 1438 appendToken2(TokenType.PLUS_EQ); | 1550 appendToken2(TokenType.PLUS_EQ); |
| 1439 return _reader.advance(); | 1551 return _reader.advance(); |
| 1440 } else { | 1552 } else { |
| 1441 appendToken2(TokenType.PLUS); | 1553 appendToken2(TokenType.PLUS); |
| 1442 return next; | 1554 return next; |
| 1443 } | 1555 } |
| 1444 } | 1556 } |
| 1557 |
| 1445 int tokenizeSingleLineComment(int next) { | 1558 int tokenizeSingleLineComment(int next) { |
| 1446 while (true) { | 1559 while (true) { |
| 1447 next = _reader.advance(); | 1560 next = _reader.advance(); |
| 1448 if (-1 == next) { | 1561 if (-1 == next) { |
| 1449 appendCommentToken(TokenType.SINGLE_LINE_COMMENT, _reader.getString(_tok
enStart, 0)); | 1562 appendCommentToken(TokenType.SINGLE_LINE_COMMENT, _reader.getString(_tok
enStart, 0)); |
| 1450 return next; | 1563 return next; |
| 1451 } else if (0xA == next || 0xD == next) { | 1564 } else if (0xA == next || 0xD == next) { |
| 1452 appendCommentToken(TokenType.SINGLE_LINE_COMMENT, _reader.getString(_tok
enStart, -1)); | 1565 appendCommentToken(TokenType.SINGLE_LINE_COMMENT, _reader.getString(_tok
enStart, -1)); |
| 1453 return next; | 1566 return next; |
| 1454 } | 1567 } |
| 1455 } | 1568 } |
| 1456 } | 1569 } |
| 1570 |
| 1457 int tokenizeSingleLineRawString(int next, int quoteChar, int start) { | 1571 int tokenizeSingleLineRawString(int next, int quoteChar, int start) { |
| 1458 next = _reader.advance(); | 1572 next = _reader.advance(); |
| 1459 while (next != -1) { | 1573 while (next != -1) { |
| 1460 if (next == quoteChar) { | 1574 if (next == quoteChar) { |
| 1461 appendStringToken(TokenType.STRING, _reader.getString(start, 0)); | 1575 appendStringToken(TokenType.STRING, _reader.getString(start, 0)); |
| 1462 return _reader.advance(); | 1576 return _reader.advance(); |
| 1463 } else if (next == 0xD || next == 0xA) { | 1577 } else if (next == 0xD || next == 0xA) { |
| 1464 reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, []); | 1578 reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, []); |
| 1465 appendStringToken(TokenType.STRING, _reader.getString(start, 0)); | 1579 appendStringToken(TokenType.STRING, _reader.getString(start, 0)); |
| 1466 return _reader.advance(); | 1580 return _reader.advance(); |
| 1467 } | 1581 } |
| 1468 next = _reader.advance(); | 1582 next = _reader.advance(); |
| 1469 } | 1583 } |
| 1470 reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, []); | 1584 reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, []); |
| 1471 appendStringToken(TokenType.STRING, _reader.getString(start, 0)); | 1585 appendStringToken(TokenType.STRING, _reader.getString(start, 0)); |
| 1472 return _reader.advance(); | 1586 return _reader.advance(); |
| 1473 } | 1587 } |
| 1588 |
| 1474 int tokenizeSingleLineString(int next, int quoteChar, int start) { | 1589 int tokenizeSingleLineString(int next, int quoteChar, int start) { |
| 1475 while (next != quoteChar) { | 1590 while (next != quoteChar) { |
| 1476 if (next == 0x5C) { | 1591 if (next == 0x5C) { |
| 1477 next = _reader.advance(); | 1592 next = _reader.advance(); |
| 1478 } else if (next == 0x24) { | 1593 } else if (next == 0x24) { |
| 1479 appendStringToken(TokenType.STRING, _reader.getString(start, -1)); | 1594 appendStringToken(TokenType.STRING, _reader.getString(start, -1)); |
| 1480 beginToken(); | 1595 beginToken(); |
| 1481 next = tokenizeStringInterpolation(start); | 1596 next = tokenizeStringInterpolation(start); |
| 1482 start = _reader.offset; | 1597 start = _reader.offset; |
| 1483 continue; | 1598 continue; |
| 1484 } | 1599 } |
| 1485 if (next <= 0xD && (next == 0xA || next == 0xD || next == -1)) { | 1600 if (next <= 0xD && (next == 0xA || next == 0xD || next == -1)) { |
| 1486 reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, []); | 1601 reportError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, []); |
| 1487 appendStringToken(TokenType.STRING, _reader.getString(start, 0)); | 1602 appendStringToken(TokenType.STRING, _reader.getString(start, 0)); |
| 1488 return _reader.advance(); | 1603 return _reader.advance(); |
| 1489 } | 1604 } |
| 1490 next = _reader.advance(); | 1605 next = _reader.advance(); |
| 1491 } | 1606 } |
| 1492 appendStringToken(TokenType.STRING, _reader.getString(start, 0)); | 1607 appendStringToken(TokenType.STRING, _reader.getString(start, 0)); |
| 1493 return _reader.advance(); | 1608 return _reader.advance(); |
| 1494 } | 1609 } |
| 1610 |
| 1495 int tokenizeSlashOrComment(int next) { | 1611 int tokenizeSlashOrComment(int next) { |
| 1496 next = _reader.advance(); | 1612 next = _reader.advance(); |
| 1497 if (0x2A == next) { | 1613 if (0x2A == next) { |
| 1498 return tokenizeMultiLineComment(next); | 1614 return tokenizeMultiLineComment(next); |
| 1499 } else if (0x2F == next) { | 1615 } else if (0x2F == next) { |
| 1500 return tokenizeSingleLineComment(next); | 1616 return tokenizeSingleLineComment(next); |
| 1501 } else if (0x3D == next) { | 1617 } else if (0x3D == next) { |
| 1502 appendToken2(TokenType.SLASH_EQ); | 1618 appendToken2(TokenType.SLASH_EQ); |
| 1503 return _reader.advance(); | 1619 return _reader.advance(); |
| 1504 } else { | 1620 } else { |
| 1505 appendToken2(TokenType.SLASH); | 1621 appendToken2(TokenType.SLASH); |
| 1506 return next; | 1622 return next; |
| 1507 } | 1623 } |
| 1508 } | 1624 } |
| 1625 |
| 1509 int tokenizeString(int next, int start, bool raw) { | 1626 int tokenizeString(int next, int start, bool raw) { |
| 1510 int quoteChar = next; | 1627 int quoteChar = next; |
| 1511 next = _reader.advance(); | 1628 next = _reader.advance(); |
| 1512 if (quoteChar == next) { | 1629 if (quoteChar == next) { |
| 1513 next = _reader.advance(); | 1630 next = _reader.advance(); |
| 1514 if (quoteChar == next) { | 1631 if (quoteChar == next) { |
| 1515 return tokenizeMultiLineString(quoteChar, start, raw); | 1632 return tokenizeMultiLineString(quoteChar, start, raw); |
| 1516 } else { | 1633 } else { |
| 1517 appendStringToken(TokenType.STRING, _reader.getString(start, -1)); | 1634 appendStringToken(TokenType.STRING, _reader.getString(start, -1)); |
| 1518 return next; | 1635 return next; |
| 1519 } | 1636 } |
| 1520 } | 1637 } |
| 1521 if (raw) { | 1638 if (raw) { |
| 1522 return tokenizeSingleLineRawString(next, quoteChar, start); | 1639 return tokenizeSingleLineRawString(next, quoteChar, start); |
| 1523 } else { | 1640 } else { |
| 1524 return tokenizeSingleLineString(next, quoteChar, start); | 1641 return tokenizeSingleLineString(next, quoteChar, start); |
| 1525 } | 1642 } |
| 1526 } | 1643 } |
| 1644 |
| 1527 int tokenizeStringInterpolation(int start) { | 1645 int tokenizeStringInterpolation(int start) { |
| 1528 beginToken(); | 1646 beginToken(); |
| 1529 int next = _reader.advance(); | 1647 int next = _reader.advance(); |
| 1530 if (next == 0x7B) { | 1648 if (next == 0x7B) { |
| 1531 return tokenizeInterpolatedExpression(next, start); | 1649 return tokenizeInterpolatedExpression(next, start); |
| 1532 } else { | 1650 } else { |
| 1533 return tokenizeInterpolatedIdentifier(next, start); | 1651 return tokenizeInterpolatedIdentifier(next, start); |
| 1534 } | 1652 } |
| 1535 } | 1653 } |
| 1654 |
| 1536 int tokenizeTag(int next) { | 1655 int tokenizeTag(int next) { |
| 1537 if (_reader.offset == 0) { | 1656 if (_reader.offset == 0) { |
| 1538 if (_reader.peek() == 0x21) { | 1657 if (_reader.peek() == 0x21) { |
| 1539 do { | 1658 do { |
| 1540 next = _reader.advance(); | 1659 next = _reader.advance(); |
| 1541 } while (next != 0xA && next != 0xD && next > 0); | 1660 } while (next != 0xA && next != 0xD && next > 0); |
| 1542 appendStringToken(TokenType.SCRIPT_TAG, _reader.getString(_tokenStart, 0
)); | 1661 appendStringToken(TokenType.SCRIPT_TAG, _reader.getString(_tokenStart, 0
)); |
| 1543 return next; | 1662 return next; |
| 1544 } | 1663 } |
| 1545 } | 1664 } |
| 1546 appendToken2(TokenType.HASH); | 1665 appendToken2(TokenType.HASH); |
| 1547 return _reader.advance(); | 1666 return _reader.advance(); |
| 1548 } | 1667 } |
| 1668 |
| 1549 int tokenizeTilde(int next) { | 1669 int tokenizeTilde(int next) { |
| 1550 next = _reader.advance(); | 1670 next = _reader.advance(); |
| 1551 if (next == 0x2F) { | 1671 if (next == 0x2F) { |
| 1552 return select(0x3D, TokenType.TILDE_SLASH_EQ, TokenType.TILDE_SLASH); | 1672 return select(0x3D, TokenType.TILDE_SLASH_EQ, TokenType.TILDE_SLASH); |
| 1553 } else { | 1673 } else { |
| 1554 appendToken2(TokenType.TILDE); | 1674 appendToken2(TokenType.TILDE); |
| 1555 return next; | 1675 return next; |
| 1556 } | 1676 } |
| 1557 } | 1677 } |
| 1558 } | 1678 } |
| 1679 |
| 1559 /** | 1680 /** |
| 1560 * Instances of the class `StringToken` represent a token whose value is indepen
dent of it's | 1681 * Instances of the class `StringToken` represent a token whose value is indepen
dent of it's |
| 1561 * type. | 1682 * type. |
| 1562 * | 1683 * |
| 1563 * @coverage dart.engine.parser | 1684 * @coverage dart.engine.parser |
| 1564 */ | 1685 */ |
| 1565 class StringToken extends Token { | 1686 class StringToken extends Token { |
| 1566 | |
| 1567 /** | 1687 /** |
| 1568 * The lexeme represented by this token. | 1688 * The lexeme represented by this token. |
| 1569 */ | 1689 */ |
| 1570 String _value2; | 1690 String _value2; |
| 1571 | 1691 |
| 1572 /** | 1692 /** |
| 1573 * Initialize a newly created token to represent a token of the given type wit
h the given value. | 1693 * Initialize a newly created token to represent a token of the given type wit
h the given value. |
| 1574 * | 1694 * |
| 1575 * @param type the type of the token | 1695 * @param type the type of the token |
| 1576 * @param value the lexeme represented by this token | 1696 * @param value the lexeme represented by this token |
| 1577 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1697 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1578 */ | 1698 */ |
| 1579 StringToken(TokenType type, String value, int offset) : super(type, offset) { | 1699 StringToken(TokenType type, String value, int offset) : super(type, offset) { |
| 1580 this._value2 = StringUtilities.intern(value); | 1700 this._value2 = StringUtilities.intern(value); |
| 1581 } | 1701 } |
| 1702 |
| 1582 Token copy() => new StringToken(type, _value2, offset); | 1703 Token copy() => new StringToken(type, _value2, offset); |
| 1704 |
| 1583 String get lexeme => _value2; | 1705 String get lexeme => _value2; |
| 1706 |
| 1584 String value() => _value2; | 1707 String value() => _value2; |
| 1585 } | 1708 } |
| 1709 |
| 1586 /** | 1710 /** |
| 1587 * Instances of the class `TokenWithComment` represent a normal token that is pr
eceded by | 1711 * Instances of the class `TokenWithComment` represent a normal token that is pr
eceded by |
| 1588 * comments. | 1712 * comments. |
| 1589 * | 1713 * |
| 1590 * @coverage dart.engine.parser | 1714 * @coverage dart.engine.parser |
| 1591 */ | 1715 */ |
| 1592 class TokenWithComment extends Token { | 1716 class TokenWithComment extends Token { |
| 1593 | |
| 1594 /** | 1717 /** |
| 1595 * The first comment in the list of comments that precede this token. | 1718 * The first comment in the list of comments that precede this token. |
| 1596 */ | 1719 */ |
| 1597 Token _precedingComment; | 1720 Token _precedingComment; |
| 1598 | 1721 |
| 1599 /** | 1722 /** |
| 1600 * Initialize a newly created token to have the given type and offset and to b
e preceded by the | 1723 * Initialize a newly created token to have the given type and offset and to b
e preceded by the |
| 1601 * comments reachable from the given comment. | 1724 * comments reachable from the given comment. |
| 1602 * | 1725 * |
| 1603 * @param type the type of the token | 1726 * @param type the type of the token |
| 1604 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1727 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1605 * @param precedingComment the first comment in the list of comments that prec
ede this token | 1728 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 1606 */ | 1729 */ |
| 1607 TokenWithComment(TokenType type, int offset, Token precedingComment) : super(t
ype, offset) { | 1730 TokenWithComment(TokenType type, int offset, Token precedingComment) : super(t
ype, offset) { |
| 1608 this._precedingComment = precedingComment; | 1731 this._precedingComment = precedingComment; |
| 1609 } | 1732 } |
| 1733 |
| 1610 Token copy() => new TokenWithComment(type, offset, _precedingComment); | 1734 Token copy() => new TokenWithComment(type, offset, _precedingComment); |
| 1735 |
| 1611 Token get precedingComments => _precedingComment; | 1736 Token get precedingComments => _precedingComment; |
| 1612 } | 1737 } |
| 1738 |
| 1613 /** | 1739 /** |
| 1614 * Instances of the class `Token` represent a token that was scanned from the in
put. Each | 1740 * Instances of the class `Token` represent a token that was scanned from the in
put. Each |
| 1615 * token knows which token follows it, acting as the head of a linked list of to
kens. | 1741 * token knows which token follows it, acting as the head of a linked list of to
kens. |
| 1616 * | 1742 * |
| 1617 * @coverage dart.engine.parser | 1743 * @coverage dart.engine.parser |
| 1618 */ | 1744 */ |
| 1619 class Token { | 1745 class Token { |
| 1620 | |
| 1621 /** | 1746 /** |
| 1622 * The type of the token. | 1747 * The type of the token. |
| 1623 */ | 1748 */ |
| 1624 TokenType type; | 1749 TokenType type; |
| 1625 | 1750 |
| 1626 /** | 1751 /** |
| 1627 * The offset from the beginning of the file to the first character in the tok
en. | 1752 * The offset from the beginning of the file to the first character in the tok
en. |
| 1628 */ | 1753 */ |
| 1629 int offset = 0; | 1754 int offset = 0; |
| 1630 | 1755 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1729 * Set the next token in the token stream to the given token without changing
which token is the | 1854 * Set the next token in the token stream to the given token without changing
which token is the |
| 1730 * previous token for the given token. | 1855 * previous token for the given token. |
| 1731 * | 1856 * |
| 1732 * @param token the next token in the token stream | 1857 * @param token the next token in the token stream |
| 1733 * @return the token that was passed in | 1858 * @return the token that was passed in |
| 1734 */ | 1859 */ |
| 1735 Token setNextWithoutSettingPrevious(Token token) { | 1860 Token setNextWithoutSettingPrevious(Token token) { |
| 1736 next = token; | 1861 next = token; |
| 1737 return token; | 1862 return token; |
| 1738 } | 1863 } |
| 1864 |
| 1739 String toString() => lexeme; | 1865 String toString() => lexeme; |
| 1740 | 1866 |
| 1741 /** | 1867 /** |
| 1742 * Return the value of this token. For keyword tokens, this is the keyword ass
ociated with the | 1868 * Return the value of this token. For keyword tokens, this is the keyword ass
ociated with the |
| 1743 * token, for other tokens it is the lexeme associated with the token. | 1869 * token, for other tokens it is the lexeme associated with the token. |
| 1744 * | 1870 * |
| 1745 * @return the value of this token | 1871 * @return the value of this token |
| 1746 */ | 1872 */ |
| 1747 Object value() => type.lexeme; | 1873 Object value() => type.lexeme; |
| 1748 | 1874 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1768 Token head = token.copy(); | 1894 Token head = token.copy(); |
| 1769 Token tail = head; | 1895 Token tail = head; |
| 1770 token = token.next; | 1896 token = token.next; |
| 1771 while (token != null) { | 1897 while (token != null) { |
| 1772 tail = tail.setNext(token.copy()); | 1898 tail = tail.setNext(token.copy()); |
| 1773 token = token.next; | 1899 token = token.next; |
| 1774 } | 1900 } |
| 1775 return head; | 1901 return head; |
| 1776 } | 1902 } |
| 1777 } | 1903 } |
| 1904 |
| 1778 /** | 1905 /** |
| 1779 * The interface `CharacterReader` | 1906 * The interface `CharacterReader` |
| 1780 */ | 1907 */ |
| 1781 abstract class CharacterReader { | 1908 abstract class CharacterReader { |
| 1782 | |
| 1783 /** | 1909 /** |
| 1784 * Advance the current position and return the character at the new current po
sition. | 1910 * Advance the current position and return the character at the new current po
sition. |
| 1785 * | 1911 * |
| 1786 * @return the character at the new current position | 1912 * @return the character at the new current position |
| 1787 */ | 1913 */ |
| 1788 int advance(); | 1914 int advance(); |
| 1789 | 1915 |
| 1790 /** | 1916 /** |
| 1791 * Return the current offset relative to the beginning of the source. Return t
he initial offset if | 1917 * Return the current offset relative to the beginning of the source. Return t
he initial offset if |
| 1792 * the scanner has not yet scanned the source code, and one (1) past the end o
f the source code if | 1918 * the scanner has not yet scanned the source code, and one (1) past the end o
f the source code if |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1816 int peek(); | 1942 int peek(); |
| 1817 | 1943 |
| 1818 /** | 1944 /** |
| 1819 * Set the current offset relative to the beginning of the source. The new off
set must be between | 1945 * Set the current offset relative to the beginning of the source. The new off
set must be between |
| 1820 * the initial offset and one (1) past the end of the source code. | 1946 * the initial offset and one (1) past the end of the source code. |
| 1821 * | 1947 * |
| 1822 * @param offset the new offset in the source | 1948 * @param offset the new offset in the source |
| 1823 */ | 1949 */ |
| 1824 void set offset(int offset); | 1950 void set offset(int offset); |
| 1825 } | 1951 } |
| 1952 |
| 1826 /** | 1953 /** |
| 1827 * Instances of the class `BeginTokenWithComment` represent a begin token that i
s preceded by | 1954 * Instances of the class `BeginTokenWithComment` represent a begin token that i
s preceded by |
| 1828 * comments. | 1955 * comments. |
| 1829 * | 1956 * |
| 1830 * @coverage dart.engine.parser | 1957 * @coverage dart.engine.parser |
| 1831 */ | 1958 */ |
| 1832 class BeginTokenWithComment extends BeginToken { | 1959 class BeginTokenWithComment extends BeginToken { |
| 1833 | |
| 1834 /** | 1960 /** |
| 1835 * The first comment in the list of comments that precede this token. | 1961 * The first comment in the list of comments that precede this token. |
| 1836 */ | 1962 */ |
| 1837 Token _precedingComment; | 1963 Token _precedingComment; |
| 1838 | 1964 |
| 1839 /** | 1965 /** |
| 1840 * Initialize a newly created token to have the given type and offset and to b
e preceded by the | 1966 * Initialize a newly created token to have the given type and offset and to b
e preceded by the |
| 1841 * comments reachable from the given comment. | 1967 * comments reachable from the given comment. |
| 1842 * | 1968 * |
| 1843 * @param type the type of the token | 1969 * @param type the type of the token |
| 1844 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1970 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1845 * @param precedingComment the first comment in the list of comments that prec
ede this token | 1971 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 1846 */ | 1972 */ |
| 1847 BeginTokenWithComment(TokenType type, int offset, Token precedingComment) : su
per(type, offset) { | 1973 BeginTokenWithComment(TokenType type, int offset, Token precedingComment) : su
per(type, offset) { |
| 1848 this._precedingComment = precedingComment; | 1974 this._precedingComment = precedingComment; |
| 1849 } | 1975 } |
| 1976 |
| 1850 Token copy() => new BeginTokenWithComment(type, offset, copyComments(_precedin
gComment)); | 1977 Token copy() => new BeginTokenWithComment(type, offset, copyComments(_precedin
gComment)); |
| 1978 |
| 1851 Token get precedingComments => _precedingComment; | 1979 Token get precedingComments => _precedingComment; |
| 1980 |
| 1852 void applyDelta(int delta) { | 1981 void applyDelta(int delta) { |
| 1853 super.applyDelta(delta); | 1982 super.applyDelta(delta); |
| 1854 Token token = _precedingComment; | 1983 Token token = _precedingComment; |
| 1855 while (token != null) { | 1984 while (token != null) { |
| 1856 token.applyDelta(delta); | 1985 token.applyDelta(delta); |
| 1857 token = token.next; | 1986 token = token.next; |
| 1858 } | 1987 } |
| 1859 } | 1988 } |
| 1860 } | 1989 } |
| 1990 |
| 1861 /** | 1991 /** |
| 1862 * Instances of the class `KeywordToken` represent a keyword in the language. | 1992 * Instances of the class `KeywordToken` represent a keyword in the language. |
| 1863 * | 1993 * |
| 1864 * @coverage dart.engine.parser | 1994 * @coverage dart.engine.parser |
| 1865 */ | 1995 */ |
| 1866 class KeywordToken extends Token { | 1996 class KeywordToken extends Token { |
| 1867 | |
| 1868 /** | 1997 /** |
| 1869 * The keyword being represented by this token. | 1998 * The keyword being represented by this token. |
| 1870 */ | 1999 */ |
| 1871 Keyword keyword; | 2000 Keyword keyword; |
| 1872 | 2001 |
| 1873 /** | 2002 /** |
| 1874 * Initialize a newly created token to represent the given keyword. | 2003 * Initialize a newly created token to represent the given keyword. |
| 1875 * | 2004 * |
| 1876 * @param keyword the keyword being represented by this token | 2005 * @param keyword the keyword being represented by this token |
| 1877 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 2006 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1878 */ | 2007 */ |
| 1879 KeywordToken(Keyword keyword, int offset) : super(TokenType.KEYWORD, offset) { | 2008 KeywordToken(Keyword keyword, int offset) : super(TokenType.KEYWORD, offset) { |
| 1880 this.keyword = keyword; | 2009 this.keyword = keyword; |
| 1881 } | 2010 } |
| 2011 |
| 1882 Token copy() => new KeywordToken(keyword, offset); | 2012 Token copy() => new KeywordToken(keyword, offset); |
| 2013 |
| 1883 String get lexeme => keyword.syntax; | 2014 String get lexeme => keyword.syntax; |
| 2015 |
| 1884 Keyword value() => keyword; | 2016 Keyword value() => keyword; |
| 1885 } | 2017 } |
| 2018 |
| 1886 /** | 2019 /** |
| 1887 * Instances of the class `BeginToken` represent the opening half of a grouping
pair of | 2020 * Instances of the class `BeginToken` represent the opening half of a grouping
pair of |
| 1888 * tokens. This is used for curly brackets ('{'), parentheses ('('), and square
brackets ('['). | 2021 * tokens. This is used for curly brackets ('{'), parentheses ('('), and square
brackets ('['). |
| 1889 * | 2022 * |
| 1890 * @coverage dart.engine.parser | 2023 * @coverage dart.engine.parser |
| 1891 */ | 2024 */ |
| 1892 class BeginToken extends Token { | 2025 class BeginToken extends Token { |
| 1893 | |
| 1894 /** | 2026 /** |
| 1895 * The token that corresponds to this token. | 2027 * The token that corresponds to this token. |
| 1896 */ | 2028 */ |
| 1897 Token endToken; | 2029 Token endToken; |
| 1898 | 2030 |
| 1899 /** | 2031 /** |
| 1900 * Initialize a newly created token representing the opening half of a groupin
g pair of tokens. | 2032 * Initialize a newly created token representing the opening half of a groupin
g pair of tokens. |
| 1901 * | 2033 * |
| 1902 * @param type the type of the token | 2034 * @param type the type of the token |
| 1903 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 2035 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1904 */ | 2036 */ |
| 1905 BeginToken(TokenType type, int offset) : super(type, offset) { | 2037 BeginToken(TokenType type, int offset) : super(type, offset) { |
| 1906 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))); | 2038 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))); |
| 1907 } | 2039 } |
| 2040 |
| 1908 Token copy() => new BeginToken(type, offset); | 2041 Token copy() => new BeginToken(type, offset); |
| 1909 } | 2042 } |
| 2043 |
| 1910 /** | 2044 /** |
| 1911 * The enumeration `TokenClass` represents classes (or groups) of tokens with a
similar use. | 2045 * The enumeration `TokenClass` represents classes (or groups) of tokens with a
similar use. |
| 1912 * | 2046 * |
| 1913 * @coverage dart.engine.parser | 2047 * @coverage dart.engine.parser |
| 1914 */ | 2048 */ |
| 1915 class TokenClass extends Enum<TokenClass> { | 2049 class TokenClass extends Enum<TokenClass> { |
| 1916 | |
| 1917 /** | 2050 /** |
| 1918 * A value used to indicate that the token type is not part of any specific cl
ass of token. | 2051 * A value used to indicate that the token type is not part of any specific cl
ass of token. |
| 1919 */ | 2052 */ |
| 1920 static final TokenClass NO_CLASS = new TokenClass.con1('NO_CLASS', 0); | 2053 static final TokenClass NO_CLASS = new TokenClass.con1('NO_CLASS', 0); |
| 1921 | 2054 |
| 1922 /** | 2055 /** |
| 1923 * A value used to indicate that the token type is an additive operator. | 2056 * A value used to indicate that the token type is an additive operator. |
| 1924 */ | 2057 */ |
| 1925 static final TokenClass ADDITIVE_OPERATOR = new TokenClass.con2('ADDITIVE_OPER
ATOR', 1, 12); | 2058 static final TokenClass ADDITIVE_OPERATOR = new TokenClass.con2('ADDITIVE_OPER
ATOR', 1, 12); |
| 1926 | 2059 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1986 | 2119 |
| 1987 /** | 2120 /** |
| 1988 * A value used to indicate that the token type is a unary operator. | 2121 * A value used to indicate that the token type is a unary operator. |
| 1989 */ | 2122 */ |
| 1990 static final TokenClass UNARY_POSTFIX_OPERATOR = new TokenClass.con2('UNARY_PO
STFIX_OPERATOR', 14, 15); | 2123 static final TokenClass UNARY_POSTFIX_OPERATOR = new TokenClass.con2('UNARY_PO
STFIX_OPERATOR', 14, 15); |
| 1991 | 2124 |
| 1992 /** | 2125 /** |
| 1993 * A value used to indicate that the token type is a unary operator. | 2126 * A value used to indicate that the token type is a unary operator. |
| 1994 */ | 2127 */ |
| 1995 static final TokenClass UNARY_PREFIX_OPERATOR = new TokenClass.con2('UNARY_PRE
FIX_OPERATOR', 15, 14); | 2128 static final TokenClass UNARY_PREFIX_OPERATOR = new TokenClass.con2('UNARY_PRE
FIX_OPERATOR', 15, 14); |
| 2129 |
| 1996 static final List<TokenClass> values = [ | 2130 static final List<TokenClass> values = [ |
| 1997 NO_CLASS, | 2131 NO_CLASS, |
| 1998 ADDITIVE_OPERATOR, | 2132 ADDITIVE_OPERATOR, |
| 1999 ASSIGNMENT_OPERATOR, | 2133 ASSIGNMENT_OPERATOR, |
| 2000 BITWISE_AND_OPERATOR, | 2134 BITWISE_AND_OPERATOR, |
| 2001 BITWISE_OR_OPERATOR, | 2135 BITWISE_OR_OPERATOR, |
| 2002 BITWISE_XOR_OPERATOR, | 2136 BITWISE_XOR_OPERATOR, |
| 2003 CASCADE_OPERATOR, | 2137 CASCADE_OPERATOR, |
| 2004 CONDITIONAL_OPERATOR, | 2138 CONDITIONAL_OPERATOR, |
| 2005 EQUALITY_OPERATOR, | 2139 EQUALITY_OPERATOR, |
| 2006 LOGICAL_AND_OPERATOR, | 2140 LOGICAL_AND_OPERATOR, |
| 2007 LOGICAL_OR_OPERATOR, | 2141 LOGICAL_OR_OPERATOR, |
| 2008 MULTIPLICATIVE_OPERATOR, | 2142 MULTIPLICATIVE_OPERATOR, |
| 2009 RELATIONAL_OPERATOR, | 2143 RELATIONAL_OPERATOR, |
| 2010 SHIFT_OPERATOR, | 2144 SHIFT_OPERATOR, |
| 2011 UNARY_POSTFIX_OPERATOR, | 2145 UNARY_POSTFIX_OPERATOR, |
| 2012 UNARY_PREFIX_OPERATOR]; | 2146 UNARY_PREFIX_OPERATOR]; |
| 2013 | 2147 |
| 2014 /** | 2148 /** |
| 2015 * The precedence of tokens of this class, or `0` if the such tokens do not re
present an | 2149 * The precedence of tokens of this class, or `0` if the such tokens do not re
present an |
| 2016 * operator. | 2150 * operator. |
| 2017 */ | 2151 */ |
| 2018 int precedence = 0; | 2152 int precedence = 0; |
| 2153 |
| 2019 TokenClass.con1(String name, int ordinal) : this.con2(name, ordinal, 0); | 2154 TokenClass.con1(String name, int ordinal) : this.con2(name, ordinal, 0); |
| 2155 |
| 2020 TokenClass.con2(String name, int ordinal, int precedence) : super(name, ordina
l) { | 2156 TokenClass.con2(String name, int ordinal, int precedence) : super(name, ordina
l) { |
| 2021 this.precedence = precedence; | 2157 this.precedence = precedence; |
| 2022 } | 2158 } |
| 2023 } | 2159 } |
| 2160 |
| 2024 /** | 2161 /** |
| 2025 * Instances of the class `KeywordTokenWithComment` implement a keyword token th
at is preceded | 2162 * Instances of the class `KeywordTokenWithComment` implement a keyword token th
at is preceded |
| 2026 * by comments. | 2163 * by comments. |
| 2027 * | 2164 * |
| 2028 * @coverage dart.engine.parser | 2165 * @coverage dart.engine.parser |
| 2029 */ | 2166 */ |
| 2030 class KeywordTokenWithComment extends KeywordToken { | 2167 class KeywordTokenWithComment extends KeywordToken { |
| 2031 | |
| 2032 /** | 2168 /** |
| 2033 * The first comment in the list of comments that precede this token. | 2169 * The first comment in the list of comments that precede this token. |
| 2034 */ | 2170 */ |
| 2035 Token _precedingComment; | 2171 Token _precedingComment; |
| 2036 | 2172 |
| 2037 /** | 2173 /** |
| 2038 * Initialize a newly created token to to represent the given keyword and to b
e preceded by the | 2174 * Initialize a newly created token to to represent the given keyword and to b
e preceded by the |
| 2039 * comments reachable from the given comment. | 2175 * comments reachable from the given comment. |
| 2040 * | 2176 * |
| 2041 * @param keyword the keyword being represented by this token | 2177 * @param keyword the keyword being represented by this token |
| 2042 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 2178 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 2043 * @param precedingComment the first comment in the list of comments that prec
ede this token | 2179 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 2044 */ | 2180 */ |
| 2045 KeywordTokenWithComment(Keyword keyword, int offset, Token precedingComment) :
super(keyword, offset) { | 2181 KeywordTokenWithComment(Keyword keyword, int offset, Token precedingComment) :
super(keyword, offset) { |
| 2046 this._precedingComment = precedingComment; | 2182 this._precedingComment = precedingComment; |
| 2047 } | 2183 } |
| 2184 |
| 2048 Token copy() => new KeywordTokenWithComment(keyword, offset, copyComments(_pre
cedingComment)); | 2185 Token copy() => new KeywordTokenWithComment(keyword, offset, copyComments(_pre
cedingComment)); |
| 2186 |
| 2049 Token get precedingComments => _precedingComment; | 2187 Token get precedingComments => _precedingComment; |
| 2188 |
| 2050 void applyDelta(int delta) { | 2189 void applyDelta(int delta) { |
| 2051 super.applyDelta(delta); | 2190 super.applyDelta(delta); |
| 2052 Token token = _precedingComment; | 2191 Token token = _precedingComment; |
| 2053 while (token != null) { | 2192 while (token != null) { |
| 2054 token.applyDelta(delta); | 2193 token.applyDelta(delta); |
| 2055 token = token.next; | 2194 token = token.next; |
| 2056 } | 2195 } |
| 2057 } | 2196 } |
| 2058 } | 2197 } |
| 2198 |
| 2059 /** | 2199 /** |
| 2060 * The enumeration `TokenType` defines the types of tokens that can be returned
by the | 2200 * The enumeration `TokenType` defines the types of tokens that can be returned
by the |
| 2061 * scanner. | 2201 * scanner. |
| 2062 * | 2202 * |
| 2063 * @coverage dart.engine.parser | 2203 * @coverage dart.engine.parser |
| 2064 */ | 2204 */ |
| 2065 class TokenType extends Enum<TokenType> { | 2205 class TokenType extends Enum<TokenType> { |
| 2066 | |
| 2067 /** | 2206 /** |
| 2068 * The type of the token that marks the end of the input. | 2207 * The type of the token that marks the end of the input. |
| 2069 */ | 2208 */ |
| 2070 static final TokenType EOF = new TokenType_EOF('EOF', 0, null, ""); | 2209 static final TokenType EOF = new TokenType_EOF('EOF', 0, null, ""); |
| 2210 |
| 2071 static final TokenType DOUBLE = new TokenType.con1('DOUBLE', 1); | 2211 static final TokenType DOUBLE = new TokenType.con1('DOUBLE', 1); |
| 2212 |
| 2072 static final TokenType HEXADECIMAL = new TokenType.con1('HEXADECIMAL', 2); | 2213 static final TokenType HEXADECIMAL = new TokenType.con1('HEXADECIMAL', 2); |
| 2214 |
| 2073 static final TokenType IDENTIFIER = new TokenType.con1('IDENTIFIER', 3); | 2215 static final TokenType IDENTIFIER = new TokenType.con1('IDENTIFIER', 3); |
| 2216 |
| 2074 static final TokenType INT = new TokenType.con1('INT', 4); | 2217 static final TokenType INT = new TokenType.con1('INT', 4); |
| 2218 |
| 2075 static final TokenType KEYWORD = new TokenType.con1('KEYWORD', 5); | 2219 static final TokenType KEYWORD = new TokenType.con1('KEYWORD', 5); |
| 2220 |
| 2076 static final TokenType MULTI_LINE_COMMENT = new TokenType.con1('MULTI_LINE_COM
MENT', 6); | 2221 static final TokenType MULTI_LINE_COMMENT = new TokenType.con1('MULTI_LINE_COM
MENT', 6); |
| 2222 |
| 2077 static final TokenType SCRIPT_TAG = new TokenType.con1('SCRIPT_TAG', 7); | 2223 static final TokenType SCRIPT_TAG = new TokenType.con1('SCRIPT_TAG', 7); |
| 2224 |
| 2078 static final TokenType SINGLE_LINE_COMMENT = new TokenType.con1('SINGLE_LINE_C
OMMENT', 8); | 2225 static final TokenType SINGLE_LINE_COMMENT = new TokenType.con1('SINGLE_LINE_C
OMMENT', 8); |
| 2226 |
| 2079 static final TokenType STRING = new TokenType.con1('STRING', 9); | 2227 static final TokenType STRING = new TokenType.con1('STRING', 9); |
| 2228 |
| 2080 static final TokenType AMPERSAND = new TokenType.con2('AMPERSAND', 10, TokenCl
ass.BITWISE_AND_OPERATOR, "&"); | 2229 static final TokenType AMPERSAND = new TokenType.con2('AMPERSAND', 10, TokenCl
ass.BITWISE_AND_OPERATOR, "&"); |
| 2230 |
| 2081 static final TokenType AMPERSAND_AMPERSAND = new TokenType.con2('AMPERSAND_AMP
ERSAND', 11, TokenClass.LOGICAL_AND_OPERATOR, "&&"); | 2231 static final TokenType AMPERSAND_AMPERSAND = new TokenType.con2('AMPERSAND_AMP
ERSAND', 11, TokenClass.LOGICAL_AND_OPERATOR, "&&"); |
| 2232 |
| 2082 static final TokenType AMPERSAND_EQ = new TokenType.con2('AMPERSAND_EQ', 12, T
okenClass.ASSIGNMENT_OPERATOR, "&="); | 2233 static final TokenType AMPERSAND_EQ = new TokenType.con2('AMPERSAND_EQ', 12, T
okenClass.ASSIGNMENT_OPERATOR, "&="); |
| 2234 |
| 2083 static final TokenType AT = new TokenType.con2('AT', 13, null, "@"); | 2235 static final TokenType AT = new TokenType.con2('AT', 13, null, "@"); |
| 2236 |
| 2084 static final TokenType BANG = new TokenType.con2('BANG', 14, TokenClass.UNARY_
PREFIX_OPERATOR, "!"); | 2237 static final TokenType BANG = new TokenType.con2('BANG', 14, TokenClass.UNARY_
PREFIX_OPERATOR, "!"); |
| 2238 |
| 2085 static final TokenType BANG_EQ = new TokenType.con2('BANG_EQ', 15, TokenClass.
EQUALITY_OPERATOR, "!="); | 2239 static final TokenType BANG_EQ = new TokenType.con2('BANG_EQ', 15, TokenClass.
EQUALITY_OPERATOR, "!="); |
| 2240 |
| 2086 static final TokenType BAR = new TokenType.con2('BAR', 16, TokenClass.BITWISE_
OR_OPERATOR, "|"); | 2241 static final TokenType BAR = new TokenType.con2('BAR', 16, TokenClass.BITWISE_
OR_OPERATOR, "|"); |
| 2242 |
| 2087 static final TokenType BAR_BAR = new TokenType.con2('BAR_BAR', 17, TokenClass.
LOGICAL_OR_OPERATOR, "||"); | 2243 static final TokenType BAR_BAR = new TokenType.con2('BAR_BAR', 17, TokenClass.
LOGICAL_OR_OPERATOR, "||"); |
| 2244 |
| 2088 static final TokenType BAR_EQ = new TokenType.con2('BAR_EQ', 18, TokenClass.AS
SIGNMENT_OPERATOR, "|="); | 2245 static final TokenType BAR_EQ = new TokenType.con2('BAR_EQ', 18, TokenClass.AS
SIGNMENT_OPERATOR, "|="); |
| 2246 |
| 2089 static final TokenType COLON = new TokenType.con2('COLON', 19, null, ":"); | 2247 static final TokenType COLON = new TokenType.con2('COLON', 19, null, ":"); |
| 2248 |
| 2090 static final TokenType COMMA = new TokenType.con2('COMMA', 20, null, ","); | 2249 static final TokenType COMMA = new TokenType.con2('COMMA', 20, null, ","); |
| 2250 |
| 2091 static final TokenType CARET = new TokenType.con2('CARET', 21, TokenClass.BITW
ISE_XOR_OPERATOR, "^"); | 2251 static final TokenType CARET = new TokenType.con2('CARET', 21, TokenClass.BITW
ISE_XOR_OPERATOR, "^"); |
| 2252 |
| 2092 static final TokenType CARET_EQ = new TokenType.con2('CARET_EQ', 22, TokenClas
s.ASSIGNMENT_OPERATOR, "^="); | 2253 static final TokenType CARET_EQ = new TokenType.con2('CARET_EQ', 22, TokenClas
s.ASSIGNMENT_OPERATOR, "^="); |
| 2254 |
| 2093 static final TokenType CLOSE_CURLY_BRACKET = new TokenType.con2('CLOSE_CURLY_B
RACKET', 23, null, "}"); | 2255 static final TokenType CLOSE_CURLY_BRACKET = new TokenType.con2('CLOSE_CURLY_B
RACKET', 23, null, "}"); |
| 2256 |
| 2094 static final TokenType CLOSE_PAREN = new TokenType.con2('CLOSE_PAREN', 24, nul
l, ")"); | 2257 static final TokenType CLOSE_PAREN = new TokenType.con2('CLOSE_PAREN', 24, nul
l, ")"); |
| 2258 |
| 2095 static final TokenType CLOSE_SQUARE_BRACKET = new TokenType.con2('CLOSE_SQUARE
_BRACKET', 25, null, "]"); | 2259 static final TokenType CLOSE_SQUARE_BRACKET = new TokenType.con2('CLOSE_SQUARE
_BRACKET', 25, null, "]"); |
| 2260 |
| 2096 static final TokenType EQ = new TokenType.con2('EQ', 26, TokenClass.ASSIGNMENT
_OPERATOR, "="); | 2261 static final TokenType EQ = new TokenType.con2('EQ', 26, TokenClass.ASSIGNMENT
_OPERATOR, "="); |
| 2262 |
| 2097 static final TokenType EQ_EQ = new TokenType.con2('EQ_EQ', 27, TokenClass.EQUA
LITY_OPERATOR, "=="); | 2263 static final TokenType EQ_EQ = new TokenType.con2('EQ_EQ', 27, TokenClass.EQUA
LITY_OPERATOR, "=="); |
| 2264 |
| 2098 static final TokenType FUNCTION = new TokenType.con2('FUNCTION', 28, null, "=>
"); | 2265 static final TokenType FUNCTION = new TokenType.con2('FUNCTION', 28, null, "=>
"); |
| 2266 |
| 2099 static final TokenType GT = new TokenType.con2('GT', 29, TokenClass.RELATIONAL
_OPERATOR, ">"); | 2267 static final TokenType GT = new TokenType.con2('GT', 29, TokenClass.RELATIONAL
_OPERATOR, ">"); |
| 2268 |
| 2100 static final TokenType GT_EQ = new TokenType.con2('GT_EQ', 30, TokenClass.RELA
TIONAL_OPERATOR, ">="); | 2269 static final TokenType GT_EQ = new TokenType.con2('GT_EQ', 30, TokenClass.RELA
TIONAL_OPERATOR, ">="); |
| 2270 |
| 2101 static final TokenType GT_GT = new TokenType.con2('GT_GT', 31, TokenClass.SHIF
T_OPERATOR, ">>"); | 2271 static final TokenType GT_GT = new TokenType.con2('GT_GT', 31, TokenClass.SHIF
T_OPERATOR, ">>"); |
| 2272 |
| 2102 static final TokenType GT_GT_EQ = new TokenType.con2('GT_GT_EQ', 32, TokenClas
s.ASSIGNMENT_OPERATOR, ">>="); | 2273 static final TokenType GT_GT_EQ = new TokenType.con2('GT_GT_EQ', 32, TokenClas
s.ASSIGNMENT_OPERATOR, ">>="); |
| 2274 |
| 2103 static final TokenType HASH = new TokenType.con2('HASH', 33, null, "#"); | 2275 static final TokenType HASH = new TokenType.con2('HASH', 33, null, "#"); |
| 2276 |
| 2104 static final TokenType INDEX = new TokenType.con2('INDEX', 34, TokenClass.UNAR
Y_POSTFIX_OPERATOR, "[]"); | 2277 static final TokenType INDEX = new TokenType.con2('INDEX', 34, TokenClass.UNAR
Y_POSTFIX_OPERATOR, "[]"); |
| 2278 |
| 2105 static final TokenType INDEX_EQ = new TokenType.con2('INDEX_EQ', 35, TokenClas
s.UNARY_POSTFIX_OPERATOR, "[]="); | 2279 static final TokenType INDEX_EQ = new TokenType.con2('INDEX_EQ', 35, TokenClas
s.UNARY_POSTFIX_OPERATOR, "[]="); |
| 2280 |
| 2106 static final TokenType IS = new TokenType.con2('IS', 36, TokenClass.RELATIONAL
_OPERATOR, "is"); | 2281 static final TokenType IS = new TokenType.con2('IS', 36, TokenClass.RELATIONAL
_OPERATOR, "is"); |
| 2282 |
| 2107 static final TokenType LT = new TokenType.con2('LT', 37, TokenClass.RELATIONAL
_OPERATOR, "<"); | 2283 static final TokenType LT = new TokenType.con2('LT', 37, TokenClass.RELATIONAL
_OPERATOR, "<"); |
| 2284 |
| 2108 static final TokenType LT_EQ = new TokenType.con2('LT_EQ', 38, TokenClass.RELA
TIONAL_OPERATOR, "<="); | 2285 static final TokenType LT_EQ = new TokenType.con2('LT_EQ', 38, TokenClass.RELA
TIONAL_OPERATOR, "<="); |
| 2286 |
| 2109 static final TokenType LT_LT = new TokenType.con2('LT_LT', 39, TokenClass.SHIF
T_OPERATOR, "<<"); | 2287 static final TokenType LT_LT = new TokenType.con2('LT_LT', 39, TokenClass.SHIF
T_OPERATOR, "<<"); |
| 2288 |
| 2110 static final TokenType LT_LT_EQ = new TokenType.con2('LT_LT_EQ', 40, TokenClas
s.ASSIGNMENT_OPERATOR, "<<="); | 2289 static final TokenType LT_LT_EQ = new TokenType.con2('LT_LT_EQ', 40, TokenClas
s.ASSIGNMENT_OPERATOR, "<<="); |
| 2290 |
| 2111 static final TokenType MINUS = new TokenType.con2('MINUS', 41, TokenClass.ADDI
TIVE_OPERATOR, "-"); | 2291 static final TokenType MINUS = new TokenType.con2('MINUS', 41, TokenClass.ADDI
TIVE_OPERATOR, "-"); |
| 2292 |
| 2112 static final TokenType MINUS_EQ = new TokenType.con2('MINUS_EQ', 42, TokenClas
s.ASSIGNMENT_OPERATOR, "-="); | 2293 static final TokenType MINUS_EQ = new TokenType.con2('MINUS_EQ', 42, TokenClas
s.ASSIGNMENT_OPERATOR, "-="); |
| 2294 |
| 2113 static final TokenType MINUS_MINUS = new TokenType.con2('MINUS_MINUS', 43, Tok
enClass.UNARY_PREFIX_OPERATOR, "--"); | 2295 static final TokenType MINUS_MINUS = new TokenType.con2('MINUS_MINUS', 43, Tok
enClass.UNARY_PREFIX_OPERATOR, "--"); |
| 2296 |
| 2114 static final TokenType OPEN_CURLY_BRACKET = new TokenType.con2('OPEN_CURLY_BRA
CKET', 44, null, "{"); | 2297 static final TokenType OPEN_CURLY_BRACKET = new TokenType.con2('OPEN_CURLY_BRA
CKET', 44, null, "{"); |
| 2298 |
| 2115 static final TokenType OPEN_PAREN = new TokenType.con2('OPEN_PAREN', 45, Token
Class.UNARY_POSTFIX_OPERATOR, "("); | 2299 static final TokenType OPEN_PAREN = new TokenType.con2('OPEN_PAREN', 45, Token
Class.UNARY_POSTFIX_OPERATOR, "("); |
| 2300 |
| 2116 static final TokenType OPEN_SQUARE_BRACKET = new TokenType.con2('OPEN_SQUARE_B
RACKET', 46, TokenClass.UNARY_POSTFIX_OPERATOR, "["); | 2301 static final TokenType OPEN_SQUARE_BRACKET = new TokenType.con2('OPEN_SQUARE_B
RACKET', 46, TokenClass.UNARY_POSTFIX_OPERATOR, "["); |
| 2302 |
| 2117 static final TokenType PERCENT = new TokenType.con2('PERCENT', 47, TokenClass.
MULTIPLICATIVE_OPERATOR, "%"); | 2303 static final TokenType PERCENT = new TokenType.con2('PERCENT', 47, TokenClass.
MULTIPLICATIVE_OPERATOR, "%"); |
| 2304 |
| 2118 static final TokenType PERCENT_EQ = new TokenType.con2('PERCENT_EQ', 48, Token
Class.ASSIGNMENT_OPERATOR, "%="); | 2305 static final TokenType PERCENT_EQ = new TokenType.con2('PERCENT_EQ', 48, Token
Class.ASSIGNMENT_OPERATOR, "%="); |
| 2306 |
| 2119 static final TokenType PERIOD = new TokenType.con2('PERIOD', 49, TokenClass.UN
ARY_POSTFIX_OPERATOR, "."); | 2307 static final TokenType PERIOD = new TokenType.con2('PERIOD', 49, TokenClass.UN
ARY_POSTFIX_OPERATOR, "."); |
| 2308 |
| 2120 static final TokenType PERIOD_PERIOD = new TokenType.con2('PERIOD_PERIOD', 50,
TokenClass.CASCADE_OPERATOR, ".."); | 2309 static final TokenType PERIOD_PERIOD = new TokenType.con2('PERIOD_PERIOD', 50,
TokenClass.CASCADE_OPERATOR, ".."); |
| 2310 |
| 2121 static final TokenType PLUS = new TokenType.con2('PLUS', 51, TokenClass.ADDITI
VE_OPERATOR, "+"); | 2311 static final TokenType PLUS = new TokenType.con2('PLUS', 51, TokenClass.ADDITI
VE_OPERATOR, "+"); |
| 2312 |
| 2122 static final TokenType PLUS_EQ = new TokenType.con2('PLUS_EQ', 52, TokenClass.
ASSIGNMENT_OPERATOR, "+="); | 2313 static final TokenType PLUS_EQ = new TokenType.con2('PLUS_EQ', 52, TokenClass.
ASSIGNMENT_OPERATOR, "+="); |
| 2314 |
| 2123 static final TokenType PLUS_PLUS = new TokenType.con2('PLUS_PLUS', 53, TokenCl
ass.UNARY_PREFIX_OPERATOR, "++"); | 2315 static final TokenType PLUS_PLUS = new TokenType.con2('PLUS_PLUS', 53, TokenCl
ass.UNARY_PREFIX_OPERATOR, "++"); |
| 2316 |
| 2124 static final TokenType QUESTION = new TokenType.con2('QUESTION', 54, TokenClas
s.CONDITIONAL_OPERATOR, "?"); | 2317 static final TokenType QUESTION = new TokenType.con2('QUESTION', 54, TokenClas
s.CONDITIONAL_OPERATOR, "?"); |
| 2318 |
| 2125 static final TokenType SEMICOLON = new TokenType.con2('SEMICOLON', 55, null, "
;"); | 2319 static final TokenType SEMICOLON = new TokenType.con2('SEMICOLON', 55, null, "
;"); |
| 2320 |
| 2126 static final TokenType SLASH = new TokenType.con2('SLASH', 56, TokenClass.MULT
IPLICATIVE_OPERATOR, "/"); | 2321 static final TokenType SLASH = new TokenType.con2('SLASH', 56, TokenClass.MULT
IPLICATIVE_OPERATOR, "/"); |
| 2322 |
| 2127 static final TokenType SLASH_EQ = new TokenType.con2('SLASH_EQ', 57, TokenClas
s.ASSIGNMENT_OPERATOR, "/="); | 2323 static final TokenType SLASH_EQ = new TokenType.con2('SLASH_EQ', 57, TokenClas
s.ASSIGNMENT_OPERATOR, "/="); |
| 2324 |
| 2128 static final TokenType STAR = new TokenType.con2('STAR', 58, TokenClass.MULTIP
LICATIVE_OPERATOR, "*"); | 2325 static final TokenType STAR = new TokenType.con2('STAR', 58, TokenClass.MULTIP
LICATIVE_OPERATOR, "*"); |
| 2326 |
| 2129 static final TokenType STAR_EQ = new TokenType.con2('STAR_EQ', 59, TokenClass.
ASSIGNMENT_OPERATOR, "*="); | 2327 static final TokenType STAR_EQ = new TokenType.con2('STAR_EQ', 59, TokenClass.
ASSIGNMENT_OPERATOR, "*="); |
| 2328 |
| 2130 static final TokenType STRING_INTERPOLATION_EXPRESSION = new TokenType.con2('S
TRING_INTERPOLATION_EXPRESSION', 60, null, "\${"); | 2329 static final TokenType STRING_INTERPOLATION_EXPRESSION = new TokenType.con2('S
TRING_INTERPOLATION_EXPRESSION', 60, null, "\${"); |
| 2330 |
| 2131 static final TokenType STRING_INTERPOLATION_IDENTIFIER = new TokenType.con2('S
TRING_INTERPOLATION_IDENTIFIER', 61, null, "\$"); | 2331 static final TokenType STRING_INTERPOLATION_IDENTIFIER = new TokenType.con2('S
TRING_INTERPOLATION_IDENTIFIER', 61, null, "\$"); |
| 2332 |
| 2132 static final TokenType TILDE = new TokenType.con2('TILDE', 62, TokenClass.UNAR
Y_PREFIX_OPERATOR, "~"); | 2333 static final TokenType TILDE = new TokenType.con2('TILDE', 62, TokenClass.UNAR
Y_PREFIX_OPERATOR, "~"); |
| 2334 |
| 2133 static final TokenType TILDE_SLASH = new TokenType.con2('TILDE_SLASH', 63, Tok
enClass.MULTIPLICATIVE_OPERATOR, "~/"); | 2335 static final TokenType TILDE_SLASH = new TokenType.con2('TILDE_SLASH', 63, Tok
enClass.MULTIPLICATIVE_OPERATOR, "~/"); |
| 2336 |
| 2134 static final TokenType TILDE_SLASH_EQ = new TokenType.con2('TILDE_SLASH_EQ', 6
4, TokenClass.ASSIGNMENT_OPERATOR, "~/="); | 2337 static final TokenType TILDE_SLASH_EQ = new TokenType.con2('TILDE_SLASH_EQ', 6
4, TokenClass.ASSIGNMENT_OPERATOR, "~/="); |
| 2338 |
| 2135 static final TokenType BACKPING = new TokenType.con2('BACKPING', 65, null, "`"
); | 2339 static final TokenType BACKPING = new TokenType.con2('BACKPING', 65, null, "`"
); |
| 2340 |
| 2136 static final TokenType BACKSLASH = new TokenType.con2('BACKSLASH', 66, null, "
\\"); | 2341 static final TokenType BACKSLASH = new TokenType.con2('BACKSLASH', 66, null, "
\\"); |
| 2342 |
| 2137 static final TokenType PERIOD_PERIOD_PERIOD = new TokenType.con2('PERIOD_PERIO
D_PERIOD', 67, null, "..."); | 2343 static final TokenType PERIOD_PERIOD_PERIOD = new TokenType.con2('PERIOD_PERIO
D_PERIOD', 67, null, "..."); |
| 2344 |
| 2138 static final List<TokenType> values = [ | 2345 static final List<TokenType> values = [ |
| 2139 EOF, | 2346 EOF, |
| 2140 DOUBLE, | 2347 DOUBLE, |
| 2141 HEXADECIMAL, | 2348 HEXADECIMAL, |
| 2142 IDENTIFIER, | 2349 IDENTIFIER, |
| 2143 INT, | 2350 INT, |
| 2144 KEYWORD, | 2351 KEYWORD, |
| 2145 MULTI_LINE_COMMENT, | 2352 MULTI_LINE_COMMENT, |
| 2146 SCRIPT_TAG, | 2353 SCRIPT_TAG, |
| 2147 SINGLE_LINE_COMMENT, | 2354 SINGLE_LINE_COMMENT, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2208 /** | 2415 /** |
| 2209 * The class of the token. | 2416 * The class of the token. |
| 2210 */ | 2417 */ |
| 2211 TokenClass _tokenClass; | 2418 TokenClass _tokenClass; |
| 2212 | 2419 |
| 2213 /** | 2420 /** |
| 2214 * The lexeme that defines this type of token, or `null` if there is more than
one possible | 2421 * The lexeme that defines this type of token, or `null` if there is more than
one possible |
| 2215 * lexeme for this type of token. | 2422 * lexeme for this type of token. |
| 2216 */ | 2423 */ |
| 2217 String lexeme; | 2424 String lexeme; |
| 2425 |
| 2218 TokenType.con1(String name, int ordinal) : this.con2(name, ordinal, TokenClass
.NO_CLASS, null); | 2426 TokenType.con1(String name, int ordinal) : this.con2(name, ordinal, TokenClass
.NO_CLASS, null); |
| 2427 |
| 2219 TokenType.con2(String name, int ordinal, TokenClass tokenClass, String lexeme)
: super(name, ordinal) { | 2428 TokenType.con2(String name, int ordinal, TokenClass tokenClass, String lexeme)
: super(name, ordinal) { |
| 2220 this._tokenClass = tokenClass == null ? TokenClass.NO_CLASS : tokenClass; | 2429 this._tokenClass = tokenClass == null ? TokenClass.NO_CLASS : tokenClass; |
| 2221 this.lexeme = lexeme; | 2430 this.lexeme = lexeme; |
| 2222 } | 2431 } |
| 2223 | 2432 |
| 2224 /** | 2433 /** |
| 2225 * Return the precedence of the token, or `0` if the token does not represent
an operator. | 2434 * Return the precedence of the token, or `0` if the token does not represent
an operator. |
| 2226 * | 2435 * |
| 2227 * @return the precedence of the token | 2436 * @return the precedence of the token |
| 2228 */ | 2437 */ |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2312 */ | 2521 */ |
| 2313 bool get isUnaryPrefixOperator => identical(_tokenClass, TokenClass.UNARY_PREF
IX_OPERATOR); | 2522 bool get isUnaryPrefixOperator => identical(_tokenClass, TokenClass.UNARY_PREF
IX_OPERATOR); |
| 2314 | 2523 |
| 2315 /** | 2524 /** |
| 2316 * Return `true` if this token type represents an operator that can be defined
by users. | 2525 * Return `true` if this token type represents an operator that can be defined
by users. |
| 2317 * | 2526 * |
| 2318 * @return `true` if this token type represents an operator that can be define
d by users | 2527 * @return `true` if this token type represents an operator that can be define
d by users |
| 2319 */ | 2528 */ |
| 2320 bool get isUserDefinableOperator => identical(lexeme, "==") || identical(lexem
e, "~") || identical(lexeme, "[]") || identical(lexeme, "[]=") || identical(lexe
me, "*") || identical(lexeme, "/") || identical(lexeme, "%") || identical(lexeme
, "~/") || identical(lexeme, "+") || identical(lexeme, "-") || identical(lexeme,
"<<") || identical(lexeme, ">>") || identical(lexeme, ">=") || identical(lexeme
, ">") || identical(lexeme, "<=") || identical(lexeme, "<") || identical(lexeme,
"&") || identical(lexeme, "^") || identical(lexeme, "|"); | 2529 bool get isUserDefinableOperator => identical(lexeme, "==") || identical(lexem
e, "~") || identical(lexeme, "[]") || identical(lexeme, "[]=") || identical(lexe
me, "*") || identical(lexeme, "/") || identical(lexeme, "%") || identical(lexeme
, "~/") || identical(lexeme, "+") || identical(lexeme, "-") || identical(lexeme,
"<<") || identical(lexeme, ">>") || identical(lexeme, ">=") || identical(lexeme
, ">") || identical(lexeme, "<=") || identical(lexeme, "<") || identical(lexeme,
"&") || identical(lexeme, "^") || identical(lexeme, "|"); |
| 2321 } | 2530 } |
| 2531 |
| 2322 class TokenType_EOF extends TokenType { | 2532 class TokenType_EOF extends TokenType { |
| 2323 TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) : super.
con2(name, ordinal, arg0, arg1); | 2533 TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) : super.
con2(name, ordinal, arg0, arg1); |
| 2534 |
| 2324 String toString() => "-eof-"; | 2535 String toString() => "-eof-"; |
| 2325 } | 2536 } |
| OLD | NEW |