// 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 #include "executable_semantics/syntax/prelude.h" #include "executable_semantics/syntax/parse.h" namespace Carbon { // Adds the Carbon prelude to `declarations`. void AddPrelude(std::string_view prelude_file_name, Nonnull arena, std::vector>* declarations) { ErrorOr parse_result = Parse(arena, prelude_file_name, false); if (!parse_result.ok()) { // Try again with tracing, to help diagnose the problem. ErrorOr trace_parse_result = Parse(arena, prelude_file_name, true); FATAL() << "Failed to parse prelude: " << trace_parse_result.error().message(); } const auto& prelude = *parse_result; declarations->insert(declarations->begin(), prelude.declarations.begin(), prelude.declarations.end()); } } // namespace Carbon