class BasePattern: (source)
Known subclasses: pytype.test_data.pytree.LeafPattern
, pytype.test_data.pytree.NegatedPattern
, pytype.test_data.pytree.NodePattern
, pytype.test_data.pytree.WildcardPattern
A pattern is a tree matching pattern. It looks for a specific node type (token or symbol), and optionally for a specific content. This is an abstract base class. There are three concrete subclasses: - LeafPattern matches a single leaf node; - NodePattern matches a single node (usually non-leaf); - WildcardPattern matches a sequence of nodes of variable length.
Method | __new__ |
Constructor that prevents BasePattern from being instantiated. |
Method | __repr__ |
Undocumented |
Method | generate |
Generator yielding all matches for this pattern. |
Method | match |
Does this pattern exactly match a node? |
Method | match |
Does this pattern exactly match a sequence of nodes? |
Method | optimize |
A subclass can define this as a hook for optimizations. |
Class Variable | content |
Undocumented |
Class Variable | name |
Undocumented |
Class Variable | type |
Undocumented |
Property | type |
Get the type as a human-readable string. |
pytype.test_data.pytree.LeafPattern
, pytype.test_data.pytree.NegatedPattern
, pytype.test_data.pytree.WildcardPattern
Does this pattern exactly match a node? Returns True if it matches, False if not. If results is not None, it must be a dict which will be updated with the nodes matching named subpatterns. Default implementation for non-wildcard patterns.
Does this pattern exactly match a sequence of nodes? Default implementation for non-wildcard patterns.
pytype.test_data.pytree.WildcardPattern
A subclass can define this as a hook for optimizations. Returns either self or another node with the same effect.
pytype.test_data.pytree.LeafPattern
, pytype.test_data.pytree.NodePattern
, pytype.test_data.pytree.WildcardPattern
Undocumented