state.h 994 B

12345678910111213141516171819202122232425262728293031323334
  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(StateKind, uint8_t) {
  10. #define CARBON_PARSE_STATE(Name) CARBON_RAW_ENUM_ENUMERATOR(Name)
  11. #include "toolchain/parse/state.def"
  12. };
  13. class StateKind : public CARBON_ENUM_BASE(StateKind) {
  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) \
  19. CARBON_ENUM_CONSTANT_DEFINITION(StateKind, Name)
  20. #include "toolchain/parse/state.def"
  21. // We expect State to fit compactly into 8 bits.
  22. static_assert(sizeof(StateKind) == 1, "State includes padding!");
  23. } // namespace Carbon::Parse
  24. #endif // CARBON_TOOLCHAIN_PARSE_STATE_H_