reprospect.test.sass.composite_impl module

Combine matchers from reprospect.test.sass.instruction into sequence matchers.

class reprospect.test.sass.composite_impl.AllInSequenceMatcher(matcher)View on GitHub

Bases: object

Use InSequenceMatcher to find all matches for matcher in a sequence of instructions.

__init__(matcher) None

Method generated by attrs for class AllInSequenceMatcher.

match(instructions: Sequence[Instruction | str]) list[InstructionMatch] | list[list[InstructionMatch]]View on GitHub
matcher: InSequenceMatcher
class reprospect.test.sass.composite_impl.AnyOfMatcher(*matchers: SequenceMatcher | InstructionMatcher)View on GitHub

Bases: SequenceMatcher

Match any of the matchers.

Note

It is not decorated with dataclasses.dataclass() because of https://github.com/mypyc/mypyc/issues/1061.

__init__(*matchers: SequenceMatcher | InstructionMatcher) NoneView on GitHub
explain(*, instructions: Sequence[Instruction | str]) strView on GitHub
match(instructions: Sequence[Instruction | str]) list[InstructionMatch] | NoneView on GitHub

Loop over the matchers and return the first match.

matched: int
matchers: Final[tuple[SequenceMatcher | InstructionMatcher, ...]]
property next_index: intView on GitHub
class reprospect.test.sass.composite_impl.CountInSequenceMatcher(matcher: InstructionMatcher, count: int)View on GitHub

Bases: SequenceMatcher

Count how many times it matches in a sequence.

Note

It is not decorated with dataclasses.dataclass() because of https://github.com/mypyc/mypyc/issues/1061.

__init__(matcher: InstructionMatcher, count: int) NoneView on GitHub
count: Final[int]
explain(*, instructions: Sequence[Instruction | str]) strView on GitHub
match(instructions: Sequence[Instruction | str]) list[InstructionMatch] | NoneView on GitHub
matcher: Final[InstructionMatcher]
property next_index: intView on GitHub
class reprospect.test.sass.composite_impl.InSequenceAtMatcher(matcher: InstructionMatcher)View on GitHub

Bases: SequenceMatcher

Check that the element matches exactly.

Note

It is not decorated with dataclasses.dataclass() because of https://github.com/mypyc/mypyc/issues/1061.

__init__(matcher: InstructionMatcher) NoneView on GitHub
explain(*, instructions: Sequence[Instruction | str]) strView on GitHub
match(instructions: Sequence[Instruction | str]) list[InstructionMatch] | NoneView on GitHub
matcher: Final[InstructionMatcher]
property next_index: intView on GitHub
class reprospect.test.sass.composite_impl.InSequenceMatcher(matcher: SequenceMatcher | InstructionMatcher)View on GitHub

Bases: SequenceMatcher

Check that a sequence contains an element that matches exactly.

Note

It is not decorated with dataclasses.dataclass() because of https://github.com/mypyc/mypyc/issues/1061.

__init__(matcher: SequenceMatcher | InstructionMatcher) NoneView on GitHub
explain(*, instructions: Sequence[Instruction | str]) strView on GitHub
match(instructions: Sequence[Instruction | str]) list[InstructionMatch] | NoneView on GitHub
matcher: Final[SequenceMatcher | InstructionMatcher]
property next_index: intView on GitHub
class reprospect.test.sass.composite_impl.ModifierValidator(matcher: InstructionMatcher, modifier: str, index: int | None = None)View on GitHub

Bases: InstructionMatcher

If index is an integer, the modifier must be present at that specific position in the matched instruction modifiers. If index is None, the modifier may be at any position in the matched instruction modifiers.

Note

It is not decorated with dataclasses.dataclass() because of https://github.com/mypyc/mypyc/issues/1061.

__init__(matcher: InstructionMatcher, modifier: str, index: int | None = None) NoneView on GitHub
index: Final[int | None]
match(inst: Instruction | str) InstructionMatch | NoneView on GitHub
matcher: Final[InstructionMatcher]
modifier: Final[str]
class reprospect.test.sass.composite_impl.OneOrMoreInSequenceMatcher(matcher: InstructionMatcher)View on GitHub

Bases: SequenceMatcher

Match one or more times.

Note

It is not decorated with dataclasses.dataclass() because of https://github.com/mypyc/mypyc/issues/1061.

__init__(matcher: InstructionMatcher) NoneView on GitHub
explain(*, instructions: Sequence[Instruction | str]) strView on GitHub
match(instructions: Sequence[Instruction | str]) list[InstructionMatch] | NoneView on GitHub
matcher: Final[InstructionMatcher]
property next_index: intView on GitHub
class reprospect.test.sass.composite_impl.OperandValidator(matcher: InstructionMatcher, operand: str | AddressMatcher | ConstantMatcher | RegisterMatcher, index: int | None = None)View on GitHub

Bases: InstructionMatcher

Validate that the operand at index matches the instruction matched with matcher.

Note

It is not decorated with dataclasses.dataclass() because of https://github.com/mypyc/mypyc/issues/1061.

