summaryrefslogtreecommitdiff
path: root/src/json.sml
diff options
context:
space:
mode:
authorGravatar Simon Van Casteren <simon.van.casteren@gmail.com>2019-12-09 14:45:37 +0100
committerGravatar Simon Van Casteren <simonvancasteren@localhost.localdomain>2019-12-13 11:46:57 +0100
commit1953cd47c6abdec2437c833cb8e26cf1e8ac1834 (patch)
treeadc917187b8affce069c7c208723944d4f8b23da /src/json.sml
parent26e16f90067ee294d1ccd6341547dbae585cdb3e (diff)
First actually working version of LSP
Diffstat (limited to 'src/json.sml')
-rw-r--r--src/json.sml11
1 files changed, 5 insertions, 6 deletions
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