parse method
- String source
override
Attempts to parse the source string matching this element.
Returns a ParseResult containing the parsed lexeme and remaining string on success. On failure, returns a failed ParseResult.
Implementation
@override
ParseResult parse(String source) {
final matched = caseSensitive
? source.startsWith(value)
: source.toLowerCase().startsWith(value.toLowerCase());
if (matched) {
return ParseResult(
true,
source.substring(value.length),
lexeme: source.substring(0, value.length),
element: toString(),
);
}
return ParseResult(false, source, element: toString());
}