Files
carbon-lang/explorer/syntax/parse.h
T
Richard SmithandJon Ross-Perkins ea60e4f491 Track the file kind on SourceLocation rather than computing it from the file name. (#2999)
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>
2023-07-19 23:07:53 +00:00

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_