literal.h 842 B

1234567891011121314151617181920212223242526272829
  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_SEMANTICS_NODES_LITERAL_H_
  5. #define CARBON_TOOLCHAIN_SEMANTICS_NODES_LITERAL_H_
  6. #include "common/ostream.h"
  7. #include "toolchain/parser/parse_tree.h"
  8. #include "toolchain/semantics/meta_node.h"
  9. namespace Carbon::Semantics {
  10. // Represents all kinds of literals: `1`, `i32`, etc.
  11. class Literal {
  12. public:
  13. static constexpr ExpressionKind MetaNodeKind = ExpressionKind::Literal;
  14. explicit Literal(ParseTree::Node node) : node_(node) {}
  15. auto node() const -> ParseTree::Node { return node_; }
  16. private:
  17. ParseTree::Node node_;
  18. };
  19. } // namespace Carbon::Semantics
  20. #endif // CARBON_TOOLCHAIN_SEMANTICS_NODES_LITERAL_H_