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

Unified Diff: src/preparser.h

Issue 1295883002: Sloppy-mode let parsing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Replace array with direct ivars 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 18fc2330eedd7f646683035bba73e311d6f8d12a..41e8dde6ffcfe1dd986348bf799076b6a775e314 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.
@@ -3746,6 +3753,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