David-Sarah Hopwood wrote:
I'll repeat my argument here for convenience:

  A DivisionPunctuator must be preceded by an expression.
  A RegularExpressionLiteral is itself an expression.

(This assumes that the omission of RegularExpressionLiteral from
Literal is a bug.)

  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 [*] 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 [*] 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.

Yes, I verified when we were writing ES3 that this was the only case where the 
syntactic grammar permitted a / to serve as both a division (or 
division-assignment) and a regexp literal.  The interaction of lexing and 
semicolon insertion would have been unclear (how can you say that the next 
token is invalid if you don't know how to lex it?), so we wrote the spec to 
explicitly resolve those in favor of division.

   Waldemar
_______________________________________________
Es-discuss mailing list
Es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to