1 package antlr; 2 3 9 10 import antlr.collections.impl.BitSet; 11 12 16 public class TokenStreamBasicFilter implements TokenStream { 17 18 protected BitSet discardMask; 19 20 21 protected TokenStream input; 22 23 public TokenStreamBasicFilter(TokenStream input) { 24 this.input = input; 25 discardMask = new BitSet(); 26 } 27 28 public void discard(int ttype) { 29 discardMask.add(ttype); 30 } 31 32 public void discard(BitSet mask) { 33 discardMask = mask; 34 } 35 36 public Token nextToken() throws TokenStreamException { 37 Token tok = input.nextToken(); 38 while (tok != null && discardMask.member(tok.getType())) { 39 tok = input.nextToken(); 40 } 41 return tok; 42 } 43 } 44 | Popular Tags |