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

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

Issue 742003002: gn format: penalty-based line breaking WIP XXX Base URL: https://chromium.googlesource.com/chromium/src.git@gn-more-disabled
Patch Set: futzing Created 6 years 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 | « tools/gn/parse_tree.h ('k') | no next file » | 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 282
283 scoped_ptr<ParseNode> Parser::IdentifierOrCall(scoped_ptr<ParseNode> left, 283 scoped_ptr<ParseNode> Parser::IdentifierOrCall(scoped_ptr<ParseNode> left,
284 Token token) { 284 Token token) {
285 scoped_ptr<ListNode> list(new ListNode); 285 scoped_ptr<ListNode> list(new ListNode);
286 list->set_begin_token(token); 286 list->set_begin_token(token);
287 list->set_end(make_scoped_ptr(new EndNode(token))); 287 list->set_end(make_scoped_ptr(new EndNode(token)));
288 scoped_ptr<BlockNode> block; 288 scoped_ptr<BlockNode> block;
289 bool has_arg = false; 289 bool has_arg = false;
290 if (LookAhead(Token::LEFT_PAREN)) { 290 if (LookAhead(Token::LEFT_PAREN)) {
291 Token start_token = Consume(); 291 Token start_token = Consume();
292 list->set_begin_token(start_token);
292 // Parsing a function call. 293 // Parsing a function call.
293 has_arg = true; 294 has_arg = true;
294 if (Match(Token::RIGHT_PAREN)) { 295 if (LookAhead(Token::RIGHT_PAREN)) {
295 // Nothing, just an empty call. 296 // Nothing, just an empty call.
297 list->set_end(make_scoped_ptr(new EndNode(Consume())));
296 } else { 298 } else {
297 list = ParseList(start_token, Token::RIGHT_PAREN, false); 299 list = ParseList(start_token, Token::RIGHT_PAREN, false);
298 if (has_error()) 300 if (has_error())
299 return scoped_ptr<ParseNode>(); 301 return scoped_ptr<ParseNode>();
300 Consume(Token::RIGHT_PAREN, "Expected ')' after call"); 302 list->set_end(make_scoped_ptr(
303 new EndNode(Consume(Token::RIGHT_PAREN, "Expected ')' after call"))));
301 } 304 }
302 // Optionally with a scope. 305 // Optionally with a scope.
303 if (LookAhead(Token::LEFT_BRACE)) { 306 if (LookAhead(Token::LEFT_BRACE)) {
304 block = ParseBlock(); 307 block = ParseBlock();
305 if (has_error()) 308 if (has_error())
306 return scoped_ptr<ParseNode>(); 309 return scoped_ptr<ParseNode>();
307 } 310 }
308 } 311 }
309 312
310 if (!left && !has_arg) { 313 if (!left && !has_arg) {
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 break; 613 break;
611 } 614 }
612 } 615 }
613 616
614 // Suffix comments were assigned in reverse, so if there were multiple on 617 // Suffix comments were assigned in reverse, so if there were multiple on
615 // the same node, they need to be reversed. 618 // the same node, they need to be reversed.
616 if ((*i)->comments() && !(*i)->comments()->suffix().empty()) 619 if ((*i)->comments() && !(*i)->comments()->suffix().empty())
617 const_cast<ParseNode*>(*i)->comments_mutable()->ReverseSuffix(); 620 const_cast<ParseNode*>(*i)->comments_mutable()->ReverseSuffix();
618 } 621 }
619 } 622 }
OLDNEW
« no previous file with comments | « tools/gn/parse_tree.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698