state.h 970 B

123456789101112131415161718192021222324252627282930313233
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TOOLCHAIN_PARSE_STATE_H_
  5. #define CARBON_TOOLCHAIN_PARSE_STATE_H_
  6. #include <cstdint>
  7. #include "common/enum_base.h"
  8. namespace Carbon::Parse {
  9. CARBON_DEFINE_RAW_ENUM_CLASS(State, uint8_t) {
  10. #define CARBON_PARSE_STATE(Name) CARBON_RAW_ENUM_ENUMERATOR(Name)
  11. #include "toolchain/parse/state.def"
  12. };
  13. class State : public CARBON_ENUM_BASE(State) {
  14. public:
  15. #define CARBON_PARSE_STATE(Name) CARBON_ENUM_CONSTANT_DECL(Name)
  16. #include "toolchain/parse/state.def"
  17. };
  18. #define CARBON_PARSE_STATE(Name) CARBON_ENUM_CONSTANT_DEFINITION(State, Name)
  19. #include "toolchain/parse/state.def"
  20. // We expect State to fit compactly into 8 bits.
  21. static_assert(sizeof(State) == 1, "State includes padding!");
  22. } // namespace Carbon::Parse
  23. #endif // CARBON_TOOLCHAIN_PARSE_STATE_H_