polytracker.parsing

parsing classes

ImmutableParseTree

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

Bases: Generic[V], ParseTree[V]

classmethod __class_getitem__(params)

Parameterizes a generic class.

At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.

However, note that this method is also called when defining generic classes in the first place with class Foo(Generic[T]): ….

__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]

classmethod __class_getitem__(params)

Parameterizes a generic class.

At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.

However, note that this method is also called when defining generic classes in the first place with class Foo(Generic[T]): ….

__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: Union[Start, TraceEvent, Terminal], children: Iterable[G] = ())

Bases: MutableParseTree[Union[Start, TraceEvent, Terminal]]

classmethod __class_getitem__(params)

Parameterizes a generic class.

At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.

However, note that this method is also called when defining generic classes in the first place with class Foo(Generic[T]): ….

__init__(value: Union[Start, TraceEvent, Terminal], children: Iterable[G] = ())
add_child(new_child: MPT)
property begin_offset: int
best_partition(right_sibling: NonGeneralizedParseTree) Optional[int]
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]

classmethod __class_getitem__(params)

Parameterizes a generic class.

At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.

However, note that this method is also called when defining generic classes in the first place with class Foo(Generic[T]): ….

__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: Union[bytes, str])

Bases: object

__init__(terminal: Union[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