Scanner class

Scanner scans strings for symbols, matches brackets, skips whitespace, etc.

Constructors

Scanner.new(String doc, [int pos = 0])
Create a new Scanner.

Properties

document String
Text to parse.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
inBounds bool
Whether or not position is between 0 and length.
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 trimWhitespace is true, whitespace is skipped in between text.
clampPos(int pos, [int min = 0]) int
Make sure pos is between min (default: 0) and the length of this document.
getLineCol([int pos = -1]) String
Get pos (defaults to this.position) as a line:column string.
matchBrackets(String open, String close, [bool canEscape = true, bool mustClose = true]) String
Get all characters between open and close, assuming open occurs at position in document. This function allows nesting unless open and close match. If canEscape is true (default) backslashes can escape open or close, otherwise they are just parsed as text. If mustClose is true, an exception will be thrown if a matching close to the top-level open is not found. Either way, this function will throw an exception if document ends with \ or if open doesn't occur at position. This function's result is exclusive, meaning it will not contain the top-level open or close (but will include any nested ones. Did you get all that?
matches(String text) bool
Check if text occurs at position in document.
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 count is negative, this function returns count.abs() characters leading up to the current position. If count is positive, this function returns count characters after the current position. If count is 0, this function returns an empty string. The calculated start and end positions of peek are bounds-checked (meaning they bottom out at 0 and top out at length.)
seek([int n = 1]) bool
Nudge the cursor n characters forward or backward. Returns true if the new position is in bounds.
skipUntil(int condition(), [bool allowEof = false]) → void
Skip until condition returns a value equal to or below 0. Throws an exception if condition returns 0. Increments by condition().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>