expression_or_field_list.h 995 B

1234567891011121314151617181920212223242526272829303132
  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 EXECUTABLE_SEMANTICS_AST_EXPRESSION_OR_FIELD_LIST_H_
  5. #define EXECUTABLE_SEMANTICS_AST_EXPRESSION_OR_FIELD_LIST_H_
  6. #include <list>
  7. #include "executable_semantics/ast/expression.h"
  8. namespace Carbon {
  9. enum class ExpOrFieldListKind { Exp, FieldList };
  10. // This is used in the parsing of tuples and parenthesized expressions.
  11. struct ExpOrFieldList {
  12. ExpOrFieldListKind tag;
  13. union {
  14. Expression* exp;
  15. std::list<std::pair<std::string, Expression*>>* fields;
  16. } u;
  17. };
  18. auto MakeExp(Expression* exp) -> ExpOrFieldList*;
  19. auto MakeFieldList(std::list<std::pair<std::string, Expression*>>* fields)
  20. -> ExpOrFieldList*;
  21. auto MakeConsField(ExpOrFieldList* e1, ExpOrFieldList* e2) -> ExpOrFieldList*;
  22. } // namespace Carbon
  23. #endif // EXECUTABLE_SEMANTICS_AST_EXPRESSION_OR_FIELD_LIST_H_