From: panasenco Date: Wed, 21 Apr 2021 02:59:01 +0000 (-0700) Subject: Now preserving distinction between ints and floats X-Git-Tag: v0.9.0~99^2~1 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=d3caba4073f451bf67ac43534abdf40839b6d107;p=scryer-prolog.git Now preserving distinction between ints and floats --- diff --git a/src/lib/json.pl b/src/lib/json.pl index 218152e2..7b833817 100644 --- a/src/lib/json.pl +++ b/src/lib/json.pl @@ -226,7 +226,11 @@ json_number(Number) --> json_integer(Integer), json_fraction(Fraction), json_exponent(Exponent), - { Number is Sign * (Integer + Fraction) * 10.0 ^ Exponent }. + { ( Exponent >= 0 -> + Base = 10 + ; Base = 10.0 + ), + Number is Sign * (Integer + Fraction) * Base ^ Exponent }. json_integer(Digit) --> json_digit(Digit). json_integer(TotalValue) --> diff --git a/src/tests/json/pass_everything.min.json b/src/tests/json/pass_everything.min.json index 85cf7acb..35137af4 100644 --- a/src/tests/json/pass_everything.min.json +++ b/src/tests/json/pass_everything.min.json @@ -1 +1 @@ -["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},{},[],-42.0,true,false,null,{"":23456789011999997000000000000000000000000000000000000000000000000000000000000.0," s p a c e d ":[1.0,2.0,3.0,4.0,5.0,6.0,7.0],"# -- --> *\/":" ","\/\\\"쫾몾ꮘﳞ볚\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","E":12345678900000000000000000000000000.0,"address":"50 St. James Street","alpha":"abcdefghijklmnopqrstuvwyz","array":[],"backslash":"\\","comment":"\/\/ \/* *\/":" ","\/\\\"쫾몾ꮘﳞ볚\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","E":12345678900000000000000000000000000.0,"address":"50 St. James Street","alpha":"abcdefghijklmnopqrstuvwyz","array":[],"backslash":"\\","comment":"\/\/ \/*