ast.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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_AST_H_
  5. #define EXECUTABLE_SEMANTICS_AST_AST_H_
  6. #include <vector>
  7. #include "executable_semantics/ast/declaration.h"
  8. #include "executable_semantics/ast/library_name.h"
  9. #include "executable_semantics/ast/static_scope.h"
  10. #include "executable_semantics/common/nonnull.h"
  11. namespace Carbon {
  12. // A Carbon file's AST.
  13. struct AST {
  14. // The package directive's library.
  15. LibraryName package;
  16. // The package directive's API or impl state.
  17. bool is_api;
  18. // Import directives.
  19. std::vector<LibraryName> imports;
  20. // The file's ordered declarations.
  21. std::vector<Nonnull<Declaration*>> declarations;
  22. // Names declared at the top level of the file.
  23. StaticScope static_scope;
  24. // Synthesized call to `Main`. Injected after parsing.
  25. std::optional<Nonnull<CallExpression*>> main_call;
  26. };
  27. } // namespace Carbon
  28. #endif // EXECUTABLE_SEMANTICS_AST_AST_H_