Thanks for the look --- I will add some comments to explain things a bit,
but I
hope the replies help make sense of it a bit!
https://codereview.chromium.org/663683006/diff/220001/src/preparser.h
File src/preparser.h (right):
https://codereview.chromium.org/663683006/diff/220001/src/preparser.h#newcode2506
src/preparser.h:2506: result->AsFunctionLiteral()->set_parenthesized();
On 2014/11/10 15:32:02, marja wrote:
Why?
It's basically copy/pasted from the MemberExpression -> CallExpression
path --- so, presumably if we have an IIFE we need to do this, but I'm
not sure what difference it makes.
https://codereview.chromium.org/663683006/diff/220001/src/preparser.h#newcode2870
src/preparser.h:2870: ExpressionT expression =
this->ParseExpression(false, CHECK_OK);
On 2014/11/10 15:32:02, marja wrote:
Why expression? Are we now inside the ${... or... what? No, not
necessarily?
*Confused*
Yeah, if we get a TEMPLATE_SPAN token, then we just finished parsing
`${`, and are ready to parse an expression. I'll add a comment about
this.
Do you think we could combine TEMPLATE_SPAN and TEMPLATE_TAIL into a
single token somehow? I'm not sure how that would work properly
https://codereview.chromium.org/663683006/diff/220001/src/scanner.cc
File src/scanner.cc (right):
https://codereview.chromium.org/663683006/diff/220001/src/scanner.cc#newcode797
src/scanner.cc:797: Token::Value Scanner::ScanTemplateSpan() {
On 2014/11/10 15:32:02, marja wrote:
Hmm, I don't fully understand this function.
Pls add comments:
1) about how literal_chars_ and raw_literal_chars_ are used and why (I
was
briefly confused when I read that part at first...)
2) about which part exactly this function scans; what's the returned
token and
what's in the literal buffer...
I'm also confused because the terminology doesn't seem to match the
spec
draft... what's "TEMPLATE_SPAN"? (The spec has stuff like template
head,
template middle, template tail..)
literal_chars_ are being used as the TV or cooked value of the template
(escaped characters -> unescaped form, basically), raw_literal_chars_
are being used as the TRV or raw value of the template (escaped
characters as they appear in the source, basically).
arv@ has suggested that we do this without keeping a separate string for
the raw values, but I don't know how it will actually work in all cases,
since raw values need to normalize line endings anyways.
Ideas on that are welcome.
So the spec has concept of template head -> template middle -> template
end -> etc, but in practice I think there are only 2 cases that matter:
the case where you have a literal span followed by an expression, and
the case where you have just a literal span.
TEMPLATE_SPAN -> always followed by an expression (ends with ${), while
TEMPLATE_TAIL -> always followed by ` or the end of the template literal
(if not, then it's a bad token).
Basically, all of the NoSubstTemplate productions become TEMPLATE_TAIL,
and all of the other template productions become TEMPLATE_SPAN, I think
it's simpler this way
https://codereview.chromium.org/663683006/diff/220001/test/mjsunit/es6/templates.js
File test/mjsunit/es6/templates.js (right):
https://codereview.chromium.org/663683006/diff/220001/test/mjsunit/es6/templates.js#newcode170
test/mjsunit/es6/templates.js:170: (function(s) {
assertEquals("\u005C\u0030", s.raw[0]); })`\0`;
On 2014/11/10 15:32:02, marja wrote:
I was confused about why you write \u005C here, at this point it's
inside a
normal string so it should be the same as \\...
I guess this is why:
"The TRV of TemplateCharacter :: \ EscapeSequence is the sequence
consisting of
the code unit value 0x005C followed by the code units of TRV of
EscapeSequence."
Yeah --- plus I found it a bit harder to read with
single-escape-characters. I'll change it if people prefer that though =)
https://codereview.chromium.org/663683006/
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.