compileParseTreePattern method
ParseTreePattern
compileParseTreePattern(])
inherited
The preferred method of getting a tree pattern. For example, here's a sample use:
ParseTree t = parser.expr(); ParseTreePattern p = parser.compileParseTreePattern("<ID>+0", MyParser.RULE_expr); ParseTreeMatch m = p.match(t); String id = m.get("ID");
Implementation
ParseTreePattern compileParseTreePattern(
String pattern,
int patternRuleIndex, [
Lexer? lexer,
]) {
if (lexer == null) {
final tokenSource = tokenStream.tokenSource;
if (tokenSource is! Lexer) {
throw UnsupportedError("Parser can't discover a lexer to use");
}
lexer = tokenSource;
}
final m = ParseTreePatternMatcher(lexer, this);
return m.compile(pattern, patternRuleIndex);
}