KeywordRule class final

Matches words with word and scopes them by table lookup.

A lookup is much faster than one large alternation of every keyword. keywords maps a scope to the words that get it. When a matched word is not in the table, each rule in otherwise is tried at the same position, which is how heuristics such as "capitalised words are types" work.

Inheritance

Constructors

KeywordRule(Map<String, List<String>> keywords, {String word = r'(?<!\w)[A-Za-z_]\w*', List<TokenRule> otherwise = const []})
Creates a keyword rule.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
keywords → Map<String, List<String>>
Scope to words, such as {'keyword': ['if', 'else']}.
final
otherwise → List<TokenRule>
Rules tried, in order, on words that are not keywords.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
word → String
Pattern for a single word.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited