unicode_set_lexer.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #include "unicode_set_token.h"
  3. #include <util/generic/strbuf.h>
  4. #include <util/system/yassert.h>
  5. namespace NUnicode {
  6. namespace NPrivate {
  7. class TUnicodeSetLexer {
  8. private:
  9. const TWtringBuf& Data;
  10. int cs;
  11. //int* stack;
  12. //int top;
  13. int act;
  14. const wchar16* ts;
  15. const wchar16* te;
  16. const wchar16* p;
  17. const wchar16* pe;
  18. const wchar16* eof;
  19. TUnicodeSetToken LastToken;
  20. bool UseLast;
  21. private:
  22. EUnicodeSetTokenType YieldToken(EUnicodeSetTokenType type);
  23. EUnicodeSetTokenType YieldToken(EUnicodeSetTokenType type, wchar16 symbol);
  24. EUnicodeSetTokenType YieldToken(EUnicodeSetTokenType type, const wchar16* dataBegin, size_t dataSize);
  25. void Reset();
  26. public:
  27. explicit TUnicodeSetLexer(const TWtringBuf& data);
  28. EUnicodeSetTokenType GetToken();
  29. const TUnicodeSetToken& GetLastToken() {
  30. return LastToken;
  31. }
  32. inline void PushBack() {
  33. Y_ABORT_UNLESS(!UseLast, "Double TUnicodeSetLexer::PushBack()");
  34. UseLast = true;
  35. }
  36. };
  37. }
  38. }