parse.h 1.1 KB

123456789101112131415161718192021222324252627282930
  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_SYNTAX_PARSE_H_
  5. #define EXECUTABLE_SEMANTICS_SYNTAX_PARSE_H_
  6. #include <string>
  7. #include <variant>
  8. #include "executable_semantics/ast/ast.h"
  9. #include "executable_semantics/common/arena.h"
  10. namespace Carbon {
  11. // Returns the AST representing the contents of the named file, or an error code
  12. // if parsing fails. Allocations go into the provided arena.
  13. auto Parse(Nonnull<Arena*> arena, std::string_view input_file_name,
  14. bool parser_debug) -> ErrorOr<Carbon::AST>;
  15. // Equivalent to `Parse`, but parses the contents of `file_contents`.
  16. // `input_file_name` is used only for reporting source locations, and does
  17. // not need to name a real file.
  18. auto ParseFromString(Nonnull<Arena*> arena, std::string_view input_file_name,
  19. std::string_view file_contents, bool parser_debug)
  20. -> ErrorOr<Carbon::AST>;
  21. } // namespace Carbon
  22. #endif // EXECUTABLE_SEMANTICS_SYNTAX_PARSE_H_