__init__(matcher: InstructionMatcher, operand: str | AddressMatcher | ConstantMatcher | RegisterMatcher, index: int | None = None) NoneView on GitHub
check(operand: str) boolView on GitHub
index: Final[int | None]
match(inst: Instruction | str) InstructionMatch | NoneView on GitHub
matcher: Final[InstructionMatcher]
operand: Final[str | AddressMatcher | ConstantMatcher | RegisterMatcher]
class reprospect.test.sass.composite_impl.OperandsValidator(matcher: InstructionMatcher, operands: Collection[tuple[int, str | AddressMatcher | ConstantMatcher | RegisterMatcher]])View on GitHub

Bases: InstructionMatcher

Validate that the operands match the instruction matched with matcher.

Note

It is not decorated with dataclasses.dataclass() because of https://github.com/mypyc/mypyc/issues/1061.

__init__(matcher: InstructionMatcher, operands: Collection[tuple[int, str | AddressMatcher | ConstantMatcher | RegisterMatcher]]) NoneView on GitHub
match(inst: Instruction | str) InstructionMatch | NoneView on GitHub
matcher: Final[InstructionMatcher]
operands: Final[tuple[tuple[int, str | AddressMatcher | ConstantMatcher | RegisterMatcher], ...]]
class reprospect.test.sass.composite_impl.OrderedInSequenceMatcher(matchers: Iterable[SequenceMatcher | InstructionMatcher])View on GitHub

Bases: SequenceMatcher

Match a sequence of matchers in the order they are provided.

Note

It is not decorated with dataclasses.dataclass() because of https://github.com/mypyc/mypyc/issues/1061.

__init__(matchers: Iterable[SequenceMatcher | InstructionMatcher]) NoneView on GitHub
explain(*, instructions: Sequence[Instruction | str]) strView on GitHub
match(instructions: Sequence[Instruction | str]) list[InstructionMatch] | NoneView on GitHub
matchers: Final[tuple[SequenceMatcher | InstructionMatcher, ...]]
property next_index: intView on GitHub
class reprospect.test.sass.composite_impl.OrderedInterleavedInSequenceMatcher(matchers: Iterable[SequenceMatcher | InstructionMatcher])View on GitHub

Bases: SequenceMatcher

Match a sequence of matchers in the order they are provided, allowing interleaved unmatched instructions in between.

Note

It is not decorated with dataclasses.dataclass() because of https://github.com/mypyc/mypyc/issues/1061.

__init__(matchers: Iterable[SequenceMatcher | InstructionMatcher]) NoneView on GitHub
match(instructions: Sequence[Instruction | str]) list[InstructionMatch] | NoneView on GitHub
matchers: Final[tuple[InSequenceMatcher, ...]]
property next_index: intView on GitHub
class reprospect.test.sass.composite_impl.SequenceMatcherView on GitHub

Bases: ABC

Base class for matchers of a sequence of instructions.

final assert_matches(instructions: Sequence[Instruction | str]) list[InstructionMatch]View on GitHub

Derived matchers are allowed to provide a nice message by implementing explain().

explain(*, instructions: Sequence[Instruction | str]) strView on GitHub
abstractmethod match(instructions: Sequence[Instruction | str]) list[InstructionMatch] | NoneView on GitHub

Note

The instructions may be consumed more than once, e.g. in reprospect.test.sass.composite_impl.UnorderedInSequenceMatcher. Therefore, it must be a typing.Sequence, not a typing.Iterable.

abstract property next_index: intView on GitHub

Return the next index in the sequence of instructions that can be matched.

This is the index after the last matched instruction during the last call to match(), i.e. how far this matcher consumed the sequence “plus one”.

The return value is only meaningful if the last call to match() returned a non-None value.

class reprospect.test.sass.composite_impl.UnorderedInSequenceMatcher(matchers: Iterable[SequenceMatcher | InstructionMatcher])View on GitHub

Bases: SequenceMatcher

Match a sequence of matchers in some permutation of the order they are provided.

Note

It is not decorated with dataclasses.dataclass() because of https://github.com/mypyc/mypyc/issues/1061.

__init__(matchers: Iterable[SequenceMatcher | InstructionMatcher]) NoneView on GitHub
explain(*, instructions: Sequence[Instruction | str]) strView on GitHub
match(instructions: Sequence[Instruction | str]) list[InstructionMatch] | NoneView on GitHub
matchers: Final[tuple[SequenceMatcher | InstructionMatcher, ...]]
property next_index: intView on GitHub
classmethod search(*, instructions: Sequence[Instruction | str], offset: int, matchers: tuple[SequenceMatcher | InstructionMatcher, ...]) tuple[int, list[InstructionMatch]] | NoneView on GitHub

Backtracking problem.

class reprospect.test.sass.composite_impl.UnorderedInterleavedInSequenceMatcher(matchers: Iterable[SequenceMatcher | InstructionMatcher])View on GitHub

Bases: UnorderedInSequenceMatcher

Match a sequence of matchers in any order, allowing interleaved unmatched instructions in between.

__init__(matchers: Iterable[SequenceMatcher | InstructionMatcher]) NoneView on GitHub
matchers: Final[tuple[SequenceMatcher | InstructionMatcher, ...]]
class reprospect.test.sass.composite_impl.ZeroOrMoreInSequenceMatcher(matcher: InstructionMatcher)View on GitHub

Bases: OneOrMoreInSequenceMatcher

Match zero or more times.

explain(*, instructions: Sequence[Instruction | str]) strView on GitHub
match(instructions: Sequence[Instruction | str]) list[InstructionMatch] | NoneView on GitHub
matcher: Final[InstructionMatcher]