Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: src/preparser.h

Issue 1315673009: Sloppy-mode let parsing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: clarify comment Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.cc ('k') | src/preparser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index 07e431bfc54790b0a65c081f9ea8021ab6fba84c..f60ada27fe2da79a94196ae9f3b2fbf4ce303ed2 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -338,6 +338,11 @@ class ParserBase : public Traits {
return scanner()->peek();
}
+ INLINE(Token::Value PeekAhead()) {
+ if (stack_overflow_) return Token::ILLEGAL;
+ return scanner()->PeekAhead();
+ }
+
INLINE(Token::Value Next()) {
if (stack_overflow_) return Token::ILLEGAL;
{
@@ -710,6 +715,8 @@ class ParserBase : public Traits {
int param_count, FunctionLiteral::ArityRestriction arity_restriction,
bool has_rest, int formals_start_pos, int formals_end_pos, bool* ok);
+ bool IsNextLetKeyword();
+
// Checks if the expression is a valid reference expression (e.g., on the
// left-hand side of assignments). Although ruled out by ECMA as early errors,
// we allow calls for web compatibility and rewrite them to a runtime throw.
@@ -3776,6 +3783,27 @@ void ParserBase<Traits>::CheckArityRestrictions(
template <class Traits>
+bool ParserBase<Traits>::IsNextLetKeyword() {
+ DCHECK(peek() == Token::LET);
+ if (!allow_let()) {
+ return false;
+ }
+ Token::Value next_next = PeekAhead();
+ switch (next_next) {
+ case Token::LBRACE:
+ case Token::LBRACK:
+ case Token::IDENTIFIER:
+ case Token::STATIC:
+ case Token::LET: // Yes, you can do let let = ... in sloppy mode
+ case Token::YIELD:
+ return true;
+ default:
+ return false;
+ }
+}
+
+
+template <class Traits>
typename ParserBase<Traits>::ExpressionT
ParserBase<Traits>::ParseArrowFunctionLiteral(
const FormalParametersT& formal_parameters,
« no previous file with comments | « src/parser.cc ('k') | src/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698