From: Eric Mahurin Date: 2008-02-04T09:32:55+09:00 Subject: Re: [QUIZ] Parsing JSON (#155) ------=_Part_3844_27695819.1202085181693 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Feb 3, 2008 6:25 PM, Clifford Heath wrote: > Eric Mahurin wrote: > > I tried this parser, but couldn't get it to work with the String > interface > > of the quize testbench. Using an IO/stream is how a parser should work, > > Not a packrat parser. If you have memory to memoize each grammar rule > attempted at each byte-offset of the input, you have memory to have all > the input in memory at once, and it's more efficient to do so. > > Obviously a simple adapter can fix that, but steve's doesn't, and > neither does mine (emailed to JEG before the 24 hours - I'll post > it soon). The adapter is needed because the parse() method expected > is different from the one that Treetop's parsers provide. > I was expecting this to work as a proxy to the Treetop parser: class JSONParser def initialize @parser = JsonParser.new end def parse(s) @parser.parse(StringIO.new(s)).value end end ------=_Part_3844_27695819.1202085181693--