}
-Expression* ParserTraits::ParseConditionalExpression(bool accept_IN, bool* ok) {
- return parser_->ParseConditionalExpression(accept_IN, ok);
+Expression* ParserTraits::ParseBinaryExpression(int prec, bool accept_IN,
+ bool* ok) {
+ return parser_->ParseBinaryExpression(prec, accept_IN, ok);
}
}
-// Precedence = 3
-Expression* Parser::ParseConditionalExpression(bool accept_IN, bool* ok) {
- // ConditionalExpression ::
- // LogicalOrExpression
- // LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression
-
- int pos = peek_position();
- // We start using the binary expression parser for prec >= 4 only!
- Expression* expression = ParseBinaryExpression(4, accept_IN, CHECK_OK);
- if (peek() != Token::CONDITIONAL) return expression;
- Consume(Token::CONDITIONAL);
- // In parsing the first assignment expression in conditional
- // expressions we always accept the 'in' keyword; see ECMA-262,
- // section 11.12, page 58.
- Expression* left = ParseAssignmentExpression(true, CHECK_OK);
- Expect(Token::COLON, CHECK_OK);
- Expression* right = ParseAssignmentExpression(accept_IN, CHECK_OK);
- return factory()->NewConditional(expression, left, right, pos);
-}
-
-
// Precedence >= 4
Expression* Parser::ParseBinaryExpression(int prec, bool accept_IN, bool* ok) {
ASSERT(prec >= 4);
int function_token_position,
FunctionLiteral::FunctionType type,
bool* ok);
- Expression* ParseConditionalExpression(bool accept_IN, bool* ok);
+ Expression* ParseBinaryExpression(int prec, bool accept_IN, bool* ok);
private:
Parser* parser_;
// Support for hamony block scoped bindings.
Block* ParseScopedBlock(ZoneStringList* labels, bool* ok);
- Expression* ParseConditionalExpression(bool accept_IN, bool* ok);
Expression* ParseBinaryExpression(int prec, bool accept_IN, bool* ok);
Expression* ParseUnaryExpression(bool* ok);
Expression* ParsePostfixExpression(bool* ok);
}
-PreParserExpression PreParserTraits::ParseConditionalExpression(bool accept_IN,
- bool* ok) {
- return pre_parser_->ParseConditionalExpression(accept_IN, ok);
+PreParserExpression PreParserTraits::ParseBinaryExpression(int prec,
+ bool accept_IN,
+ bool* ok) {
+ return pre_parser_->ParseBinaryExpression(prec, accept_IN, ok);
}
#undef DUMMY
-// Precedence = 3
-PreParser::Expression PreParser::ParseConditionalExpression(bool accept_IN,
- bool* ok) {
- // ConditionalExpression ::
- // LogicalOrExpression
- // LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression
-
- // We start using the binary expression parser for prec >= 4 only!
- Expression expression = ParseBinaryExpression(4, accept_IN, CHECK_OK);
- if (peek() != Token::CONDITIONAL) return expression;
- Consume(Token::CONDITIONAL);
- // In parsing the first assignment expression in conditional
- // expressions we always accept the 'in' keyword; see ECMA-262,
- // section 11.12, page 58.
- ParseAssignmentExpression(true, CHECK_OK);
- Expect(Token::COLON, CHECK_OK);
- ParseAssignmentExpression(accept_IN, CHECK_OK);
- return Expression::Default();
-}
-
-
// Precedence >= 4
PreParser::Expression PreParser::ParseBinaryExpression(int prec,
bool accept_IN,
typename Traits::Type::Expression ParseAssignmentExpression(bool accept_IN,
bool* ok);
typename Traits::Type::Expression ParseYieldExpression(bool* ok);
+ typename Traits::Type::Expression ParseConditionalExpression(bool accept_IN,
+ bool* ok);
// Used to detect duplicates in object literals. Each of the values
// kGetterProperty, kSetterProperty and kValueProperty represents
int pos) {
return PreParserExpression::Default();
}
+
+ PreParserExpression NewConditional(PreParserExpression condition,
+ PreParserExpression then_expression,
+ PreParserExpression else_expression,
+ int pos) {
+ return PreParserExpression::Default();
+ }
};
int function_token_position,
FunctionLiteral::FunctionType type,
bool* ok);
- PreParserExpression ParseConditionalExpression(bool accept_IN, bool* ok);
+ PreParserExpression ParseBinaryExpression(int prec, bool accept_IN, bool* ok);
private:
PreParser* pre_parser_;
}
+// Precedence = 3
+template <class Traits>
+typename Traits::Type::Expression
+ParserBase<Traits>::ParseConditionalExpression(bool accept_IN, bool* ok) {
+ // ConditionalExpression ::
+ // LogicalOrExpression
+ // LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression
+
+ int pos = peek_position();
+ // We start using the binary expression parser for prec >= 4 only!
+ typename Traits::Type::Expression expression =
+ this->ParseBinaryExpression(4, accept_IN, CHECK_OK);
+ if (peek() != Token::CONDITIONAL) return expression;
+ Consume(Token::CONDITIONAL);
+ // In parsing the first assignment expression in conditional
+ // expressions we always accept the 'in' keyword; see ECMA-262,
+ // section 11.12, page 58.
+ typename Traits::Type::Expression left =
+ ParseAssignmentExpression(true, CHECK_OK);
+ Expect(Token::COLON, CHECK_OK);
+ typename Traits::Type::Expression right =
+ ParseAssignmentExpression(accept_IN, CHECK_OK);
+ return factory()->NewConditional(expression, left, right, pos);
+}
+
+
#undef CHECK_OK
#undef CHECK_OK_CUSTOM