Directive prologue members, escapes, and retroactive syntax errors

Brendan Eich brendan at mozilla.org
Sat Oct 16 08:49:34 PDT 2010


On Oct 16, 2010, at 2:33 AM, Peter van der Zee wrote:

> Brendan: well for my own parser the lookhead is kind of "free" (or inherent
> because it always does an exhaustive tree search). In the production I gave
> earlier, the lookahead cost would be at most one StringLiteral, since as soon as
> the next character after that string is not a semi-colon or newline, you know
> you're no longer parsing a directive.

Yes, that's fine -- parsing directives is not the issue. The question is when do you detect an octal escape in an already-lexed directive and, because of a later "use strict"; call it an error? Do you have to re-scan for octal escapes, or remember whether you scanned any in a preceding directive?

/be


More information about the es5-discuss mailing list