summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-07-22 08:07:19 -0700
committerKaz Kylheku <kaz@kylheku.com>2024-07-22 08:07:19 -0700
commite5a6c31be5da033320f6414fab0b31ef88f3260c (patch)
treea2f55843aab915431f18ee0946b0eae84a9dbfcd /tests
parent74d7277b99dfe15797464f41adc5204c728eca6b (diff)
downloadtxr-e5a6c31be5da033320f6414fab0b31ef88f3260c.tar.gz
txr-e5a6c31be5da033320f6414fab0b31ef88f3260c.tar.bz2
txr-e5a6c31be5da033320f6414fab0b31ef88f3260c.zip
json: new *read-json-int* variable.
* parser.h (struct parser): New member, read_json_int. * parser.c (read_json_int_s): New symbol variable for *read-json-int* symbol. (parser_common_init): Look up value of *read-json-int* and store in read_json_int struct member. (parse_init): Initialize read_json_int_s with interned symbol and also register the dynamic variable. * parser.l (grammar): Extend the {JNUM} rule to check the read_json_int flag and produce an integer value if the lexeme does not contain a decimal point, e or E. * tests/010/json.tl: New tests. * txr.1: Documented. * lex.yy.c.shipped: Regenerated.
Diffstat (limited to 'tests')
-rw-r--r--tests/010/json.tl15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/010/json.tl b/tests/010/json.tl
index d419295f..b7117d8a 100644
--- a/tests/010/json.tl
+++ b/tests/010/json.tl
@@ -192,3 +192,18 @@
(test
(get-json "[1, 2, ; foo\n 3]") #(1.0 2.0 3.0))
+
+(let ((*read-json-int* t))
+ (mtest
+ (get-json "1") 1
+ (get-json "-1") -1
+ (get-json "0") 0
+ (get-json "12345") 12345
+ (get-json "12345678900000000000000000") 12345678900000000000000000))
+
+(mtest
+ (get-json "1") 1.0
+ (get-json "-1") -1.0
+ (get-json "0") 0.0
+ (get-json "12345") 12345.0
+ (get-json "12345678900000000000000000") 1.23456789E25)