Ejemplo n.º 1
0
        private ANTLRTreePrinter.block_return Block(GrammarAST t, bool forceParens)
        {
            ANTLRTreePrinter other = new ANTLRTreePrinter(new CommonTreeNodeStream(t));

            other.buf = buf;
            return(other.block(forceParens));
        }
        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;
            }
        }
Ejemplo n.º 3
0
 private TreeRuleReturnScope<GrammarAST> Block( GrammarAST t, bool forceParens )
 {
     ANTLRTreePrinter other = new ANTLRTreePrinter(new CommonTreeNodeStream(t));
     other.buf = buf;
     return other.block( forceParens );
 }
Ejemplo n.º 4
0
 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 );
     }
 }
Ejemplo n.º 5
0
 public virtual string GrammarTreeToString( GrammarAST t, bool showActions )
 {
     string s = null;
     try
     {
         s = t.Line + ":" + (t.CharPositionInLine+1) + ": ";
         s += new ANTLRTreePrinter( new Antlr.Runtime.Tree.CommonTreeNodeStream( t ) ).toString( this, showActions );
     }
     catch ( Exception /*e*/ )
     {
         s = "<invalid or missing tree structure>";
     }
     return s;
 }
Ejemplo n.º 6
0
 public ANTLRTreePrinter.block_return Block( GrammarAST t, bool forceParens )
 {
     ANTLRTreePrinter other = new ANTLRTreePrinter( new CommonTreeNodeStream( t ) );
     return other.block( forceParens );
 }