| 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 library engine.scanner; | 3 library engine.scanner; |
| 4 import 'dart:collection'; | 4 import 'dart:collection'; |
| 5 import 'java_core.dart'; | 5 import 'java_core.dart'; |
| 6 import 'java_engine.dart'; | 6 import 'java_engine.dart'; |
| 7 import 'source.dart'; | 7 import 'source.dart'; |
| 8 import 'error.dart'; | 8 import 'error.dart'; |
| 9 import 'instrumentation.dart'; | 9 import 'instrumentation.dart'; |
| 10 /** | 10 /** |
| 11 * Instances of the abstract class {@code KeywordState} represent a state in a s
tate machine used to | 11 * Instances of the abstract class `KeywordState` represent a state in a state m
achine used to |
| 12 * scan keywords. | 12 * scan keywords. |
| 13 * @coverage dart.engine.parser | 13 * @coverage dart.engine.parser |
| 14 */ | 14 */ |
| 15 class KeywordState { | 15 class KeywordState { |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * An empty transition table used by leaf states. | 18 * An empty transition table used by leaf states. |
| 19 */ | 19 */ |
| 20 static List<KeywordState> _EMPTY_TABLE = new List<KeywordState>(26); | 20 static List<KeywordState> _EMPTY_TABLE = new List<KeywordState>(26); |
| 21 | 21 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 List<String> strings = new List<String>(values.length); | 80 List<String> strings = new List<String>(values.length); |
| 81 for (int i = 0; i < values.length; i++) { | 81 for (int i = 0; i < values.length; i++) { |
| 82 strings[i] = values[i].syntax; | 82 strings[i] = values[i].syntax; |
| 83 } | 83 } |
| 84 strings.sort(); | 84 strings.sort(); |
| 85 return computeKeywordStateTable(0, strings, 0, strings.length); | 85 return computeKeywordStateTable(0, strings, 0, strings.length); |
| 86 } | 86 } |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * A table mapping characters to the states to which those characters will tra
nsition. (The index | 89 * A table mapping characters to the states to which those characters will tra
nsition. (The index |
| 90 * into the array is the offset from the character {@code 'a'} to the transiti
oning character.) | 90 * into the array is the offset from the character `'a'` to the transitioning
character.) |
| 91 */ | 91 */ |
| 92 List<KeywordState> _table; | 92 List<KeywordState> _table; |
| 93 | 93 |
| 94 /** | 94 /** |
| 95 * The keyword that is recognized by this state, or {@code null} if this state
is not a terminal | 95 * The keyword that is recognized by this state, or `null` if this state is no
t a terminal |
| 96 * state. | 96 * state. |
| 97 */ | 97 */ |
| 98 Keyword _keyword2; | 98 Keyword _keyword2; |
| 99 | 99 |
| 100 /** | 100 /** |
| 101 * Initialize a newly created state to have the given transitions and to recog
nize the keyword | 101 * Initialize a newly created state to have the given transitions and to recog
nize the keyword |
| 102 * with the given syntax. | 102 * with the given syntax. |
| 103 * @param table a table mapping characters to the states to which those charac
ters will transition | 103 * @param table a table mapping characters to the states to which those charac
ters will transition |
| 104 * @param syntax the syntax of the keyword that is recognized by the state | 104 * @param syntax the syntax of the keyword that is recognized by the state |
| 105 */ | 105 */ |
| 106 KeywordState(List<KeywordState> table, String syntax) { | 106 KeywordState(List<KeywordState> table, String syntax) { |
| 107 this._table = table; | 107 this._table = table; |
| 108 this._keyword2 = (syntax == null) ? null : Keyword.keywords[syntax]; | 108 this._keyword2 = (syntax == null) ? null : Keyword.keywords[syntax]; |
| 109 } | 109 } |
| 110 | 110 |
| 111 /** | 111 /** |
| 112 * Return the keyword that was recognized by this state, or {@code null} if th
is state does not | 112 * Return the keyword that was recognized by this state, or `null` if this sta
te does not |
| 113 * recognized a keyword. | 113 * recognized a keyword. |
| 114 * @return the keyword that was matched by reaching this state | 114 * @return the keyword that was matched by reaching this state |
| 115 */ | 115 */ |
| 116 Keyword keyword() => _keyword2; | 116 Keyword keyword() => _keyword2; |
| 117 | 117 |
| 118 /** | 118 /** |
| 119 * Return the state that follows this state on a transition of the given chara
cter, or{@code null} if there is no valid state reachable from this state with s
uch a transition. | 119 * Return the state that follows this state on a transition of the given chara
cter, or`null` if there is no valid state reachable from this state with such a
transition. |
| 120 * @param c the character used to transition from this state to another state | 120 * @param c the character used to transition from this state to another state |
| 121 * @return the state that follows this state on a transition of the given char
acter | 121 * @return the state that follows this state on a transition of the given char
acter |
| 122 */ | 122 */ |
| 123 KeywordState next(int c) => _table[c - 0x61]; | 123 KeywordState next(int c) => _table[c - 0x61]; |
| 124 } | 124 } |
| 125 /** | 125 /** |
| 126 * The enumeration {@code ScannerErrorCode} defines the error codes used for err
ors detected by the | 126 * The enumeration `ScannerErrorCode` defines the error codes used for errors de
tected by the |
| 127 * scanner. | 127 * scanner. |
| 128 * @coverage dart.engine.parser | 128 * @coverage dart.engine.parser |
| 129 */ | 129 */ |
| 130 class ScannerErrorCode implements Comparable<ScannerErrorCode>, ErrorCode { | 130 class ScannerErrorCode implements Comparable<ScannerErrorCode>, ErrorCode { |
| 131 static final ScannerErrorCode ILLEGAL_CHARACTER = new ScannerErrorCode('ILLEGA
L_CHARACTER', 0, "Illegal character %x"); | 131 static final ScannerErrorCode ILLEGAL_CHARACTER = new ScannerErrorCode('ILLEGA
L_CHARACTER', 0, "Illegal character %x"); |
| 132 static final ScannerErrorCode MISSING_DIGIT = new ScannerErrorCode('MISSING_DI
GIT', 1, "Decimal digit expected"); | 132 static final ScannerErrorCode MISSING_DIGIT = new ScannerErrorCode('MISSING_DI
GIT', 1, "Decimal digit expected"); |
| 133 static final ScannerErrorCode MISSING_HEX_DIGIT = new ScannerErrorCode('MISSIN
G_HEX_DIGIT', 2, "Hexidecimal digit expected"); | 133 static final ScannerErrorCode MISSING_HEX_DIGIT = new ScannerErrorCode('MISSIN
G_HEX_DIGIT', 2, "Hexidecimal digit expected"); |
| 134 static final ScannerErrorCode MISSING_QUOTE = new ScannerErrorCode('MISSING_QU
OTE', 3, "Expected quote (' or \")"); | 134 static final ScannerErrorCode MISSING_QUOTE = new ScannerErrorCode('MISSING_QU
OTE', 3, "Expected quote (' or \")"); |
| 135 static final ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT = new ScannerErr
orCode('UNTERMINATED_MULTI_LINE_COMMENT', 4, "Unterminated multi-line comment"); | 135 static final ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT = new ScannerErr
orCode('UNTERMINATED_MULTI_LINE_COMMENT', 4, "Unterminated multi-line comment"); |
| 136 static final ScannerErrorCode UNTERMINATED_STRING_LITERAL = new ScannerErrorCo
de('UNTERMINATED_STRING_LITERAL', 5, "Unterminated string literal"); | 136 static final ScannerErrorCode UNTERMINATED_STRING_LITERAL = new ScannerErrorCo
de('UNTERMINATED_STRING_LITERAL', 5, "Unterminated string literal"); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 155 this._message = message; | 155 this._message = message; |
| 156 } | 156 } |
| 157 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; | 157 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; |
| 158 String get message => _message; | 158 String get message => _message; |
| 159 ErrorType get type => ErrorType.SYNTACTIC_ERROR; | 159 ErrorType get type => ErrorType.SYNTACTIC_ERROR; |
| 160 int compareTo(ScannerErrorCode other) => ordinal - other.ordinal; | 160 int compareTo(ScannerErrorCode other) => ordinal - other.ordinal; |
| 161 int get hashCode => ordinal; | 161 int get hashCode => ordinal; |
| 162 String toString() => name; | 162 String toString() => name; |
| 163 } | 163 } |
| 164 /** | 164 /** |
| 165 * Instances of the class {@code TokenWithComment} represent a string token that
is preceded by | 165 * Instances of the class `TokenWithComment` represent a string token that is pr
eceded by |
| 166 * comments. | 166 * comments. |
| 167 * @coverage dart.engine.parser | 167 * @coverage dart.engine.parser |
| 168 */ | 168 */ |
| 169 class StringTokenWithComment extends StringToken { | 169 class StringTokenWithComment extends StringToken { |
| 170 | 170 |
| 171 /** | 171 /** |
| 172 * The first comment in the list of comments that precede this token. | 172 * The first comment in the list of comments that precede this token. |
| 173 */ | 173 */ |
| 174 Token _precedingComment; | 174 Token _precedingComment; |
| 175 | 175 |
| 176 /** | 176 /** |
| 177 * Initialize a newly created token to have the given type and offset and to b
e preceded by the | 177 * Initialize a newly created token to have the given type and offset and to b
e preceded by the |
| 178 * comments reachable from the given comment. | 178 * comments reachable from the given comment. |
| 179 * @param type the type of the token | 179 * @param type the type of the token |
| 180 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 180 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 181 * @param precedingComment the first comment in the list of comments that prec
ede this token | 181 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 182 */ | 182 */ |
| 183 StringTokenWithComment(TokenType type, String value, int offset, Token precedi
ngComment) : super(type, value, offset) { | 183 StringTokenWithComment(TokenType type, String value, int offset, Token precedi
ngComment) : super(type, value, offset) { |
| 184 this._precedingComment = precedingComment; | 184 this._precedingComment = precedingComment; |
| 185 } | 185 } |
| 186 Token get precedingComments => _precedingComment; | 186 Token get precedingComments => _precedingComment; |
| 187 } | 187 } |
| 188 /** | 188 /** |
| 189 * The enumeration {@code Keyword} defines the keywords in the Dart programming
language. | 189 * The enumeration `Keyword` defines the keywords in the Dart programming langua
ge. |
| 190 * @coverage dart.engine.parser | 190 * @coverage dart.engine.parser |
| 191 */ | 191 */ |
| 192 class Keyword implements Comparable<Keyword> { | 192 class Keyword implements Comparable<Keyword> { |
| 193 static final Keyword ASSERT = new Keyword.con1('ASSERT', 0, "assert"); | 193 static final Keyword ASSERT = new Keyword.con1('ASSERT', 0, "assert"); |
| 194 static final Keyword BREAK = new Keyword.con1('BREAK', 1, "break"); | 194 static final Keyword BREAK = new Keyword.con1('BREAK', 1, "break"); |
| 195 static final Keyword CASE = new Keyword.con1('CASE', 2, "case"); | 195 static final Keyword CASE = new Keyword.con1('CASE', 2, "case"); |
| 196 static final Keyword CATCH = new Keyword.con1('CATCH', 3, "catch"); | 196 static final Keyword CATCH = new Keyword.con1('CATCH', 3, "catch"); |
| 197 static final Keyword CLASS = new Keyword.con1('CLASS', 4, "class"); | 197 static final Keyword CLASS = new Keyword.con1('CLASS', 4, "class"); |
| 198 static final Keyword CONST = new Keyword.con1('CONST', 5, "const"); | 198 static final Keyword CONST = new Keyword.con1('CONST', 5, "const"); |
| 199 static final Keyword CONTINUE = new Keyword.con1('CONTINUE', 6, "continue"); | 199 static final Keyword CONTINUE = new Keyword.con1('CONTINUE', 6, "continue"); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 */ | 281 */ |
| 282 Keyword.con1(this.name, this.ordinal, String syntax) { | 282 Keyword.con1(this.name, this.ordinal, String syntax) { |
| 283 _jtd_constructor_318_impl(syntax); | 283 _jtd_constructor_318_impl(syntax); |
| 284 } | 284 } |
| 285 _jtd_constructor_318_impl(String syntax) { | 285 _jtd_constructor_318_impl(String syntax) { |
| 286 _jtd_constructor_319_impl(syntax, false); | 286 _jtd_constructor_319_impl(syntax, false); |
| 287 } | 287 } |
| 288 | 288 |
| 289 /** | 289 /** |
| 290 * Initialize a newly created keyword to have the given syntax. The keyword is
a pseudo-keyword if | 290 * Initialize a newly created keyword to have the given syntax. The keyword is
a pseudo-keyword if |
| 291 * the given flag is {@code true}. | 291 * the given flag is `true`. |
| 292 * @param syntax the lexeme for the keyword | 292 * @param syntax the lexeme for the keyword |
| 293 * @param isPseudoKeyword {@code true} if this keyword is a pseudo-keyword | 293 * @param isPseudoKeyword `true` if this keyword is a pseudo-keyword |
| 294 */ | 294 */ |
| 295 Keyword.con2(this.name, this.ordinal, String syntax2, bool isPseudoKeyword) { | 295 Keyword.con2(this.name, this.ordinal, String syntax2, bool isPseudoKeyword) { |
| 296 _jtd_constructor_319_impl(syntax2, isPseudoKeyword); | 296 _jtd_constructor_319_impl(syntax2, isPseudoKeyword); |
| 297 } | 297 } |
| 298 _jtd_constructor_319_impl(String syntax2, bool isPseudoKeyword) { | 298 _jtd_constructor_319_impl(String syntax2, bool isPseudoKeyword) { |
| 299 this._syntax = syntax2; | 299 this._syntax = syntax2; |
| 300 this._isPseudoKeyword2 = isPseudoKeyword; | 300 this._isPseudoKeyword2 = isPseudoKeyword; |
| 301 } | 301 } |
| 302 | 302 |
| 303 /** | 303 /** |
| 304 * Return the lexeme for the keyword. | 304 * Return the lexeme for the keyword. |
| 305 * @return the lexeme for the keyword | 305 * @return the lexeme for the keyword |
| 306 */ | 306 */ |
| 307 String get syntax => _syntax; | 307 String get syntax => _syntax; |
| 308 | 308 |
| 309 /** | 309 /** |
| 310 * Return {@code true} if this keyword is a pseudo-keyword. Pseudo keywords ca
n be used as | 310 * Return `true` if this keyword is a pseudo-keyword. Pseudo keywords can be u
sed as |
| 311 * identifiers. | 311 * identifiers. |
| 312 * @return {@code true} if this keyword is a pseudo-keyword | 312 * @return `true` if this keyword is a pseudo-keyword |
| 313 */ | 313 */ |
| 314 bool isPseudoKeyword() => _isPseudoKeyword2; | 314 bool isPseudoKeyword() => _isPseudoKeyword2; |
| 315 int compareTo(Keyword other) => ordinal - other.ordinal; | 315 int compareTo(Keyword other) => ordinal - other.ordinal; |
| 316 int get hashCode => ordinal; | 316 int get hashCode => ordinal; |
| 317 String toString() => name; | 317 String toString() => name; |
| 318 } | 318 } |
| 319 /** | 319 /** |
| 320 * The abstract class {@code AbstractScanner} implements a scanner for Dart code
. Subclasses are | 320 * The abstract class `AbstractScanner` implements a scanner for Dart code. Subc
lasses are |
| 321 * required to implement the interface used to access the characters being scann
ed. | 321 * required to implement the interface used to access the characters being scann
ed. |
| 322 * <p> | 322 * |
| 323 * The lexical structure of Dart is ambiguous without knowledge of the context i
n which a token is | 323 * The lexical structure of Dart is ambiguous without knowledge of the context i
n which a token is |
| 324 * being scanned. For example, without context we cannot determine whether sourc
e of the form "<<" | 324 * being scanned. For example, without context we cannot determine whether sourc
e of the form "<<" |
| 325 * should be scanned as a single left-shift operator or as two left angle bracke
ts. This scanner | 325 * should be scanned as a single left-shift operator or as two left angle bracke
ts. This scanner |
| 326 * does not have any context, so it always resolves such conflicts by scanning t
he longest possible | 326 * does not have any context, so it always resolves such conflicts by scanning t
he longest possible |
| 327 * token. | 327 * token. |
| 328 * @coverage dart.engine.parser | 328 * @coverage dart.engine.parser |
| 329 */ | 329 */ |
| 330 abstract class AbstractScanner { | 330 abstract class AbstractScanner { |
| 331 | 331 |
| 332 /** | 332 /** |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 | 408 |
| 409 /** | 409 /** |
| 410 * Return the current offset relative to the beginning of the file. Return the
initial offset if | 410 * Return the current offset relative to the beginning of the file. Return the
initial offset if |
| 411 * the scanner has not yet scanned the source code, and one (1) past the end o
f the source code if | 411 * the scanner has not yet scanned the source code, and one (1) past the end o
f the source code if |
| 412 * the source code has been scanned. | 412 * the source code has been scanned. |
| 413 * @return the current offset of the scanner in the source | 413 * @return the current offset of the scanner in the source |
| 414 */ | 414 */ |
| 415 int get offset; | 415 int get offset; |
| 416 | 416 |
| 417 /** | 417 /** |
| 418 * Return {@code true} if any unmatched groups were found during the parse. | 418 * Return `true` if any unmatched groups were found during the parse. |
| 419 * @return {@code true} if any unmatched groups were found during the parse | 419 * @return `true` if any unmatched groups were found during the parse |
| 420 */ | 420 */ |
| 421 bool hasUnmatchedGroups() => _hasUnmatchedGroups2; | 421 bool hasUnmatchedGroups() => _hasUnmatchedGroups2; |
| 422 | 422 |
| 423 /** | 423 /** |
| 424 * Scan the source code to produce a list of tokens representing the source. | 424 * Scan the source code to produce a list of tokens representing the source. |
| 425 * @return the first token in the list of tokens that were produced | 425 * @return the first token in the list of tokens that were produced |
| 426 */ | 426 */ |
| 427 Token tokenize() { | 427 Token tokenize() { |
| 428 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi
ne.AbstractScanner.tokenize"); | 428 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi
ne.AbstractScanner.tokenize"); |
| 429 int tokenCounter = 0; | 429 int tokenCounter = 0; |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 next = advance(); | 1265 next = advance(); |
| 1266 if (next == 0x2F) { | 1266 if (next == 0x2F) { |
| 1267 return select(0x3D, TokenType.TILDE_SLASH_EQ, TokenType.TILDE_SLASH); | 1267 return select(0x3D, TokenType.TILDE_SLASH_EQ, TokenType.TILDE_SLASH); |
| 1268 } else { | 1268 } else { |
| 1269 appendToken(TokenType.TILDE); | 1269 appendToken(TokenType.TILDE); |
| 1270 return next; | 1270 return next; |
| 1271 } | 1271 } |
| 1272 } | 1272 } |
| 1273 } | 1273 } |
| 1274 /** | 1274 /** |
| 1275 * Instances of the class {@code StringToken} represent a token whose value is i
ndependent of it's | 1275 * Instances of the class `StringToken` represent a token whose value is indepen
dent of it's |
| 1276 * type. | 1276 * type. |
| 1277 * @coverage dart.engine.parser | 1277 * @coverage dart.engine.parser |
| 1278 */ | 1278 */ |
| 1279 class StringToken extends Token { | 1279 class StringToken extends Token { |
| 1280 | 1280 |
| 1281 /** | 1281 /** |
| 1282 * The lexeme represented by this token. | 1282 * The lexeme represented by this token. |
| 1283 */ | 1283 */ |
| 1284 String _value2; | 1284 String _value2; |
| 1285 | 1285 |
| 1286 /** | 1286 /** |
| 1287 * Initialize a newly created token to represent a token of the given type wit
h the given value. | 1287 * Initialize a newly created token to represent a token of the given type wit
h the given value. |
| 1288 * @param type the type of the token | 1288 * @param type the type of the token |
| 1289 * @param value the lexeme represented by this token | 1289 * @param value the lexeme represented by this token |
| 1290 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1290 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1291 */ | 1291 */ |
| 1292 StringToken(TokenType type, String value, int offset) : super(type, offset) { | 1292 StringToken(TokenType type, String value, int offset) : super(type, offset) { |
| 1293 this._value2 = StringUtilities.intern(value); | 1293 this._value2 = StringUtilities.intern(value); |
| 1294 } | 1294 } |
| 1295 String get lexeme => _value2; | 1295 String get lexeme => _value2; |
| 1296 String value() => _value2; | 1296 String value() => _value2; |
| 1297 } | 1297 } |
| 1298 /** | 1298 /** |
| 1299 * Instances of the class {@code CharBufferScanner} implement a scanner that rea
ds from a character | 1299 * Instances of the class `CharBufferScanner` implement a scanner that reads fro
m a character |
| 1300 * buffer. The scanning logic is in the superclass. | 1300 * buffer. The scanning logic is in the superclass. |
| 1301 * @coverage dart.engine.parser | 1301 * @coverage dart.engine.parser |
| 1302 */ | 1302 */ |
| 1303 class CharBufferScanner extends AbstractScanner { | 1303 class CharBufferScanner extends AbstractScanner { |
| 1304 | 1304 |
| 1305 /** | 1305 /** |
| 1306 * The buffer from which characters will be read. | 1306 * The buffer from which characters will be read. |
| 1307 */ | 1307 */ |
| 1308 CharBuffer _buffer; | 1308 CharBuffer _buffer; |
| 1309 | 1309 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1337 } | 1337 } |
| 1338 String getString(int start, int endDelta) => ((_buffer as CharSequence)).subSe
quence(start, _charOffset + 1 + endDelta).toString(); | 1338 String getString(int start, int endDelta) => ((_buffer as CharSequence)).subSe
quence(start, _charOffset + 1 + endDelta).toString(); |
| 1339 int peek() { | 1339 int peek() { |
| 1340 if (_charOffset + 1 >= _buffer.length()) { | 1340 if (_charOffset + 1 >= _buffer.length()) { |
| 1341 return -1; | 1341 return -1; |
| 1342 } | 1342 } |
| 1343 return _buffer.charAt(_charOffset + 1); | 1343 return _buffer.charAt(_charOffset + 1); |
| 1344 } | 1344 } |
| 1345 } | 1345 } |
| 1346 /** | 1346 /** |
| 1347 * Instances of the class {@code TokenWithComment} represent a normal token that
is preceded by | 1347 * Instances of the class `TokenWithComment` represent a normal token that is pr
eceded by |
| 1348 * comments. | 1348 * comments. |
| 1349 * @coverage dart.engine.parser | 1349 * @coverage dart.engine.parser |
| 1350 */ | 1350 */ |
| 1351 class TokenWithComment extends Token { | 1351 class TokenWithComment extends Token { |
| 1352 | 1352 |
| 1353 /** | 1353 /** |
| 1354 * The first comment in the list of comments that precede this token. | 1354 * The first comment in the list of comments that precede this token. |
| 1355 */ | 1355 */ |
| 1356 Token _precedingComment; | 1356 Token _precedingComment; |
| 1357 | 1357 |
| 1358 /** | 1358 /** |
| 1359 * Initialize a newly created token to have the given type and offset and to b
e preceded by the | 1359 * Initialize a newly created token to have the given type and offset and to b
e preceded by the |
| 1360 * comments reachable from the given comment. | 1360 * comments reachable from the given comment. |
| 1361 * @param type the type of the token | 1361 * @param type the type of the token |
| 1362 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1362 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1363 * @param precedingComment the first comment in the list of comments that prec
ede this token | 1363 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 1364 */ | 1364 */ |
| 1365 TokenWithComment(TokenType type, int offset, Token precedingComment) : super(t
ype, offset) { | 1365 TokenWithComment(TokenType type, int offset, Token precedingComment) : super(t
ype, offset) { |
| 1366 this._precedingComment = precedingComment; | 1366 this._precedingComment = precedingComment; |
| 1367 } | 1367 } |
| 1368 Token get precedingComments => _precedingComment; | 1368 Token get precedingComments => _precedingComment; |
| 1369 } | 1369 } |
| 1370 /** | 1370 /** |
| 1371 * Instances of the class {@code Token} represent a token that was scanned from
the input. Each | 1371 * Instances of the class `Token` represent a token that was scanned from the in
put. Each |
| 1372 * token knows which token follows it, acting as the head of a linked list of to
kens. | 1372 * token knows which token follows it, acting as the head of a linked list of to
kens. |
| 1373 * @coverage dart.engine.parser | 1373 * @coverage dart.engine.parser |
| 1374 */ | 1374 */ |
| 1375 class Token { | 1375 class Token { |
| 1376 | 1376 |
| 1377 /** | 1377 /** |
| 1378 * The type of the token. | 1378 * The type of the token. |
| 1379 */ | 1379 */ |
| 1380 TokenType _type; | 1380 TokenType _type; |
| 1381 | 1381 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1430 */ | 1430 */ |
| 1431 Token get next => _next; | 1431 Token get next => _next; |
| 1432 | 1432 |
| 1433 /** | 1433 /** |
| 1434 * Return the offset from the beginning of the file to the first character in
the token. | 1434 * Return the offset from the beginning of the file to the first character in
the token. |
| 1435 * @return the offset from the beginning of the file to the first character in
the token | 1435 * @return the offset from the beginning of the file to the first character in
the token |
| 1436 */ | 1436 */ |
| 1437 int get offset => _offset; | 1437 int get offset => _offset; |
| 1438 | 1438 |
| 1439 /** | 1439 /** |
| 1440 * Return the first comment in the list of comments that precede this token, o
r {@code null} if | 1440 * Return the first comment in the list of comments that precede this token, o
r `null` if |
| 1441 * there are no comments preceding this token. Additional comments can be reac
hed by following the | 1441 * there are no comments preceding this token. Additional comments can be reac
hed by following the |
| 1442 * token stream using {@link #getNext()} until {@code null} is returned. | 1442 * token stream using [getNext] until `null` is returned. |
| 1443 * @return the first comment in the list of comments that precede this token | 1443 * @return the first comment in the list of comments that precede this token |
| 1444 */ | 1444 */ |
| 1445 Token get precedingComments => null; | 1445 Token get precedingComments => null; |
| 1446 | 1446 |
| 1447 /** | 1447 /** |
| 1448 * Return the previous token in the token stream. | 1448 * Return the previous token in the token stream. |
| 1449 * @return the previous token in the token stream | 1449 * @return the previous token in the token stream |
| 1450 */ | 1450 */ |
| 1451 Token get previous => _previous; | 1451 Token get previous => _previous; |
| 1452 | 1452 |
| 1453 /** | 1453 /** |
| 1454 * Return the type of the token. | 1454 * Return the type of the token. |
| 1455 * @return the type of the token | 1455 * @return the type of the token |
| 1456 */ | 1456 */ |
| 1457 TokenType get type => _type; | 1457 TokenType get type => _type; |
| 1458 | 1458 |
| 1459 /** | 1459 /** |
| 1460 * Return {@code true} if this token represents an operator. | 1460 * Return `true` if this token represents an operator. |
| 1461 * @return {@code true} if this token represents an operator | 1461 * @return `true` if this token represents an operator |
| 1462 */ | 1462 */ |
| 1463 bool isOperator() => _type.isOperator(); | 1463 bool isOperator() => _type.isOperator(); |
| 1464 | 1464 |
| 1465 /** | 1465 /** |
| 1466 * Return {@code true} if this token is a synthetic token. A synthetic token i
s a token that was | 1466 * Return `true` if this token is a synthetic token. A synthetic token is a to
ken that was |
| 1467 * introduced by the parser in order to recover from an error in the code. Syn
thetic tokens always | 1467 * introduced by the parser in order to recover from an error in the code. Syn
thetic tokens always |
| 1468 * have a length of zero ({@code 0}). | 1468 * have a length of zero (`0`). |
| 1469 * @return {@code true} if this token is a synthetic token | 1469 * @return `true` if this token is a synthetic token |
| 1470 */ | 1470 */ |
| 1471 bool isSynthetic() => length == 0; | 1471 bool isSynthetic() => length == 0; |
| 1472 | 1472 |
| 1473 /** | 1473 /** |
| 1474 * Return {@code true} if this token represents an operator that can be define
d by users. | 1474 * Return `true` if this token represents an operator that can be defined by u
sers. |
| 1475 * @return {@code true} if this token represents an operator that can be defin
ed by users | 1475 * @return `true` if this token represents an operator that can be defined by
users |
| 1476 */ | 1476 */ |
| 1477 bool isUserDefinableOperator() => _type.isUserDefinableOperator(); | 1477 bool isUserDefinableOperator() => _type.isUserDefinableOperator(); |
| 1478 | 1478 |
| 1479 /** | 1479 /** |
| 1480 * Set the next token in the token stream to the given token. This has the sid
e-effect of setting | 1480 * Set the next token in the token stream to the given token. This has the sid
e-effect of setting |
| 1481 * this token to be the previous token for the given token. | 1481 * this token to be the previous token for the given token. |
| 1482 * @param token the next token in the token stream | 1482 * @param token the next token in the token stream |
| 1483 * @return the token that was passed in | 1483 * @return the token that was passed in |
| 1484 */ | 1484 */ |
| 1485 Token setNext(Token token) { | 1485 Token setNext(Token token) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1518 | 1518 |
| 1519 /** | 1519 /** |
| 1520 * Set the previous token in the token stream to the given token. | 1520 * Set the previous token in the token stream to the given token. |
| 1521 * @param previous the previous token in the token stream | 1521 * @param previous the previous token in the token stream |
| 1522 */ | 1522 */ |
| 1523 void set previous(Token previous2) { | 1523 void set previous(Token previous2) { |
| 1524 this._previous = previous2; | 1524 this._previous = previous2; |
| 1525 } | 1525 } |
| 1526 } | 1526 } |
| 1527 /** | 1527 /** |
| 1528 * Instances of the class {@code StringScanner} implement a scanner that reads f
rom a string. The | 1528 * Instances of the class `StringScanner` implement a scanner that reads from a
string. The |
| 1529 * scanning logic is in the superclass. | 1529 * scanning logic is in the superclass. |
| 1530 * @coverage dart.engine.parser | 1530 * @coverage dart.engine.parser |
| 1531 */ | 1531 */ |
| 1532 class StringScanner extends AbstractScanner { | 1532 class StringScanner extends AbstractScanner { |
| 1533 | 1533 |
| 1534 /** | 1534 /** |
| 1535 * The offset from the beginning of the file to the beginning of the source be
ing scanned. | 1535 * The offset from the beginning of the file to the beginning of the source be
ing scanned. |
| 1536 */ | 1536 */ |
| 1537 int _offsetDelta = 0; | 1537 int _offsetDelta = 0; |
| 1538 | 1538 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1561 this._offsetDelta = 0; | 1561 this._offsetDelta = 0; |
| 1562 this._string = string; | 1562 this._string = string; |
| 1563 this._stringLength = string.length; | 1563 this._stringLength = string.length; |
| 1564 this._charOffset = -1; | 1564 this._charOffset = -1; |
| 1565 } | 1565 } |
| 1566 int get offset => _offsetDelta + _charOffset; | 1566 int get offset => _offsetDelta + _charOffset; |
| 1567 | 1567 |
| 1568 /** | 1568 /** |
| 1569 * Record that the source begins on the given line and column at the given off
set. The line starts | 1569 * Record that the source begins on the given line and column at the given off
set. The line starts |
| 1570 * for lines before the given line will not be correct. | 1570 * for lines before the given line will not be correct. |
| 1571 * <p> | 1571 * |
| 1572 * This method must be invoked at most one time and must be invoked before sca
nning begins. The | 1572 * This method must be invoked at most one time and must be invoked before sca
nning begins. The |
| 1573 * values provided must be sensible. The results are undefined if these condit
ions are violated. | 1573 * values provided must be sensible. The results are undefined if these condit
ions are violated. |
| 1574 * @param line the one-based index of the line containing the first character
of the source | 1574 * @param line the one-based index of the line containing the first character
of the source |
| 1575 * @param column the one-based index of the column in which the first characte
r of the source | 1575 * @param column the one-based index of the column in which the first characte
r of the source |
| 1576 * occurs | 1576 * occurs |
| 1577 * @param offset the zero-based offset from the beginning of the larger contex
t to the first | 1577 * @param offset the zero-based offset from the beginning of the larger contex
t to the first |
| 1578 * character of the source | 1578 * character of the source |
| 1579 */ | 1579 */ |
| 1580 void setSourceStart(int line, int column, int offset) { | 1580 void setSourceStart(int line, int column, int offset) { |
| 1581 if (line < 1 || column < 1 || offset < 0 || (line + column - 2) >= offset) { | 1581 if (line < 1 || column < 1 || offset < 0 || (line + column - 2) >= offset) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1597 } | 1597 } |
| 1598 String getString(int start, int endDelta) => _string.substring(start - _offset
Delta, _charOffset + 1 + endDelta); | 1598 String getString(int start, int endDelta) => _string.substring(start - _offset
Delta, _charOffset + 1 + endDelta); |
| 1599 int peek() { | 1599 int peek() { |
| 1600 if (_charOffset + 1 >= _string.length) { | 1600 if (_charOffset + 1 >= _string.length) { |
| 1601 return -1; | 1601 return -1; |
| 1602 } | 1602 } |
| 1603 return _string.codeUnitAt(_charOffset + 1); | 1603 return _string.codeUnitAt(_charOffset + 1); |
| 1604 } | 1604 } |
| 1605 } | 1605 } |
| 1606 /** | 1606 /** |
| 1607 * Instances of the class {@code BeginTokenWithComment} represent a begin token
that is preceded by | 1607 * Instances of the class `BeginTokenWithComment` represent a begin token that i
s preceded by |
| 1608 * comments. | 1608 * comments. |
| 1609 * @coverage dart.engine.parser | 1609 * @coverage dart.engine.parser |
| 1610 */ | 1610 */ |
| 1611 class BeginTokenWithComment extends BeginToken { | 1611 class BeginTokenWithComment extends BeginToken { |
| 1612 | 1612 |
| 1613 /** | 1613 /** |
| 1614 * The first comment in the list of comments that precede this token. | 1614 * The first comment in the list of comments that precede this token. |
| 1615 */ | 1615 */ |
| 1616 Token _precedingComment; | 1616 Token _precedingComment; |
| 1617 | 1617 |
| 1618 /** | 1618 /** |
| 1619 * Initialize a newly created token to have the given type and offset and to b
e preceded by the | 1619 * Initialize a newly created token to have the given type and offset and to b
e preceded by the |
| 1620 * comments reachable from the given comment. | 1620 * comments reachable from the given comment. |
| 1621 * @param type the type of the token | 1621 * @param type the type of the token |
| 1622 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1622 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1623 * @param precedingComment the first comment in the list of comments that prec
ede this token | 1623 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 1624 */ | 1624 */ |
| 1625 BeginTokenWithComment(TokenType type, int offset, Token precedingComment) : su
per(type, offset) { | 1625 BeginTokenWithComment(TokenType type, int offset, Token precedingComment) : su
per(type, offset) { |
| 1626 this._precedingComment = precedingComment; | 1626 this._precedingComment = precedingComment; |
| 1627 } | 1627 } |
| 1628 Token get precedingComments => _precedingComment; | 1628 Token get precedingComments => _precedingComment; |
| 1629 } | 1629 } |
| 1630 /** | 1630 /** |
| 1631 * Instances of the class {@code KeywordToken} represent a keyword in the langua
ge. | 1631 * Instances of the class `KeywordToken` represent a keyword in the language. |
| 1632 * @coverage dart.engine.parser | 1632 * @coverage dart.engine.parser |
| 1633 */ | 1633 */ |
| 1634 class KeywordToken extends Token { | 1634 class KeywordToken extends Token { |
| 1635 | 1635 |
| 1636 /** | 1636 /** |
| 1637 * The keyword being represented by this token. | 1637 * The keyword being represented by this token. |
| 1638 */ | 1638 */ |
| 1639 Keyword _keyword; | 1639 Keyword _keyword; |
| 1640 | 1640 |
| 1641 /** | 1641 /** |
| 1642 * Initialize a newly created token to represent the given keyword. | 1642 * Initialize a newly created token to represent the given keyword. |
| 1643 * @param keyword the keyword being represented by this token | 1643 * @param keyword the keyword being represented by this token |
| 1644 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1644 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1645 */ | 1645 */ |
| 1646 KeywordToken(Keyword keyword, int offset) : super(TokenType.KEYWORD, offset) { | 1646 KeywordToken(Keyword keyword, int offset) : super(TokenType.KEYWORD, offset) { |
| 1647 this._keyword = keyword; | 1647 this._keyword = keyword; |
| 1648 } | 1648 } |
| 1649 | 1649 |
| 1650 /** | 1650 /** |
| 1651 * Return the keyword being represented by this token. | 1651 * Return the keyword being represented by this token. |
| 1652 * @return the keyword being represented by this token | 1652 * @return the keyword being represented by this token |
| 1653 */ | 1653 */ |
| 1654 Keyword get keyword => _keyword; | 1654 Keyword get keyword => _keyword; |
| 1655 String get lexeme => _keyword.syntax; | 1655 String get lexeme => _keyword.syntax; |
| 1656 Keyword value() => _keyword; | 1656 Keyword value() => _keyword; |
| 1657 } | 1657 } |
| 1658 /** | 1658 /** |
| 1659 * Instances of the class {@code BeginToken} represent the opening half of a gro
uping pair of | 1659 * Instances of the class `BeginToken` represent the opening half of a grouping
pair of |
| 1660 * tokens. This is used for curly brackets ('{'), parentheses ('('), and square
brackets ('\['). | 1660 * tokens. This is used for curly brackets ('{'), parentheses ('('), and square
brackets ('\['). |
| 1661 * @coverage dart.engine.parser | 1661 * @coverage dart.engine.parser |
| 1662 */ | 1662 */ |
| 1663 class BeginToken extends Token { | 1663 class BeginToken extends Token { |
| 1664 | 1664 |
| 1665 /** | 1665 /** |
| 1666 * The token that corresponds to this token. | 1666 * The token that corresponds to this token. |
| 1667 */ | 1667 */ |
| 1668 Token _endToken; | 1668 Token _endToken; |
| 1669 | 1669 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1684 | 1684 |
| 1685 /** | 1685 /** |
| 1686 * Set the token that corresponds to this token to the given token. | 1686 * Set the token that corresponds to this token to the given token. |
| 1687 * @param token the token that corresponds to this token | 1687 * @param token the token that corresponds to this token |
| 1688 */ | 1688 */ |
| 1689 void set endToken(Token token) { | 1689 void set endToken(Token token) { |
| 1690 this._endToken = token; | 1690 this._endToken = token; |
| 1691 } | 1691 } |
| 1692 } | 1692 } |
| 1693 /** | 1693 /** |
| 1694 * The enumeration {@code TokenClass} represents classes (or groups) of tokens w
ith a similar use. | 1694 * The enumeration `TokenClass` represents classes (or groups) of tokens with a
similar use. |
| 1695 * @coverage dart.engine.parser | 1695 * @coverage dart.engine.parser |
| 1696 */ | 1696 */ |
| 1697 class TokenClass implements Comparable<TokenClass> { | 1697 class TokenClass implements Comparable<TokenClass> { |
| 1698 | 1698 |
| 1699 /** | 1699 /** |
| 1700 * A value used to indicate that the token type is not part of any specific cl
ass of token. | 1700 * A value used to indicate that the token type is not part of any specific cl
ass of token. |
| 1701 */ | 1701 */ |
| 1702 static final TokenClass NO_CLASS = new TokenClass.con1('NO_CLASS', 0); | 1702 static final TokenClass NO_CLASS = new TokenClass.con1('NO_CLASS', 0); |
| 1703 | 1703 |
| 1704 /** | 1704 /** |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1777 static final TokenClass UNARY_PREFIX_OPERATOR = new TokenClass.con2('UNARY_PRE
FIX_OPERATOR', 15, 14); | 1777 static final TokenClass UNARY_PREFIX_OPERATOR = new TokenClass.con2('UNARY_PRE
FIX_OPERATOR', 15, 14); |
| 1778 static final List<TokenClass> values = [NO_CLASS, ADDITIVE_OPERATOR, ASSIGNMEN
T_OPERATOR, BITWISE_AND_OPERATOR, BITWISE_OR_OPERATOR, BITWISE_XOR_OPERATOR, CAS
CADE_OPERATOR, CONDITIONAL_OPERATOR, EQUALITY_OPERATOR, LOGICAL_AND_OPERATOR, LO
GICAL_OR_OPERATOR, MULTIPLICATIVE_OPERATOR, RELATIONAL_OPERATOR, SHIFT_OPERATOR,
UNARY_POSTFIX_OPERATOR, UNARY_PREFIX_OPERATOR]; | 1778 static final List<TokenClass> values = [NO_CLASS, ADDITIVE_OPERATOR, ASSIGNMEN
T_OPERATOR, BITWISE_AND_OPERATOR, BITWISE_OR_OPERATOR, BITWISE_XOR_OPERATOR, CAS
CADE_OPERATOR, CONDITIONAL_OPERATOR, EQUALITY_OPERATOR, LOGICAL_AND_OPERATOR, LO
GICAL_OR_OPERATOR, MULTIPLICATIVE_OPERATOR, RELATIONAL_OPERATOR, SHIFT_OPERATOR,
UNARY_POSTFIX_OPERATOR, UNARY_PREFIX_OPERATOR]; |
| 1779 | 1779 |
| 1780 /// The name of this enum constant, as declared in the enum declaration. | 1780 /// The name of this enum constant, as declared in the enum declaration. |
| 1781 final String name; | 1781 final String name; |
| 1782 | 1782 |
| 1783 /// The position in the enum declaration. | 1783 /// The position in the enum declaration. |
| 1784 final int ordinal; | 1784 final int ordinal; |
| 1785 | 1785 |
| 1786 /** | 1786 /** |
| 1787 * The precedence of tokens of this class, or {@code 0} if the such tokens do
not represent an | 1787 * The precedence of tokens of this class, or `0` if the such tokens do not re
present an |
| 1788 * operator. | 1788 * operator. |
| 1789 */ | 1789 */ |
| 1790 int _precedence = 0; | 1790 int _precedence = 0; |
| 1791 TokenClass.con1(this.name, this.ordinal) { | 1791 TokenClass.con1(this.name, this.ordinal) { |
| 1792 _jtd_constructor_328_impl(); | 1792 _jtd_constructor_328_impl(); |
| 1793 } | 1793 } |
| 1794 _jtd_constructor_328_impl() { | 1794 _jtd_constructor_328_impl() { |
| 1795 _jtd_constructor_329_impl(0); | 1795 _jtd_constructor_329_impl(0); |
| 1796 } | 1796 } |
| 1797 TokenClass.con2(this.name, this.ordinal, int precedence2) { | 1797 TokenClass.con2(this.name, this.ordinal, int precedence2) { |
| 1798 _jtd_constructor_329_impl(precedence2); | 1798 _jtd_constructor_329_impl(precedence2); |
| 1799 } | 1799 } |
| 1800 _jtd_constructor_329_impl(int precedence2) { | 1800 _jtd_constructor_329_impl(int precedence2) { |
| 1801 this._precedence = precedence2; | 1801 this._precedence = precedence2; |
| 1802 } | 1802 } |
| 1803 | 1803 |
| 1804 /** | 1804 /** |
| 1805 * Return the precedence of tokens of this class, or {@code 0} if the such tok
ens do not represent | 1805 * Return the precedence of tokens of this class, or `0` if the such tokens do
not represent |
| 1806 * an operator. | 1806 * an operator. |
| 1807 * @return the precedence of tokens of this class | 1807 * @return the precedence of tokens of this class |
| 1808 */ | 1808 */ |
| 1809 int get precedence => _precedence; | 1809 int get precedence => _precedence; |
| 1810 int compareTo(TokenClass other) => ordinal - other.ordinal; | 1810 int compareTo(TokenClass other) => ordinal - other.ordinal; |
| 1811 int get hashCode => ordinal; | 1811 int get hashCode => ordinal; |
| 1812 String toString() => name; | 1812 String toString() => name; |
| 1813 } | 1813 } |
| 1814 /** | 1814 /** |
| 1815 * Instances of the class {@code KeywordTokenWithComment} implement a keyword to
ken that is preceded | 1815 * Instances of the class `KeywordTokenWithComment` implement a keyword token th
at is preceded |
| 1816 * by comments. | 1816 * by comments. |
| 1817 * @coverage dart.engine.parser | 1817 * @coverage dart.engine.parser |
| 1818 */ | 1818 */ |
| 1819 class KeywordTokenWithComment extends KeywordToken { | 1819 class KeywordTokenWithComment extends KeywordToken { |
| 1820 | 1820 |
| 1821 /** | 1821 /** |
| 1822 * The first comment in the list of comments that precede this token. | 1822 * The first comment in the list of comments that precede this token. |
| 1823 */ | 1823 */ |
| 1824 Token _precedingComment; | 1824 Token _precedingComment; |
| 1825 | 1825 |
| 1826 /** | 1826 /** |
| 1827 * Initialize a newly created token to to represent the given keyword and to b
e preceded by the | 1827 * Initialize a newly created token to to represent the given keyword and to b
e preceded by the |
| 1828 * comments reachable from the given comment. | 1828 * comments reachable from the given comment. |
| 1829 * @param keyword the keyword being represented by this token | 1829 * @param keyword the keyword being represented by this token |
| 1830 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1830 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1831 * @param precedingComment the first comment in the list of comments that prec
ede this token | 1831 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 1832 */ | 1832 */ |
| 1833 KeywordTokenWithComment(Keyword keyword, int offset, Token precedingComment) :
super(keyword, offset) { | 1833 KeywordTokenWithComment(Keyword keyword, int offset, Token precedingComment) :
super(keyword, offset) { |
| 1834 this._precedingComment = precedingComment; | 1834 this._precedingComment = precedingComment; |
| 1835 } | 1835 } |
| 1836 Token get precedingComments => _precedingComment; | 1836 Token get precedingComments => _precedingComment; |
| 1837 } | 1837 } |
| 1838 /** | 1838 /** |
| 1839 * The enumeration {@code TokenType} defines the types of tokens that can be ret
urned by the | 1839 * The enumeration `TokenType` defines the types of tokens that can be returned
by the |
| 1840 * scanner. | 1840 * scanner. |
| 1841 * @coverage dart.engine.parser | 1841 * @coverage dart.engine.parser |
| 1842 */ | 1842 */ |
| 1843 class TokenType implements Comparable<TokenType> { | 1843 class TokenType implements Comparable<TokenType> { |
| 1844 | 1844 |
| 1845 /** | 1845 /** |
| 1846 * The type of the token that marks the end of the input. | 1846 * The type of the token that marks the end of the input. |
| 1847 */ | 1847 */ |
| 1848 static final TokenType EOF = new TokenType_EOF('EOF', 0, null, ""); | 1848 static final TokenType EOF = new TokenType_EOF('EOF', 0, null, ""); |
| 1849 static final TokenType DOUBLE = new TokenType.con1('DOUBLE', 1); | 1849 static final TokenType DOUBLE = new TokenType.con1('DOUBLE', 1); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1920 | 1920 |
| 1921 /// The position in the enum declaration. | 1921 /// The position in the enum declaration. |
| 1922 final int ordinal; | 1922 final int ordinal; |
| 1923 | 1923 |
| 1924 /** | 1924 /** |
| 1925 * The class of the token. | 1925 * The class of the token. |
| 1926 */ | 1926 */ |
| 1927 TokenClass _tokenClass; | 1927 TokenClass _tokenClass; |
| 1928 | 1928 |
| 1929 /** | 1929 /** |
| 1930 * The lexeme that defines this type of token, or {@code null} if there is mor
e than one possible | 1930 * The lexeme that defines this type of token, or `null` if there is more than
one possible |
| 1931 * lexeme for this type of token. | 1931 * lexeme for this type of token. |
| 1932 */ | 1932 */ |
| 1933 String _lexeme; | 1933 String _lexeme; |
| 1934 TokenType.con1(this.name, this.ordinal) { | 1934 TokenType.con1(this.name, this.ordinal) { |
| 1935 _jtd_constructor_330_impl(); | 1935 _jtd_constructor_330_impl(); |
| 1936 } | 1936 } |
| 1937 _jtd_constructor_330_impl() { | 1937 _jtd_constructor_330_impl() { |
| 1938 _jtd_constructor_331_impl(TokenClass.NO_CLASS, null); | 1938 _jtd_constructor_331_impl(TokenClass.NO_CLASS, null); |
| 1939 } | 1939 } |
| 1940 TokenType.con2(this.name, this.ordinal, TokenClass tokenClass2, String lexeme2
) { | 1940 TokenType.con2(this.name, this.ordinal, TokenClass tokenClass2, String lexeme2
) { |
| 1941 _jtd_constructor_331_impl(tokenClass2, lexeme2); | 1941 _jtd_constructor_331_impl(tokenClass2, lexeme2); |
| 1942 } | 1942 } |
| 1943 _jtd_constructor_331_impl(TokenClass tokenClass2, String lexeme2) { | 1943 _jtd_constructor_331_impl(TokenClass tokenClass2, String lexeme2) { |
| 1944 this._tokenClass = tokenClass2 == null ? TokenClass.NO_CLASS : tokenClass2; | 1944 this._tokenClass = tokenClass2 == null ? TokenClass.NO_CLASS : tokenClass2; |
| 1945 this._lexeme = lexeme2; | 1945 this._lexeme = lexeme2; |
| 1946 } | 1946 } |
| 1947 | 1947 |
| 1948 /** | 1948 /** |
| 1949 * Return the lexeme that defines this type of token, or {@code null} if there
is more than one | 1949 * Return the lexeme that defines this type of token, or `null` if there is mo
re than one |
| 1950 * possible lexeme for this type of token. | 1950 * possible lexeme for this type of token. |
| 1951 * @return the lexeme that defines this type of token | 1951 * @return the lexeme that defines this type of token |
| 1952 */ | 1952 */ |
| 1953 String get lexeme => _lexeme; | 1953 String get lexeme => _lexeme; |
| 1954 | 1954 |
| 1955 /** | 1955 /** |
| 1956 * Return the precedence of the token, or {@code 0} if the token does not repr
esent an operator. | 1956 * Return the precedence of the token, or `0` if the token does not represent
an operator. |
| 1957 * @return the precedence of the token | 1957 * @return the precedence of the token |
| 1958 */ | 1958 */ |
| 1959 int get precedence => _tokenClass.precedence; | 1959 int get precedence => _tokenClass.precedence; |
| 1960 | 1960 |
| 1961 /** | 1961 /** |
| 1962 * Return {@code true} if this type of token represents an additive operator. | 1962 * Return `true` if this type of token represents an additive operator. |
| 1963 * @return {@code true} if this type of token represents an additive operator | 1963 * @return `true` if this type of token represents an additive operator |
| 1964 */ | 1964 */ |
| 1965 bool isAdditiveOperator() => identical(_tokenClass, TokenClass.ADDITIVE_OPERAT
OR); | 1965 bool isAdditiveOperator() => identical(_tokenClass, TokenClass.ADDITIVE_OPERAT
OR); |
| 1966 | 1966 |
| 1967 /** | 1967 /** |
| 1968 * Return {@code true} if this type of token represents an assignment operator
. | 1968 * Return `true` if this type of token represents an assignment operator. |
| 1969 * @return {@code true} if this type of token represents an assignment operato
r | 1969 * @return `true` if this type of token represents an assignment operator |
| 1970 */ | 1970 */ |
| 1971 bool isAssignmentOperator() => identical(_tokenClass, TokenClass.ASSIGNMENT_OP
ERATOR); | 1971 bool isAssignmentOperator() => identical(_tokenClass, TokenClass.ASSIGNMENT_OP
ERATOR); |
| 1972 | 1972 |
| 1973 /** | 1973 /** |
| 1974 * Return {@code true} if this type of token represents an associative operato
r. An associative | 1974 * Return `true` if this type of token represents an associative operator. An
associative |
| 1975 * operator is an operator for which the following equality is true:{@code (a
* b) * c == a * (b * c)}. In other words, if the result of applying the operator
to | 1975 * operator is an operator for which the following equality is true:`(a * b) *
c == a * (b * c)`. In other words, if the result of applying the operator to |
| 1976 * multiple operands does not depend on the order in which those applications
occur. | 1976 * multiple operands does not depend on the order in which those applications
occur. |
| 1977 * <p> | 1977 * |
| 1978 * Note: This method considers the logical-and and logical-or operators to be
associative, even | 1978 * Note: This method considers the logical-and and logical-or operators to be
associative, even |
| 1979 * though the order in which the application of those operators can have an ef
fect because | 1979 * though the order in which the application of those operators can have an ef
fect because |
| 1980 * evaluation of the right-hand operand is conditional. | 1980 * evaluation of the right-hand operand is conditional. |
| 1981 * @return {@code true} if this type of token represents an associative operat
or | 1981 * @return `true` if this type of token represents an associative operator |
| 1982 */ | 1982 */ |
| 1983 bool isAssociativeOperator() => identical(this, AMPERSAND) || identical(this,
AMPERSAND_AMPERSAND) || identical(this, BAR) || identical(this, BAR_BAR) || iden
tical(this, CARET) || identical(this, PLUS) || identical(this, STAR); | 1983 bool isAssociativeOperator() => identical(this, AMPERSAND) || identical(this,
AMPERSAND_AMPERSAND) || identical(this, BAR) || identical(this, BAR_BAR) || iden
tical(this, CARET) || identical(this, PLUS) || identical(this, STAR); |
| 1984 | 1984 |
| 1985 /** | 1985 /** |
| 1986 * Return {@code true} if this type of token represents an equality operator. | 1986 * Return `true` if this type of token represents an equality operator. |
| 1987 * @return {@code true} if this type of token represents an equality operator | 1987 * @return `true` if this type of token represents an equality operator |
| 1988 */ | 1988 */ |
| 1989 bool isEqualityOperator() => identical(_tokenClass, TokenClass.EQUALITY_OPERAT
OR); | 1989 bool isEqualityOperator() => identical(_tokenClass, TokenClass.EQUALITY_OPERAT
OR); |
| 1990 | 1990 |
| 1991 /** | 1991 /** |
| 1992 * Return {@code true} if this type of token represents an increment operator. | 1992 * Return `true` if this type of token represents an increment operator. |
| 1993 * @return {@code true} if this type of token represents an increment operator | 1993 * @return `true` if this type of token represents an increment operator |
| 1994 */ | 1994 */ |
| 1995 bool isIncrementOperator() => identical(_lexeme, "++") || identical(_lexeme, "
--"); | 1995 bool isIncrementOperator() => identical(_lexeme, "++") || identical(_lexeme, "
--"); |
| 1996 | 1996 |
| 1997 /** | 1997 /** |
| 1998 * Return {@code true} if this type of token represents a multiplicative opera
tor. | 1998 * Return `true` if this type of token represents a multiplicative operator. |
| 1999 * @return {@code true} if this type of token represents a multiplicative oper
ator | 1999 * @return `true` if this type of token represents a multiplicative operator |
| 2000 */ | 2000 */ |
| 2001 bool isMultiplicativeOperator() => identical(_tokenClass, TokenClass.MULTIPLIC
ATIVE_OPERATOR); | 2001 bool isMultiplicativeOperator() => identical(_tokenClass, TokenClass.MULTIPLIC
ATIVE_OPERATOR); |
| 2002 | 2002 |
| 2003 /** | 2003 /** |
| 2004 * Return {@code true} if this token type represents an operator. | 2004 * Return `true` if this token type represents an operator. |
| 2005 * @return {@code true} if this token type represents an operator | 2005 * @return `true` if this token type represents an operator |
| 2006 */ | 2006 */ |
| 2007 bool isOperator() => _tokenClass != TokenClass.NO_CLASS && this != OPEN_PAREN
&& this != OPEN_SQUARE_BRACKET && this != PERIOD; | 2007 bool isOperator() => _tokenClass != TokenClass.NO_CLASS && this != OPEN_PAREN
&& this != OPEN_SQUARE_BRACKET && this != PERIOD; |
| 2008 | 2008 |
| 2009 /** | 2009 /** |
| 2010 * Return {@code true} if this type of token represents a relational operator. | 2010 * Return `true` if this type of token represents a relational operator. |
| 2011 * @return {@code true} if this type of token represents a relational operator | 2011 * @return `true` if this type of token represents a relational operator |
| 2012 */ | 2012 */ |
| 2013 bool isRelationalOperator() => identical(_tokenClass, TokenClass.RELATIONAL_OP
ERATOR); | 2013 bool isRelationalOperator() => identical(_tokenClass, TokenClass.RELATIONAL_OP
ERATOR); |
| 2014 | 2014 |
| 2015 /** | 2015 /** |
| 2016 * Return {@code true} if this type of token represents a shift operator. | 2016 * Return `true` if this type of token represents a shift operator. |
| 2017 * @return {@code true} if this type of token represents a shift operator | 2017 * @return `true` if this type of token represents a shift operator |
| 2018 */ | 2018 */ |
| 2019 bool isShiftOperator() => identical(_tokenClass, TokenClass.SHIFT_OPERATOR); | 2019 bool isShiftOperator() => identical(_tokenClass, TokenClass.SHIFT_OPERATOR); |
| 2020 | 2020 |
| 2021 /** | 2021 /** |
| 2022 * Return {@code true} if this type of token represents a unary postfix operat
or. | 2022 * Return `true` if this type of token represents a unary postfix operator. |
| 2023 * @return {@code true} if this type of token represents a unary postfix opera
tor | 2023 * @return `true` if this type of token represents a unary postfix operator |
| 2024 */ | 2024 */ |
| 2025 bool isUnaryPostfixOperator() => identical(_tokenClass, TokenClass.UNARY_POSTF
IX_OPERATOR); | 2025 bool isUnaryPostfixOperator() => identical(_tokenClass, TokenClass.UNARY_POSTF
IX_OPERATOR); |
| 2026 | 2026 |
| 2027 /** | 2027 /** |
| 2028 * Return {@code true} if this type of token represents a unary prefix operato
r. | 2028 * Return `true` if this type of token represents a unary prefix operator. |
| 2029 * @return {@code true} if this type of token represents a unary prefix operat
or | 2029 * @return `true` if this type of token represents a unary prefix operator |
| 2030 */ | 2030 */ |
| 2031 bool isUnaryPrefixOperator() => identical(_tokenClass, TokenClass.UNARY_PREFIX
_OPERATOR); | 2031 bool isUnaryPrefixOperator() => identical(_tokenClass, TokenClass.UNARY_PREFIX
_OPERATOR); |
| 2032 | 2032 |
| 2033 /** | 2033 /** |
| 2034 * Return {@code true} if this token type represents an operator that can be d
efined by users. | 2034 * Return `true` if this token type represents an operator that can be defined
by users. |
| 2035 * @return {@code true} if this token type represents an operator that can be
defined by users | 2035 * @return `true` if this token type represents an operator that can be define
d by users |
| 2036 */ | 2036 */ |
| 2037 bool isUserDefinableOperator() => identical(_lexeme, "==") || identical(_lexem
e, "~") || identical(_lexeme, "[]") || identical(_lexeme, "[]=") || identical(_l
exeme, "*") || identical(_lexeme, "/") || identical(_lexeme, "%") || identical(_
lexeme, "~/") || identical(_lexeme, "+") || identical(_lexeme, "-") || identical
(_lexeme, "<<") || identical(_lexeme, ">>") || identical(_lexeme, ">=") || ident
ical(_lexeme, ">") || identical(_lexeme, "<=") || identical(_lexeme, "<") || ide
ntical(_lexeme, "&") || identical(_lexeme, "^") || identical(_lexeme, "|"); | 2037 bool isUserDefinableOperator() => identical(_lexeme, "==") || identical(_lexem
e, "~") || identical(_lexeme, "[]") || identical(_lexeme, "[]=") || identical(_l
exeme, "*") || identical(_lexeme, "/") || identical(_lexeme, "%") || identical(_
lexeme, "~/") || identical(_lexeme, "+") || identical(_lexeme, "-") || identical
(_lexeme, "<<") || identical(_lexeme, ">>") || identical(_lexeme, ">=") || ident
ical(_lexeme, ">") || identical(_lexeme, "<=") || identical(_lexeme, "<") || ide
ntical(_lexeme, "&") || identical(_lexeme, "^") || identical(_lexeme, "|"); |
| 2038 int compareTo(TokenType other) => ordinal - other.ordinal; | 2038 int compareTo(TokenType other) => ordinal - other.ordinal; |
| 2039 int get hashCode => ordinal; | 2039 int get hashCode => ordinal; |
| 2040 String toString() => name; | 2040 String toString() => name; |
| 2041 } | 2041 } |
| 2042 class TokenType_EOF extends TokenType { | 2042 class TokenType_EOF extends TokenType { |
| 2043 TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) : super.
con2(name, ordinal, arg0, arg1); | 2043 TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) : super.
con2(name, ordinal, arg0, arg1); |
| 2044 String toString() => "-eof-"; | 2044 String toString() => "-eof-"; |
| 2045 } | 2045 } |
| OLD | NEW |