Lines Matching refs:content
421 optionally for a specific content.
433 content = None # Optional content matching pattern
442 args = [type_repr(self.type), self.content, self.name]
468 if self.content is not None:
503 def __init__(self, type=None, content=None, name=None):
505 Initializer. Takes optional type, content, and name.
508 this matches any *leaf* node; the content may still be required.
510 The content, if given, must be a string.
517 if content is not None:
518 assert isinstance(content, str), repr(content)
520 self.content = content
531 Match the pattern's content to the node's children.
533 This assumes the node type matches and self.content is not None.
542 return self.content == node.value
549 def __init__(self, type=None, content=None, name=None):
551 Initializer. Takes optional type, content, and name.
555 except if content is not None, in which it only matches
556 non-leaf nodes that also match the content pattern.
558 The content, if not None, must be a sequence of Patterns that
559 must match the node's children exactly. If the content is
567 if content is not None:
568 assert not isinstance(content, str), repr(content)
569 content = list(content)
570 for i, item in enumerate(content):
575 self.content = content
580 Match the pattern's content to the node's children.
582 This assumes the node type matches and self.content is not None.
592 for c, r in generate_matches(self.content, node.children):
598 if len(self.content) != len(node.children):
600 for subpattern, child in zip(self.content, node.children):
620 def __init__(self, content=None, min=0, max=HUGE, name=None):
625 content: optional sequence of subsequences of patterns;
632 [*] Thus, if content is [[a, b, c], [d, e], [f, g, h]] this is
633 equivalent to (a b c | d e | f g h); if content is None,
640 If content is not None, replace the dot with the parenthesized
644 if content is not None:
645 content = tuple(map(tuple, content)) # Protect against alterations
647 assert len(content), repr(content) # Can't have zero alternatives
648 for alt in content:
650 self.content = content
658 if (self.content is not None and
659 len(self.content) == 1 and len(self.content[0]) == 1):
660 subpattern = self.content[0][0]
662 if self.content is None:
668 return WildcardPattern(subpattern.content,
701 if self.content is None:
741 # generate matches that use just one alt from self.content
742 for alt in self.content:
753 for alt in self.content:
771 for leaf in self.content:
781 assert self.content is not None
785 for alt in self.content:
796 def __init__(self, content=None):
805 if content is not None:
806 assert isinstance(content, BasePattern), repr(content)
807 self.content = content
818 if self.content is None:
824 for c, r in self.content.generate_matches(nodes):