Exactly where is a RegularExpressionLiteral allowed?

Allen Wirfs-Brock Allen.Wirfs-Brock at microsoft.com
Mon Mar 23 12:38:28 PDT 2009

=/ was my typo, it's not in the specification.

But see below:

>From: Brendan Eich [mailto:brendan at mozilla.com] 
>Sent: Monday, March 23, 2009 11:57 AM
>If you make the /= correction, there is no ambiguity. 7.1 last paragraph:
>Note that contexts exist in the syntactic grammar where both a division and a RegularExpressionLiteral are permitted by the syntactic grammar; however, since the lexical grammar uses the InputElementDiv goal symbol in such cases, the opening slash is not recognised as starting a regular expression literal in such a context. As a workaround, one may enclose the regular expression literal in parentheses.

It's actually in 7 not 7.1.  However the problem is that RegularExpressionLiteral doesn't even occur in the syntactic grammar so strictly speaking there are no such specified contexts. 

>>This isn't a new ES3.1 problem.  Nothing has changed from the ES3 specification in this regard.  Am I missing something obvious?  Obviously this can't be unambiguously specified in the grammar but it sure seems like there should be some sort of comprehensible specification of exactly when RegularExpressionLiteral is allowed.

>I think that's 7.1.

I don't think so, although perhaps the fix is as easy as adding RegularExpressionLiteral as an alternative RHS for PrimaryExpression.

As it stands right now, I still content that the specification does actually say how a RegularExpressionLiteral can be used in an expression. I think this is only discoverable by examining existing implementations.


More information about the Es-discuss mailing list