aboutsummaryrefslogtreecommitdiffstats
path: root/frontends/json
diff options
context:
space:
mode:
authorKarol Gugala <kgugala@antmicro.com>2021-01-27 20:34:00 +0100
committerMarcelina Koƛcielnicka <mwk@0x04.net>2021-02-23 00:26:11 +0100
commitcc7d18d29a5314c6350b7378bc788f48f3925337 (patch)
tree9f63c31e50197bef1ae8ac6c90c7475dd7542f9e /frontends/json
parent4746ffd7b2f5de0bc1f29f35e9044091a3c704e0 (diff)
downloadyosys-cc7d18d29a5314c6350b7378bc788f48f3925337.tar.gz
yosys-cc7d18d29a5314c6350b7378bc788f48f3925337.tar.bz2
yosys-cc7d18d29a5314c6350b7378bc788f48f3925337.zip
frontend: json: parse negative values
Signed-off-by: Karol Gugala <kgugala@antmicro.com>
Diffstat (limited to 'frontends/json')
-rw-r--r--frontends/json/jsonparse.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/frontends/json/jsonparse.cc b/frontends/json/jsonparse.cc
index 1b34aaf3a..312f6d3be 100644
--- a/frontends/json/jsonparse.cc
+++ b/frontends/json/jsonparse.cc
@@ -72,10 +72,17 @@ struct JsonNode
break;
}
- if ('0' <= ch && ch <= '9')
+ if (('0' <= ch && ch <= '9') || ch == '-')
{
+ bool negative = false;
type = 'N';
- data_number = ch - '0';
+ if (ch == '-') {
+ data_number = 0;
+ negative = true;
+ } else {
+ data_number = ch - '0';
+ }
+
data_string += ch;
while (1)
@@ -97,6 +104,7 @@ struct JsonNode
data_string += ch;
}
+ data_number = negative ? -data_number : data_number;
data_string = "";
break;