aboutsummaryrefslogtreecommitdiffstats
path: root/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'frontend')
-rw-r--r--frontend/json/jsonparse.cc33
-rw-r--r--frontend/json/jsonparse.h2
2 files changed, 20 insertions, 15 deletions
diff --git a/frontend/json/jsonparse.cc b/frontend/json/jsonparse.cc
index 7d9e9dcf..a832e9e5 100644
--- a/frontend/json/jsonparse.cc
+++ b/frontend/json/jsonparse.cc
@@ -797,27 +797,32 @@ void json_import(Context *ctx, string modname, JsonNode *node)
}
}; // End Namespace JsonParser
-void parse_json_file(std::istream &f, std::string &filename, Context *ctx)
+bool parse_json_file(std::istream &f, std::string &filename, Context *ctx)
{
- using namespace JsonParser;
+ try {
+ using namespace JsonParser;
- JsonNode root(f);
+ JsonNode root(f);
- if (root.type != 'D')
- log_error("JSON root node is not a dictionary.\n");
+ if (root.type != 'D')
+ log_error("JSON root node is not a dictionary.\n");
- if (root.data_dict.count("modules") != 0) {
- JsonNode *modules = root.data_dict.at("modules");
+ if (root.data_dict.count("modules") != 0) {
+ JsonNode *modules = root.data_dict.at("modules");
- if (modules->type != 'D')
- log_error("JSON modules node is not a dictionary.\n");
+ if (modules->type != 'D')
+ log_error("JSON modules node is not a dictionary.\n");
- for (auto &it : modules->data_dict)
- json_import(ctx, it.first, it.second);
- }
+ for (auto &it : modules->data_dict)
+ json_import(ctx, it.first, it.second);
+ }
- log_info("Checksum: 0x%08x\n", ctx->checksum());
- log_break();
+ log_info("Checksum: 0x%08x\n", ctx->checksum());
+ log_break();
+ return true;
+ } catch (log_execution_error_exception) {
+ return false;
+ }
}
NEXTPNR_NAMESPACE_END
diff --git a/frontend/json/jsonparse.h b/frontend/json/jsonparse.h
index 351b6558..fe71444f 100644
--- a/frontend/json/jsonparse.h
+++ b/frontend/json/jsonparse.h
@@ -26,7 +26,7 @@
NEXTPNR_NAMESPACE_BEGIN
-extern void parse_json_file(std::istream &, std::string &, Context *);
+extern bool parse_json_file(std::istream &, std::string &, Context *);
NEXTPNR_NAMESPACE_END