From: Clifford Wolf Date: Tue, 26 Sep 2017 12:37:03 +0000 (+0200) Subject: Parse reals as string in JSON front-end X-Git-Tag: yosys-0.8~314 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=91d9c50bb30583cbaad09620a42c0d8fe2421273;p=yosys.git Parse reals as string in JSON front-end --- diff --git a/frontends/json/jsonparse.cc b/frontends/json/jsonparse.cc index d34a27944..629578c61 100644 --- a/frontends/json/jsonparse.cc +++ b/frontends/json/jsonparse.cc @@ -76,6 +76,7 @@ struct JsonNode { type = 'N'; data_number = ch - '0'; + data_string += ch; while (1) { @@ -84,12 +85,39 @@ struct JsonNode if (ch == EOF) break; + if (ch == '.') + goto parse_real; + if (ch < '0' || '9' < ch) { f.unget(); break; } data_number = data_number*10 + (ch - '0'); + data_string += ch; + } + + data_string = ""; + break; + + parse_real: + type = 'S'; + data_number = 0; + data_string += ch; + + while (1) + { + ch = f.get(); + + if (ch == EOF) + break; + + if (ch < '0' || '9' < ch) { + f.unget(); + break; + } + + data_string += ch; } break;