"where both a division and a RegularExpressionLiteral are permitted"
david.hopwood at industrial-designers.co.uk
Sat Nov 29 17:41:05 PST 2008
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.
More information about the Es-discuss