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 package org.antlr.runtime.debug;
00029
00030 import org.antlr.runtime.*;
00031 import org.antlr.runtime.tree.TreeNodeStream;
00032 import org.antlr.runtime.tree.TreeParser;
00033
00034 import java.io.IOException;
00035
00036 public class DebugTreeParser extends TreeParser {
00038 protected DebugEventListener dbg = null;
00039
00043 public boolean isCyclicDecision = false;
00044
00048 public DebugTreeParser(TreeNodeStream input, DebugEventListener dbg, RecognizerSharedState state) {
00049 super(input instanceof DebugTreeNodeStream?input:new DebugTreeNodeStream(input,dbg), state);
00050 setDebugListener(dbg);
00051 }
00052
00053 public DebugTreeParser(TreeNodeStream input, RecognizerSharedState state) {
00054 super(input instanceof DebugTreeNodeStream?input:new DebugTreeNodeStream(input,null), state);
00055 }
00056
00057 public DebugTreeParser(TreeNodeStream input, DebugEventListener dbg) {
00058 this(input instanceof DebugTreeNodeStream?input:new DebugTreeNodeStream(input,dbg), dbg, null);
00059 }
00060
00064 public void setDebugListener(DebugEventListener dbg) {
00065 if ( input instanceof DebugTreeNodeStream ) {
00066 ((DebugTreeNodeStream)input).setDebugListener(dbg);
00067 }
00068 this.dbg = dbg;
00069 }
00070
00071 public DebugEventListener getDebugListener() {
00072 return dbg;
00073 }
00074
00075 public void reportError(IOException e) {
00076 System.err.println(e);
00077 e.printStackTrace(System.err);
00078 }
00079
00080 public void reportError(RecognitionException e) {
00081 dbg.recognitionException(e);
00082 }
00083
00084 protected Object getMissingSymbol(IntStream input,
00085 RecognitionException e,
00086 int expectedTokenType,
00087 BitSet follow)
00088 {
00089 Object o = super.getMissingSymbol(input, e, expectedTokenType, follow);
00090 dbg.consumeNode(o);
00091 return o;
00092 }
00093
00094 public void beginResync() {
00095 dbg.beginResync();
00096 }
00097
00098 public void endResync() {
00099 dbg.endResync();
00100 }
00101
00102 public void beginBacktrack(int level) {
00103 dbg.beginBacktrack(level);
00104 }
00105
00106 public void endBacktrack(int level, boolean successful) {
00107 dbg.endBacktrack(level,successful);
00108 }
00109 }