From 1953cd47c6abdec2437c833cb8e26cf1e8ac1834 Mon Sep 17 00:00:00 2001 From: Simon Van Casteren Date: Mon, 9 Dec 2019 14:45:37 +0100 Subject: First actually working version of LSP --- src/json.sml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/json.sml') diff --git a/src/json.sml b/src/json.sml index fab15a6c..f189cc4d 100644 --- a/src/json.sml +++ b/src/json.sml @@ -79,7 +79,7 @@ struct and parsePair () = Callbacks.json_pair (parseString (), - (ws(); consume ":"; parseValue ())) + (ws(); consume ":"; ws(); parseValue ())) and parseArray () = if not (matches "[") then @@ -142,10 +142,9 @@ struct and parseInt () = let val f = - if peek () = #"0" then - raise JSONParseError ("Invalid number", !inputPosition) - else if peek () = #"-" then (take (); "~") - else String.str (take ()) + if peek () = #"-" + then (take (); "~") + else String.str (take ()) in f ^ parseDigits () end @@ -270,6 +269,6 @@ fun print (ast: json): string = | Bool b => if b then "true" else "false" | Int i => Int.toString i | Obj l => "{" - ^ List.foldl (fn ((k, v), acc) => k ^ ": " ^ print v ) "" l + ^ List.foldl (fn ((k, v), acc) => acc ^ (if acc = "" then "" else ", ") ^ "\"" ^ k ^ "\": " ^ print v ) "" l ^ "}" end -- cgit v1.2.3