JSON parser grammar

David-Sarah Hopwood david-sarah at jacaranda.org
Thu Jun 4 16:58:55 PDT 2009


David-Sarah Hopwood wrote:
> Mark S. Miller wrote:
>> 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.
> 
> This is mistaken; 010 is a syntax error (modulo section 16 extensions)
> in both strict and non-strict modes:
> 
>   DecimalIntegerLiteral ::
>     0
>     NonZeroDigit DecimalDigits_opt
>     ^^^^^^^^^^^^
> 
>   DecimalDigits ::
>     DecimalDigit
>     DecimalDigits DecimalDigit

Oh, I see, you're referring to the fact that in strict mode an
implementation is prohibited from using its section 16 wiggle room
to allow octal (by the last sentence of 7.8.3). You're still mistaken
about 010 being interpreted as decimal 10 in either mode, though,
which is the main point.

-- 
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com



More information about the es5-discuss mailing list