Lines Matching refs:content
420 optionally for a specific content.
432 content = None # Optional content matching pattern
441 args = [type_repr(self.type), self.content, self.name]
467 if self.content is not None:
502 def __init__(self, type=None, content=None, name=None):
504 Initializer. Takes optional type, content, and name.
507 this matches any *leaf* node; the content may still be required.
509 The content, if given, must be a string.
516 if content is not None:
517 assert isinstance(content, str), repr(content)
519 self.content = content
530 Match the pattern's content to the node's children.
532 This assumes the node type matches and self.content is not None.
541 return self.content == node.value
548 def __init__(self, type=None, content=None, name=None):
550 Initializer. Takes optional type, content, and name.
554 except if content is not None, in which it only matches
555 non-leaf nodes that also match the content pattern.
557 The content, if not None, must be a sequence of Patterns that
558 must match the node's children exactly. If the content is
566 if content is not None:
567 assert not isinstance(content, str), repr(content)
568 content = list(content)
569 for i, item in enumerate(content):
574 self.content = content
579 Match the pattern's content to the node's children.
581 This assumes the node type matches and self.content is not None.
591 for c, r in generate_matches(self.content, node.children):
597 if len(self.content) != len(node.children):
599 for subpattern, child in zip(self.content, node.children):
619 def __init__(self, content=None, min=0, max=HUGE, name=None):
624 content: optional sequence of subsequences of patterns;
631 [*] Thus, if content is [[a, b, c], [d, e], [f, g, h]] this is
632 equivalent to (a b c | d e | f g h); if content is None,
639 If content is not None, replace the dot with the parenthesized
643 if content is not None:
644 content = tuple(map(tuple, content)) # Protect against alterations
646 assert len(content), repr(content) # Can't have zero alternatives
647 for alt in content:
649 self.content = content
657 if (self.content is not None and
658 len(self.content) == 1 and len(self.content[0]) == 1):
659 subpattern = self.content[0][0]
661 if self.content is None:
667 return WildcardPattern(subpattern.content,
700 if self.content is None:
740 # generate matches that use just one alt from self.content
741 for alt in self.content:
752 for alt in self.content:
770 for leaf in self.content:
780 assert self.content is not None
784 for alt in self.content:
795 def __init__(self, content=None):
804 if content is not None:
805 assert isinstance(content, BasePattern), repr(content)
806 self.content = content
817 if self.content is None:
823 for c, r in self.content.generate_matches(nodes):