1 namespace Antlr.Runtime.Debug 2 { 3 using System; 4 using System.Collections.Generic; 5 using System.Linq; 6 using System.Text; 7 8 using IOException = System.IO.IOException; 9 using Antlr.Runtime.Tree; 10 11 public class ParserDebugger 12 { 13 IDebugEventListener dbg; 14 ParserDebugger( Parser parser )15 public ParserDebugger( Parser parser ) 16 : this( parser, DebugEventSocketProxy.DEFAULT_DEBUGGER_PORT ) 17 { 18 } ParserDebugger( Parser parser, int port )19 public ParserDebugger( Parser parser, int port ) 20 { 21 DebugEventSocketProxy proxy = new DebugEventSocketProxy( parser, port, null ); 22 DebugListener = proxy; 23 parser.TokenStream = new DebugTokenStream( parser.TokenStream, proxy ); 24 try 25 { 26 proxy.handshake(); 27 } 28 catch ( IOException e ) 29 { 30 reportError( ioe ); 31 } 32 ITreeAdaptor adap = new CommonTreeAdaptor(); 33 TreeAdaptor = adap; 34 proxy.TreeAdaptor = adap; 35 } ParserDebugger( Parser parser, IDebugEventListener dbg )36 public ParserDebugger( Parser parser, IDebugEventListener dbg ) 37 { 38 ITreeAdaptor adap = new CommonTreeAdaptor(); 39 TreeAdaptor = adap; 40 } 41 EvalPredicate( bool result, string predicate )42 protected virtual bool EvalPredicate( bool result, string predicate ) 43 { 44 dbg.SemanticPredicate( result, predicate ); 45 return result; 46 } 47 48 } 49 } 50