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

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

Issue 207233003: Add "." accessors to GN. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 6 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 | Annotate | Revision Log
« no previous file with comments | « tools/gn/token.h ('k') | tools/gn/tokenizer_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/tokenizer.h" 5 #include "tools/gn/tokenizer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "tools/gn/input_file.h" 8 #include "tools/gn/input_file.h"
9 9
10 namespace { 10 namespace {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 if (value == "<") 57 if (value == "<")
58 return Token::LESS_THAN; 58 return Token::LESS_THAN;
59 if (value == ">") 59 if (value == ">")
60 return Token::GREATER_THAN; 60 return Token::GREATER_THAN;
61 if (value == "&&") 61 if (value == "&&")
62 return Token::BOOLEAN_AND; 62 return Token::BOOLEAN_AND;
63 if (value == "||") 63 if (value == "||")
64 return Token::BOOLEAN_OR; 64 return Token::BOOLEAN_OR;
65 if (value == "!") 65 if (value == "!")
66 return Token::BANG; 66 return Token::BANG;
67 if (value == ".")
68 return Token::DOT;
67 return Token::INVALID; 69 return Token::INVALID;
68 } 70 }
69 71
70 } // namespace 72 } // namespace
71 73
72 Tokenizer::Tokenizer(const InputFile* input_file, Err* err) 74 Tokenizer::Tokenizer(const InputFile* input_file, Err* err)
73 : input_file_(input_file), 75 : input_file_(input_file),
74 input_(input_file->contents()), 76 input_(input_file->contents()),
75 err_(err), 77 err_(err),
76 cur_(0), 78 cur_(0),
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return Token::RIGHT_BRACKET; 191 return Token::RIGHT_BRACKET;
190 if (next_char == '(') 192 if (next_char == '(')
191 return Token::LEFT_PAREN; 193 return Token::LEFT_PAREN;
192 if (next_char == ')') 194 if (next_char == ')')
193 return Token::RIGHT_PAREN; 195 return Token::RIGHT_PAREN;
194 if (next_char == '{') 196 if (next_char == '{')
195 return Token::LEFT_BRACE; 197 return Token::LEFT_BRACE;
196 if (next_char == '}') 198 if (next_char == '}')
197 return Token::RIGHT_BRACE; 199 return Token::RIGHT_BRACE;
198 200
201 if (next_char == '.')
202 return Token::DOT;
199 if (next_char == ',') 203 if (next_char == ',')
200 return Token::COMMA; 204 return Token::COMMA;
201 205
202 if (next_char == '#') 206 if (next_char == '#')
203 return Token::COMMENT; 207 return Token::COMMENT;
204 208
205 // For the case of '-' differentiate between a negative number and anything 209 // For the case of '-' differentiate between a negative number and anything
206 // else. 210 // else.
207 if (next_char == '-') { 211 if (next_char == '-') {
208 if (!CanIncrement()) 212 if (!CanIncrement())
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 while (!at_end() && IsIdentifierContinuingChar(cur_char())) 280 while (!at_end() && IsIdentifierContinuingChar(cur_char()))
277 Advance(); 281 Advance();
278 break; 282 break;
279 283
280 case Token::LEFT_BRACKET: 284 case Token::LEFT_BRACKET:
281 case Token::RIGHT_BRACKET: 285 case Token::RIGHT_BRACKET:
282 case Token::LEFT_BRACE: 286 case Token::LEFT_BRACE:
283 case Token::RIGHT_BRACE: 287 case Token::RIGHT_BRACE:
284 case Token::LEFT_PAREN: 288 case Token::LEFT_PAREN:
285 case Token::RIGHT_PAREN: 289 case Token::RIGHT_PAREN:
290 case Token::DOT:
286 case Token::COMMA: 291 case Token::COMMA:
287 Advance(); // All are one char. 292 Advance(); // All are one char.
288 break; 293 break;
289 294
290 case Token::COMMENT: 295 case Token::COMMENT:
291 // Eat to EOL. 296 // Eat to EOL.
292 while (!at_end() && !IsCurrentNewline()) 297 while (!at_end() && !IsCurrentNewline())
293 Advance(); 298 Advance();
294 break; 299 break;
295 300
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } else if (cur_char() == '/' && cur_ + 1 < input_.size() && 361 } else if (cur_char() == '/' && cur_ + 1 < input_.size() &&
357 (input_[cur_ + 1] == '/' || input_[cur_ + 1] == '*')) { 362 (input_[cur_ + 1] == '/' || input_[cur_ + 1] == '*')) {
358 // Different types of comments. 363 // Different types of comments.
359 help = "Comments should start with # instead"; 364 help = "Comments should start with # instead";
360 } else { 365 } else {
361 help = "I have no idea what this is."; 366 help = "I have no idea what this is.";
362 } 367 }
363 368
364 return Err(location, "Invalid token.", help); 369 return Err(location, "Invalid token.", help);
365 } 370 }
OLDNEW
« no previous file with comments | « tools/gn/token.h ('k') | tools/gn/tokenizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698