Switch executable semantics to use ErrorBuilder directly and relocate macros (#1184)

This commit is contained in:
Jon Meow
2022-04-13 09:05:21 -07:00
committed by GitHub
parent 6542506cdc
commit 87e58f5db3
37 changed files with 327 additions and 376 deletions
+5 -4
View File
@@ -6,7 +6,7 @@
#include "common/check.h"
#include "common/error.h"
#include "executable_semantics/common/error.h"
#include "executable_semantics/common/error_builders.h"
#include "executable_semantics/syntax/lexer.h"
#include "executable_semantics/syntax/parse_and_lex_context.h"
#include "executable_semantics/syntax/parser.h"
@@ -41,10 +41,11 @@ auto ParseImpl(yyscan_t scanner, Nonnull<Arena*> arena,
auto Parse(Nonnull<Arena*> arena, std::string_view input_file_name, bool trace)
-> ErrorOr<AST> {
FILE* input_file = fopen(std::string(input_file_name).c_str(), "r");
std::string name_str(input_file_name);
FILE* input_file = fopen(name_str.c_str(), "r");
if (input_file == nullptr) {
return FATAL_PROGRAM_ERROR_NO_LINE() << "Error opening '" << input_file_name
<< "': " << std::strerror(errno);
return ProgramError(SourceLocation(name_str.c_str(), 0))
<< "Error opening file: " << std::strerror(errno);
}
// Prepare the lexer.