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:
objectUse
InSequenceMatcherto find all matches formatcherin a sequence of instructions.- 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:
SequenceMatcherMatch 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
matchersand return the first match.
- 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:
SequenceMatcherCount 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
- 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:
SequenceMatcherCheck 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:
SequenceMatcherCheck 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:
InstructionMatcherIf
indexis an integer, the modifier must be present at that specific position in the matched instruction modifiers. IfindexisNone, 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
- match(inst: Instruction | str) InstructionMatch | NoneView on GitHub
- matcher: Final[InstructionMatcher]
- class reprospect.test.sass.composite_impl.OneOrMoreInSequenceMatcher(matcher: InstructionMatcher)View on GitHub
Bases:
SequenceMatcherMatch 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:
InstructionMatcherValidate that the operand at
indexmatches the instruction matched withmatcher.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
- 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:
InstructionMatcherValidate that the
operandsmatch the instruction matched withmatcher.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:
SequenceMatcherMatch a sequence of
matchersin 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:
SequenceMatcherMatch a sequence of
matchersin 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:
ABCBase 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 atyping.Sequence, not atyping.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-Nonevalue.
- class reprospect.test.sass.composite_impl.UnorderedInSequenceMatcher(matchers: Iterable[SequenceMatcher | InstructionMatcher])View on GitHub
Bases:
SequenceMatcherMatch a sequence of
matchersin 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:
UnorderedInSequenceMatcherMatch a sequence of
matchersin 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:
OneOrMoreInSequenceMatcherMatch 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]