[Seaside-dev] Javascript-Core-pmm.23

Philippe Marschall philippe.marschall at gmail.com
Mon Dec 15 19:30:47 UTC 2008


Hi

As a follow up to Javascript-Core-lr.22 Javascript-Core-pmm.23
replaces the SmaCC generated parser with a hand written one. The most
important difference (besides the eliminated dependency on SmaCC
runtime) is that it is a JSON and not a JavaScript parser [1] [2]. The
SmaCC generated parser accepted a lot of stuff that is valid
JavaScript but invalid JSON. The hand written parser is a bit more
relaxed in the way that it allows anything but a number to be the top
level element (the standard allows only for Arrays and Dictionaries).
Should that be a show stopper numbers could be added.

differences in detail:
- numbers can not be top level elements
- doesn't support comments (not part of standard)
- uses Array instead of OrderedCollection for arrays
- allows only double quoted string literals (according to standard)
- handles escape characters including Unicode escapes (doesn't reduce
a surrogate pair to a single character)
- treats \" as an escape for " instead of \" (according to standard)
- is about four times faster in a certainly flawed and biased micro benchmark
- tries to use descriptive error messages and throws non-SmaCC errors

 [1] http://json.org/
 [2] http://tools.ietf.org/html/rfc4627

Cheers
Philippe


More information about the seaside-dev mailing list