public ParseTreePattern compile(String pattern, int patternRuleIndex) {List<? extends Token> tokenList = tokenize(pattern);ListTokenSource tokenSrc = new ListTokenSource(tokenList);CommonTokenStream tokens = new CommonTokenStream(tokenSrc);ParserInterpreter parserInterp = new ParserInterpreter(parser.getGrammarFileName(),parser.getVocabulary(),Arrays.asList(parser.getRuleNames()),parser.getATNWithBypassAlts(),tokens);ParseTree tree = null;try {parserInterp.setErrorHandler(new BailErrorStrategy());tree = parserInterp.parse(patternRuleIndex);}catch (ParseCancellationException e) {throw (RecognitionException)e.getCause();}catch (RecognitionException re) {throw re;}catch (Exception e) {throw new CannotInvokeStartRule(e);}if ( tokens.LA(1)!=Token.EOF ) {throw new StartRuleDoesNotConsumeFullPattern();}return new ParseTreePattern(this, pattern, patternRuleIndex, tree);}
public virtual ParseTreePattern Compile(string pattern, int patternRuleIndex){IList<IToken> tokenList = Tokenize(pattern);ListTokenSource tokenSrc = new ListTokenSource(tokenList);CommonTokenStream tokens = new CommonTokenStream(tokenSrc);ParserInterpreter parserInterp = new ParserInterpreter(parser.GrammarFileName, parser.Vocabulary, Arrays.AsList(parser.RuleNames), parser.GetATNWithBypassAlts(), tokens);IParseTree tree = null;try{parserInterp.ErrorHandler = new BailErrorStrategy();tree = parserInterp.Parse(patternRuleIndex);}catch (ParseCanceledException e){throw (RecognitionException)e.InnerException;}catch (RecognitionException){throw;}catch (Exception e){throw new ParseTreePatternMatcher.CannotInvokeStartRule(e);}if (tokens.LA(1) != TokenConstants.EOF){throw new ParseTreePatternMatcher.StartRuleDoesNotConsumeFullPattern();}return new ParseTreePattern(this, pattern, patternRuleIndex, tree);}