polytracker.parsing

parsing classes

ImmutableParseTree

class polytracker.parsing.ImmutableParseTree(value: V, children: Iterable[IPT] = ())

Bases: Generic[V], ParseTree[V]

__init__(value: V, children: Iterable[IPT] = ())
property children: List[IPT]
clone() IPT
property descendants: int
is_leaf() bool
leaves() Iterator[T]
postorder_traversal() Iterator[T]
preorder_traversal() Iterator[T]
to_dag() DAG[ParseTree[V]]
value: V

MutableParseTree

class polytracker.parsing.MutableParseTree(value: V, children: Iterable[IPT] = ())

Bases: Generic[V], ImmutableParseTree[V]

__init__(value: V, children: Iterable[IPT] = ())
add_child(new_child: MPT)
property children: List[IPT]
clone() IPT
property descendants: int
is_leaf() bool
leaves() Iterator[T]
postorder_traversal() Iterator[T]
preorder_traversal() Iterator[T]
to_dag() DAG[ParseTree[V]]
value: V

NonGeneralizedParseTree

class polytracker.parsing.NonGeneralizedParseTree(value: Start | TraceEvent | Terminal, children: Iterable[G] = ())

Bases: MutableParseTree[Start | TraceEvent | Terminal]

__init__(value: Start | TraceEvent | Terminal, children: Iterable[G] = ())
add_child(new_child: MPT)
property begin_offset: int
best_partition(right_sibling: NonGeneralizedParseTree) int | None
best_subset(parent: NonGeneralizedParseTree) Tuple[int, int]
bottom_up_pass()
property children: List[IPT]
clone() IPT
deconflict_parent(parent: NonGeneralizedParseTree)
deconflict_sibling(right_sibling: NonGeneralizedParseTree)
property descendants: int
property end_offset: int
is_leaf() bool
leaves() Iterator[T]
matches() bytes
postorder_traversal() Iterator[T]
preorder_traversal() Iterator[T]
simplify()
terminals() Iterator[Terminal]
to_dag() DAG[ParseTree[V]]
top_down_pass()
value: V
verify(string: bytes)
verify_bounds(check_overlap=True, check_coverage=True, check_missing_children=True)

ParseTree

class polytracker.parsing.ParseTree(value: V)

Bases: ABC, Generic[V]

__init__(value: V)
abstract property children: List[T]
abstract clone() T
property descendants: int
is_leaf() bool
leaves() Iterator[T]
postorder_traversal() Iterator[T]
preorder_traversal() Iterator[T]
to_dag() DAG[ParseTree[V]]
value: V

Start

class polytracker.parsing.Start

Bases: object

__init__()

Terminal

class polytracker.parsing.Terminal(terminal: bytes | str)

Bases: object

__init__(terminal: bytes | str)

parsing functions

escape_byte

polytracker.parsing.escape_byte(byte_value: int) str

highlight_offset

polytracker.parsing.highlight_offset(text: bytes, offset, highlight_length=20) str

trace_to_non_generalized_tree

polytracker.parsing.trace_to_non_generalized_tree(trace: ProgramTrace) NonGeneralizedParseTree

trace_to_tree

polytracker.parsing.trace_to_tree(trace: ProgramTrace, node_type: Type[N] = polytracker.parsing.ParseTree[typing.Union[polytracker.parsing.Start, polytracker.tracing.TraceEvent, polytracker.parsing.Terminal]], include_terminals: bool = True) N