StringTokenImpl class
A String-valued token. Represents identifiers, string literals, number literals, comments, and error tokens, using the corresponding precedence info.
- Implemented types
Constructors
- StringTokenImpl.fromString(TokenType type, String value, int charOffset, {bool canonicalize = false, CommentToken? precedingComments})
-
Creates a non-lazy string token. If
canonicalize
is true, the string is canonicalized before the token is created. - StringTokenImpl.fromSubstring(TokenType type, String data, int start, int end, int charOffset, {bool canonicalize = false, CommentToken? precedingComments})
-
Creates a lazy string token. If
canonicalize
is true, the string is canonicalized before the token is created. -
StringTokenImpl.fromUtf8Bytes(TokenType type, List<
int> data, int start, int end, bool asciiOnly, int charOffset, {CommentToken? precedingComments}) -
Creates a lazy string token. If
asciiOnly
is false, the byte array is passed through a UTF-8 decoder.
Properties
- beforeSynthetic ↔ Token?
-
The token before this synthetic token,
or
null
if this is not a synthetic)
,]
,}
, or>
token.getter/setter pairinherited - charCount → int
-
The number of characters parsed by this token.
no setterinherited
- charEnd → int
-
The character offset of the end of this token within the source text.
no setterinherited
- charOffset → int
-
The character offset of the start of this token within the source text.
no setterinherited
- end → int
-
Return the offset from the beginning of the file to the character after the
last character of the syntactic entity.
no setterinherited
- endGroup → Token?
-
The token that corresponds to this token, or
null
if this token is not the first of a pair of matching tokens (such as parentheses).no setterinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- isEof → bool
-
Return
true
if this token represents an end of file.no setterinherited - isIdentifier → bool
-
True if this token is an identifier. Some keywords allowed as identifiers,
see implementation in
KeywordToken
.no setter - isKeyword → bool
-
True if this token is a keyword. Some keywords allowed as identifiers,
see implementation in
KeywordToken
.no setterinherited - isKeywordOrIdentifier → bool
-
True if this token is a keyword or an identifier.
no setterinherited
- isModifier → bool
-
Return
true
if this token is a modifier such asabstract
orconst
.no setterinherited - isOperator → bool
-
Return
true
if this token represents an operator.no setterinherited - isSynthetic → bool
-
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.no setterinherited - isTopLevelKeyword → bool
-
Return
true
if this token is a keyword starting a top level declaration such asclass
,enum
,import
, etc.no setterinherited - isUserDefinableOperator → bool
-
Return
true
if this token represents an operator that can be defined by users.no setterinherited - keyword → Keyword?
-
Return the keyword, if a keyword token, or
null
otherwise.no setterinherited - kind → int
-
The kind enum of this token as determined by its type.
no setterinherited
- length → int
-
Return the number of characters in the syntactic entity's source range.
no setterinherited
- lexeme → String
-
Return the lexeme that represents this token.
no setter
- next ↔ Token?
-
Return the next token in the token stream.
getter/setter pairinherited
- offset ↔ int
-
The offset from the beginning of the file to the first character in the
token.
getter/setter pairinherited
- precedingComments ↔ CommentToken?
-
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 untilnull
is returned.getter/setter pairinherited - previous ↔ Token?
-
The previous token in the token stream.
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stringValue → String?
-
For symbol and keyword tokens, returns the string value represented by this
token. For
StringToken
s this method returnsnull
.no setterinherited - type → TokenType
-
The type of the token.
no setterinherited
- valueOrLazySubstring ↔ dynamic
-
getter/setter pair
Methods
-
matchesAny(
List< TokenType> types) → bool -
Return
true
if this token has any one of the giventypes
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setNext(
Token token) → 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. Return the token that was passed in.inherited -
setNextWithoutSettingPrevious(
Token? token) → 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. Return the token
that was passed in.
inherited
-
toString(
) → String - A string representation of this object.
-
value(
) → String - 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.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- canonicalizer → StringCanonicalizer
-
final
Static Methods
Constants
- LAZY_THRESHOLD → const int
- The length threshold above which substring tokens are computed lazily.