match method
ParseTreeMatch
match(
- ParseTree tree, {
- ParseTreePattern? pattern,
- String? patternStr,
- int? patternRuleIndex,
Compare pattern
matched against tree
and return a
ParseTreeMatch object that contains the matched elements, or the
node at which the match failed. Pass in a compiled pattern instead of a
string representation of a tree pattern.
Implementation
ParseTreeMatch match(
ParseTree tree, {
ParseTreePattern? pattern,
String? patternStr,
int? patternRuleIndex,
}) {
assert(pattern != null || patternStr != null && patternRuleIndex != null);
pattern ??= compile(patternStr!, patternRuleIndex!);
final labels = MultiMap<String, ParseTree>();
final mismatchedNode = matchImpl(tree, pattern.patternTree, labels);
return ParseTreeMatch(tree, pattern, labels, mismatchedNode);
}