01: package antlr.debug;
02:
03: public class Tracer extends TraceAdapter implements TraceListener {
04: String indent = ""; // TBD: should be StringBuffer
05:
06: protected void dedent() {
07: if (indent.length() < 2)
08: indent = "";
09: else
10: indent = indent.substring(2);
11: }
12:
13: public void enterRule(TraceEvent e) {
14: System.out.println(indent + e);
15: indent();
16: }
17:
18: public void exitRule(TraceEvent e) {
19: dedent();
20: System.out.println(indent + e);
21: }
22:
23: protected void indent() {
24: indent += " ";
25: }
26: }
|