API Documentation¶
Combinators¶
Combinators.
-
class
slrp.combos.Combinable¶ An abstract class extended by concrete combinator classes and expression parsers. This class implements the operator methods, all of which return combinators
-
__add__(other) → slrp.combos.Then¶ Create a matcher that matches self’s expression followed by repetitions of other’s expression.
- Parameters
other (Matcher) – A matcher following self
- Returns
matcher for self then repeated other
- Return type
Many
-
__mod__(call) → slrp.combos.Either¶ Create a matcher that matches self’s expression then passes it to callable as positional args.
- Parameters
other (Matcher) – A matcher self
- Returns
the match from self, passed to call
- Return type
Apply
-
__mul__(other) → slrp.combos.Then¶ Combine self with another matcher to create a matcher for self’s expression followed *by other’s expression.
- Parameters
other (Matcher) – A matcher following self
- Returns
matcher for self then other
- Return type
Then
-
__neg__() → slrp.combos.Maybe¶ Create a matcher that optionally matches self’s expression.
- Returns
matcher for maybe self
- Return type
Maybe
-
__or__(other) → slrp.combos.Either¶ Create a matcher that matches either self’s expression or other’s.
- Parameters
other (Matcher) – A matcher self
- Returns
matcher for either self or other
- Return type
Either
-
__pos__() → slrp.combos.Many¶ Create a matcher that matches repetitions of self’s expression.
- Returns
matcher for repeated self
- Return type
Many
-
__sub__(other) → slrp.combos.Then¶ Combine self with another matcher to create a matcher for self’s expression followed optionally by other’s expression.
- Parameters
other (Matcher) – A matcher following self
- Returns
matcher for self then maybe other
- Return type
Then
-
-
class
slrp.combos.Either(left: slrp.combos.Combinable, right: slrp.combos.Combinable)¶ Match on of two expressions.
-
class
slrp.combos.Then(first: slrp.combos.Combinable, then: slrp.combos.Combinable)¶ Match some expression, followed by another expression.
-
class
slrp.combos.Maybe(matcher)¶ Match some expression, or not.
-
class
slrp.combos.Many(extractor: slrp.combos.Combinable)¶ Match an expression repeatedly.
-
class
slrp.combos.Apply(matcher, call: Callable)¶
-
class
slrp.combos.Lazy(extr_call)¶