mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-29 15:05:04 +01:00
This will be more correct if a user file is named prelude.carbon, and reduces the explorer runtime by about 10% by removing a string comparison from the check for whether trace output is enabled. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
32 lines
1.2 KiB
C++
32 lines
1.2 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#ifndef CARBON_EXPLORER_SYNTAX_PARSE_H_
|
|
#define CARBON_EXPLORER_SYNTAX_PARSE_H_
|
|
|
|
#include <string>
|
|
#include <variant>
|
|
|
|
#include "explorer/ast/ast.h"
|
|
#include "explorer/common/arena.h"
|
|
#include "explorer/common/source_location.h"
|
|
|
|
namespace Carbon {
|
|
|
|
// Returns the AST representing the contents of the named file, or an error code
|
|
// if parsing fails. Allocations go into the provided arena.
|
|
auto Parse(Nonnull<Arena*> arena, std::string_view input_file_name,
|
|
FileKind file_kind, bool parser_debug) -> ErrorOr<Carbon::AST>;
|
|
|
|
// Equivalent to `Parse`, but parses the contents of `file_contents`.
|
|
// `input_file_name` is used only for reporting source locations, and does
|
|
// not need to name a real file.
|
|
auto ParseFromString(Nonnull<Arena*> arena, std::string_view input_file_name,
|
|
FileKind file_kind, std::string_view file_contents,
|
|
bool parser_debug) -> ErrorOr<Carbon::AST>;
|
|
|
|
} // namespace Carbon
|
|
|
|
#endif // CARBON_EXPLORER_SYNTAX_PARSE_H_
|