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

Side by Side Diff: tools/gn/parser.cc

Issue 1068623002: tools/gn: provide better error message for bogus binary expressions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scottmg feedback Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/gn/parser_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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()) {
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() + "'");
394 }
394 return scoped_ptr<ParseNode>(); 395 return scoped_ptr<ParseNode>();
395 } 396 }
396 scoped_ptr<BinaryOpNode> binary_op(new BinaryOpNode); 397 scoped_ptr<BinaryOpNode> binary_op(new BinaryOpNode);
397 binary_op->set_op(token); 398 binary_op->set_op(token);
398 binary_op->set_left(left.Pass()); 399 binary_op->set_left(left.Pass());
399 binary_op->set_right(right.Pass()); 400 binary_op->set_right(right.Pass());
400 return binary_op.Pass(); 401 return binary_op.Pass();
401 } 402 }
402 403
403 scoped_ptr<ParseNode> Parser::IdentifierOrCall(scoped_ptr<ParseNode> left, 404 scoped_ptr<ParseNode> Parser::IdentifierOrCall(scoped_ptr<ParseNode> left,
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 break; 737 break;
737 } 738 }
738 } 739 }
739 740
740 // Suffix comments were assigned in reverse, so if there were multiple on 741 // Suffix comments were assigned in reverse, so if there were multiple on
741 // the same node, they need to be reversed. 742 // the same node, they need to be reversed.
742 if ((*i)->comments() && !(*i)->comments()->suffix().empty()) 743 if ((*i)->comments() && !(*i)->comments()->suffix().empty())
743 const_cast<ParseNode*>(*i)->comments_mutable()->ReverseSuffix(); 744 const_cast<ParseNode*>(*i)->comments_mutable()->ReverseSuffix();
744 } 745 }
745 } 746 }
OLDNEW
« no previous file with comments | « no previous file | tools/gn/parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698