class documentation
class LeafPattern(BasePattern): (source)
Undocumented
Method | __init__ |
Initializer. Takes optional type, content, and name. |
Method | match |
Override match() to insist on a leaf node. |
Instance Variable | content |
Undocumented |
Instance Variable | name |
Undocumented |
Instance Variable | type |
Undocumented |
Method | _submatch |
Match the pattern's content to the node's children. |
Inherited from BasePattern
:
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 sequence of nodes? |
Method | optimize |
A subclass can define this as a hook for optimizations. |
Property | type |
Get the type as a human-readable string. |
Initializer. Takes optional type, content, and name. The type, if given must be a token type (< 256). If not given, this matches any *leaf* node; the content may still be required. The content, if given, must be a string. If a name is given, the matching node is stored in the results dict under that key.
Match the pattern's content to the node's children. This assumes the node type matches and self.content is not None. 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. When returning False, the results dict may still be updated.