Date literals

David-Sarah Hopwood david.hopwood at industrial-designers.co.uk
Wed Nov 19 15:52:25 PST 2008


Breton Slivka wrote:
> On Thu, Nov 20, 2008 at 9:40 AM, David-Sarah Hopwood
> <david.hopwood at industrial-designers.co.uk> wrote:
>> Peter Michaux wrote:
>>> All the data types in ES3 listed in section 15 have literals version
>>> (e.g. {} for Object, [] for Array etc) except for Date. Is there any
>>> reason that the Kona 15.9.1.15 "Date Time string format" could not be
>>> a literal form for date objects?
>>>
>>> YYYY-MM-DDTHH:mm:ss.sssTZ
>>>
>>> The 'T' in the middle makes this identifiable as a date literal
>>> similar to how the 'e' or 'E' of an exponential number literal works.
>> When lexing this syntax, the lexer would recognize the tokens
>>
>>  N - N - N : N : N .
>>
>> where N is a NumericLiteral, before seeing that the next 'sssTZ'
>> is invalid and then having to backtrack 10 tokens. This requires
>> something like an LL(*) parser; it is not LL(k) for any finite k
>> (because each NumericLiteral can be an arbitrary number of
>> characters), or in any similar nicely-behaved grammar category.
>> Please don't add syntax like this.
>>
> I'm a little confused. I don't suppose it makes a difference to what
> sort of parser is required, but I wouldn't have thought that the
> parser would recognize something like 12T06 as a numeric literal.
> Wouldn't the T in the middle tip the parser off a little bit earlier
> than 10 tokens?

Sorry, I missed the T in the middle. But that only changes the
details of the argument, not the substance. It should have been:

When lexing this syntax, the lexer would recognize the tokens

  N - N -

where N is a NumericLiteral, before seeing that the next 'DD' is
invalid as a NumericLiteral because it is followed immediately by
an IdentifierStart character, and then having to backtrack 4 tokens.
This requires something like an LL(*) parser; it is not LL(k) for any
finite k (because each NumericLiteral can be an arbitrary number of
characters), or in any similar nicely-behaved grammar category.
Please don't add syntax like this.

-- 
David-Sarah Hopwood


More information about the Es-discuss mailing list