source: trunk/yao/share/antlr-2.7.7/lib/csharp/antlr.runtime/antlr/TokenStreamBasicFilter.cs @ 1

Last change on this file since 1 was 1, checked in by lnalod, 15 years ago

Initial import of YAO sources

File size: 1.3 KB
Line 
1using System;
2using BitSet = antlr.collections.impl.BitSet;
3       
4namespace antlr
5{
6        /*ANTLR Translator Generator
7        * Project led by Terence Parr at http://www.jGuru.com
8        * Software rights: http://www.antlr.org/license.html
9        *
10        * $Id:$
11        */
12
13        //
14        // ANTLR C# Code Generator by Micheal Jordan
15        //                            Kunle Odutola       : kunle UNDERSCORE odutola AT hotmail DOT com
16        //                            Anthony Oguntimehin
17        //
18        // With many thanks to Eric V. Smith from the ANTLR list.
19        //
20
21        /*This object is a TokenStream that passes through all
22        *  tokens except for those that you tell it to discard.
23        *  There is no buffering of the tokens.
24        */
25        public class TokenStreamBasicFilter : TokenStream
26        {
27                /*The set of token types to discard */
28                protected internal BitSet discardMask;
29               
30                /*The input stream */
31                protected internal TokenStream input;
32               
33                public TokenStreamBasicFilter(TokenStream input)
34                {
35                        this.input = input;
36                        discardMask = new BitSet();
37                }
38                public virtual void  discard(int ttype)
39                {
40                        discardMask.add(ttype);
41                }
42                public virtual void  discard(BitSet mask)
43                {
44                        discardMask = mask;
45                }
46                public virtual IToken nextToken()
47                {
48                        IToken tok = input.nextToken();
49                        while (tok != null && discardMask.member(tok.Type))
50                        {
51                                tok = input.nextToken();
52                        }
53                        return tok;
54                }
55        }
56}
Note: See TracBrowser for help on using the repository browser.