PageRenderTime 56ms CodeModel.GetById 34ms RepoModel.GetById 1ms app.codeStats 0ms

/Dependencies/boo/src/Boo.Lang.Parser/antlr/antlr/TokenStreamBasicFilter.cs

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