aboutsummaryrefslogtreecommitdiff
path: root/runtime/CSharp3/Sources/Antlr3.Runtime.Debug/ParserDebugger.cs
blob: 0b60f2bc9d18750e95cc6dc20bb49202ddd179a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
namespace Antlr.Runtime.Debug
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    using IOException = System.IO.IOException;
    using Antlr.Runtime.Tree;

    public class ParserDebugger
    {
        IDebugEventListener dbg;

        public ParserDebugger( Parser parser )
            : this( parser, DebugEventSocketProxy.DEFAULT_DEBUGGER_PORT )
        {
        }
        public ParserDebugger( Parser parser, int port )
        {
            DebugEventSocketProxy proxy = new DebugEventSocketProxy( parser, port, null );
            DebugListener = proxy;
            parser.TokenStream = new DebugTokenStream( parser.TokenStream, proxy );
            try
            {
                proxy.handshake();
            }
            catch ( IOException e )
            {
                reportError( ioe );
            }
            ITreeAdaptor adap = new CommonTreeAdaptor();
            TreeAdaptor = adap;
            proxy.TreeAdaptor = adap;
        }
        public ParserDebugger( Parser parser, IDebugEventListener dbg )
        {
            ITreeAdaptor adap = new CommonTreeAdaptor();
            TreeAdaptor = adap;
        }

        protected virtual bool EvalPredicate( bool result, string predicate )
        {
            dbg.SemanticPredicate( result, predicate );
            return result;
        }

    }
}