/// <exception cref="System.IO.IOException"/> /// <exception cref="System.MemberAccessException"/> /// <exception cref="System.Reflection.TargetInvocationException"/> /// <exception cref="Javax.Print.PrintException"/> protected internal virtual void Process <_T0>(Lexer lexer, Type <_T0> parserClass, Parser parser, Stream @is, TextReader r) where _T0 : Parser { try { AntlrInputStream input = new AntlrInputStream(r); lexer.SetInputStream(input); CommonTokenStream tokens = new CommonTokenStream(lexer); tokens.Fill(); if (showTokens) { foreach (object tok in tokens.GetTokens()) { System.Console.Out.WriteLine(tok); } } if (startRuleName.Equals(LexerStartRuleName)) { return; } if (diagnostics) { parser.AddErrorListener(new DiagnosticErrorListener()); parser.Interpreter.PredictionMode = PredictionMode.LlExactAmbigDetection; } if (printTree || gui || psFile != null) { parser.BuildParseTree = true; } if (Sll) { // overrides diagnostics parser.Interpreter.PredictionMode = PredictionMode.Sll; } parser.SetInputStream(tokens); parser.Trace = trace; try { MethodInfo startRule = parserClass.GetMethod(startRuleName, (Type[])null); ParserRuleContext tree = (ParserRuleContext)startRule.Invoke(parser, (object[])null); if (printTree) { System.Console.Out.WriteLine(tree.ToStringTree(parser)); } if (gui) { tree.Inspect(parser); } if (psFile != null) { tree.Save(parser, psFile); } } catch (NoSuchMethodException) { // Generate postscript System.Console.Error.WriteLine("No method for rule " + startRuleName + " or it has arguments"); } } finally { if (r != null) { r.Close(); } if (@is != null) { @is.Close(); } } }