Hello!

Here's some info about a packrat parser library by Tony Garnock-Jones:

http://www.lshift.net/blog/2005/08/22/json-for-mzscheme-and-a-portable-packrat-parsing-combinator-library

With some finangling, I got it to load in Ikarus and Ypsilon:

    http://proteus.freeshell.org/_packrat-r6rs-b

It comes with a JSON parser:

> (import (packrat json))
> (json-read (open-input-file "/tmp/test"))
#(("firstName" . "John") ("lastName" . "Smith")
  ("address"
   . #(("streetAddress" . "21 2nd Street")
       ("city" . "New York") ("state" . "NY")
       ("postalCode" . "10021")))
  ("phoneNumbers"
    #(("type" . "home") ("number" . "212 555-1234"))
    #(("type" . "fax") ("number" . "646 555-4567"))))
>

Where "/tmp/test" contains:

{
     "firstName": "John",
     "lastName": "Smith",
     "address": {
         "streetAddress": "21 2nd Street",
         "city": "New York",
         "state": "NY",
         "postalCode": "10021"
     },
     "phoneNumbers": [
         { "type": "home", "number": "212 555-1234" },
         { "type": "fax", "number": "646 555-4567" }
     ]
 }

The original implementation uses '@' as an identifier which tripped up Ikarus and Ypsilon. I changed those to 'x@'

A more careful port should be made, but I wanted to share this quick hack to encourage exploration with this particular library as it appears to be *very* low haning fruit.

It also appears to be actively developed so collaboration with Tony to get the changes upstream would be a win for everyone.

Ed

Reply via email to