This defines the substitution body of a quasi using the PrimaryExpression syntactic production. Determining where a substitution ends requires, in the general case, the ability to parse an EcmaScript expression. See a lexer demo that demonstrates how to lex JavaScript when quasiliterals can nest.
| Production | Result |
|---|---|
QuasiLiteral :: QuasiTag`LiteralPortion QuasiLiteralTail | SVE(QuasiLiteralTail) |
| QuasiLiteralTail :: Substitution LiteralPortion QuasiLiteralTail | array-concat(single-element-array(SVE(Substitution)), SVE(QuasiLiteralTail)) |
QuasiLiteralTail :: ` | an empty array |
Substitution :: $Identifier | PrimaryExpression : Identifier |
Substitution :: ${SubstitutionModifier SubstitutionBody} | SVE(SubstitutionBody) |
| SubstitutionBody :: PrimaryExpression | PrimaryExpression |
The SVE is an expression that evaluates the specified expression in the scope in which the quasi appears. The SVE of the quasi literal is the array of the SVE for each substitution body.