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

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

Issue 591373002: gn: start of format command (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-more-comment-stuff
Patch Set: change 'copyright header block' to 'standard header block' for android_webview/tools/check_licenses… Created 6 years, 2 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 | « tools/gn/token.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/tokenizer.h" 5 #include "tools/gn/tokenizer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "tools/gn/input_file.h" 9 #include "tools/gn/input_file.h"
10 10
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 type = Token::FALSE_TOKEN; 121 type = Token::FALSE_TOKEN;
122 } else if (type == Token::UNCLASSIFIED_COMMENT) { 122 } else if (type == Token::UNCLASSIFIED_COMMENT) {
123 if (AtStartOfLine(token_begin) && 123 if (AtStartOfLine(token_begin) &&
124 // If it's a standalone comment, but is a continuation of a comment on 124 // If it's a standalone comment, but is a continuation of a comment on
125 // a previous line, then instead make it a continued suffix comment. 125 // a previous line, then instead make it a continued suffix comment.
126 (tokens_.empty() || tokens_.back().type() != Token::SUFFIX_COMMENT || 126 (tokens_.empty() || tokens_.back().type() != Token::SUFFIX_COMMENT ||
127 tokens_.back().location().line_number() + 1 != 127 tokens_.back().location().line_number() + 1 !=
128 location.line_number() || 128 location.line_number() ||
129 tokens_.back().location().char_offset() != location.char_offset())) { 129 tokens_.back().location().char_offset() != location.char_offset())) {
130 type = Token::LINE_COMMENT; 130 type = Token::LINE_COMMENT;
131 Advance(); // The current \n.
132 // If this comment is separated from the next syntax element, then we
133 // want to tag it as a block comment. This will become a standalone
134 // statement at the parser level to keep this comment separate, rather
135 // than attached to the subsequent statement.
136 while (!at_end() && IsCurrentWhitespace()) {
137 if (IsCurrentNewline()) {
138 type = Token::BLOCK_COMMENT;
139 break;
140 }
141 Advance();
142 }
131 } else { 143 } else {
132 type = Token::SUFFIX_COMMENT; 144 type = Token::SUFFIX_COMMENT;
133 } 145 }
134 } 146 }
135 147
136 tokens_.push_back(Token(location, type, token_value)); 148 tokens_.push_back(Token(location, type, token_value));
137 } 149 }
138 if (err_->has_error()) 150 if (err_->has_error())
139 tokens_.clear(); 151 tokens_.clear();
140 return tokens_; 152 return tokens_;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } else if (cur_char() == '/' && cur_ + 1 < input_.size() && 387 } else if (cur_char() == '/' && cur_ + 1 < input_.size() &&
376 (input_[cur_ + 1] == '/' || input_[cur_ + 1] == '*')) { 388 (input_[cur_ + 1] == '/' || input_[cur_ + 1] == '*')) {
377 // Different types of comments. 389 // Different types of comments.
378 help = "Comments should start with # instead"; 390 help = "Comments should start with # instead";
379 } else { 391 } else {
380 help = "I have no idea what this is."; 392 help = "I have no idea what this is.";
381 } 393 }
382 394
383 return Err(location, "Invalid token.", help); 395 return Err(location, "Invalid token.", help);
384 } 396 }
OLDNEW
« no previous file with comments | « tools/gn/token.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698