Scanner class
Scanner scans strings for symbols, matches brackets, skips whitespace, etc.
Properties
- document ↔ String
-
Text to parse.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- inBounds → bool
-
Whether or not
positionis between 0 andlength.no setter - length → int
-
Shorthand for
document.length.no setter - position ↔ int
-
Current index into
document.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
chainParse(
Map< String, void Function()> handlerChain, [bool trimWhitespace = true]) → void -
Call a series of functions based on the first matched symbol. If
trimWhitespaceis true, whitespace is skipped in between text. -
clampPos(
int pos, [int min = 0]) → int -
Make sure
posis betweenmin(default: 0) and the length of this document. -
getLineCol(
[int pos = -1]) → String -
Get
pos(defaults tothis.position) as a line:column string. -
matchBrackets(
String open, String close, [bool canEscape = true, bool mustClose = true]) → String -
Get all characters between
openandclose, assumingopenoccurs atpositionindocument. This function allows nesting unlessopenandclosematch. IfcanEscapeistrue(default) backslashes can escapeopenorclose, otherwise they are just parsed as text. IfmustCloseistrue, an exception will be thrown if a matchingcloseto the top-levelopenis not found. Either way, this function will throw an exception ifdocumentends with\or ifopendoesn't occur atposition. This function's result is exclusive, meaning it will not contain the top-levelopenorclose(but will include any nested ones. Did you get all that? -
matches(
String text) → bool -
Check if
textoccurs atpositionindocument. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parseAttributes(
) → Map< String, String> -
Parse a series of Dingo-style attributes starting at
position. -
parseName(
NameScannerMode mode) → String - Read a Dingo-compliant name.
-
peek(
[int count = 1]) → String -
Get a substring from the document. If
countis negative, this function returnscount.abs()characters leading up to the current position. Ifcountis positive, this function returnscountcharacters after the current position. Ifcountis 0, this function returns an empty string. The calculated start and end positions ofpeekare bounds-checked (meaning they bottom out at0and top out atlength.) -
seek(
[int n = 1]) → bool -
Nudge the cursor
ncharacters forward or backward. Returnstrueif the new position is in bounds. -
skipUntil(
int condition(), [bool allowEof = false]) → void -
Skip until
conditionreturns a value equal to or below 0. Throws an exception ifconditionreturns 0. Increments bycondition().abs(). -
skipWhitespace(
) → void - Skip until we've left whitespace. Does nothing if we're not in whitespace.
-
toString(
) → String -
A string representation of this object.
inherited
-
unexpectedSymbol(
[String? expected]) → String - Throw an 'unexpected symbol' style exception.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- invalidChars → const String
- quoteChars → const String
-
whitespaceChars
→ const List<
String>