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