Skip to content
Snippets Groups Projects
Verified Commit 894f5cda authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Macro-processor: more robust handling of empty files

The support for empty files at the macro-processor level, as implemented in
12913200, was relying on
basic_streambuf::in_avail(), which does not seem to behave consistently across
platforms, and which may not be the right tool for the job.

Rather use the Bison grammar to support empty files.

Closes: #93
parent 285a4389
Branches
Tags
No related merge requests found
/*
* Copyright © 2019-2020 Dynare Team
* Copyright © 2019-2022 Dynare Team
*
* This file is part of Dynare.
*
......@@ -40,10 +40,6 @@ Driver::parse(const string &file_arg, const string &basename_arg, const istream
m.parse("command_line_defines", "command_line_defines", is, debug, {}, env, paths, output);
}
// Handle empty files
if (modfile.rdbuf()->in_avail() == 0)
return;
stringstream file_with_endl;
file_with_endl << modfile.rdbuf() << endl;
......
// -*- C++ -*-
/*
* Copyright © 2019-2021 Dynare Team
* Copyright © 2019-2022 Dynare Team
*
* This file is part of Dynare.
*
......@@ -105,7 +105,11 @@ using namespace macro;
%%
%start statements;
%start statements_or_empty_file;
statements_or_empty_file : %empty
| statements
;
statements : statement
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment