1/* 2 * [The "BSD licence"] 3 * Copyright (c) 2005-2008 Terence Parr 4 * All rights reserved. 5 * 6 * Conversion to C#: 7 * Copyright (c) 2008-2009 Sam Harwell, Pixel Mine, Inc. 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33namespace Antlr.Runtime.Debug { 34 /** <summary> 35 * A blank listener that does nothing; useful for real classes so 36 * they don't have to have lots of blank methods and are less 37 * sensitive to updates to debug interface. 38 * </summary> 39 */ 40 public class BlankDebugEventListener : IDebugEventListener { 41 public int RuleLevel { 42 get; 43 protected set; 44 } 45 46 public virtual void Initialize() { 47 } 48 49 public virtual void EnterRule(string grammarFileName, string ruleName) { 50 if (RuleLevel == 0) 51 Commence(); 52 RuleLevel++; 53 } 54 public virtual void ExitRule(string grammarFileName, string ruleName) { 55 RuleLevel--; 56 if (RuleLevel == 0) 57 Terminate(); 58 } 59 public virtual void EnterAlt(int alt) { 60 } 61 public virtual void EnterSubRule(int decisionNumber) { 62 } 63 public virtual void ExitSubRule(int decisionNumber) { 64 } 65 public virtual void EnterDecision(int decisionNumber, bool couldBacktrack) { 66 } 67 public virtual void ExitDecision(int decisionNumber) { 68 } 69 public virtual void Location(int line, int pos) { 70 } 71 public virtual void ConsumeToken(IToken token) { 72 } 73 public virtual void ConsumeHiddenToken(IToken token) { 74 } 75 public virtual void LT(int i, IToken t) { 76 } 77 public virtual void Mark(int i) { 78 } 79 public virtual void Rewind(int i) { 80 } 81 public virtual void Rewind() { 82 } 83 public virtual void BeginBacktrack(int level) { 84 } 85 public virtual void EndBacktrack(int level, bool successful) { 86 } 87 public virtual void RecognitionException(RecognitionException e) { 88 } 89 public virtual void BeginResync() { 90 } 91 public virtual void EndResync() { 92 } 93 public virtual void SemanticPredicate(bool result, string predicate) { 94 } 95 public virtual void Commence() { 96 } 97 public virtual void Terminate() { 98 } 99 100 #region Tree parsing stuff 101 102 public virtual void ConsumeNode(object t) { 103 } 104 public virtual void LT(int i, object t) { 105 } 106 107 #endregion 108 109 110 #region AST Stuff 111 112 public virtual void NilNode(object t) { 113 } 114 public virtual void ErrorNode(object t) { 115 } 116 public virtual void CreateNode(object t) { 117 } 118 public virtual void CreateNode(object node, IToken token) { 119 } 120 public virtual void BecomeRoot(object newRoot, object oldRoot) { 121 } 122 public virtual void AddChild(object root, object child) { 123 } 124 public virtual void SetTokenBoundaries(object t, int tokenStartIndex, int tokenStopIndex) { 125 } 126 127 #endregion 128 } 129} 130 131