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{
35
36    /** <summary>
37     *  A simple event repeater (proxy) that delegates all functionality to the
38     *  listener sent into the ctor.  Useful if you want to listen in on a few
39     *  debug events w/o interrupting the debugger.  Just subclass the repeater
40     *  and override the methods you want to listen in on.  Remember to call
41     *  the method in this class so the event will continue on to the original
42     *  recipient.
43     *  </summary>
44     *
45     *  <seealso cref="DebugEventHub"/>
46     */
47    public class DebugEventRepeater : IDebugEventListener
48    {
49        IDebugEventListener _listener;
50
51        public DebugEventRepeater( IDebugEventListener listener )
52        {
53            _listener = listener;
54        }
55
56        public virtual void Initialize()
57        {
58        }
59
60        public virtual void EnterRule( string grammarFileName, string ruleName )
61        {
62            _listener.EnterRule( grammarFileName, ruleName );
63        }
64        public virtual void ExitRule( string grammarFileName, string ruleName )
65        {
66            _listener.ExitRule( grammarFileName, ruleName );
67        }
68        public virtual void EnterAlt( int alt )
69        {
70            _listener.EnterAlt( alt );
71        }
72        public virtual void EnterSubRule( int decisionNumber )
73        {
74            _listener.EnterSubRule( decisionNumber );
75        }
76        public virtual void ExitSubRule( int decisionNumber )
77        {
78            _listener.ExitSubRule( decisionNumber );
79        }
80        public virtual void EnterDecision(int decisionNumber, bool couldBacktrack)
81        {
82            _listener.EnterDecision( decisionNumber, couldBacktrack );
83        }
84        public virtual void ExitDecision( int decisionNumber )
85        {
86            _listener.ExitDecision( decisionNumber );
87        }
88        public virtual void Location( int line, int pos )
89        {
90            _listener.Location( line, pos );
91        }
92        public virtual void ConsumeToken( IToken token )
93        {
94            _listener.ConsumeToken( token );
95        }
96        public virtual void ConsumeHiddenToken( IToken token )
97        {
98            _listener.ConsumeHiddenToken( token );
99        }
100        public virtual void LT( int i, IToken t )
101        {
102            _listener.LT( i, t );
103        }
104        public virtual void Mark( int i )
105        {
106            _listener.Mark( i );
107        }
108        public virtual void Rewind( int i )
109        {
110            _listener.Rewind( i );
111        }
112        public virtual void Rewind()
113        {
114            _listener.Rewind();
115        }
116        public virtual void BeginBacktrack( int level )
117        {
118            _listener.BeginBacktrack( level );
119        }
120        public virtual void EndBacktrack( int level, bool successful )
121        {
122            _listener.EndBacktrack( level, successful );
123        }
124        public virtual void RecognitionException( RecognitionException e )
125        {
126            _listener.RecognitionException( e );
127        }
128        public virtual void BeginResync()
129        {
130            _listener.BeginResync();
131        }
132        public virtual void EndResync()
133        {
134            _listener.EndResync();
135        }
136        public virtual void SemanticPredicate( bool result, string predicate )
137        {
138            _listener.SemanticPredicate( result, predicate );
139        }
140        public virtual void Commence()
141        {
142            _listener.Commence();
143        }
144        public virtual void Terminate()
145        {
146            _listener.Terminate();
147        }
148
149        #region Tree parsing stuff
150
151        public virtual void ConsumeNode( object t )
152        {
153            _listener.ConsumeNode( t );
154        }
155        public virtual void LT( int i, object t )
156        {
157            _listener.LT( i, t );
158        }
159
160        #endregion
161
162
163        #region AST Stuff
164
165        public virtual void NilNode( object t )
166        {
167            _listener.NilNode( t );
168        }
169        public virtual void ErrorNode( object t )
170        {
171            _listener.ErrorNode( t );
172        }
173        public virtual void CreateNode( object t )
174        {
175            _listener.CreateNode( t );
176        }
177        public virtual void CreateNode( object node, IToken token )
178        {
179            _listener.CreateNode( node, token );
180        }
181        public virtual void BecomeRoot( object newRoot, object oldRoot )
182        {
183            _listener.BecomeRoot( newRoot, oldRoot );
184        }
185        public virtual void AddChild( object root, object child )
186        {
187            _listener.AddChild( root, child );
188        }
189        public virtual void SetTokenBoundaries( object t, int tokenStartIndex, int tokenStopIndex )
190        {
191            _listener.SetTokenBoundaries( t, tokenStartIndex, tokenStopIndex );
192        }
193
194        #endregion
195    }
196}
197