Recognizer
Core trait providing pattern matching functionality over an input stream.
The Recognizer trait defines a composable pattern matching DSL with support for backtracking, value capture, and transformation. It implements a recursive descent parser with explicit backtracking control through choice points.
Type parameters
- E
-
the type of elements in the input stream
- W
-
the type of wrapped values associated with input elements
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
trait CharRecognizer[W]
Members list
Type members
Classlikes
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Patternclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class ChoicePointobject Fence
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Choiceclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Patternclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Patternclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Patternclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Patternclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Patternclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Patternclass Objecttrait Matchableclass AnyShow all
The core pattern type representing a pattern to match.
The core pattern type representing a pattern to match.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Patternclass Objecttrait Matchableclass AnyShow all
Represents the execution state during pattern matching.
Represents the execution state during pattern matching.
Value parameters
- pat
-
the initial pattern to match
- pointer
-
the current input position
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Patternclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Patternclass Objecttrait Matchableclass AnyShow all
Value members
Concrete methods
Cut operator - disallows backtracking past this point.
Cut operator - disallows backtracking past this point.
Attributes
- Returns
-
a pattern representing a cut point
Creates a pattern that applies an action to a single value on the stack.
Creates a pattern that applies an action to a single value on the stack.
Value parameters
- f
-
the action function
Attributes
- Returns
-
a pattern that applies the action
Creates a pattern that applies an action to two values on the stack.
Creates a pattern that applies an action to two values on the stack.
Value parameters
- f
-
the action function
Attributes
- Returns
-
a pattern that applies the action
Creates a pattern that applies an action to three values on the stack.
Creates a pattern that applies an action to three values on the stack.
Value parameters
- f
-
the action function
Attributes
- Returns
-
a pattern that applies the action
Creates a pattern that applies an action to four values on the stack.
Creates a pattern that applies an action to four values on the stack.
Value parameters
- f
-
the action function
Attributes
- Returns
-
a pattern that applies the action
Creates a pattern that matches any element.
Creates a pattern that matches any element.
Attributes
- Returns
-
a pattern that matches any element
Creates a pattern that matches any element in a specified set.
Creates a pattern that matches any element in a specified set.
Value parameters
- es
-
the elements to match against
Attributes
- Returns
-
a pattern that matches any element in the set
Creates a pattern that captures the region matched by a pattern and applies an action.
Creates a pattern that captures the region matched by a pattern and applies an action.
Value parameters
- action
-
a function that processes the start and end positions
- p
-
the pattern to match
Attributes
- Returns
-
a pattern that captures the matched region
Creates a pattern that captures the wrapped values matched by a pattern.
Creates a pattern that captures the wrapped values matched by a pattern.
Value parameters
- p
-
the pattern to match
Attributes
- Returns
-
a pattern that captures the wrapped values
Creates a pattern that matches any element satisfying a predicate.
Creates a pattern that matches any element satisfying a predicate.
Value parameters
- c
-
the predicate function
Attributes
- Returns
-
a pattern that matches elements satisfying the predicate
A pattern that always fails.
A pattern that always fails.
Attributes
- Returns
-
a pattern that always fails
Creates a fence marker for backtracking control.
Creates a fence marker for backtracking control.
Attributes
- Returns
-
a pattern representing a fence
Positive look-behind
Positive look-behind
Value parameters
- p
-
the predicate
Attributes
- Returns
-
a pattern that matches if there is a previous element that matches p
Creates a pattern with lazy evaluation, useful for recursive pattern definitions.
Creates a pattern with lazy evaluation, useful for recursive pattern definitions.
Value parameters
- p
-
a function that returns a pattern when called
Attributes
- Returns
-
a non-strict pattern that evaluates p when needed
Creates a pattern that matches any element not in a specified set.
Creates a pattern that matches any element not in a specified set.
Value parameters
- es
-
the elements to exclude
Attributes
- Returns
-
a pattern that matches any element not in the set
A pattern that always succeeds without consuming input.
A pattern that always succeeds without consuming input.
Attributes
- Returns
-
a pattern that always succeeds
Creates a negative lookahead pattern that succeeds only if the given pattern fails.
Creates a negative lookahead pattern that succeeds only if the given pattern fails.
Value parameters
- p
-
the pattern to negate
Attributes
- Returns
-
a pattern that succeeds only if p fails
Negative look-behind
Negative look-behind
Value parameters
- p
-
the predicate
Attributes
- Returns
-
a pattern that matches if there is no previous element that matches p
Creates an optional pattern that succeeds even if the given pattern fails.
Creates an optional pattern that succeeds even if the given pattern fails.
Value parameters
- p
-
the pattern that is optional
Attributes
- Returns
-
a pattern that succeeds whether p matches or not
Creates an optional pattern with action that applies a function to the matched value if the pattern succeeds, or pushes None if it fails.
Creates an optional pattern with action that applies a function to the matched value if the pattern succeeds, or pushes None if it fails.
Value parameters
- f
-
the action function
- p
-
the pattern that is optional
Attributes
- Returns
-
a pattern that pushes Some(result) or None
Creates an optional pattern that preserves the matched value if the pattern succeeds, or pushes None if it fails.
Creates an optional pattern that preserves the matched value if the pattern succeeds, or pushes None if it fails.
Value parameters
- p
-
the pattern that is optional
Attributes
- Returns
-
a pattern that pushes Some(value) or None
Creates a right-associative optional pattern.
Creates a right-associative optional pattern.
This is like opt() but with reversed order of alternatives, which can affect the order of backtracking.
Value parameters
- p
-
the pattern that is optional
Attributes
- Returns
-
a right-associative optional pattern
Creates a right-associative optional pattern with action.
Creates a right-associative optional pattern with action.
Value parameters
- f
-
the action function
- p
-
the pattern that is optional
Attributes
- Returns
-
a pattern that pushes None or Some(result)
Creates a right-associative optional pattern that preserves the matched value.
Creates a right-associative optional pattern that preserves the matched value.
Value parameters
- p
-
the pattern that is optional
Attributes
- Returns
-
a pattern that pushes None or Some(value)
Creates a right-associative optional pattern with transformation.
Creates a right-associative optional pattern with transformation.
Value parameters
- arity
-
the number of values to transform
- f
-
the transformation function
- p
-
the pattern that is optional
Attributes
- Returns
-
a pattern that pushes None or Some(result)
Creates an optional pattern with transformation that applies a function to matched values if the pattern succeeds, or pushes None if it fails.
Creates an optional pattern with transformation that applies a function to matched values if the pattern succeeds, or pushes None if it fails.
Value parameters
- arity
-
the number of values to transform
- f
-
the transformation function
- p
-
the pattern that is optional
Attributes
- Returns
-
a pattern that pushes Some(result) or None
Creates a pattern that pushes the current input position onto the value stack.
Creates a pattern that pushes the current input position onto the value stack.
Attributes
- Returns
-
a pattern that captures the current position
Creates a pattern that pushes a value onto the value stack.
Creates a pattern that pushes a value onto the value stack.
Value parameters
- v
-
the value to push
Attributes
- Returns
-
a pattern that pushes the value
Creates a pattern that matches zero or more repetitions of a given pattern.
Creates a pattern that matches zero or more repetitions of a given pattern.
Value parameters
- p
-
the pattern to repeat
Attributes
- Returns
-
a pattern matching zero or more occurrences of p
Creates a pattern that matches one or more repetitions of a given pattern.
Creates a pattern that matches one or more repetitions of a given pattern.
Value parameters
- p
-
the pattern to repeat
Attributes
- Returns
-
a pattern matching one or more occurrences of p
Creates a pattern that matches one or more repetitions and collects transformed values.
Creates a pattern that matches one or more repetitions and collects transformed values.
Value parameters
- f
-
the action function to apply to each match
- p
-
the pattern to repeat
Attributes
- Returns
-
a pattern that collects transformed values into a list
Creates a pattern that matches one or more repetitions and collects the matched values.
Creates a pattern that matches one or more repetitions and collects the matched values.
Value parameters
- p
-
the pattern to repeat
Attributes
- Returns
-
a pattern that collects matched values into a list
Creates a pattern that matches one or more repetitions and collects transformed values.
Creates a pattern that matches one or more repetitions and collects transformed values.
Value parameters
- arity
-
the number of values to transform for each match
- f
-
the transformation function
- p
-
the pattern to repeat
Attributes
- Returns
-
a pattern that collects transformed values into a list
Creates a pattern that matches zero or more repetitions and collects transformed values.
Creates a pattern that matches zero or more repetitions and collects transformed values.
Value parameters
- f
-
the action function to apply to each match
- p
-
the pattern to repeat
Attributes
- Returns
-
a pattern that collects transformed values into a list
Creates a pattern that matches zero or more repetitions and collects the matched values.
Creates a pattern that matches zero or more repetitions and collects the matched values.
Value parameters
- p
-
the pattern to repeat
Attributes
- Returns
-
a pattern that collects matched values into a list
Creates a right-associative pattern that matches zero or more repetitions.
Creates a right-associative pattern that matches zero or more repetitions.
Value parameters
- p
-
the pattern to repeat
Attributes
- Returns
-
a right-associative pattern matching zero or more occurrences of p
Creates a right-associative pattern that matches one or more repetitions.
Creates a right-associative pattern that matches one or more repetitions.
This is similar to rep1 but with right-associative nesting of repetitions.
Value parameters
- p
-
the pattern to repeat
Attributes
- Returns
-
a right-associative pattern matching one or more occurrences of p
Creates a right-associative pattern that matches one or more repetitions and collects transformed values.
Creates a right-associative pattern that matches one or more repetitions and collects transformed values.
Value parameters
- f
-
the action function to apply to each match
- p
-
the pattern to repeat
Attributes
- Returns
-
a right-associative pattern that collects transformed values into a list
Creates a right-associative pattern that matches one or more repetitions and collects the matched values.
Creates a right-associative pattern that matches one or more repetitions and collects the matched values.
Value parameters
- p
-
the pattern to repeat
Attributes
- Returns
-
a right-associative pattern that collects matched values into a list
Creates a right-associative pattern that matches one or more repetitions and collects transformed values.
Creates a right-associative pattern that matches one or more repetitions and collects transformed values.
Value parameters
- arity
-
the number of values to transform for each match
- f
-
the transformation function
- p
-
the pattern to repeat
Attributes
- Returns
-
a right-associative pattern that collects transformed values into a list
Creates a right-associative pattern that matches zero or more repetitions and collects transformed values.
Creates a right-associative pattern that matches zero or more repetitions and collects transformed values.
Value parameters
- f
-
the action function to apply to each match
- p
-
the pattern to repeat
Attributes
- Returns
-
a right-associative pattern that collects transformed values into a list
Creates a right-associative pattern that matches zero or more repetitions and collects transformed values.
Creates a right-associative pattern that matches zero or more repetitions and collects transformed values.
Value parameters
- arity
-
the number of values to transform for each match
- f
-
the transformation function
- p
-
the pattern to repeat
Attributes
- Returns
-
a right-associative pattern that collects transformed values into a list
Creates a pattern that matches zero or more repetitions and collects transformed values.
Creates a pattern that matches zero or more repetitions and collects transformed values.
Value parameters
- arity
-
the number of values to transform for each match
- f
-
the transformation function
- p
-
the pattern to repeat
Attributes
- Returns
-
a pattern that collects transformed values into a list
Continues running from an existing runstate to find the next match.
Continues running from an existing runstate to find the next match.
Value parameters
- state
-
the current execution state
Attributes
- Returns
-
Some((value, remaining input, runstate)) if match succeeded, None if failed
Runs a pattern on input and returns the first match.
Runs a pattern on input and returns the first match.
Value parameters
- input
-
the input to match against
- pat
-
the pattern to match
Attributes
- Returns
-
Some((value, remaining input, runstate)) if match succeeded, None if failed
Core pattern matching engine that executes patterns against input.
Core pattern matching engine that executes patterns against input.
Value parameters
- state
-
the current execution state
Attributes
- Returns
-
Some((value, remaining input, runstate)) if match succeeded, None if failed
Runs a pattern on input and returns all possible matches.
Runs a pattern on input and returns all possible matches.
Value parameters
- input
-
the input to match against
- pat
-
the pattern to match
Attributes
- Returns
-
a list of all possible matches and remaining inputs
Creates a pattern that matches a sequence of elements.
Creates a pattern that matches a sequence of elements.
Value parameters
- es
-
the elements to match in sequence
Attributes
- Returns
-
a pattern matching the given sequence of elements
Creates a pattern that tests the top value on the stack against a predicate.
Creates a pattern that tests the top value on the stack against a predicate.
Value parameters
- c
-
the predicate function
Attributes
- Returns
-
a pattern that succeeds if the predicate returns true
Creates a pattern that tests values on the stack against a predicate.
Creates a pattern that tests values on the stack against a predicate.
Value parameters
- c
-
the predicate function
Attributes
- Returns
-
a pattern that succeeds if the predicate returns true
Creates a pattern that transforms values on the stack.
Creates a pattern that transforms values on the stack.
Value parameters
- arity
-
the number of values to transform
- f
-
the transformation function
Attributes
- Returns
-
a pattern that applies the transformation
Concrete fields
Execution limit for pattern matching, useful for debugging infinite loops. Set to Int.MaxValue by default (effectively unlimited).
Execution limit for pattern matching, useful for debugging infinite loops. Set to Int.MaxValue by default (effectively unlimited).