class Pegmatite::Pattern::Choice
- Pegmatite::Pattern::Choice
- Pegmatite::Pattern
- Reference
- Object
Overview
Pattern::Choice is used to specify an ordered choice of patterns.
Returns the result of the first child pattern that matched. Returns the longest-length failure of all child patterns fail.
Defined in:
pegmatite/pattern/choice.crConstructors
Instance Method Summary
- #_match(source, offset, state) : MatchResult
-
#|(other)
Override this DSL operator to accrue into the existing choice.
- #description
- #dsl_name
- #inspect(io)
-
#match(source, offset, state) : MatchResult
Explicitly memoize Choice patterns, which happens to have a significant speedup on otherwise troublesome grammars with a lot of backtracking.
Instance methods inherited from class Pegmatite::Pattern
_match(source, offset, state) : MatchResult
_match,
match(source, offset, state) : MatchResult
match
Instance methods inherited from module Pegmatite::DSL::Methods
>>(other)
>>,
^(other)
^,
|(other)
|,
~
~,
dynamic_pop(label)
dynamic_pop,
dynamic_push(label)
dynamic_push,
maybe
maybe,
named(label, tokenize = true)
named,
repeat(min = 0, max = nil)
repeat,
repeat_exactly(times)
repeat_exactly,
then_eof
then_eof
Constructor Detail
Instance Method Detail
def match(source, offset, state) : MatchResult
#
Explicitly memoize Choice patterns, which happens to have a significant speedup on otherwise troublesome grammars with a lot of backtracking. We don't do this for other patterns.