Added ability to order the execution of dictionary adapter behaviors.
[castle.git] / Experiments / Attic / Rook / Castle.Rook.Compiler / Parser / antlr / debug / DebuggingInputBuffer.cs
blob87a2d9e4f8a46c081f351998780f48b29fb199ba
1 namespace antlr.debug
3 using System;
4 using ArrayList = System.Collections.ArrayList;
6 public class DebuggingInputBuffer : InputBuffer
8 public virtual ArrayList InputBufferListeners
10 get { return inputBufferEventSupport.InputBufferListeners; }
12 public virtual bool DebugMode
14 set { debugMode = value; }
17 private InputBuffer buffer;
18 private InputBufferEventSupport inputBufferEventSupport;
19 private bool debugMode = true;
22 public DebuggingInputBuffer(InputBuffer buffer)
24 this.buffer = buffer;
25 inputBufferEventSupport = new InputBufferEventSupport(this);
27 public virtual void addInputBufferListener(InputBufferListener l)
29 inputBufferEventSupport.addInputBufferListener(l);
31 public override char consume()
33 char la = ' ';
34 try
36 la = buffer.LA(1);
38 catch (CharStreamException)
40 } // vaporize it...
41 buffer.consume();
42 if (debugMode)
43 inputBufferEventSupport.fireConsume(la);
44 return la;
46 public override void fill(int a)
48 buffer.fill(a);
50 public virtual bool isDebugMode()
52 return debugMode;
54 public override bool isMarked()
56 return buffer.isMarked();
58 public override char LA(int i)
60 char la = buffer.LA(i);
61 if (debugMode)
62 inputBufferEventSupport.fireLA(la, i);
63 return la;
65 public override int mark()
67 int m = buffer.mark();
68 inputBufferEventSupport.fireMark(m);
69 return m;
71 public virtual void removeInputBufferListener(InputBufferListener l)
73 if (inputBufferEventSupport != null)
74 inputBufferEventSupport.removeInputBufferListener(l);
76 public override void rewind(int mark)
78 buffer.rewind(mark);
79 inputBufferEventSupport.fireRewind(mark);