fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <memory>
  4. using namespace std;
  5.  
  6. struct TokenTypeStore {};
  7.  
  8. class TokenType final {
  9. public:
  10. TokenType() = default;
  11. enum class MatchType : uint8_t {
  12. non_greedy,
  13. greedy
  14. };
  15.  
  16. TokenType(
  17. std::string const& name,
  18. std::string const& regex = "",
  19. TokenTypeStore store_type = {},
  20. MatchType match_type = MatchType::non_greedy);
  21.  
  22. TokenType(TokenType const& other) = default;
  23. TokenType & operator=(TokenType const& other) = default;
  24. TokenType & operator=(TokenType && other) = default;
  25. };
  26.  
  27. class CionTokenTypes final {
  28. private:
  29. CionTokenTypes();
  30.  
  31. TokenType init_tt(TokenType token_type, bool skipped = false);
  32.  
  33. std::vector<TokenType> m_all_token_types;
  34. std::vector<TokenType> m_skipped_token_types;
  35.  
  36. static const CionTokenTypes c_instance;
  37.  
  38. public:
  39. CionTokenTypes(CionTokenTypes const&) = delete;
  40. CionTokenTypes(CionTokenTypes &&) = delete;
  41.  
  42. static CionTokenTypes const& get_instance();
  43.  
  44. std::vector<TokenType> const& get_all() const;
  45. std::vector<TokenType> const& get_skipped() const;
  46.  
  47. TokenType const my_custom_token_type;
  48. };
  49.  
  50. const CionTokenTypes CionTokenTypes::c_instance = {};
  51.  
  52. TokenType CionTokenTypes::init_tt(
  53. TokenType token_type,
  54. bool skipped
  55. ) {
  56. m_all_token_types.push_back(token_type);
  57. if (skipped) {
  58. m_skipped_token_types.push_back(token_type);
  59. }
  60. return std::move(token_type);
  61. }
  62.  
  63. CionTokenTypes const& CionTokenTypes::get_instance() {
  64. return c_instance;
  65. }
  66.  
  67. std::vector<TokenType> const& CionTokenTypes::get_all() const {
  68. return m_all_token_types;
  69. }
  70.  
  71. std::vector<TokenType> const& CionTokenTypes::get_skipped() const {
  72. return m_skipped_token_types;
  73. }
  74.  
  75. CionTokenTypes::CionTokenTypes():
  76. m_all_token_types{},
  77. m_skipped_token_types{},
  78. my_custom_token_type{init_tt({"bracket: closing bracket ]", "\\]"})}
  79. {}
  80.  
  81. TokenType::TokenType(
  82. std::string const& name,
  83. std::string const& regex,
  84. TokenTypeStore store_type,
  85. TokenType::MatchType match_type
  86. )
  87. {}
  88.  
  89. int main() {
  90. // your code goes here
  91. return 0;
  92. }
Success #stdin #stdout 0s 3424KB
stdin
Standard input is empty
stdout
Standard output is empty