public string Text(GrammarAST t) { if (t == null) return null; try { ITreeNodeStream input = new CommonTreeNodeStream(new ANTLRParser.grammar_Adaptor(null), t); ANTLRTreePrinter printer = new ANTLRTreePrinter(input); return printer.toString(grammar, true); } catch (Exception e) { if (e.IsCritical()) throw; ErrorManager.Error(ErrorManager.MSG_BAD_AST_STRUCTURE, e); return null; } }
public virtual void PrintGrammar( TextWriter output ) { ANTLRTreePrinter printer = new ANTLRTreePrinter( new Antlr.Runtime.Tree.CommonTreeNodeStream( grammarTree ) ); //printer.setASTNodeClass( "org.antlr.tool.GrammarAST" ); try { string g = printer.toString( this, false ); output.WriteLine( g ); } catch ( RecognitionException re ) { ErrorManager.Error( ErrorManager.MSG_SYNTAX_ERROR, re ); } }