aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/json/jsonparse.cc
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2018-06-21 18:08:28 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2018-06-21 18:08:28 +0200
commitc33a039ac388bfcb5e068a04a7cb1b05ebec7d7f (patch)
treefaa50278ae2e700246453b85afbff10c91c411cc /frontend/json/jsonparse.cc
parent8fac26c2b795865098b1ba16152cd1c510133f29 (diff)
downloadnextpnr-c33a039ac388bfcb5e068a04a7cb1b05ebec7d7f.tar.gz
nextpnr-c33a039ac388bfcb5e068a04a7cb1b05ebec7d7f.tar.bz2
nextpnr-c33a039ac388bfcb5e068a04a7cb1b05ebec7d7f.zip
Added return code to json parsing and pcf reading
Diffstat (limited to 'frontend/json/jsonparse.cc')
-rw-r--r--frontend/json/jsonparse.cc33
1 files changed, 19 insertions, 14 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