estree / estree

The ESTree Spec
Other
5.12k stars 358 forks source link

[ES6] TemplateLiteral #34

Closed ikarienator closed 9 years ago

ikarienator commented 9 years ago

SPEC:

https://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components https://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literals

We need to represent both "tagged" or "untagged" template literals.

For example:

raw`x${y}z`

should have:

  1. raw as an expression
  2. x as a template literal element
  3. y as an expression
  4. z as a template literal element

    SpiderMonkey Parser API:

Not implemented

Esprima-harmony:

interface TemplateElement <: Node {
  type = "TemplateElement",
  value: {
    raw: string,
    cooked: string
  },
  tail: boolean
}

interface TemplateLiteral <: Expression {
   type = "TemplateLiteral",
   expressions: [Expression],
   quasis: [TemplateElement]
}

interface TaggedTemplateExpression <: Expression {
  type = "TaggedTemplateExpression",
  tag: Expression,
  quasi: TemplateLiteral
}

Acorn:

Same as Esprima-harmony

Shift-API:

Kinda bad naming...

interface TemplateString : Expression {
  attribute Expression? tag;
  attribute (Expression or TemplateLiteral)[] elements;
};

interface TemplateLiteral : Node {
  attribute string value;
}
sebmck commented 9 years ago

I take it you missed #25?

ikarienator commented 9 years ago

I did...