New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial: instead of the [Tagged] parameter #966

Open
jmdyck opened this Issue Aug 3, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@jmdyck
Collaborator

jmdyck commented Aug 3, 2017

The [Tagged] grammatical parameter doesn't actually alter the grammar -- there are no right-hand-sides preceded by [+Tagged] or [~Tagged]. Its purpose appears to be: for a given TemplateLiteral, capture whether it belongs to a tagged template, and then convey that fact to the TemplateLiteral's literal components, so that they know whether or not to raise a Syntax Error on NotEscapeSequence.

But if that's the case, then we don't need to use a grammatical parameter, we could just say things like:

TemplateMiddle :: `}` TemplateCharacters? `${`
    It is a Syntax Error if |TemplateCharacters| Contains |NotEscapeSequence| and
    the |TemplateLiteral| that most closely contains |TemplateMiddle| is a |PrimaryExpression|.

Note that we use similar 'context-examining' formulations in the early error rules for 'break' and 'continue', for uninitialized constant-decls, and (kind of) whenever an EE rule says "if [something] is contained in strict mode code".

(You could do it in a single early error rule:

TemplateCharacter :: `\` NotEscapeSequence
    It is a Syntax Error if the |TemplateLiteral| that most closely contains
    this |TemplateCharacter| is a |PrimaryExpression|

but that makes an assumption about the syntactic/lexical boundary that we may not want to make.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment