OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
7 | 7 |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/base/hashmap.h" | 10 #include "src/base/hashmap.h" |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 bool* is_strict_reserved, | 1049 bool* is_strict_reserved, |
1050 bool* ok); | 1050 bool* ok); |
1051 IdentifierT ParseIdentifierOrStrictReservedWord(bool* is_strict_reserved, | 1051 IdentifierT ParseIdentifierOrStrictReservedWord(bool* is_strict_reserved, |
1052 bool* ok) { | 1052 bool* ok) { |
1053 return ParseIdentifierOrStrictReservedWord(this->is_generator(), | 1053 return ParseIdentifierOrStrictReservedWord(this->is_generator(), |
1054 is_strict_reserved, ok); | 1054 is_strict_reserved, ok); |
1055 } | 1055 } |
1056 | 1056 |
1057 IdentifierT ParseIdentifierName(bool* ok); | 1057 IdentifierT ParseIdentifierName(bool* ok); |
1058 | 1058 |
1059 ExpressionT ParseRegExpLiteral(bool seen_equal, bool* ok); | 1059 ExpressionT ParseRegExpLiteral(bool* ok); |
1060 | 1060 |
1061 ExpressionT ParsePrimaryExpression(ExpressionClassifier* classifier, | 1061 ExpressionT ParsePrimaryExpression(ExpressionClassifier* classifier, |
1062 bool* is_async, bool* ok); | 1062 bool* is_async, bool* ok); |
1063 ExpressionT ParsePrimaryExpression(ExpressionClassifier* classifier, | 1063 ExpressionT ParsePrimaryExpression(ExpressionClassifier* classifier, |
1064 bool* ok) { | 1064 bool* ok) { |
1065 bool is_async; | 1065 bool is_async; |
1066 return ParsePrimaryExpression(classifier, &is_async, ok); | 1066 return ParsePrimaryExpression(classifier, &is_async, ok); |
1067 } | 1067 } |
1068 ExpressionT ParseExpression(bool accept_IN, bool* ok); | 1068 ExpressionT ParseExpression(bool accept_IN, bool* ok); |
1069 ExpressionT ParseExpression(bool accept_IN, ExpressionClassifier* classifier, | 1069 ExpressionT ParseExpression(bool accept_IN, ExpressionClassifier* classifier, |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1339 *message = MessageTemplate::kInvalidEscapedReservedWord; | 1339 *message = MessageTemplate::kInvalidEscapedReservedWord; |
1340 break; | 1340 break; |
1341 case Token::ILLEGAL: | 1341 case Token::ILLEGAL: |
1342 if (scanner()->has_error()) { | 1342 if (scanner()->has_error()) { |
1343 *message = scanner()->error(); | 1343 *message = scanner()->error(); |
1344 *location = scanner()->error_location(); | 1344 *location = scanner()->error_location(); |
1345 } else { | 1345 } else { |
1346 *message = MessageTemplate::kInvalidOrUnexpectedToken; | 1346 *message = MessageTemplate::kInvalidOrUnexpectedToken; |
1347 } | 1347 } |
1348 break; | 1348 break; |
| 1349 case Token::REGEXP_LITERAL: |
| 1350 *message = MessageTemplate::kUnexpectedTokenRegExp; |
| 1351 break; |
1349 default: | 1352 default: |
1350 const char* name = Token::String(token); | 1353 const char* name = Token::String(token); |
1351 DCHECK(name != NULL); | 1354 DCHECK(name != NULL); |
1352 *arg = name; | 1355 *arg = name; |
1353 break; | 1356 break; |
1354 } | 1357 } |
1355 } | 1358 } |
1356 | 1359 |
1357 | 1360 |
1358 template <class Traits> | 1361 template <class Traits> |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1492 this->ReportUnexpectedToken(next); | 1495 this->ReportUnexpectedToken(next); |
1493 *ok = false; | 1496 *ok = false; |
1494 return Traits::EmptyIdentifier(); | 1497 return Traits::EmptyIdentifier(); |
1495 } | 1498 } |
1496 | 1499 |
1497 return this->GetSymbol(scanner()); | 1500 return this->GetSymbol(scanner()); |
1498 } | 1501 } |
1499 | 1502 |
1500 template <class Traits> | 1503 template <class Traits> |
1501 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseRegExpLiteral( | 1504 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseRegExpLiteral( |
1502 bool seen_equal, bool* ok) { | 1505 bool* ok) { |
1503 int pos = peek_position(); | 1506 int pos = peek_position(); |
1504 if (!scanner()->ScanRegExpPattern(seen_equal)) { | 1507 if (!scanner()->ScanRegExpPattern()) { |
1505 Next(); | 1508 Next(); |
1506 ReportMessage(MessageTemplate::kUnterminatedRegExp); | 1509 ReportMessage(MessageTemplate::kUnterminatedRegExp); |
1507 *ok = false; | 1510 *ok = false; |
1508 return Traits::EmptyExpression(); | 1511 return Traits::EmptyExpression(); |
1509 } | 1512 } |
1510 | 1513 |
1511 int literal_index = function_state_->NextMaterializedLiteralIndex(); | 1514 int literal_index = function_state_->NextMaterializedLiteralIndex(); |
1512 | 1515 |
1513 IdentifierT js_pattern = this->GetNextSymbol(scanner()); | 1516 IdentifierT js_pattern = this->GetNextSymbol(scanner()); |
1514 Maybe<RegExp::Flags> flags = scanner()->ScanRegExpFlags(); | 1517 Maybe<RegExp::Flags> flags = scanner()->ScanRegExpFlags(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 scanner()->location().end_pos); | 1589 scanner()->location().end_pos); |
1587 } | 1590 } |
1588 | 1591 |
1589 case Token::STRING: { | 1592 case Token::STRING: { |
1590 BindingPatternUnexpectedToken(classifier); | 1593 BindingPatternUnexpectedToken(classifier); |
1591 Consume(Token::STRING); | 1594 Consume(Token::STRING); |
1592 return this->ExpressionFromString(beg_pos, scanner(), factory()); | 1595 return this->ExpressionFromString(beg_pos, scanner(), factory()); |
1593 } | 1596 } |
1594 | 1597 |
1595 case Token::ASSIGN_DIV: | 1598 case Token::ASSIGN_DIV: |
1596 classifier->RecordBindingPatternError( | |
1597 scanner()->peek_location(), MessageTemplate::kUnexpectedTokenRegExp); | |
1598 return this->ParseRegExpLiteral(true, ok); | |
1599 | |
1600 case Token::DIV: | 1599 case Token::DIV: |
1601 classifier->RecordBindingPatternError( | 1600 classifier->RecordBindingPatternError( |
1602 scanner()->peek_location(), MessageTemplate::kUnexpectedTokenRegExp); | 1601 scanner()->peek_location(), MessageTemplate::kUnexpectedTokenRegExp); |
1603 return this->ParseRegExpLiteral(false, ok); | 1602 return this->ParseRegExpLiteral(ok); |
1604 | 1603 |
1605 case Token::LBRACK: | 1604 case Token::LBRACK: |
1606 return this->ParseArrayLiteral(classifier, ok); | 1605 return this->ParseArrayLiteral(classifier, ok); |
1607 | 1606 |
1608 case Token::LBRACE: | 1607 case Token::LBRACE: |
1609 return this->ParseObjectLiteral(classifier, ok); | 1608 return this->ParseObjectLiteral(classifier, ok); |
1610 | 1609 |
1611 case Token::LPAREN: { | 1610 case Token::LPAREN: { |
1612 // Arrow function formal parameters are either a single identifier or a | 1611 // Arrow function formal parameters are either a single identifier or a |
1613 // list of BindingPattern productions enclosed in parentheses. | 1612 // list of BindingPattern productions enclosed in parentheses. |
(...skipping 2082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3696 has_seen_constructor_ = true; | 3695 has_seen_constructor_ = true; |
3697 return; | 3696 return; |
3698 } | 3697 } |
3699 } | 3698 } |
3700 | 3699 |
3701 | 3700 |
3702 } // namespace internal | 3701 } // namespace internal |
3703 } // namespace v8 | 3702 } // namespace v8 |
3704 | 3703 |
3705 #endif // V8_PARSING_PARSER_BASE_H | 3704 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |