diff options
author | Clifford Wolf <clifford@clifford.at> | 2017-09-26 14:37:03 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2017-09-26 14:37:03 +0200 |
commit | 91d9c50bb30583cbaad09620a42c0d8fe2421273 (patch) | |
tree | d2b241337fd317025247b12b5eff0e731f314f08 /frontends/json | |
parent | 660473a485019ab07f0af19d3c84aff11be41d1c (diff) | |
download | yosys-91d9c50bb30583cbaad09620a42c0d8fe2421273.tar.gz yosys-91d9c50bb30583cbaad09620a42c0d8fe2421273.tar.bz2 yosys-91d9c50bb30583cbaad09620a42c0d8fe2421273.zip |
Parse reals as string in JSON front-end
Diffstat (limited to 'frontends/json')
-rw-r--r-- | frontends/json/jsonparse.cc | 28 |
1 files changed, 28 insertions, 0 deletions
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; |