Skip to content

Instantly share code, notes, and snippets.

@Idorobots
Created August 17, 2012 15:07
Show Gist options
  • Save Idorobots/3379669 to your computer and use it in GitHub Desktop.
Save Idorobots/3379669 to your computer and use it in GitHub Desktop.
JSON part two
(grammar ((JValue < (/ String Number JObject JArray JTrue JFalse JNull)))
((JObject < (: "\\{") (? JPair (* (:",") JPair)) (:"\\}"))
`($(car JObject)
($(cons 'scope (cadr JObject)))))
((JPair < String (: ":") JValue)
`($(car JPair)
((var $(str->symbol (caadr JPair)) $(cadadr JPair)))))
((JArray < (:"\\[") (? JValue (* (:",") JValue)) (:"\\]"))
`($(car JArray)
($(vectorof (cadr JArray)))))
((JTrue <- (: "true"))
`($(car JTrue)
('t)))
((JFalse <- (: "false")))
((JNull <- (: "null"))))
(syntax (Expression < (/ Quote JObject String List Atom)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment