1324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver/*
2324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * [The "BSD licence"]
3324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * Copyright (c) 2005-2008 Terence Parr
4324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * All rights reserved.
5324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver *
6324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * Conversion to C#:
7324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * Copyright (c) 2008-2009 Sam Harwell, Pixel Mine, Inc.
8324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * All rights reserved.
9324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver *
10324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * Redistribution and use in source and binary forms, with or without
11324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * modification, are permitted provided that the following conditions
12324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * are met:
13324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * 1. Redistributions of source code must retain the above copyright
14324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver *    notice, this list of conditions and the following disclaimer.
15324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * 2. Redistributions in binary form must reproduce the above copyright
16324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver *    notice, this list of conditions and the following disclaimer in the
17324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver *    documentation and/or other materials provided with the distribution.
18324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * 3. The name of the author may not be used to endorse or promote products
19324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver *    derived from this software without specific prior written permission.
20324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver *
21324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver */
32324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
33324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruvernamespace Antlr.Runtime.Tree
34324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver{
35324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    using System.Collections.Generic;
36324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    using Antlr.Runtime.Misc;
37324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
38324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    using StringBuilder = System.Text.StringBuilder;
39324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    using NotSupportedException = System.NotSupportedException;
40324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
41324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    [System.Serializable]
42324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    public class CommonTreeNodeStream : LookaheadStream<object>, ITreeNodeStream
43324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    {
44324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public const int DEFAULT_INITIAL_BUFFER_SIZE = 100;
45324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public const int INITIAL_CALL_STACK_SIZE = 10;
46324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
47324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        /** <summary>Pull nodes from which tree?</summary> */
48324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        object _root;
49324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
50324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        /** <summary>If this tree (root) was created from a token stream, track it.</summary> */
51324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        protected ITokenStream tokens;
52324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
53324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        /** <summary>What tree adaptor was used to build these trees</summary> */
54324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        [System.NonSerialized]
55324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        ITreeAdaptor _adaptor;
56324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
57324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        /** The tree iterator we are using */
58324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        TreeIterator _it;
59324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
60324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        /** <summary>Stack of indexes used for push/pop calls</summary> */
61324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        Stack<int> _calls;
62324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
63324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        /** <summary>Tree (nil A B C) trees like flat A B C streams</summary> */
64324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        bool _hasNilRoot = false;
65324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
66324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        /** <summary>Tracks tree depth.  Level=0 means we're at root node level.</summary> */
67324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        int _level = 0;
68324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
69324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public CommonTreeNodeStream( object tree )
70324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            : this( new CommonTreeAdaptor(), tree )
71324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        {
72324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        }
73324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
74324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public CommonTreeNodeStream( ITreeAdaptor adaptor, object tree )
75324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        {
76324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            this._root = tree;
77324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            this._adaptor = adaptor;
78324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            _it = new TreeIterator( adaptor, _root );
79324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        }
80324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
81324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        #region Properties
82324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
83324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public virtual string SourceName
84324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        {
85324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            get
86324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            {
87324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                if ( TokenStream == null )
88324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                    return null;
89324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
90324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                return TokenStream.SourceName;
91324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            }
92324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        }
93324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
94324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public virtual ITokenStream TokenStream
95324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        {
96324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            get
97324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            {
98324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                return tokens;
99324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            }
100324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            set
101324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            {
102324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                tokens = value;
103324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            }
104324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        }
105324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
106324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public virtual ITreeAdaptor TreeAdaptor
107324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        {
108324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            get
109324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            {
110324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                return _adaptor;
111324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            }
112324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
113324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            set
114324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            {
115324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                _adaptor = value;
116324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            }
117324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        }
118324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
119324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public virtual object TreeSource
120324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        {
121324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            get
122324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            {
123324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                return _root;
124324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            }
125324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        }
126324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
127324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public virtual bool UniqueNavigationNodes
128324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        {
129324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            get
130324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            {
131324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                return false;
132324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            }
133324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
134324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            set
135324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            {
136324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            }
137324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        }
138324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
139324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        #endregion
140324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
141324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public virtual void Reset()
142324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        {
143324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            base.Clear();
144324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            _it.Reset();
145324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            _hasNilRoot = false;
146324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            _level = 0;
147324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            if ( _calls != null )
148324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                _calls.Clear();
149324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        }
150324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
151324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public override object NextElement()
152324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        {
153324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            _it.MoveNext();
154324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            object t = _it.Current;
155324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            //System.out.println("pulled "+adaptor.getType(t));
156324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            if ( t == _it.up )
157324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            {
158324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                _level--;
159324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                if ( _level == 0 && _hasNilRoot )
160324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                {
161324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                    _it.MoveNext();
162324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                    return _it.Current; // don't give last UP; get EOF
163324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                }
164324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            }
165324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            else if ( t == _it.down )
166324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            {
167324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                _level++;
168324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            }
169324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
170324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            if ( _level == 0 && TreeAdaptor.IsNil( t ) )
171324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            {
172324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                // if nil root, scarf nil, DOWN
173324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                _hasNilRoot = true;
174324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                _it.MoveNext();
175324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                t = _it.Current; // t is now DOWN, so get first real node next
176324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                _level++;
177324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                _it.MoveNext();
178324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                t = _it.Current;
179324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            }
180324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
181324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            return t;
182324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        }
183324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
184324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public override bool IsEndOfFile(object o)
185324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        {
186324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            return TreeAdaptor.GetType(o) == CharStreamConstants.EndOfFile;
187324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        }
188324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
189324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public virtual int LA( int i )
190324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        {
191324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            return TreeAdaptor.GetType( LT( i ) );
192324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        }
193324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
194324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        /** Make stream jump to a new location, saving old location.
195324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver         *  Switch back with pop().
196324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver         */
197324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public virtual void Push( int index )
198324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        {
199324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            if ( _calls == null )
200324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            {
201324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                _calls = new Stack<int>();
202324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            }
203324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            _calls.Push( _p ); // save current index
204324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            Seek( index );
205324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        }
206324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
207324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        /** Seek back to previous index saved during last push() call.
208324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver         *  Return top of stack (return index).
209324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver         */
210324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public virtual int Pop()
211324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        {
212324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            int ret = _calls.Pop();
213324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            Seek( ret );
214324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            return ret;
215324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        }
216324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
217324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        #region Tree rewrite interface
218324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
219324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public virtual void ReplaceChildren( object parent, int startChildIndex, int stopChildIndex, object t )
220324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        {
221324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            if ( parent != null )
222324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            {
223324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                TreeAdaptor.ReplaceChildren( parent, startChildIndex, stopChildIndex, t );
224324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            }
225324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        }
226324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
227324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        #endregion
228324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
229324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public virtual string ToString( object start, object stop )
230324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        {
231324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            // we'll have to walk from start to stop in tree; we're not keeping
232324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            // a complete node stream buffer
233324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            return "n/a";
234324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        }
235324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
236324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        /** <summary>For debugging; destructive: moves tree iterator to end.</summary> */
237324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        public virtual string ToTokenTypeString()
238324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        {
239324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            Reset();
240324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            StringBuilder buf = new StringBuilder();
241324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            object o = LT( 1 );
242324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            int type = TreeAdaptor.GetType( o );
243324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            while ( type != TokenTypes.EndOfFile )
244324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            {
245324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                buf.Append( " " );
246324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                buf.Append( type );
247324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                Consume();
248324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                o = LT( 1 );
249324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver                type = TreeAdaptor.GetType( o );
250324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            }
251324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver            return buf.ToString();
252324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver        }
253324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    }
254324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver}
255