diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-06-21 19:31:50 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2018-06-21 19:31:50 +0200 |
commit | bfae4663fcb6028e8c20f28d5ffa15fd20d8e1fa (patch) | |
tree | b5dd0075a7a75ef9c24e0f758b80b5da5ee18b3f /frontend/json | |
parent | 38dc1cc5504961f666da32d7249532a23d5876ad (diff) | |
parent | c33a039ac388bfcb5e068a04a7cb1b05ebec7d7f (diff) | |
download | nextpnr-bfae4663fcb6028e8c20f28d5ffa15fd20d8e1fa.tar.gz nextpnr-bfae4663fcb6028e8c20f28d5ffa15fd20d8e1fa.tar.bz2 nextpnr-bfae4663fcb6028e8c20f28d5ffa15fd20d8e1fa.zip |
Merge branch 'master' of gitlab.com:SymbioticEDA/nextpnr
# Conflicts:
# common/route.cc
Diffstat (limited to 'frontend/json')
-rw-r--r-- | frontend/json/jsonparse.cc | 33 | ||||
-rw-r--r-- | frontend/json/jsonparse.h | 2 |
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 |