JSON parser grammar

Mark S. Miller erights at google.com
Thu Jun 4 09:23:24 PDT 2009


On Thu, Jun 4, 2009 at 8:07 AM, Allen Wirfs-Brock
<Allen.Wirfs-Brock at microsoft.com> wrote:

> [...] Not supporting JSON octal literals adds no complexity to
> the ES5 JSON spec. because they are simply not part of the
> format and are never mentioned. It only adds complexity to
> implementations if they are trying to reuse their JavaScript
> lexer (assuming it supports octal constants) to lex JSON text
> and there are already enough other differences between the JSON
> and ECMAScript token set that it isn't clear that this is a
> good idea.  Regardless, ES5 lexers are already required to not
> recognize octal number when operating in strict mode.

No, it does add some complexity to the spec differently from the sense
in which octal is prohibited in ES5/strict. In ES5/strict code, the
literal 010 must be interpreted at a decimal 10. In JSON.parse, 010
must be rejected. In order to mandate this, the standard JSON grammar
(as documented both in the RFC and on json.org) does not allow any
digits after a leading zero. I support this added complexity for all
the reasons discussed. But it is undeniably added complexity.

-- 
    Cheers,
    --MarkM


More information about the es-discuss mailing list