"where both a division and a RegularExpressionLiteral are permitted"

Eric Suen eric.suen.tech at gmail.com
Sat Nov 29 18:53:03 PST 2008


a = a
 /a/

this will cause syntax error instead of

a = a;
/a/

Regards,

Eric Suen

----- Original Message ----- 
From: "David-Sarah Hopwood" 
<david.hopwood-mRVxzIiVagSlV3Ge8JjJtnfLna9zW77MtUK59QYPAWc at public.gmane.org>
Newsgroups: gmane.comp.lang.javascript.ecmascript4.general
To: <es-discuss-4eJtQOnFJqFAfugRpC6u6w at public.gmane.org>
Sent: Sunday, November 30, 2008 9:41 AM
Subject: "where both a division and a RegularExpressionLiteral are permitted"


> Section 7 (Lexical Conventions):
>
> # Note that contexts exist in the syntactic grammar where both a division
> # and a RegularExpressionLiteral are permitted by the syntactic grammar;
> # [...]
>
> I believe this statement is incorrect [*1].
> If I'm wrong, what is an example of such a context?
>
>
> [*1] A DivisionPunctuator must be preceded by an expression.
>     A RegularExpressionLiteral is itself an expression.
>     Therefore, for there to exist syntactic contexts in which either
>     a DivisionPunctuator or a RegularExpressionLiteral could occur,
>     it would have to be possible for an expression to immediately
>     follow [*2] another expression with no intervening operator.
>     The only case in which that can occur is where a semicolon is
>     automatically inserted between the two expressions.
>     Assume that case: then the second expression cannot begin
>     with [*2] a token whose first character is '/', because that
>     would have been interpreted as a DivisionPunctuator, and so
>     no semicolon insertion would have occurred (because semicolon
>     insertion only occurs where there would otherwise have been a
>     syntax error); contradiction.
>
> [*2] Ignoring comments and whitespace.
>
> -- 
> David-Sarah Hopwood 




More information about the Es-discuss mailing list