| Index: pkg/analyzer/lib/src/generated/scanner.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/scanner.dart b/pkg/analyzer/lib/src/generated/scanner.dart
|
| index 9eca58cdf947206a93c3d6f0c5ddf4668650603c..813f07ea98b40e4897715a13428a553724f0381b 100644
|
| --- a/pkg/analyzer/lib/src/generated/scanner.dart
|
| +++ b/pkg/analyzer/lib/src/generated/scanner.dart
|
| @@ -12,14 +12,13 @@ import 'dart:collection';
|
|
|
| import 'error.dart';
|
| import 'instrumentation.dart';
|
| -import 'java_core.dart';
|
| import 'java_engine.dart';
|
| import 'source.dart';
|
| import 'utilities_collection.dart' show TokenMap;
|
|
|
| /**
|
| - * Instances of the class `BeginToken` represent the opening half of a grouping pair of
|
| - * tokens. This is used for curly brackets ('{'), parentheses ('('), and square brackets ('[').
|
| + * A `BeginToken` is the opening half of a grouping pair of tokens. This is used
|
| + * for curly brackets ('{'), parentheses ('('), and square brackets ('[').
|
| */
|
| class BeginToken extends Token {
|
| /**
|
| @@ -28,16 +27,14 @@ class BeginToken extends Token {
|
| Token endToken;
|
|
|
| /**
|
| - * Initialize a newly created token representing the opening half of a grouping pair of tokens.
|
| - *
|
| - * @param type the type of the token
|
| - * @param offset the offset from the beginning of the file to the first character in the token
|
| + * Initialize a newly created token to have the given [type] at the given
|
| + * [offset].
|
| */
|
| BeginToken(TokenType type, int offset) : super(type, offset) {
|
| - assert((type == TokenType.OPEN_CURLY_BRACKET ||
|
| + assert(type == TokenType.OPEN_CURLY_BRACKET ||
|
| type == TokenType.OPEN_PAREN ||
|
| type == TokenType.OPEN_SQUARE_BRACKET ||
|
| - type == TokenType.STRING_INTERPOLATION_EXPRESSION));
|
| + type == TokenType.STRING_INTERPOLATION_EXPRESSION);
|
| }
|
|
|
| @override
|
| @@ -45,8 +42,7 @@ class BeginToken extends Token {
|
| }
|
|
|
| /**
|
| - * Instances of the class `BeginTokenWithComment` represent a begin token that is preceded by
|
| - * comments.
|
| + * A `BeginTokenWithComment` is a begin token that is preceded by comments.
|
| */
|
| class BeginTokenWithComment extends BeginToken {
|
| /**
|
| @@ -55,12 +51,9 @@ class BeginTokenWithComment extends BeginToken {
|
| final Token _precedingComment;
|
|
|
| /**
|
| - * Initialize a newly created token to have the given type and offset and to be preceded by the
|
| - * comments reachable from the given comment.
|
| - *
|
| - * @param type the type of the token
|
| - * @param offset the offset from the beginning of the file to the first character in the token
|
| - * @param precedingComment the first comment in the list of comments that precede this token
|
| + * Initialize a newly created token to have the given [type] at the given
|
| + * [offset] and to be preceded by the comments reachable from the given
|
| + * [comment].
|
| */
|
| BeginTokenWithComment(TokenType type, int offset, this._precedingComment)
|
| : super(type, offset);
|
| @@ -84,56 +77,8 @@ class BeginTokenWithComment extends BeginToken {
|
| }
|
|
|
| /**
|
| - * The interface `CharacterReader`
|
| - */
|
| -abstract class CharacterReader {
|
| - /**
|
| - * Return the current offset relative to the beginning of the source. Return the initial offset if
|
| - * the scanner has not yet scanned the source code, and one (1) past the end of the source code if
|
| - * the entire source code has been scanned.
|
| - *
|
| - * @return the current offset of the scanner in the source
|
| - */
|
| - int get offset;
|
| -
|
| - /**
|
| - * Set the current offset relative to the beginning of the source. The new offset must be between
|
| - * the initial offset and one (1) past the end of the source code.
|
| - *
|
| - * @param offset the new offset in the source
|
| - */
|
| - void set offset(int offset);
|
| -
|
| - /**
|
| - * Advance the current position and return the character at the new current position.
|
| - *
|
| - * @return the character at the new current position
|
| - */
|
| - int advance();
|
| -
|
| - /**
|
| - * Return the substring of the source code between the start offset and the modified current
|
| - * position. The current position is modified by adding the end delta.
|
| - *
|
| - * @param start the offset to the beginning of the string, relative to the start of the file
|
| - * @param endDelta the number of characters after the current location to be included in the
|
| - * string, or the number of characters before the current location to be excluded if the
|
| - * offset is negative
|
| - * @return the specified substring of the source code
|
| - */
|
| - String getString(int start, int endDelta);
|
| -
|
| - /**
|
| - * Return the character at the current position without changing the current position.
|
| - *
|
| - * @return the character at the current position
|
| - */
|
| - int peek();
|
| -}
|
| -
|
| -/**
|
| - * Instances of the class `CharSequenceReader` implement a [CharacterReader] that reads
|
| - * characters from a character sequence.
|
| + * A `CharSequenceReader` is a [CharacterReader] that reads characters from a
|
| + * character sequence.
|
| */
|
| class CharSequenceReader implements CharacterReader {
|
| /**
|
| @@ -152,9 +97,8 @@ class CharSequenceReader implements CharacterReader {
|
| int _charOffset = 0;
|
|
|
| /**
|
| - * Initialize a newly created reader to read the characters in the given sequence.
|
| - *
|
| - * @param sequence the sequence from which characters will be read
|
| + * Initialize a newly created reader to read the characters in the given
|
| + * [_sequence].
|
| */
|
| CharSequenceReader(this._sequence) {
|
| this._stringLength = _sequence.length;
|
| @@ -191,6 +135,100 @@ class CharSequenceReader implements CharacterReader {
|
| }
|
|
|
| /**
|
| + * A `CharacterRangeReader` is a [CharacterReader] that reads a range of
|
| + * characters from another character reader.
|
| + */
|
| +class CharacterRangeReader extends CharacterReader {
|
| + /**
|
| + * The reader from which the characters are actually being read.
|
| + */
|
| + final CharacterReader baseReader;
|
| +
|
| + /**
|
| + * The last character to be read.
|
| + */
|
| + final int endIndex;
|
| +
|
| + /**
|
| + * Initialize a newly created reader to read the characters from the given
|
| + * [baseReader] between the [startIndex] inclusive to [endIndex] exclusive.
|
| + */
|
| + CharacterRangeReader(this.baseReader, int startIndex, this.endIndex) {
|
| + baseReader.offset = startIndex - 1;
|
| + }
|
| +
|
| + @override
|
| + int get offset => baseReader.offset;
|
| +
|
| + @override
|
| + void set offset(int offset) {
|
| + baseReader.offset = offset;
|
| + }
|
| +
|
| + @override
|
| + int advance() {
|
| + if (baseReader.offset + 1 >= endIndex) {
|
| + return -1;
|
| + }
|
| + return baseReader.advance();
|
| + }
|
| +
|
| + @override
|
| + String getString(int start, int endDelta) =>
|
| + baseReader.getString(start, endDelta);
|
| +
|
| + @override
|
| + int peek() {
|
| + if (baseReader.offset + 1 >= endIndex) {
|
| + return -1;
|
| + }
|
| + return baseReader.peek();
|
| + }
|
| +}
|
| +
|
| +/**
|
| + * A `CharacterReader` is used by the scanner to read the characters to be
|
| + * scanned.
|
| + */
|
| +abstract class CharacterReader {
|
| + /**
|
| + * The current offset relative to the beginning of the source. Return the
|
| + * initial offset if the scanner has not yet scanned the source code, and one
|
| + * (1) past the end of the source code if the entire source code has been
|
| + * scanned.
|
| + */
|
| + int get offset;
|
| +
|
| + /**
|
| + * Set the current offset relative to the beginning of the source to the given
|
| + * [offset]. The new offset must be between the initial offset and one (1)
|
| + * past the end of the source code.
|
| + */
|
| + void set offset(int offset);
|
| +
|
| + /**
|
| + * Advance the current position and return the character at the new current
|
| + * position.
|
| + */
|
| + int advance();
|
| +
|
| + /**
|
| + * Return the substring of the source code between the [start] offset and the
|
| + * modified current position. The current position is modified by adding the
|
| + * [endDelta], which is the number of characters after the current location to
|
| + * be included in the string, or the number of characters before the current
|
| + * location to be excluded if the offset is negative.
|
| + */
|
| + String getString(int start, int endDelta);
|
| +
|
| + /**
|
| + * Return the character at the current position without changing the current
|
| + * position.
|
| + */
|
| + int peek();
|
| +}
|
| +
|
| +/**
|
| * Instances of the class `IncrementalScanner` implement a scanner that scans a subset of a
|
| * string and inserts the resulting tokens into the middle of an existing token stream.
|
| */
|
| @@ -406,7 +444,7 @@ class IncrementalScanner extends Scanner {
|
| Token _copyAndAdvance(Token originalToken, int delta) {
|
| Token copiedToken = originalToken.copy();
|
| _tokenMap.put(originalToken, copiedToken);
|
| - copiedToken.applyDelta(delta);
|
| + copiedToken.offset += delta;
|
| appendToken(copiedToken);
|
| Token originalComment = originalToken.precedingComments;
|
| Token copiedComment = originalToken.precedingComments;
|
| @@ -433,118 +471,108 @@ class IncrementalScanner extends Scanner {
|
| }
|
|
|
| /**
|
| - * The enumeration `Keyword` defines the keywords in the Dart programming language.
|
| + * The enumeration `Keyword` defines the keywords in the Dart programming
|
| + * language.
|
| */
|
| -class Keyword extends Enum<Keyword> {
|
| - static const Keyword ASSERT = const Keyword.con1('ASSERT', 0, "assert");
|
| +class Keyword {
|
| + static const Keyword ASSERT = const Keyword('ASSERT', "assert");
|
|
|
| - static const Keyword BREAK = const Keyword.con1('BREAK', 1, "break");
|
| + static const Keyword BREAK = const Keyword('BREAK', "break");
|
|
|
| - static const Keyword CASE = const Keyword.con1('CASE', 2, "case");
|
| + static const Keyword CASE = const Keyword('CASE', "case");
|
|
|
| - static const Keyword CATCH = const Keyword.con1('CATCH', 3, "catch");
|
| + static const Keyword CATCH = const Keyword('CATCH', "catch");
|
|
|
| - static const Keyword CLASS = const Keyword.con1('CLASS', 4, "class");
|
| + static const Keyword CLASS = const Keyword('CLASS', "class");
|
|
|
| - static const Keyword CONST = const Keyword.con1('CONST', 5, "const");
|
| + static const Keyword CONST = const Keyword('CONST', "const");
|
|
|
| - static const Keyword CONTINUE = const Keyword.con1('CONTINUE', 6, "continue");
|
| + static const Keyword CONTINUE = const Keyword('CONTINUE', "continue");
|
|
|
| - static const Keyword DEFAULT = const Keyword.con1('DEFAULT', 7, "default");
|
| + static const Keyword DEFAULT = const Keyword('DEFAULT', "default");
|
|
|
| - static const Keyword DO = const Keyword.con1('DO', 8, "do");
|
| + static const Keyword DO = const Keyword('DO', "do");
|
|
|
| - static const Keyword ELSE = const Keyword.con1('ELSE', 9, "else");
|
| + static const Keyword ELSE = const Keyword('ELSE', "else");
|
|
|
| - static const Keyword ENUM = const Keyword.con1('ENUM', 10, "enum");
|
| + static const Keyword ENUM = const Keyword('ENUM', "enum");
|
|
|
| - static const Keyword EXTENDS = const Keyword.con1('EXTENDS', 11, "extends");
|
| + static const Keyword EXTENDS = const Keyword('EXTENDS', "extends");
|
|
|
| - static const Keyword FALSE = const Keyword.con1('FALSE', 12, "false");
|
| + static const Keyword FALSE = const Keyword('FALSE', "false");
|
|
|
| - static const Keyword FINAL = const Keyword.con1('FINAL', 13, "final");
|
| + static const Keyword FINAL = const Keyword('FINAL', "final");
|
|
|
| - static const Keyword FINALLY = const Keyword.con1('FINALLY', 14, "finally");
|
| + static const Keyword FINALLY = const Keyword('FINALLY', "finally");
|
|
|
| - static const Keyword FOR = const Keyword.con1('FOR', 15, "for");
|
| + static const Keyword FOR = const Keyword('FOR', "for");
|
|
|
| - static const Keyword IF = const Keyword.con1('IF', 16, "if");
|
| + static const Keyword IF = const Keyword('IF', "if");
|
|
|
| - static const Keyword IN = const Keyword.con1('IN', 17, "in");
|
| + static const Keyword IN = const Keyword('IN', "in");
|
|
|
| - static const Keyword IS = const Keyword.con1('IS', 18, "is");
|
| + static const Keyword IS = const Keyword('IS', "is");
|
|
|
| - static const Keyword NEW = const Keyword.con1('NEW', 19, "new");
|
| + static const Keyword NEW = const Keyword('NEW', "new");
|
|
|
| - static const Keyword NULL = const Keyword.con1('NULL', 20, "null");
|
| + static const Keyword NULL = const Keyword('NULL', "null");
|
|
|
| - static const Keyword RETHROW = const Keyword.con1('RETHROW', 21, "rethrow");
|
| + static const Keyword RETHROW = const Keyword('RETHROW', "rethrow");
|
|
|
| - static const Keyword RETURN = const Keyword.con1('RETURN', 22, "return");
|
| + static const Keyword RETURN = const Keyword('RETURN', "return");
|
|
|
| - static const Keyword SUPER = const Keyword.con1('SUPER', 23, "super");
|
| + static const Keyword SUPER = const Keyword('SUPER', "super");
|
|
|
| - static const Keyword SWITCH = const Keyword.con1('SWITCH', 24, "switch");
|
| + static const Keyword SWITCH = const Keyword('SWITCH', "switch");
|
|
|
| - static const Keyword THIS = const Keyword.con1('THIS', 25, "this");
|
| + static const Keyword THIS = const Keyword('THIS', "this");
|
|
|
| - static const Keyword THROW = const Keyword.con1('THROW', 26, "throw");
|
| + static const Keyword THROW = const Keyword('THROW', "throw");
|
|
|
| - static const Keyword TRUE = const Keyword.con1('TRUE', 27, "true");
|
| + static const Keyword TRUE = const Keyword('TRUE', "true");
|
|
|
| - static const Keyword TRY = const Keyword.con1('TRY', 28, "try");
|
| + static const Keyword TRY = const Keyword('TRY', "try");
|
|
|
| - static const Keyword VAR = const Keyword.con1('VAR', 29, "var");
|
| + static const Keyword VAR = const Keyword('VAR', "var");
|
|
|
| - static const Keyword VOID = const Keyword.con1('VOID', 30, "void");
|
| + static const Keyword VOID = const Keyword('VOID', "void");
|
|
|
| - static const Keyword WHILE = const Keyword.con1('WHILE', 31, "while");
|
| + static const Keyword WHILE = const Keyword('WHILE', "while");
|
|
|
| - static const Keyword WITH = const Keyword.con1('WITH', 32, "with");
|
| + static const Keyword WITH = const Keyword('WITH', "with");
|
|
|
| - static const Keyword ABSTRACT =
|
| - const Keyword.con2('ABSTRACT', 33, "abstract", true);
|
| + static const Keyword ABSTRACT = const Keyword('ABSTRACT', "abstract", true);
|
|
|
| - static const Keyword AS = const Keyword.con2('AS', 34, "as", true);
|
| + static const Keyword AS = const Keyword('AS', "as", true);
|
|
|
| - static const Keyword DEFERRED =
|
| - const Keyword.con2('DEFERRED', 35, "deferred", true);
|
| + static const Keyword DEFERRED = const Keyword('DEFERRED', "deferred", true);
|
|
|
| - static const Keyword DYNAMIC =
|
| - const Keyword.con2('DYNAMIC', 36, "dynamic", true);
|
| + static const Keyword DYNAMIC = const Keyword('DYNAMIC', "dynamic", true);
|
|
|
| - static const Keyword EXPORT =
|
| - const Keyword.con2('EXPORT', 37, "export", true);
|
| + static const Keyword EXPORT = const Keyword('EXPORT', "export", true);
|
|
|
| - static const Keyword EXTERNAL =
|
| - const Keyword.con2('EXTERNAL', 38, "external", true);
|
| + static const Keyword EXTERNAL = const Keyword('EXTERNAL', "external", true);
|
|
|
| - static const Keyword FACTORY =
|
| - const Keyword.con2('FACTORY', 39, "factory", true);
|
| + static const Keyword FACTORY = const Keyword('FACTORY', "factory", true);
|
|
|
| - static const Keyword GET = const Keyword.con2('GET', 40, "get", true);
|
| + static const Keyword GET = const Keyword('GET', "get", true);
|
|
|
| static const Keyword IMPLEMENTS =
|
| - const Keyword.con2('IMPLEMENTS', 41, "implements", true);
|
| + const Keyword('IMPLEMENTS', "implements", true);
|
|
|
| - static const Keyword IMPORT =
|
| - const Keyword.con2('IMPORT', 42, "import", true);
|
| + static const Keyword IMPORT = const Keyword('IMPORT', "import", true);
|
|
|
| - static const Keyword LIBRARY =
|
| - const Keyword.con2('LIBRARY', 43, "library", true);
|
| + static const Keyword LIBRARY = const Keyword('LIBRARY', "library", true);
|
|
|
| - static const Keyword OPERATOR =
|
| - const Keyword.con2('OPERATOR', 44, "operator", true);
|
| + static const Keyword OPERATOR = const Keyword('OPERATOR', "operator", true);
|
|
|
| - static const Keyword PART = const Keyword.con2('PART', 45, "part", true);
|
| + static const Keyword PART = const Keyword('PART', "part", true);
|
|
|
| - static const Keyword SET = const Keyword.con2('SET', 46, "set", true);
|
| + static const Keyword SET = const Keyword('SET', "set", true);
|
|
|
| - static const Keyword STATIC =
|
| - const Keyword.con2('STATIC', 47, "static", true);
|
| + static const Keyword STATIC = const Keyword('STATIC', "static", true);
|
|
|
| - static const Keyword TYPEDEF =
|
| - const Keyword.con2('TYPEDEF', 48, "typedef", true);
|
| + static const Keyword TYPEDEF = const Keyword('TYPEDEF', "typedef", true);
|
|
|
| static const List<Keyword> values = const [
|
| ASSERT,
|
| @@ -600,43 +628,33 @@ class Keyword extends Enum<Keyword> {
|
| /**
|
| * A table mapping the lexemes of keywords to the corresponding keyword.
|
| */
|
| - static Map<String, Keyword> keywords = _createKeywordMap();
|
| + static final Map<String, Keyword> keywords = _createKeywordMap();
|
|
|
| /**
|
| - * The lexeme for the keyword.
|
| + * The name of the keyword type.
|
| */
|
| - final String syntax;
|
| + final String name;
|
|
|
| /**
|
| - * A flag indicating whether the keyword is a pseudo-keyword. Pseudo keywords can be used as
|
| - * identifiers.
|
| + * The lexeme for the keyword.
|
| */
|
| - final bool isPseudoKeyword;
|
| + final String syntax;
|
|
|
| /**
|
| - * Initialize a newly created keyword to have the given syntax. The keyword is not a
|
| - * pseudo-keyword.
|
| - *
|
| - * @param syntax the lexeme for the keyword
|
| + * A flag indicating whether the keyword is a pseudo-keyword. Pseudo keywords
|
| + * can be used as identifiers.
|
| */
|
| - const Keyword.con1(String name, int ordinal, String syntax)
|
| - : this.con2(name, ordinal, syntax, false);
|
| + final bool isPseudoKeyword;
|
|
|
| /**
|
| - * Initialize a newly created keyword to have the given syntax. The keyword is a pseudo-keyword if
|
| - * the given flag is `true`.
|
| - *
|
| - * @param syntax the lexeme for the keyword
|
| - * @param isPseudoKeyword `true` if this keyword is a pseudo-keyword
|
| + * Initialize a newly created keyword to have the given [name] and [syntax].
|
| + * The keyword is a pseudo-keyword if the [isPseudoKeyword] flag is `true`.
|
| */
|
| - const Keyword.con2(String name, int ordinal, this.syntax,
|
| - this.isPseudoKeyword)
|
| - : super(name, ordinal);
|
| + const Keyword(this.name, this.syntax, [this.isPseudoKeyword = false]);
|
|
|
| /**
|
| - * Create a table mapping the lexemes of keywords to the corresponding keyword.
|
| - *
|
| - * @return the table that was created
|
| + * Create a table mapping the lexemes of keywords to the corresponding keyword
|
| + * and return the table that was created.
|
| */
|
| static Map<String, Keyword> _createKeywordMap() {
|
| LinkedHashMap<String, Keyword> result =
|
| @@ -649,8 +667,7 @@ class Keyword extends Enum<Keyword> {
|
| }
|
|
|
| /**
|
| - * Instances of the abstract class `KeywordState` represent a state in a state machine used to
|
| - * scan keywords.
|
| + * A `KeywordState` is a state in a state machine used to scan keywords.
|
| */
|
| class KeywordState {
|
| /**
|
| @@ -661,60 +678,57 @@ class KeywordState {
|
| /**
|
| * The initial state in the state machine.
|
| */
|
| - static KeywordState KEYWORD_STATE = _createKeywordStateTable();
|
| + static final KeywordState KEYWORD_STATE = _createKeywordStateTable();
|
|
|
| /**
|
| - * A table mapping characters to the states to which those characters will transition. (The index
|
| - * into the array is the offset from the character `'a'` to the transitioning character.)
|
| + * A table mapping characters to the states to which those characters will
|
| + * transition. (The index into the array is the offset from the character
|
| + * `'a'` to the transitioning character.)
|
| */
|
| final List<KeywordState> _table;
|
|
|
| /**
|
| - * The keyword that is recognized by this state, or `null` if this state is not a terminal
|
| - * state.
|
| + * The keyword that is recognized by this state, or `null` if this state is
|
| + * not a terminal state.
|
| */
|
| Keyword _keyword;
|
|
|
| /**
|
| - * Initialize a newly created state to have the given transitions and to recognize the keyword
|
| - * with the given syntax.
|
| - *
|
| - * @param table a table mapping characters to the states to which those characters will transition
|
| - * @param syntax the syntax of the keyword that is recognized by the state
|
| + * Initialize a newly created state to have the given transitions and to
|
| + * recognize the keyword with the given [syntax].
|
| */
|
| KeywordState(this._table, String syntax) {
|
| this._keyword = (syntax == null) ? null : Keyword.keywords[syntax];
|
| }
|
|
|
| /**
|
| - * Return the keyword that was recognized by this state, or `null` if this state does not
|
| - * recognized a keyword.
|
| - *
|
| - * @return the keyword that was matched by reaching this state
|
| + * Return the keyword that was recognized by this state, or `null` if this
|
| + * state does not recognized a keyword.
|
| */
|
| Keyword keyword() => _keyword;
|
|
|
| /**
|
| - * Return the state that follows this state on a transition of the given character, or
|
| - * `null` if there is no valid state reachable from this state with such a transition.
|
| - *
|
| - * @param c the character used to transition from this state to another state
|
| - * @return the state that follows this state on a transition of the given character
|
| + * Return the state that follows this state on a transition of the given
|
| + * [character], or `null` if there is no valid state reachable from this state
|
| + * with such a transition.
|
| */
|
| - KeywordState next(int c) => _table[c - 0x61];
|
| + KeywordState next(int character) => _table[character - 0x61];
|
|
|
| /**
|
| - * Create the next state in the state machine where we have already recognized the subset of
|
| - * strings in the given array of strings starting at the given offset and having the given length.
|
| - * All of these strings have a common prefix and the next character is at the given start index.
|
| + * Create the next state in the state machine where we have already recognized
|
| + * the subset of strings in the given array of [strings] starting at the given
|
| + * [offset] and having the given [length]. All of these strings have a common
|
| + * prefix and the next character is at the given [start] index.
|
| *
|
| - * @param start the index of the character in the strings used to transition to a new state
|
| - * @param strings an array containing all of the strings that will be recognized by the state
|
| - * machine
|
| - * @param offset the offset of the first string in the array that has the prefix that is assumed
|
| - * to have been recognized by the time we reach the state being built
|
| - * @param length the number of strings in the array that pass through the state being built
|
| - * @return the state that was created
|
| + * [start] the index of the character in the strings used to transition to a
|
| + * new state
|
| + * [strings] an array containing all of the strings that will be recognized by
|
| + * the state machine
|
| + * [offset] the offset of the first string in the array that has the prefix
|
| + * that is assumed to have been recognized by the time we reach the state
|
| + * being built
|
| + * [length] the number of strings in the array that pass through the state
|
| + * being built
|
| */
|
| static KeywordState _computeKeywordStateTable(int start, List<String> strings,
|
| int offset, int length) {
|
| @@ -759,9 +773,7 @@ class KeywordState {
|
| }
|
|
|
| /**
|
| - * Create the initial state in the state machine.
|
| - *
|
| - * @return the state that was created
|
| + * Create and return the initial state in the state machine.
|
| */
|
| static KeywordState _createKeywordStateTable() {
|
| List<Keyword> values = Keyword.values;
|
| @@ -775,7 +787,7 @@ class KeywordState {
|
| }
|
|
|
| /**
|
| - * Instances of the class `KeywordToken` represent a keyword in the language.
|
| + * A `KeywordToken` is a keyword in the language.
|
| */
|
| class KeywordToken extends Token {
|
| /**
|
| @@ -784,10 +796,8 @@ class KeywordToken extends Token {
|
| final Keyword keyword;
|
|
|
| /**
|
| - * Initialize a newly created token to represent the given keyword.
|
| - *
|
| - * @param keyword the keyword being represented by this token
|
| - * @param offset the offset from the beginning of the file to the first character in the token
|
| + * Initialize a newly created token to represent the given [keyword] at the
|
| + * given [offset].
|
| */
|
| KeywordToken(this.keyword, int offset) : super(TokenType.KEYWORD, offset);
|
|
|
| @@ -802,8 +812,7 @@ class KeywordToken extends Token {
|
| }
|
|
|
| /**
|
| - * Instances of the class `KeywordTokenWithComment` implement a keyword token that is preceded
|
| - * by comments.
|
| + * A `KeywordTokenWithComment` is a keyword token that is preceded by comments.
|
| */
|
| class KeywordTokenWithComment extends KeywordToken {
|
| /**
|
| @@ -812,12 +821,9 @@ class KeywordTokenWithComment extends KeywordToken {
|
| final Token _precedingComment;
|
|
|
| /**
|
| - * Initialize a newly created token to to represent the given keyword and to be preceded by the
|
| - * comments reachable from the given comment.
|
| - *
|
| - * @param keyword the keyword being represented by this token
|
| - * @param offset the offset from the beginning of the file to the first character in the token
|
| - * @param precedingComment the first comment in the list of comments that precede this token
|
| + * Initialize a newly created token to to represent the given [keyword] at the
|
| + * given [offset] and to be preceded by the comments reachable from the given
|
| + * [comment].
|
| */
|
| KeywordTokenWithComment(Keyword keyword, int offset, this._precedingComment)
|
| : super(keyword, offset);
|
| @@ -843,11 +849,12 @@ class KeywordTokenWithComment extends KeywordToken {
|
| /**
|
| * The class `Scanner` implements a scanner for Dart code.
|
| *
|
| - * The lexical structure of Dart is ambiguous without knowledge of the context in which a token is
|
| - * being scanned. For example, without context we cannot determine whether source of the form "<<"
|
| - * should be scanned as a single left-shift operator or as two left angle brackets. This scanner
|
| - * does not have any context, so it always resolves such conflicts by scanning the longest possible
|
| - * token.
|
| + * The lexical structure of Dart is ambiguous without knowledge of the context
|
| + * in which a token is being scanned. For example, without context we cannot
|
| + * determine whether source of the form "<<" should be scanned as a single
|
| + * left-shift operator or as two left angle brackets. This scanner does not have
|
| + * any context, so it always resolves such conflicts by scanning the longest
|
| + * possible token.
|
| */
|
| class Scanner {
|
| /**
|
| @@ -861,12 +868,13 @@ class Scanner {
|
| final CharacterReader _reader;
|
|
|
| /**
|
| - * The error listener that will be informed of any errors that are found during the scan.
|
| + * The error listener that will be informed of any errors that are found
|
| + * during the scan.
|
| */
|
| final AnalysisErrorListener _errorListener;
|
|
|
| /**
|
| - * The flag specifying if documentation comments should be parsed.
|
| + * The flag specifying whether documentation comments should be parsed.
|
| */
|
| bool _preserveComments = true;
|
|
|
| @@ -881,12 +889,14 @@ class Scanner {
|
| Token _tail;
|
|
|
| /**
|
| - * The first token in the list of comment tokens found since the last non-comment token.
|
| + * The first token in the list of comment tokens found since the last
|
| + * non-comment token.
|
| */
|
| Token _firstComment;
|
|
|
| /**
|
| - * The last token in the list of comment tokens found since the last non-comment token.
|
| + * The last token in the list of comment tokens found since the last
|
| + * non-comment token.
|
| */
|
| Token _lastComment;
|
|
|
| @@ -896,18 +906,21 @@ class Scanner {
|
| int _tokenStart = 0;
|
|
|
| /**
|
| - * A list containing the offsets of the first character of each line in the source code.
|
| + * A list containing the offsets of the first character of each line in the
|
| + * source code.
|
| */
|
| List<int> _lineStarts = new List<int>();
|
|
|
| /**
|
| - * A list, treated something like a stack, of tokens representing the beginning of a matched pair.
|
| - * It is used to pair the end tokens with the begin tokens.
|
| + * A list, treated something like a stack, of tokens representing the
|
| + * beginning of a matched pair. It is used to pair the end tokens with the
|
| + * begin tokens.
|
| */
|
| List<BeginToken> _groupingStack = new List<BeginToken>();
|
|
|
| /**
|
| - * The index of the last item in the [groupingStack], or `-1` if the stack is empty.
|
| + * The index of the last item in the [_groupingStack], or `-1` if the stack is
|
| + * empty.
|
| */
|
| int _stackEnd = -1;
|
|
|
| @@ -917,11 +930,10 @@ class Scanner {
|
| bool _hasUnmatchedGroups = false;
|
|
|
| /**
|
| - * Initialize a newly created scanner.
|
| - *
|
| - * @param source the source being scanned
|
| - * @param reader the character reader used to read the characters in the source
|
| - * @param errorListener the error listener that will be informed of any errors that are found
|
| + * Initialize a newly created scanner to scan characters from the given
|
| + * [source]. The given character [_reader] will be used to read the characters
|
| + * in the source. The given [_errorListener] will be informed of any errors
|
| + * that are found.
|
| */
|
| Scanner(this.source, this._reader, this._errorListener) {
|
| _tokens = new Token(TokenType.EOF, -1);
|
| @@ -933,29 +945,22 @@ class Scanner {
|
|
|
| /**
|
| * Return the first token in the token stream that was scanned.
|
| - *
|
| - * @return the first token in the token stream that was scanned
|
| */
|
| Token get firstToken => _tokens.next;
|
|
|
| /**
|
| * Return `true` if any unmatched groups were found during the parse.
|
| - *
|
| - * @return `true` if any unmatched groups were found during the parse
|
| */
|
| bool get hasUnmatchedGroups => _hasUnmatchedGroups;
|
|
|
| /**
|
| - * Return an array containing the offsets of the first character of each line in the source code.
|
| - *
|
| - * @return an array containing the offsets of the first character of each line in the source code
|
| + * Return an array containing the offsets of the first character of each line
|
| + * in the source code.
|
| */
|
| List<int> get lineStarts => _lineStarts;
|
|
|
| /**
|
| - * Set whether documentation tokens should be scanned.
|
| - *
|
| - * @param preserveComments `true` if documentation tokens should be scanned
|
| + * Set whether documentation tokens should be preserved.
|
| */
|
| void set preserveComments(bool preserveComments) {
|
| this._preserveComments = preserveComments;
|
| @@ -963,17 +968,14 @@ class Scanner {
|
|
|
| /**
|
| * Return the last token that was scanned.
|
| - *
|
| - * @return the last token that was scanned
|
| */
|
| Token get tail => _tail;
|
|
|
| /**
|
| - * Append the given token to the end of the token stream being scanned. This method is intended to
|
| - * be used by subclasses that copy existing tokens and should not normally be used because it will
|
| - * fail to correctly associate any comments with the token being passed in.
|
| - *
|
| - * @param token the token to be appended
|
| + * Append the given [token] to the end of the token stream being scanned. This
|
| + * method is intended to be used by subclasses that copy existing tokens and
|
| + * should not normally be used because it will fail to correctly associate any
|
| + * comments with the token being passed in.
|
| */
|
| void appendToken(Token token) {
|
| _tail = _tail.setNext(token);
|
| @@ -1132,15 +1134,18 @@ class Scanner {
|
| }
|
|
|
| /**
|
| - * Record that the source begins on the given line and column at the current offset as given by
|
| - * the reader. The line starts for lines before the given line will not be correct.
|
| + * Record that the source begins on the given [line] and [column] at the
|
| + * current offset as given by the reader. The line starts for lines before the
|
| + * given line will not be correct.
|
| *
|
| - * This method must be invoked at most one time and must be invoked before scanning begins. The
|
| - * values provided must be sensible. The results are undefined if these conditions are violated.
|
| + * This method must be invoked at most one time and must be invoked before
|
| + * scanning begins. The values provided must be sensible. The results are
|
| + * undefined if these conditions are violated.
|
| *
|
| - * @param line the one-based index of the line containing the first character of the source
|
| - * @param column the one-based index of the column in which the first character of the source
|
| - * occurs
|
| + * [line] the one-based index of the line containing the first character of
|
| + * the source
|
| + * [column] the one-based index of the column in which the first character of
|
| + * the source occurs
|
| */
|
| void setSourceStart(int line, int column) {
|
| int offset = _reader.offset;
|
| @@ -1154,9 +1159,8 @@ class Scanner {
|
| }
|
|
|
| /**
|
| - * Scan the source code to produce a list of tokens representing the source.
|
| - *
|
| - * @return the first token in the list of tokens that were produced
|
| + * Scan the source code to produce a list of tokens representing the source,
|
| + * and return the first token in the list of tokens that were produced.
|
| */
|
| Token tokenize() {
|
| InstrumentationBuilder instrumentation =
|
| @@ -1304,11 +1308,9 @@ class Scanner {
|
| }
|
|
|
| /**
|
| - * Return the beginning token corresponding to a closing brace that was found while scanning
|
| - * inside a string interpolation expression. Tokens that cannot be matched with the closing brace
|
| - * will be dropped from the stack.
|
| - *
|
| - * @return the token to be paired with the closing brace
|
| + * Return the beginning token corresponding to a closing brace that was found
|
| + * while scanning inside a string interpolation expression. Tokens that cannot
|
| + * be matched with the closing brace will be dropped from the stack.
|
| */
|
| BeginToken _findTokenMatchingClosingBraceInInterpolationExpression() {
|
| while (_stackEnd >= 0) {
|
| @@ -1331,8 +1333,8 @@ class Scanner {
|
| /**
|
| * Report an error at the current offset.
|
| *
|
| - * @param errorCode the error code indicating the nature of the error
|
| - * @param arguments any arguments needed to complete the error message
|
| + * [errorCode] the error code indicating the nature of the error
|
| + * [arguments] any arguments needed to complete the error message
|
| */
|
| void _reportError(ScannerErrorCode errorCode, [List<Object> arguments]) {
|
| _errorListener.onError(
|
| @@ -2029,8 +2031,7 @@ class ScannerErrorCode extends ErrorCode {
|
| }
|
|
|
| /**
|
| - * Instances of the class `StringToken` represent a token whose value is independent of it's
|
| - * type.
|
| + * A `StringToken` is a token whose value is independent of it's type.
|
| */
|
| class StringToken extends Token {
|
| /**
|
| @@ -2039,11 +2040,8 @@ class StringToken extends Token {
|
| String _value;
|
|
|
| /**
|
| - * Initialize a newly created token to represent a token of the given type with the given value.
|
| - *
|
| - * @param type the type of the token
|
| - * @param value the lexeme represented by this token
|
| - * @param offset the offset from the beginning of the file to the first character in the token
|
| + * Initialize a newly created token to represent a token of the given [type]
|
| + * with the given [value] at the given [offset].
|
| */
|
| StringToken(TokenType type, String value, int offset) : super(type, offset) {
|
| this._value = StringUtilities.intern(value);
|
| @@ -2060,8 +2058,7 @@ class StringToken extends Token {
|
| }
|
|
|
| /**
|
| - * Instances of the class `TokenWithComment` represent a string token that is preceded by
|
| - * comments.
|
| + * A `StringTokenWithComment` is a string token that is preceded by comments.
|
| */
|
| class StringTokenWithComment extends StringToken {
|
| /**
|
| @@ -2070,12 +2067,9 @@ class StringTokenWithComment extends StringToken {
|
| final Token _precedingComment;
|
|
|
| /**
|
| - * Initialize a newly created token to have the given type and offset and to be preceded by the
|
| - * comments reachable from the given comment.
|
| - *
|
| - * @param type the type of the token
|
| - * @param offset the offset from the beginning of the file to the first character in the token
|
| - * @param precedingComment the first comment in the list of comments that precede this token
|
| + * Initialize a newly created token to have the given [type] at the given
|
| + * [offset] and to be preceded by the comments reachable from the given
|
| + * [comment].
|
| */
|
| StringTokenWithComment(TokenType type, String value, int offset,
|
| this._precedingComment)
|
| @@ -2104,22 +2098,22 @@ class StringTokenWithComment extends StringToken {
|
| }
|
|
|
| /**
|
| - * Instances of the class `SubSequenceReader` implement a [CharacterReader] that reads
|
| - * characters from a character sequence, but adds a delta when reporting the current character
|
| - * offset so that the character sequence can be a subsequence from a larger sequence.
|
| + * A `SubSequenceReader` is a [CharacterReader] that reads characters from a
|
| + * character sequence, but adds a delta when reporting the current character
|
| + * offset so that the character sequence can be a subsequence from a larger
|
| + * sequence.
|
| */
|
| class SubSequenceReader extends CharSequenceReader {
|
| /**
|
| - * The offset from the beginning of the file to the beginning of the source being scanned.
|
| + * The offset from the beginning of the file to the beginning of the source
|
| + * being scanned.
|
| */
|
| final int _offsetDelta;
|
|
|
| /**
|
| - * Initialize a newly created reader to read the characters in the given sequence.
|
| - *
|
| - * @param sequence the sequence from which characters will be read
|
| - * @param offsetDelta the offset from the beginning of the file to the beginning of the source
|
| - * being scanned
|
| + * Initialize a newly created reader to read the characters in the given
|
| + * [sequence]. The [_offsetDelta] is the offset from the beginning of the file
|
| + * to the beginning of the source being scanned
|
| */
|
| SubSequenceReader(String sequence, this._offsetDelta) : super(sequence);
|
|
|
| @@ -2137,15 +2131,12 @@ class SubSequenceReader extends CharSequenceReader {
|
| }
|
|
|
| /**
|
| - * Synthetic `StringToken` represent a token whose value is independent of it's type.
|
| + * A `SyntheticStringToken` is a token whose value is independent of it's type.
|
| */
|
| class SyntheticStringToken extends StringToken {
|
| /**
|
| - * Initialize a newly created token to represent a token of the given type with the given value.
|
| - *
|
| - * @param type the type of the token
|
| - * @param value the lexeme represented by this token
|
| - * @param offset the offset from the beginning of the file to the first character in the token
|
| + * Initialize a newly created token to represent a token of the given [type]
|
| + * with the given [value] at the given [offset].
|
| */
|
| SyntheticStringToken(TokenType type, String value, int offset)
|
| : super(type, value, offset);
|
| @@ -2155,8 +2146,9 @@ class SyntheticStringToken extends StringToken {
|
| }
|
|
|
| /**
|
| - * Instances of the class `Token` represent a token that was scanned from the input. Each
|
| - * token knows which token follows it, acting as the head of a linked list of tokens.
|
| + * Instances of the class `Token` represent a token that was scanned from the
|
| + * input. Each token knows which tokens preceed and follow it, acting as a link
|
| + * in a doubly linked list of tokens.
|
| */
|
| class Token {
|
| /**
|
| @@ -2165,7 +2157,8 @@ class Token {
|
| final TokenType type;
|
|
|
| /**
|
| - * The offset from the beginning of the file to the first character in the token.
|
| + * The offset from the beginning of the file to the first character in the
|
| + * token.
|
| */
|
| int offset = 0;
|
|
|
| @@ -2180,99 +2173,78 @@ class Token {
|
| Token _next;
|
|
|
| /**
|
| - * Initialize a newly created token to have the given type and offset.
|
| - *
|
| - * @param type the type of the token
|
| - * @param offset the offset from the beginning of the file to the first character in the token
|
| + * Initialize a newly created token to have the given [type] and [offset].
|
| */
|
| Token(this.type, int offset) {
|
| this.offset = offset;
|
| }
|
|
|
| -
|
| /**
|
| - * Return the offset from the beginning of the file to the character after last character of the
|
| - * token.
|
| - *
|
| - * @return the offset from the beginning of the file to the first character after last character
|
| - * of the token
|
| + * Return the offset from the beginning of the file to the character after the
|
| + * last character of the token.
|
| */
|
| int get end => offset + length;
|
|
|
| /**
|
| * Return `true` if this token represents an operator.
|
| - *
|
| - * @return `true` if this token represents an operator
|
| */
|
| bool get isOperator => type.isOperator;
|
|
|
| /**
|
| - * Return `true` if this token is a synthetic token. A synthetic token is a token that was
|
| - * introduced by the parser in order to recover from an error in the code.
|
| - *
|
| - * @return `true` if this token is a synthetic token
|
| + * Return `true` if this token is a synthetic token. A synthetic token is a
|
| + * token that was introduced by the parser in order to recover from an error
|
| + * in the code.
|
| */
|
| bool get isSynthetic => length == 0;
|
|
|
| /**
|
| - * Return `true` if this token represents an operator that can be defined by users.
|
| - *
|
| - * @return `true` if this token represents an operator that can be defined by users
|
| + * Return `true` if this token represents an operator that can be defined by
|
| + * users.
|
| */
|
| bool get isUserDefinableOperator => type.isUserDefinableOperator;
|
|
|
| /**
|
| * Return the number of characters in the node's source range.
|
| - *
|
| - * @return the number of characters in the node's source range
|
| */
|
| int get length => lexeme.length;
|
|
|
| /**
|
| * Return the lexeme that represents this token.
|
| - *
|
| - * @return the lexeme that represents this token
|
| */
|
| String get lexeme => type.lexeme;
|
|
|
| /**
|
| * Return the next token in the token stream.
|
| - *
|
| - * @return the next token in the token stream
|
| */
|
| Token get next => _next;
|
|
|
| /**
|
| - * Return the first comment in the list of comments that precede this token, or `null` if
|
| - * there are no comments preceding this token. Additional comments can be reached by following the
|
| - * token stream using [getNext] until `null` is returned.
|
| + * Return the first comment in the list of comments that precede this token,
|
| + * or `null` if there are no comments preceding this token. Additional
|
| + * comments can be reached by following the token stream using [next] until
|
| + * `null` is returned.
|
| *
|
| - * @return the first comment in the list of comments that precede this token
|
| + * For example, if the original contents were "/* one */ /* two */ id", then
|
| + * the first precceding comment token will have a lexeme of "/* one */" and
|
| + * the next comment token will have a lexeme of "/* two */".
|
| */
|
| Token get precedingComments => null;
|
|
|
| /**
|
| - * Apply (add) the given delta to this token's offset.
|
| - *
|
| - * @param delta the amount by which the offset is to be adjusted
|
| + * Apply (add) the given [delta] to this token's offset.
|
| */
|
| void applyDelta(int delta) {
|
| offset += delta;
|
| }
|
|
|
| /**
|
| - * Return a newly created token that is a copy of this token but that is not a part of any token
|
| - * stream.
|
| - *
|
| - * @return a newly created token that is a copy of this token
|
| + * Return a newly created token that is a copy of this token but that is not a
|
| + * part of any token stream.
|
| */
|
| Token copy() => new Token(type, offset);
|
|
|
| /**
|
| * Copy a linked list of comment tokens identical to the given comment tokens.
|
| - *
|
| - * @param token the first token in the list, or `null` if there are no tokens to be copied
|
| - * @return the tokens that were created
|
| */
|
| Token copyComments(Token token) {
|
| if (token == null) {
|
| @@ -2289,10 +2261,7 @@ class Token {
|
| }
|
|
|
| /**
|
| - * Return `true` if this token has any one of the given types.
|
| - *
|
| - * @param types the types of token that are being tested for
|
| - * @return `true` if this token has any of the given types
|
| + * Return `true` if this token has any one of the given [types].
|
| */
|
| bool matchesAny(List<TokenType> types) {
|
| for (TokenType type in types) {
|
| @@ -2304,11 +2273,9 @@ class Token {
|
| }
|
|
|
| /**
|
| - * Set the next token in the token stream to the given token. This has the side-effect of setting
|
| - * this token to be the previous token for the given token.
|
| - *
|
| - * @param token the next token in the token stream
|
| - * @return the token that was passed in
|
| + * Set the next token in the token stream to the given [token]. This has the
|
| + * side-effect of setting this token to be the previous token for the given
|
| + * token. Return the token that was passed in.
|
| */
|
| Token setNext(Token token) {
|
| _next = token;
|
| @@ -2317,11 +2284,9 @@ class Token {
|
| }
|
|
|
| /**
|
| - * Set the next token in the token stream to the given token without changing which token is the
|
| - * previous token for the given token.
|
| - *
|
| - * @param token the next token in the token stream
|
| - * @return the token that was passed in
|
| + * Set the next token in the token stream to the given token without changing
|
| + * which token is the previous token for the given token. Return the token
|
| + * that was passed in.
|
| */
|
| Token setNextWithoutSettingPrevious(Token token) {
|
| _next = token;
|
| @@ -2332,10 +2297,9 @@ class Token {
|
| String toString() => lexeme;
|
|
|
| /**
|
| - * Return the value of this token. For keyword tokens, this is the keyword associated with the
|
| - * token, for other tokens it is the lexeme associated with the token.
|
| - *
|
| - * @return the value of this token
|
| + * Return the value of this token. For keyword tokens, this is the keyword
|
| + * associated with the token, for other tokens it is the lexeme associated
|
| + * with the token.
|
| */
|
| Object value() => type.lexeme;
|
|
|
| @@ -2343,8 +2307,8 @@ class Token {
|
| * Compare the given [tokens] to find the token that appears first in the
|
| * source being parsed. That is, return the left-most of all of the tokens.
|
| * The list must be non-`null`, but the elements of the list are allowed to be
|
| - * `null`. Return the token with the smallest offset, or `null` if there are
|
| - * no tokens or if all of the tokens are `null`.
|
| + * `null`. Return the token with the smallest offset, or `null` if the list is
|
| + * empty or if all of the elements of the list are `null`.
|
| */
|
| static Token lexicallyFirst(List<Token> tokens) {
|
| Token first = null;
|
| @@ -2360,429 +2324,322 @@ class Token {
|
| }
|
|
|
| /**
|
| - * The enumeration `TokenClass` represents classes (or groups) of tokens with a similar use.
|
| + * The enumeration `TokenClass` represents classes (or groups) of tokens with a
|
| + * similar use.
|
| */
|
| -class TokenClass extends Enum<TokenClass> {
|
| +class TokenClass {
|
| /**
|
| - * A value used to indicate that the token type is not part of any specific class of token.
|
| + * A value used to indicate that the token type is not part of any specific
|
| + * class of token.
|
| */
|
| - static const TokenClass NO_CLASS = const TokenClass.con1('NO_CLASS', 0);
|
| + static const TokenClass NO_CLASS = const TokenClass('NO_CLASS');
|
|
|
| /**
|
| * A value used to indicate that the token type is an additive operator.
|
| */
|
| static const TokenClass ADDITIVE_OPERATOR =
|
| - const TokenClass.con2('ADDITIVE_OPERATOR', 1, 12);
|
| + const TokenClass('ADDITIVE_OPERATOR', 12);
|
|
|
| /**
|
| * A value used to indicate that the token type is an assignment operator.
|
| */
|
| static const TokenClass ASSIGNMENT_OPERATOR =
|
| - const TokenClass.con2('ASSIGNMENT_OPERATOR', 2, 1);
|
| + const TokenClass('ASSIGNMENT_OPERATOR', 1);
|
|
|
| /**
|
| * A value used to indicate that the token type is a bitwise-and operator.
|
| */
|
| static const TokenClass BITWISE_AND_OPERATOR =
|
| - const TokenClass.con2('BITWISE_AND_OPERATOR', 3, 10);
|
| + const TokenClass('BITWISE_AND_OPERATOR', 10);
|
|
|
| /**
|
| * A value used to indicate that the token type is a bitwise-or operator.
|
| */
|
| static const TokenClass BITWISE_OR_OPERATOR =
|
| - const TokenClass.con2('BITWISE_OR_OPERATOR', 4, 8);
|
| + const TokenClass('BITWISE_OR_OPERATOR', 8);
|
|
|
| /**
|
| * A value used to indicate that the token type is a bitwise-xor operator.
|
| */
|
| static const TokenClass BITWISE_XOR_OPERATOR =
|
| - const TokenClass.con2('BITWISE_XOR_OPERATOR', 5, 9);
|
| + const TokenClass('BITWISE_XOR_OPERATOR', 9);
|
|
|
| /**
|
| * A value used to indicate that the token type is a cascade operator.
|
| */
|
| static const TokenClass CASCADE_OPERATOR =
|
| - const TokenClass.con2('CASCADE_OPERATOR', 6, 2);
|
| + const TokenClass('CASCADE_OPERATOR', 2);
|
|
|
| /**
|
| * A value used to indicate that the token type is a conditional operator.
|
| */
|
| static const TokenClass CONDITIONAL_OPERATOR =
|
| - const TokenClass.con2('CONDITIONAL_OPERATOR', 7, 3);
|
| + const TokenClass('CONDITIONAL_OPERATOR', 3);
|
|
|
| /**
|
| * A value used to indicate that the token type is an equality operator.
|
| */
|
| static const TokenClass EQUALITY_OPERATOR =
|
| - const TokenClass.con2('EQUALITY_OPERATOR', 8, 6);
|
| + const TokenClass('EQUALITY_OPERATOR', 6);
|
|
|
| /**
|
| * A value used to indicate that the token type is a logical-and operator.
|
| */
|
| static const TokenClass LOGICAL_AND_OPERATOR =
|
| - const TokenClass.con2('LOGICAL_AND_OPERATOR', 9, 5);
|
| + const TokenClass('LOGICAL_AND_OPERATOR', 5);
|
|
|
| /**
|
| * A value used to indicate that the token type is a logical-or operator.
|
| */
|
| static const TokenClass LOGICAL_OR_OPERATOR =
|
| - const TokenClass.con2('LOGICAL_OR_OPERATOR', 10, 4);
|
| + const TokenClass('LOGICAL_OR_OPERATOR', 4);
|
|
|
| /**
|
| * A value used to indicate that the token type is a multiplicative operator.
|
| */
|
| static const TokenClass MULTIPLICATIVE_OPERATOR =
|
| - const TokenClass.con2('MULTIPLICATIVE_OPERATOR', 11, 13);
|
| + const TokenClass('MULTIPLICATIVE_OPERATOR', 13);
|
|
|
| /**
|
| * A value used to indicate that the token type is a relational operator.
|
| */
|
| static const TokenClass RELATIONAL_OPERATOR =
|
| - const TokenClass.con2('RELATIONAL_OPERATOR', 12, 7);
|
| + const TokenClass('RELATIONAL_OPERATOR', 7);
|
|
|
| /**
|
| * A value used to indicate that the token type is a shift operator.
|
| */
|
| static const TokenClass SHIFT_OPERATOR =
|
| - const TokenClass.con2('SHIFT_OPERATOR', 13, 11);
|
| + const TokenClass('SHIFT_OPERATOR', 11);
|
|
|
| /**
|
| * A value used to indicate that the token type is a unary operator.
|
| */
|
| static const TokenClass UNARY_POSTFIX_OPERATOR =
|
| - const TokenClass.con2('UNARY_POSTFIX_OPERATOR', 14, 15);
|
| + const TokenClass('UNARY_POSTFIX_OPERATOR', 15);
|
|
|
| /**
|
| * A value used to indicate that the token type is a unary operator.
|
| */
|
| static const TokenClass UNARY_PREFIX_OPERATOR =
|
| - const TokenClass.con2('UNARY_PREFIX_OPERATOR', 15, 14);
|
| -
|
| - static const List<TokenClass> values = const [
|
| - NO_CLASS,
|
| - ADDITIVE_OPERATOR,
|
| - ASSIGNMENT_OPERATOR,
|
| - BITWISE_AND_OPERATOR,
|
| - BITWISE_OR_OPERATOR,
|
| - BITWISE_XOR_OPERATOR,
|
| - CASCADE_OPERATOR,
|
| - CONDITIONAL_OPERATOR,
|
| - EQUALITY_OPERATOR,
|
| - LOGICAL_AND_OPERATOR,
|
| - LOGICAL_OR_OPERATOR,
|
| - MULTIPLICATIVE_OPERATOR,
|
| - RELATIONAL_OPERATOR,
|
| - SHIFT_OPERATOR,
|
| - UNARY_POSTFIX_OPERATOR,
|
| - UNARY_PREFIX_OPERATOR];
|
| -
|
| - /**
|
| - * The precedence of tokens of this class, or `0` if the such tokens do not represent an
|
| - * operator.
|
| + const TokenClass('UNARY_PREFIX_OPERATOR', 14);
|
| +
|
| + /**
|
| + * The name of the token class.
|
| */
|
| - final int precedence;
|
| + final String name;
|
|
|
| - const TokenClass.con1(String name, int ordinal) : this.con2(name, ordinal, 0);
|
| + /**
|
| + * The precedence of tokens of this class, or `0` if the such tokens do not
|
| + * represent an operator.
|
| + */
|
| + final int precedence;
|
|
|
| - const TokenClass.con2(String name, int ordinal, this.precedence)
|
| - : super(name, ordinal);
|
| + const TokenClass(this.name, [this.precedence = 0]);
|
| }
|
|
|
| /**
|
| - * The enumeration `TokenType` defines the types of tokens that can be returned by the
|
| - * scanner.
|
| + * The enumeration `TokenType` defines the types of tokens that can be returned
|
| + * by the scanner.
|
| */
|
| -class TokenType extends Enum<TokenType> {
|
| +class TokenType {
|
| /**
|
| * The type of the token that marks the end of the input.
|
| */
|
| - static const TokenType EOF =
|
| - const TokenType_EOF('EOF', 0, TokenClass.NO_CLASS, "");
|
| + static const TokenType EOF = const TokenType_EOF('EOF');
|
|
|
| - static const TokenType DOUBLE = const TokenType.con1('DOUBLE', 1);
|
| + static const TokenType DOUBLE = const TokenType('DOUBLE');
|
|
|
| - static const TokenType HEXADECIMAL = const TokenType.con1('HEXADECIMAL', 2);
|
| + static const TokenType HEXADECIMAL = const TokenType('HEXADECIMAL');
|
|
|
| - static const TokenType IDENTIFIER = const TokenType.con1('IDENTIFIER', 3);
|
| + static const TokenType IDENTIFIER = const TokenType('IDENTIFIER');
|
|
|
| - static const TokenType INT = const TokenType.con1('INT', 4);
|
| + static const TokenType INT = const TokenType('INT');
|
|
|
| - static const TokenType KEYWORD = const TokenType.con1('KEYWORD', 5);
|
| + static const TokenType KEYWORD = const TokenType('KEYWORD');
|
|
|
| static const TokenType MULTI_LINE_COMMENT =
|
| - const TokenType.con1('MULTI_LINE_COMMENT', 6);
|
| + const TokenType('MULTI_LINE_COMMENT');
|
|
|
| - static const TokenType SCRIPT_TAG = const TokenType.con1('SCRIPT_TAG', 7);
|
| + static const TokenType SCRIPT_TAG = const TokenType('SCRIPT_TAG');
|
|
|
| static const TokenType SINGLE_LINE_COMMENT =
|
| - const TokenType.con1('SINGLE_LINE_COMMENT', 8);
|
| + const TokenType('SINGLE_LINE_COMMENT');
|
|
|
| - static const TokenType STRING = const TokenType.con1('STRING', 9);
|
| + static const TokenType STRING = const TokenType('STRING');
|
|
|
| static const TokenType AMPERSAND =
|
| - const TokenType.con2('AMPERSAND', 10, TokenClass.BITWISE_AND_OPERATOR, "&");
|
| + const TokenType('AMPERSAND', TokenClass.BITWISE_AND_OPERATOR, "&");
|
|
|
| - static const TokenType AMPERSAND_AMPERSAND = const TokenType.con2(
|
| - 'AMPERSAND_AMPERSAND',
|
| - 11,
|
| - TokenClass.LOGICAL_AND_OPERATOR,
|
| - "&&");
|
| + static const TokenType AMPERSAND_AMPERSAND =
|
| + const TokenType('AMPERSAND_AMPERSAND', TokenClass.LOGICAL_AND_OPERATOR, "&&");
|
|
|
| static const TokenType AMPERSAND_EQ =
|
| - const TokenType.con2('AMPERSAND_EQ', 12, TokenClass.ASSIGNMENT_OPERATOR, "&=");
|
| + const TokenType('AMPERSAND_EQ', TokenClass.ASSIGNMENT_OPERATOR, "&=");
|
|
|
| - static const TokenType AT =
|
| - const TokenType.con2('AT', 13, TokenClass.NO_CLASS, "@");
|
| + static const TokenType AT = const TokenType('AT', TokenClass.NO_CLASS, "@");
|
|
|
| static const TokenType BANG =
|
| - const TokenType.con2('BANG', 14, TokenClass.UNARY_PREFIX_OPERATOR, "!");
|
| + const TokenType('BANG', TokenClass.UNARY_PREFIX_OPERATOR, "!");
|
|
|
| static const TokenType BANG_EQ =
|
| - const TokenType.con2('BANG_EQ', 15, TokenClass.EQUALITY_OPERATOR, "!=");
|
| + const TokenType('BANG_EQ', TokenClass.EQUALITY_OPERATOR, "!=");
|
|
|
| static const TokenType BAR =
|
| - const TokenType.con2('BAR', 16, TokenClass.BITWISE_OR_OPERATOR, "|");
|
| + const TokenType('BAR', TokenClass.BITWISE_OR_OPERATOR, "|");
|
|
|
| static const TokenType BAR_BAR =
|
| - const TokenType.con2('BAR_BAR', 17, TokenClass.LOGICAL_OR_OPERATOR, "||");
|
| + const TokenType('BAR_BAR', TokenClass.LOGICAL_OR_OPERATOR, "||");
|
|
|
| static const TokenType BAR_EQ =
|
| - const TokenType.con2('BAR_EQ', 18, TokenClass.ASSIGNMENT_OPERATOR, "|=");
|
| + const TokenType('BAR_EQ', TokenClass.ASSIGNMENT_OPERATOR, "|=");
|
|
|
| static const TokenType COLON =
|
| - const TokenType.con2('COLON', 19, TokenClass.NO_CLASS, ":");
|
| + const TokenType('COLON', TokenClass.NO_CLASS, ":");
|
|
|
| static const TokenType COMMA =
|
| - const TokenType.con2('COMMA', 20, TokenClass.NO_CLASS, ",");
|
| + const TokenType('COMMA', TokenClass.NO_CLASS, ",");
|
|
|
| static const TokenType CARET =
|
| - const TokenType.con2('CARET', 21, TokenClass.BITWISE_XOR_OPERATOR, "^");
|
| + const TokenType('CARET', TokenClass.BITWISE_XOR_OPERATOR, "^");
|
|
|
| static const TokenType CARET_EQ =
|
| - const TokenType.con2('CARET_EQ', 22, TokenClass.ASSIGNMENT_OPERATOR, "^=");
|
| + const TokenType('CARET_EQ', TokenClass.ASSIGNMENT_OPERATOR, "^=");
|
|
|
| static const TokenType CLOSE_CURLY_BRACKET =
|
| - const TokenType.con2('CLOSE_CURLY_BRACKET', 23, TokenClass.NO_CLASS, "}");
|
| + const TokenType('CLOSE_CURLY_BRACKET', TokenClass.NO_CLASS, "}");
|
|
|
| static const TokenType CLOSE_PAREN =
|
| - const TokenType.con2('CLOSE_PAREN', 24, TokenClass.NO_CLASS, ")");
|
| + const TokenType('CLOSE_PAREN', TokenClass.NO_CLASS, ")");
|
|
|
| static const TokenType CLOSE_SQUARE_BRACKET =
|
| - const TokenType.con2('CLOSE_SQUARE_BRACKET', 25, TokenClass.NO_CLASS, "]");
|
| + const TokenType('CLOSE_SQUARE_BRACKET', TokenClass.NO_CLASS, "]");
|
|
|
| static const TokenType EQ =
|
| - const TokenType.con2('EQ', 26, TokenClass.ASSIGNMENT_OPERATOR, "=");
|
| + const TokenType('EQ', TokenClass.ASSIGNMENT_OPERATOR, "=");
|
|
|
| static const TokenType EQ_EQ =
|
| - const TokenType.con2('EQ_EQ', 27, TokenClass.EQUALITY_OPERATOR, "==");
|
| + const TokenType('EQ_EQ', TokenClass.EQUALITY_OPERATOR, "==");
|
|
|
| static const TokenType FUNCTION =
|
| - const TokenType.con2('FUNCTION', 28, TokenClass.NO_CLASS, "=>");
|
| + const TokenType('FUNCTION', TokenClass.NO_CLASS, "=>");
|
|
|
| static const TokenType GT =
|
| - const TokenType.con2('GT', 29, TokenClass.RELATIONAL_OPERATOR, ">");
|
| + const TokenType('GT', TokenClass.RELATIONAL_OPERATOR, ">");
|
|
|
| static const TokenType GT_EQ =
|
| - const TokenType.con2('GT_EQ', 30, TokenClass.RELATIONAL_OPERATOR, ">=");
|
| + const TokenType('GT_EQ', TokenClass.RELATIONAL_OPERATOR, ">=");
|
|
|
| static const TokenType GT_GT =
|
| - const TokenType.con2('GT_GT', 31, TokenClass.SHIFT_OPERATOR, ">>");
|
| + const TokenType('GT_GT', TokenClass.SHIFT_OPERATOR, ">>");
|
|
|
| static const TokenType GT_GT_EQ =
|
| - const TokenType.con2('GT_GT_EQ', 32, TokenClass.ASSIGNMENT_OPERATOR, ">>=");
|
| + const TokenType('GT_GT_EQ', TokenClass.ASSIGNMENT_OPERATOR, ">>=");
|
|
|
| static const TokenType HASH =
|
| - const TokenType.con2('HASH', 33, TokenClass.NO_CLASS, "#");
|
| + const TokenType('HASH', TokenClass.NO_CLASS, "#");
|
|
|
| static const TokenType INDEX =
|
| - const TokenType.con2('INDEX', 34, TokenClass.UNARY_POSTFIX_OPERATOR, "[]");
|
| + const TokenType('INDEX', TokenClass.UNARY_POSTFIX_OPERATOR, "[]");
|
|
|
| static const TokenType INDEX_EQ =
|
| - const TokenType.con2('INDEX_EQ', 35, TokenClass.UNARY_POSTFIX_OPERATOR, "[]=");
|
| + const TokenType('INDEX_EQ', TokenClass.UNARY_POSTFIX_OPERATOR, "[]=");
|
|
|
| static const TokenType IS =
|
| - const TokenType.con2('IS', 36, TokenClass.RELATIONAL_OPERATOR, "is");
|
| + const TokenType('IS', TokenClass.RELATIONAL_OPERATOR, "is");
|
|
|
| static const TokenType LT =
|
| - const TokenType.con2('LT', 37, TokenClass.RELATIONAL_OPERATOR, "<");
|
| + const TokenType('LT', TokenClass.RELATIONAL_OPERATOR, "<");
|
|
|
| static const TokenType LT_EQ =
|
| - const TokenType.con2('LT_EQ', 38, TokenClass.RELATIONAL_OPERATOR, "<=");
|
| + const TokenType('LT_EQ', TokenClass.RELATIONAL_OPERATOR, "<=");
|
|
|
| static const TokenType LT_LT =
|
| - const TokenType.con2('LT_LT', 39, TokenClass.SHIFT_OPERATOR, "<<");
|
| + const TokenType('LT_LT', TokenClass.SHIFT_OPERATOR, "<<");
|
|
|
| static const TokenType LT_LT_EQ =
|
| - const TokenType.con2('LT_LT_EQ', 40, TokenClass.ASSIGNMENT_OPERATOR, "<<=");
|
| + const TokenType('LT_LT_EQ', TokenClass.ASSIGNMENT_OPERATOR, "<<=");
|
|
|
| static const TokenType MINUS =
|
| - const TokenType.con2('MINUS', 41, TokenClass.ADDITIVE_OPERATOR, "-");
|
| + const TokenType('MINUS', TokenClass.ADDITIVE_OPERATOR, "-");
|
|
|
| static const TokenType MINUS_EQ =
|
| - const TokenType.con2('MINUS_EQ', 42, TokenClass.ASSIGNMENT_OPERATOR, "-=");
|
| + const TokenType('MINUS_EQ', TokenClass.ASSIGNMENT_OPERATOR, "-=");
|
|
|
| - static const TokenType MINUS_MINUS = const TokenType.con2(
|
| - 'MINUS_MINUS',
|
| - 43,
|
| - TokenClass.UNARY_PREFIX_OPERATOR,
|
| - "--");
|
| + static const TokenType MINUS_MINUS =
|
| + const TokenType('MINUS_MINUS', TokenClass.UNARY_PREFIX_OPERATOR, "--");
|
|
|
| static const TokenType OPEN_CURLY_BRACKET =
|
| - const TokenType.con2('OPEN_CURLY_BRACKET', 44, TokenClass.NO_CLASS, "{");
|
| + const TokenType('OPEN_CURLY_BRACKET', TokenClass.NO_CLASS, "{");
|
|
|
| static const TokenType OPEN_PAREN =
|
| - const TokenType.con2('OPEN_PAREN', 45, TokenClass.UNARY_POSTFIX_OPERATOR, "(");
|
| + const TokenType('OPEN_PAREN', TokenClass.UNARY_POSTFIX_OPERATOR, "(");
|
|
|
| - static const TokenType OPEN_SQUARE_BRACKET = const TokenType.con2(
|
| - 'OPEN_SQUARE_BRACKET',
|
| - 46,
|
| - TokenClass.UNARY_POSTFIX_OPERATOR,
|
| - "[");
|
| + static const TokenType OPEN_SQUARE_BRACKET =
|
| + const TokenType('OPEN_SQUARE_BRACKET', TokenClass.UNARY_POSTFIX_OPERATOR, "[");
|
|
|
| static const TokenType PERCENT =
|
| - const TokenType.con2('PERCENT', 47, TokenClass.MULTIPLICATIVE_OPERATOR, "%");
|
| + const TokenType('PERCENT', TokenClass.MULTIPLICATIVE_OPERATOR, "%");
|
|
|
| static const TokenType PERCENT_EQ =
|
| - const TokenType.con2('PERCENT_EQ', 48, TokenClass.ASSIGNMENT_OPERATOR, "%=");
|
| + const TokenType('PERCENT_EQ', TokenClass.ASSIGNMENT_OPERATOR, "%=");
|
|
|
| static const TokenType PERIOD =
|
| - const TokenType.con2('PERIOD', 49, TokenClass.UNARY_POSTFIX_OPERATOR, ".");
|
| + const TokenType('PERIOD', TokenClass.UNARY_POSTFIX_OPERATOR, ".");
|
|
|
| static const TokenType PERIOD_PERIOD =
|
| - const TokenType.con2('PERIOD_PERIOD', 50, TokenClass.CASCADE_OPERATOR, "..");
|
| + const TokenType('PERIOD_PERIOD', TokenClass.CASCADE_OPERATOR, "..");
|
|
|
| static const TokenType PLUS =
|
| - const TokenType.con2('PLUS', 51, TokenClass.ADDITIVE_OPERATOR, "+");
|
| + const TokenType('PLUS', TokenClass.ADDITIVE_OPERATOR, "+");
|
|
|
| static const TokenType PLUS_EQ =
|
| - const TokenType.con2('PLUS_EQ', 52, TokenClass.ASSIGNMENT_OPERATOR, "+=");
|
| + const TokenType('PLUS_EQ', TokenClass.ASSIGNMENT_OPERATOR, "+=");
|
|
|
| static const TokenType PLUS_PLUS =
|
| - const TokenType.con2('PLUS_PLUS', 53, TokenClass.UNARY_PREFIX_OPERATOR, "++");
|
| + const TokenType('PLUS_PLUS', TokenClass.UNARY_PREFIX_OPERATOR, "++");
|
|
|
| static const TokenType QUESTION =
|
| - const TokenType.con2('QUESTION', 54, TokenClass.CONDITIONAL_OPERATOR, "?");
|
| + const TokenType('QUESTION', TokenClass.CONDITIONAL_OPERATOR, "?");
|
|
|
| static const TokenType SEMICOLON =
|
| - const TokenType.con2('SEMICOLON', 55, TokenClass.NO_CLASS, ";");
|
| + const TokenType('SEMICOLON', TokenClass.NO_CLASS, ";");
|
|
|
| static const TokenType SLASH =
|
| - const TokenType.con2('SLASH', 56, TokenClass.MULTIPLICATIVE_OPERATOR, "/");
|
| + const TokenType('SLASH', TokenClass.MULTIPLICATIVE_OPERATOR, "/");
|
|
|
| static const TokenType SLASH_EQ =
|
| - const TokenType.con2('SLASH_EQ', 57, TokenClass.ASSIGNMENT_OPERATOR, "/=");
|
| + const TokenType('SLASH_EQ', TokenClass.ASSIGNMENT_OPERATOR, "/=");
|
|
|
| static const TokenType STAR =
|
| - const TokenType.con2('STAR', 58, TokenClass.MULTIPLICATIVE_OPERATOR, "*");
|
| + const TokenType('STAR', TokenClass.MULTIPLICATIVE_OPERATOR, "*");
|
|
|
| static const TokenType STAR_EQ =
|
| - const TokenType.con2('STAR_EQ', 59, TokenClass.ASSIGNMENT_OPERATOR, "*=");
|
| + const TokenType('STAR_EQ', TokenClass.ASSIGNMENT_OPERATOR, "*=");
|
|
|
| - static const TokenType STRING_INTERPOLATION_EXPRESSION = const TokenType.con2(
|
| - 'STRING_INTERPOLATION_EXPRESSION',
|
| - 60,
|
| - TokenClass.NO_CLASS,
|
| - "\${");
|
| + static const TokenType STRING_INTERPOLATION_EXPRESSION =
|
| + const TokenType('STRING_INTERPOLATION_EXPRESSION', TokenClass.NO_CLASS, "\${");
|
|
|
| - static const TokenType STRING_INTERPOLATION_IDENTIFIER = const TokenType.con2(
|
| - 'STRING_INTERPOLATION_IDENTIFIER',
|
| - 61,
|
| - TokenClass.NO_CLASS,
|
| - "\$");
|
| + static const TokenType STRING_INTERPOLATION_IDENTIFIER =
|
| + const TokenType('STRING_INTERPOLATION_IDENTIFIER', TokenClass.NO_CLASS, "\$");
|
|
|
| static const TokenType TILDE =
|
| - const TokenType.con2('TILDE', 62, TokenClass.UNARY_PREFIX_OPERATOR, "~");
|
| + const TokenType('TILDE', TokenClass.UNARY_PREFIX_OPERATOR, "~");
|
|
|
| - static const TokenType TILDE_SLASH = const TokenType.con2(
|
| - 'TILDE_SLASH',
|
| - 63,
|
| - TokenClass.MULTIPLICATIVE_OPERATOR,
|
| - "~/");
|
| + static const TokenType TILDE_SLASH =
|
| + const TokenType('TILDE_SLASH', TokenClass.MULTIPLICATIVE_OPERATOR, "~/");
|
|
|
| - static const TokenType TILDE_SLASH_EQ = const TokenType.con2(
|
| - 'TILDE_SLASH_EQ',
|
| - 64,
|
| - TokenClass.ASSIGNMENT_OPERATOR,
|
| - "~/=");
|
| + static const TokenType TILDE_SLASH_EQ =
|
| + const TokenType('TILDE_SLASH_EQ', TokenClass.ASSIGNMENT_OPERATOR, "~/=");
|
|
|
| static const TokenType BACKPING =
|
| - const TokenType.con2('BACKPING', 65, TokenClass.NO_CLASS, "`");
|
| + const TokenType('BACKPING', TokenClass.NO_CLASS, "`");
|
|
|
| static const TokenType BACKSLASH =
|
| - const TokenType.con2('BACKSLASH', 66, TokenClass.NO_CLASS, "\\");
|
| + const TokenType('BACKSLASH', TokenClass.NO_CLASS, "\\");
|
|
|
| static const TokenType PERIOD_PERIOD_PERIOD =
|
| - const TokenType.con2('PERIOD_PERIOD_PERIOD', 67, TokenClass.NO_CLASS, "...");
|
| -
|
| - static const List<TokenType> values = const [
|
| - EOF,
|
| - DOUBLE,
|
| - HEXADECIMAL,
|
| - IDENTIFIER,
|
| - INT,
|
| - KEYWORD,
|
| - MULTI_LINE_COMMENT,
|
| - SCRIPT_TAG,
|
| - SINGLE_LINE_COMMENT,
|
| - STRING,
|
| - AMPERSAND,
|
| - AMPERSAND_AMPERSAND,
|
| - AMPERSAND_EQ,
|
| - AT,
|
| - BANG,
|
| - BANG_EQ,
|
| - BAR,
|
| - BAR_BAR,
|
| - BAR_EQ,
|
| - COLON,
|
| - COMMA,
|
| - CARET,
|
| - CARET_EQ,
|
| - CLOSE_CURLY_BRACKET,
|
| - CLOSE_PAREN,
|
| - CLOSE_SQUARE_BRACKET,
|
| - EQ,
|
| - EQ_EQ,
|
| - FUNCTION,
|
| - GT,
|
| - GT_EQ,
|
| - GT_GT,
|
| - GT_GT_EQ,
|
| - HASH,
|
| - INDEX,
|
| - INDEX_EQ,
|
| - IS,
|
| - LT,
|
| - LT_EQ,
|
| - LT_LT,
|
| - LT_LT_EQ,
|
| - MINUS,
|
| - MINUS_EQ,
|
| - MINUS_MINUS,
|
| - OPEN_CURLY_BRACKET,
|
| - OPEN_PAREN,
|
| - OPEN_SQUARE_BRACKET,
|
| - PERCENT,
|
| - PERCENT_EQ,
|
| - PERIOD,
|
| - PERIOD_PERIOD,
|
| - PLUS,
|
| - PLUS_EQ,
|
| - PLUS_PLUS,
|
| - QUESTION,
|
| - SEMICOLON,
|
| - SLASH,
|
| - SLASH_EQ,
|
| - STAR,
|
| - STAR_EQ,
|
| - STRING_INTERPOLATION_EXPRESSION,
|
| - STRING_INTERPOLATION_IDENTIFIER,
|
| - TILDE,
|
| - TILDE_SLASH,
|
| - TILDE_SLASH_EQ,
|
| - BACKPING,
|
| - BACKSLASH,
|
| - PERIOD_PERIOD_PERIOD];
|
| + const TokenType('PERIOD_PERIOD_PERIOD', TokenClass.NO_CLASS, "...");
|
|
|
| /**
|
| * The class of the token.
|
| @@ -2790,43 +2647,41 @@ class TokenType extends Enum<TokenType> {
|
| final TokenClass _tokenClass;
|
|
|
| /**
|
| - * The lexeme that defines this type of token, or `null` if there is more than one possible
|
| - * lexeme for this type of token.
|
| + * The name of the token type.
|
| */
|
| - final String lexeme;
|
| + final String name;
|
|
|
| - const TokenType.con1(String name, int ordinal)
|
| - : this.con2(name, ordinal, TokenClass.NO_CLASS, null);
|
| + /**
|
| + * The lexeme that defines this type of token, or `null` if there is more than
|
| + * one possible lexeme for this type of token.
|
| + */
|
| + final String lexeme;
|
|
|
| - const TokenType.con2(String name, int ordinal, this._tokenClass, this.lexeme)
|
| - : super(name, ordinal);
|
| + const TokenType(this.name, [this._tokenClass = TokenClass.NO_CLASS,
|
| + this.lexeme = null]);
|
|
|
| /**
|
| * Return `true` if this type of token represents an additive operator.
|
| - *
|
| - * @return `true` if this type of token represents an additive operator
|
| */
|
| bool get isAdditiveOperator => _tokenClass == TokenClass.ADDITIVE_OPERATOR;
|
|
|
| /**
|
| * Return `true` if this type of token represents an assignment operator.
|
| - *
|
| - * @return `true` if this type of token represents an assignment operator
|
| */
|
| bool get isAssignmentOperator =>
|
| _tokenClass == TokenClass.ASSIGNMENT_OPERATOR;
|
|
|
| /**
|
| - * Return `true` if this type of token represents an associative operator. An associative
|
| - * 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
|
| - * multiple operands does not depend on the order in which those applications occur.
|
| + * Return `true` if this type of token represents an associative operator. An
|
| + * associative 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 multiple operands does not depend on the order in
|
| + * which those applications occur.
|
| *
|
| - * Note: This method considers the logical-and and logical-or operators to be associative, even
|
| - * though the order in which the application of those operators can have an effect because
|
| - * evaluation of the right-hand operand is conditional.
|
| - *
|
| - * @return `true` if this type of token represents an associative operator
|
| + * Note: This method considers the logical-and and logical-or operators to be
|
| + * associative, even though the order in which the application of those
|
| + * operators can have an effect because evaluation of the right-hand operand
|
| + * is conditional.
|
| */
|
| bool get isAssociativeOperator =>
|
| this == AMPERSAND ||
|
| @@ -2839,31 +2694,23 @@ class TokenType extends Enum<TokenType> {
|
|
|
| /**
|
| * Return `true` if this type of token represents an equality operator.
|
| - *
|
| - * @return `true` if this type of token represents an equality operator
|
| */
|
| bool get isEqualityOperator => _tokenClass == TokenClass.EQUALITY_OPERATOR;
|
|
|
| /**
|
| * Return `true` if this type of token represents an increment operator.
|
| - *
|
| - * @return `true` if this type of token represents an increment operator
|
| */
|
| bool get isIncrementOperator =>
|
| identical(lexeme, "++") || identical(lexeme, "--");
|
|
|
| /**
|
| * Return `true` if this type of token represents a multiplicative operator.
|
| - *
|
| - * @return `true` if this type of token represents a multiplicative operator
|
| */
|
| bool get isMultiplicativeOperator =>
|
| _tokenClass == TokenClass.MULTIPLICATIVE_OPERATOR;
|
|
|
| /**
|
| * Return `true` if this token type represents an operator.
|
| - *
|
| - * @return `true` if this token type represents an operator
|
| */
|
| bool get isOperator =>
|
| _tokenClass != TokenClass.NO_CLASS &&
|
| @@ -2873,39 +2720,30 @@ class TokenType extends Enum<TokenType> {
|
|
|
| /**
|
| * Return `true` if this type of token represents a relational operator.
|
| - *
|
| - * @return `true` if this type of token represents a relational operator
|
| */
|
| bool get isRelationalOperator =>
|
| _tokenClass == TokenClass.RELATIONAL_OPERATOR;
|
|
|
| /**
|
| * Return `true` if this type of token represents a shift operator.
|
| - *
|
| - * @return `true` if this type of token represents a shift operator
|
| */
|
| bool get isShiftOperator => _tokenClass == TokenClass.SHIFT_OPERATOR;
|
|
|
| /**
|
| * Return `true` if this type of token represents a unary postfix operator.
|
| - *
|
| - * @return `true` if this type of token represents a unary postfix operator
|
| */
|
| bool get isUnaryPostfixOperator =>
|
| _tokenClass == TokenClass.UNARY_POSTFIX_OPERATOR;
|
|
|
| /**
|
| * Return `true` if this type of token represents a unary prefix operator.
|
| - *
|
| - * @return `true` if this type of token represents a unary prefix operator
|
| */
|
| bool get isUnaryPrefixOperator =>
|
| _tokenClass == TokenClass.UNARY_PREFIX_OPERATOR;
|
|
|
| /**
|
| - * Return `true` if this token type represents an operator that can be defined by users.
|
| - *
|
| - * @return `true` if this token type represents an operator that can be defined by users
|
| + * Return `true` if this token type represents an operator that can be defined
|
| + * by users.
|
| */
|
| bool get isUserDefinableOperator =>
|
| identical(lexeme, "==") ||
|
| @@ -2929,24 +2767,21 @@ class TokenType extends Enum<TokenType> {
|
| identical(lexeme, "|");
|
|
|
| /**
|
| - * Return the precedence of the token, or `0` if the token does not represent an operator.
|
| - *
|
| - * @return the precedence of the token
|
| + * Return the precedence of the token, or `0` if the token does not represent
|
| + * an operator.
|
| */
|
| int get precedence => _tokenClass.precedence;
|
| }
|
|
|
| class TokenType_EOF extends TokenType {
|
| - const TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1)
|
| - : super.con2(name, ordinal, arg0, arg1);
|
| + const TokenType_EOF(String name) : super(name, TokenClass.NO_CLASS, "");
|
|
|
| @override
|
| String toString() => "-eof-";
|
| }
|
|
|
| /**
|
| - * Instances of the class `TokenWithComment` represent a normal token that is preceded by
|
| - * comments.
|
| + * A `TokenWithComment` is a normal token that is preceded by comments.
|
| */
|
| class TokenWithComment extends Token {
|
| /**
|
| @@ -2955,12 +2790,9 @@ class TokenWithComment extends Token {
|
| final Token _precedingComment;
|
|
|
| /**
|
| - * Initialize a newly created token to have the given type and offset and to be preceded by the
|
| - * comments reachable from the given comment.
|
| - *
|
| - * @param type the type of the token
|
| - * @param offset the offset from the beginning of the file to the first character in the token
|
| - * @param precedingComment the first comment in the list of comments that precede this token
|
| + * Initialize a newly created token to have the given [type] at the given
|
| + * [offset] and to be preceded by the comments reachable from the given
|
| + * [comment].
|
| */
|
| TokenWithComment(TokenType type, int offset, this._precedingComment)
|
| : super(type, offset);
|
|
|