View source on GitHub |
A pattern for repeated sub-patterns inside of a sequence.
Inherits From: Pattern
oryx.experimental.matching.matcher.Star(
pattern: Any,
name: Optional[str] = None,
accumulate: Sequence[str] = (),
greedy: bool = False,
plus: bool = False
)
Methods
accumulate_match
accumulate_match(
expr: Expr,
bindings: oryx.experimental.matching.jax_rewrite.Bindings
,
succeed: oryx.experimental.matching.jax_rewrite.Continuation
) -> oryx.experimental.matching.jax_rewrite.Success
Matches each element of a sequence to this Star
's pattern.
Iteratively matches each element of expr
with self.pattern
. For any
created as the result of each match, they are accumulated if the names
are in the Star
pattern's accumulate
property. If not, the bindings need
to match over all elemnets of expr
.
Args | |
---|---|
expr
|
An expression to match. |
bindings
|
A dictionary mapping string names to values representing the results of previous matches. |
succeed
|
A function that when passed in bindings returns a generator
over results.
|
Yields | |
---|---|
The results of the succeed continuation function, augmented with
bindings corresponding to matches made over the course of the accumulate
match.
|
accumulate_value
accumulate_value(
bindings: oryx.experimental.matching.jax_rewrite.Bindings
,
name: str,
value: Any
) -> oryx.experimental.matching.jax_rewrite.Bindings
bind
bind(
bindings: oryx.experimental.matching.jax_rewrite.Bindings
,
value: Any
) -> oryx.experimental.matching.jax_rewrite.Bindings
match
match(
expr: Expr,
bindings: oryx.experimental.matching.jax_rewrite.Bindings
,
succeed: StarContinuation
) -> oryx.experimental.matching.jax_rewrite.Success
Matches the Star
pattern against an expression.
Constructs all splits of the expression and performs an accumulate_match
on each of the left halves. The right half is matched using sequence
matching.
Args | |
---|---|
expr
|
An expression to match. |
bindings
|
A dictionary mapping string names to values representing the results of previous matches. |
succeed
|
A function that when passed in bindings returns a generator
over results.
|
Yields | |
---|---|
The results of the succeed continuation function, augmented with
bindings corresponding to matches made over the course of the Star match.
|
__eq__
__eq__(
other
)
Class Variables | |
---|---|
accumulate |
()
|
greedy |
False
|
name |
None
|
plus |
False
|