00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 namespace Antlr.Runtime.Debug
00037 {
00038 using System;
00039 using Antlr.Runtime;
00040 using ITreeAdaptor = Antlr.Runtime.Tree.ITreeAdaptor;
00041 using ITreeNodeStream = Antlr.Runtime.Tree.ITreeNodeStream;
00042 using ITokenStream = Antlr.Runtime.ITokenStream;
00043
00044
00050 public class DebugTreeNodeStream : ITreeNodeStream
00051 {
00052 protected IDebugEventListener dbg;
00053 protected ITreeAdaptor adaptor;
00054 protected ITreeNodeStream input;
00055 protected bool initialStreamState = true;
00056
00058 protected int lastMarker;
00059
00060 public DebugTreeNodeStream(ITreeNodeStream input, IDebugEventListener dbg)
00061 {
00062 this.input = input;
00063 this.adaptor = input.TreeAdaptor;
00064 this.input.HasUniqueNavigationNodes = true;
00065 SetDebugListener(dbg);
00066 }
00067
00068 public void SetDebugListener(IDebugEventListener dbg)
00069 {
00070 this.dbg = dbg;
00071 }
00072
00073 public ITokenStream TokenStream
00074 {
00075 get { return input.TokenStream; }
00076 }
00077
00078 public string SourceName {
00079 get { return TokenStream.SourceName; }
00080 }
00081
00082 public ITreeAdaptor TreeAdaptor
00083 {
00084 get { return adaptor; }
00085 }
00086
00087 public void Consume()
00088 {
00089 object node = input.LT(1);
00090 input.Consume();
00091 dbg.ConsumeNode(node);
00092 }
00093
00094 public object Get(int i)
00095 {
00096 return input.Get(i);
00097 }
00098
00099 public object LT(int i)
00100 {
00101 object node = input.LT(i);
00102 dbg.LT(i, node);
00103 return node;
00104 }
00105
00106 public int LA(int i)
00107 {
00108 object node = input.LT(i);
00109 int type = adaptor.GetNodeType(node);
00110 dbg.LT(i, node);
00111 return type;
00112 }
00113
00114 public int Mark()
00115 {
00116 lastMarker = input.Mark();
00117 dbg.Mark(lastMarker);
00118 return lastMarker;
00119 }
00120
00121 public int Index()
00122 {
00123 return input.Index();
00124 }
00125
00126 public void Rewind(int marker)
00127 {
00128 dbg.Rewind(marker);
00129 input.Rewind(marker);
00130 }
00131
00132 public void Rewind()
00133 {
00134 dbg.Rewind();
00135 input.Rewind(lastMarker);
00136 }
00137
00138 public void Release(int marker)
00139 {
00140 }
00141
00142 public void Seek(int index)
00143 {
00144 input.Seek(index);
00145 }
00146
00147 public int Size()
00148 {
00149 return input.Size();
00150 }
00151
00152 public object TreeSource
00153 {
00154 get { return input; }
00155 }
00156
00163 public virtual bool HasUniqueNavigationNodes
00164 {
00165 set { input.HasUniqueNavigationNodes = value; }
00166 }
00167
00168 public void ReplaceChildren(object parent, int startChildIndex, int stopChildIndex, object t)
00169 {
00170 input.ReplaceChildren(parent, startChildIndex, stopChildIndex, t);
00171 }
00172
00173 public string ToString(object start, object stop)
00174 {
00175 return input.ToString(start, stop);
00176 }
00177 }
00178 }