Pass the flag instead of using a global. (#893)

Arguably missed in #769 

Note, this is reminding me we have more class members to rename for `_`, but I felt it's best to use the new naming instead of adding more to clean up.
This commit is contained in:
Jon Meow
2021-10-19 09:16:57 -07:00
committed by GitHub
parent a3eac75a5b
commit a9eed3dbf1
17 changed files with 43 additions and 79 deletions
+4 -5
View File
@@ -6,15 +6,14 @@
#include "common/check.h"
#include "executable_semantics/common/error.h"
#include "executable_semantics/common/tracing_flag.h"
#include "executable_semantics/syntax/lexer.h"
#include "executable_semantics/syntax/parse_and_lex_context.h"
#include "executable_semantics/syntax/parser.h"
namespace Carbon {
auto Parse(Nonnull<Arena*> arena, const std::string& input_file_name)
-> std::variant<AST, SyntaxErrorCode> {
auto Parse(Nonnull<Arena*> arena, const std::string& input_file_name,
bool trace) -> std::variant<AST, SyntaxErrorCode> {
FILE* input_file = fopen(input_file_name.c_str(), "r");
if (input_file == nullptr) {
FATAL_PROGRAM_ERROR_NO_LINE() << "Error opening '" << input_file_name
@@ -28,11 +27,11 @@ auto Parse(Nonnull<Arena*> arena, const std::string& input_file_name)
// Prepare other parser arguments.
std::optional<AST> ast = std::nullopt;
ParseAndLexContext context(arena->New<std::string>(input_file_name));
ParseAndLexContext context(arena->New<std::string>(input_file_name), trace);
// Do the parse.
auto parser = Parser(arena, scanner, context, &ast);
if (tracing_output) {
if (trace) {
parser.set_debug_level(1);
}
auto syntax_error_code = parser();