3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-15 13:28:59 +00:00

frontend: json: parse negative values

Signed-off-by: Karol Gugala <kgugala@antmicro.com>
This commit is contained in:
Karol Gugala 2021-01-27 20:34:00 +01:00 committed by Marcelina Kościelnicka
parent 4746ffd7b2
commit cc7d18d29a

View file

@ -72,10 +72,17 @@ struct JsonNode
break; break;
} }
if ('0' <= ch && ch <= '9') if (('0' <= ch && ch <= '9') || ch == '-')
{ {
bool negative = false;
type = 'N'; type = 'N';
data_number = ch - '0'; if (ch == '-') {
data_number = 0;
negative = true;
} else {
data_number = ch - '0';
}
data_string += ch; data_string += ch;
while (1) while (1)
@ -97,6 +104,7 @@ struct JsonNode
data_string += ch; data_string += ch;
} }
data_number = negative ? -data_number : data_number;
data_string = ""; data_string = "";
break; break;