
Kirit Sælensminde wrote:
I did not make mine to be a 'real' library though, as stated, just an example code, but I did try to make it as accurate to the spec as I saw.
As soon as karma is finished for Spirit2x I was planning to make a writer for my Value object as well, both as a condensed (efficient) printer and a pretty printer.
I have a pretty printer, which I'm not unhappy with, but also think it would be better in some ways to be able to separate out better the pretty printing strategy from the structure walking.
As for comments, in my version it would be simple to change, the whitespace skipping parser could easily be extended to catch other things, such as comments, which would always be saved out. As stated, was just making it as an example of the magic of Spirit2x.
I'm not sure that I can see where the comments would be stored in my structure so that it made any sense. To have the parser skip them as whitespace is certainly doable. For that I guess the JavaScript grammar is the place to look for a specification.
I suggest porting the parser to Spirit2. It is so much faster and flexible. Attribute handling of recursive types is built-in. Your grammars will be a lot better and simpler. I'll be accepting a set of (peer reviewed) reusable grammars as part of Spirit2 distrib. I'd be interested in having a JSON grammar. OvermindDL1's grammar is a good candidate. It would be super if you both can iron out the details. Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net