OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium 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 #include "tools/gn/parser.h" | 5 #include "tools/gn/parser.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "tools/gn/functions.h" | 8 #include "tools/gn/functions.h" |
9 #include "tools/gn/operators.h" | 9 #include "tools/gn/operators.h" |
10 #include "tools/gn/token.h" | 10 #include "tools/gn/token.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 if (!has_error() && !at_end()) | 381 if (!has_error() && !at_end()) |
382 Consume(Token::RIGHT_BRACKET, "Expected ']'"); | 382 Consume(Token::RIGHT_BRACKET, "Expected ']'"); |
383 return list.Pass(); | 383 return list.Pass(); |
384 } | 384 } |
385 | 385 |
386 scoped_ptr<ParseNode> Parser::BinaryOperator(scoped_ptr<ParseNode> left, | 386 scoped_ptr<ParseNode> Parser::BinaryOperator(scoped_ptr<ParseNode> left, |
387 Token token) { | 387 Token token) { |
388 scoped_ptr<ParseNode> right = | 388 scoped_ptr<ParseNode> right = |
389 ParseExpression(expressions_[token.type()].precedence + 1); | 389 ParseExpression(expressions_[token.type()].precedence + 1); |
390 if (!right) { | 390 if (!right) { |
391 *err_ = | 391 if (!has_error()) |
scottmg
2015/04/07 19:49:52
nit; braces for multiline if.
mdempsky
2015/04/07 19:58:44
Done.
| |
392 Err(token, | 392 *err_ = Err(token, "Expected right hand side for '" + |
393 "Expected right hand side for '" + token.value().as_string() + "'"); | 393 token.value().as_string() + "'"); |
scottmg
2015/04/07 19:49:52
is there a test that hits this code path now? if y
mdempsky
2015/04/07 19:58:44
Yes, DoExpressionErrorTest("(a +", 1, 4) in Parser
| |
394 return scoped_ptr<ParseNode>(); | 394 return scoped_ptr<ParseNode>(); |
395 } | 395 } |
396 scoped_ptr<BinaryOpNode> binary_op(new BinaryOpNode); | 396 scoped_ptr<BinaryOpNode> binary_op(new BinaryOpNode); |
397 binary_op->set_op(token); | 397 binary_op->set_op(token); |
398 binary_op->set_left(left.Pass()); | 398 binary_op->set_left(left.Pass()); |
399 binary_op->set_right(right.Pass()); | 399 binary_op->set_right(right.Pass()); |
400 return binary_op.Pass(); | 400 return binary_op.Pass(); |
401 } | 401 } |
402 | 402 |
403 scoped_ptr<ParseNode> Parser::IdentifierOrCall(scoped_ptr<ParseNode> left, | 403 scoped_ptr<ParseNode> Parser::IdentifierOrCall(scoped_ptr<ParseNode> left, |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
736 break; | 736 break; |
737 } | 737 } |
738 } | 738 } |
739 | 739 |
740 // Suffix comments were assigned in reverse, so if there were multiple on | 740 // Suffix comments were assigned in reverse, so if there were multiple on |
741 // the same node, they need to be reversed. | 741 // the same node, they need to be reversed. |
742 if ((*i)->comments() && !(*i)->comments()->suffix().empty()) | 742 if ((*i)->comments() && !(*i)->comments()->suffix().empty()) |
743 const_cast<ParseNode*>(*i)->comments_mutable()->ReverseSuffix(); | 743 const_cast<ParseNode*>(*i)->comments_mutable()->ReverseSuffix(); |
744 } | 744 } |
745 } | 745 } |
OLD | NEW |