Changeset 186379 in webkit for trunk/Source/JavaScriptCore/parser/Parser.cpp
- Timestamp:
- Jul 6, 2015, 3:18:58 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/parser/Parser.cpp
r186279 r186379 370 370 #endif 371 371 372 while (TreeStatement statement = parseStatement (context, directive, &directiveLiteralLength)) {372 while (TreeStatement statement = parseStatementListItem(context, directive, &directiveLiteralLength)) { 373 373 if (mode == CheckForStrictMode && !seenNonDirective) { 374 374 if (directive) { … … 402 402 propagateError(); 403 403 return sourceElements; 404 } 405 template <typename LexerType> 406 template <class TreeBuilder> TreeStatement Parser<LexerType>::parseStatementListItem(TreeBuilder& context, const Identifier*& directive, unsigned* directiveLiteralLength) 407 { 408 // The grammar is documented here: 409 // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-statements 410 TreeStatement result = 0; 411 switch (m_token.m_type) { 412 case CONSTTOKEN: 413 result = parseConstDeclaration(context); 414 break; 415 #if ENABLE(ES6_CLASS_SYNTAX) 416 case CLASSTOKEN: 417 result = parseClassDeclaration(context); 418 break; 419 #endif 420 default: 421 // FIXME: This needs to consider 'let' in bug: 422 // https://bugs.webkit.org/show_bug.cgi?id=142944 423 result = parseStatement(context, directive, directiveLiteralLength); 424 break; 425 } 426 427 return result; 404 428 } 405 429 … … 1264 1288 result = parseVarDeclaration(context); 1265 1289 break; 1266 case CONSTTOKEN:1267 result = parseConstDeclaration(context);1268 break;1269 #if ENABLE(ES6_CLASS_SYNTAX)1270 case CLASSTOKEN:1271 failIfFalse(m_statementDepth == 1, "Class declaration is not allowed in a lexically nested statement");1272 result = parseClassDeclaration(context);1273 break;1274 #endif1275 1290 case FUNCTION: 1276 1291 failIfFalseIfStrict(m_statementDepth == 1, "Strict mode does not allow function declarations in a lexically nested statement"); … … 1939 1954 template <class TreeBuilder> TreeStatement Parser<LexerType>::parseExpressionStatement(TreeBuilder& context) 1940 1955 { 1956 switch (m_token.m_type) { 1957 // Consult: http://www.ecma-international.org/ecma-262/6.0/index.html#sec-expression-statement 1958 // The ES6 spec mandates that we should fail from FUNCTION token here. We handle this case 1959 // in parseStatement() which is the only caller of parseExpressionStatement(). 1960 // We actually allow FUNCTION in situations where it should not be allowed unless we're in strict mode. 1961 case CLASSTOKEN: 1962 failWithMessage("'class' declaration is not directly within a block statement"); 1963 break; 1964 default: 1965 // FIXME: when implementing 'let' we should fail when we see the token sequence "let [". 1966 // https://bugs.webkit.org/show_bug.cgi?id=142944 1967 break; 1968 } 1941 1969 JSTextPosition start = tokenStartPosition(); 1942 1970 JSTokenLocation location(tokenLocation());
Note:
See TracChangeset
for help on using the changeset viewer.