PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Dependencies/boo/lib/antlr-2.7.5/lib/cpp/antlr/TokenStreamHiddenTokenFilter.hpp

https://github.com/w4x/boolangstudio
C++ Header | 95 lines | 38 code | 21 blank | 36 comment | 0 complexity | b023cb7793b57b5b7b28be3a97a0b9bc MD5 | raw file
Possible License(s): GPL-2.0
  1. #ifndef INC_TokenStreamHiddenTokenFilter_hpp__
  2. #define INC_TokenStreamHiddenTokenFilter_hpp__
  3. /* ANTLR Translator Generator
  4. * Project led by Terence Parr at http://www.jGuru.com
  5. * Software rights: http://www.antlr.org/license.html
  6. *
  7. * $Id: //depot/code/org.antlr/release/antlr-2.7.5/lib/cpp/antlr/TokenStreamHiddenTokenFilter.hpp#1 $
  8. */
  9. #include <antlr/config.hpp>
  10. #include <antlr/TokenStreamBasicFilter.hpp>
  11. #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
  12. namespace antlr {
  13. #endif
  14. /**This object filters a token stream coming from a lexer
  15. * or another TokenStream so that only certain token channels
  16. * get transmitted to the parser.
  17. *
  18. * Any of the channels can be filtered off as "hidden" channels whose
  19. * tokens can be accessed from the parser.
  20. */
  21. class ANTLR_API TokenStreamHiddenTokenFilter : public TokenStreamBasicFilter {
  22. // protected BitSet discardMask;
  23. protected:
  24. BitSet hideMask;
  25. private:
  26. RefToken nextMonitoredToken;
  27. protected:
  28. /** track tail of hidden list emanating from previous
  29. * monitored token
  30. */
  31. RefToken lastHiddenToken;
  32. RefToken firstHidden; // = null;
  33. public:
  34. TokenStreamHiddenTokenFilter(TokenStream& input);
  35. protected:
  36. void consume();
  37. private:
  38. void consumeFirst();
  39. public:
  40. BitSet getDiscardMask() const;
  41. /** Return a ptr to the hidden token appearing immediately after
  42. * token t in the input stream.
  43. */
  44. RefToken getHiddenAfter(RefToken t);
  45. /** Return a ptr to the hidden token appearing immediately before
  46. * token t in the input stream.
  47. */
  48. RefToken getHiddenBefore(RefToken t);
  49. BitSet getHideMask() const;
  50. /** Return the first hidden token if one appears
  51. * before any monitored token.
  52. */
  53. RefToken getInitialHiddenToken();
  54. void hide(int m);
  55. void hide(const BitSet& mask);
  56. protected:
  57. RefToken LA(int i);
  58. public:
  59. /** Return the next monitored token.
  60. * Test the token following the monitored token.
  61. * If following is another monitored token, save it
  62. * for the next invocation of nextToken (like a single
  63. * lookahead token) and return it then.
  64. * If following is unmonitored, nondiscarded (hidden)
  65. * channel token, add it to the monitored token.
  66. *
  67. * Note: EOF must be a monitored Token.
  68. */
  69. RefToken nextToken();
  70. };
  71. #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
  72. }
  73. #endif
  74. #endif //INC_TokenStreamHiddenTokenFilter_hpp__