13447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein/* 23447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein [The "BSD license"] 33447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein Copyright (c) 2005-2009 Terence Parr 43447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein All rights reserved. 53447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 63447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein Redistribution and use in source and binary forms, with or without 73447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein modification, are permitted provided that the following conditions 83447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein are met: 93447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 1. Redistributions of source code must retain the above copyright 103447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein notice, this list of conditions and the following disclaimer. 113447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 2. Redistributions in binary form must reproduce the above copyright 123447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein notice, this list of conditions and the following disclaimer in the 133447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein documentation and/or other materials provided with the distribution. 143447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 3. The name of the author may not be used to endorse or promote products 153447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein derived from this software without specific prior written permission. 163447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 173447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 183447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 193447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 203447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 213447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 223447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 233447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 243447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 253447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 263447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 273447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein */ 283447a5916aa62f44de24cc441fc9987116ddff52Andrew Sappersteinpackage org.antlr.runtime.debug; 293447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 303447a5916aa62f44de24cc441fc9987116ddff52Andrew Sappersteinimport org.antlr.runtime.Token; 313447a5916aa62f44de24cc441fc9987116ddff52Andrew Sappersteinimport org.antlr.runtime.RecognitionException; 323447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 333447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein/** A simple event repeater (proxy) that delegates all functionality to the 343447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * listener sent into the ctor. Useful if you want to listen in on a few 353447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * debug events w/o interrupting the debugger. Just subclass the repeater 363447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * and override the methods you want to listen in on. Remember to call 373447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * the method in this class so the event will continue on to the original 383447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * recipient. 393447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * 403447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * @see DebugEventHub 413447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein */ 423447a5916aa62f44de24cc441fc9987116ddff52Andrew Sappersteinpublic class DebugEventRepeater implements DebugEventListener { 433447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein protected DebugEventListener listener; 443447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 453447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public DebugEventRepeater(DebugEventListener listener) { 463447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein this.listener = listener; 473447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein } 483447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 493447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void enterRule(String grammarFileName, String ruleName) { listener.enterRule(grammarFileName, ruleName); } 503447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void exitRule(String grammarFileName, String ruleName) { listener.exitRule(grammarFileName, ruleName); } 513447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void enterAlt(int alt) { listener.enterAlt(alt); } 523447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void enterSubRule(int decisionNumber) { listener.enterSubRule(decisionNumber); } 533447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void exitSubRule(int decisionNumber) { listener.exitSubRule(decisionNumber); } 543447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void enterDecision(int decisionNumber, boolean couldBacktrack) { listener.enterDecision(decisionNumber, couldBacktrack); } 553447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void exitDecision(int decisionNumber) { listener.exitDecision(decisionNumber); } 563447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void location(int line, int pos) { listener.location(line, pos); } 573447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void consumeToken(Token token) { listener.consumeToken(token); } 583447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void consumeHiddenToken(Token token) { listener.consumeHiddenToken(token); } 593447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void LT(int i, Token t) { listener.LT(i, t); } 603447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void mark(int i) { listener.mark(i); } 613447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void rewind(int i) { listener.rewind(i); } 623447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void rewind() { listener.rewind(); } 633447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void beginBacktrack(int level) { listener.beginBacktrack(level); } 643447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void endBacktrack(int level, boolean successful) { listener.endBacktrack(level, successful); } 653447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void recognitionException(RecognitionException e) { listener.recognitionException(e); } 663447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void beginResync() { listener.beginResync(); } 673447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void endResync() { listener.endResync(); } 683447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void semanticPredicate(boolean result, String predicate) { listener.semanticPredicate(result, predicate); } 693447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void commence() { listener.commence(); } 703447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void terminate() { listener.terminate(); } 713447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 723447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein // Tree parsing stuff 733447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 743447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void consumeNode(Object t) { listener.consumeNode(t); } 753447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void LT(int i, Object t) { listener.LT(i, t); } 763447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 773447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein // AST Stuff 783447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 793447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void nilNode(Object t) { listener.nilNode(t); } 803447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void errorNode(Object t) { listener.errorNode(t); } 813447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void createNode(Object t) { listener.createNode(t); } 823447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void createNode(Object node, Token token) { listener.createNode(node, token); } 833447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void becomeRoot(Object newRoot, Object oldRoot) { listener.becomeRoot(newRoot, oldRoot); } 843447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void addChild(Object root, Object child) { listener.addChild(root, child); } 853447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public void setTokenBoundaries(Object t, int tokenStartIndex, int tokenStopIndex) { 863447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein listener.setTokenBoundaries(t, tokenStartIndex, tokenStopIndex); 873447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein } 883447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein} 89