java: public ParseTreePattern compileParseTreePattern(String pattern, int patternRuleIndex) {if ( getTokenStream()!=null ) {TokenSource tokenSource = getTokenStream().getTokenSource();if ( tokenSource instanceof Lexer ) {Lexer lexer = (Lexer)tokenSource;return compileParseTreePattern(pattern, patternRuleIndex, lexer);}}throw new UnsupportedOperationException("Parser can't discover a lexer to use");}
C#: public virtual ParseTreePattern CompileParseTreePattern(string pattern, int patternRuleIndex){if (((ITokenStream)InputStream) != null){ITokenSource tokenSource = ((ITokenStream)InputStream).TokenSource;if (tokenSource is Lexer){Lexer lexer = (Lexer)tokenSource;return CompileParseTreePattern(pattern, patternRuleIndex, lexer);}}throw new NotSupportedException("Parser can't discover a lexer to use");}