oryx.experimental.matching.matcher.Plus

A pattern for repeated sub-patterns inside of a sequence.

Inherits From: Star, Pattern

pattern an object that will be matched against elements of a sequence.
name an optional str name to bind the result of the star match.
accumulate a sequence of str names corresponding to Vars in pattern that will be accumulated into a sequence instead of having to match across the elements of the sequence.
greedy a bool that sets whether or not the Plus greedily matches a sequence. A greedy Plus will try to match slices starting from the largest possible and then trying smaller ones. A non-greedy Plus will match slices starting from the smallest possible. Default: False.
plus Dataclass field

Methods

accumulate_match

View source

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

View source

bind

View source

match

View source

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__

accumulate ()
greedy False
name None
plus False