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

Side by Side Diff: tools/gn/token.h

Issue 588893006: gn: attach comments to parse tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: x64 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/string_utils.cc ('k') | tools/gn/tokenizer.h » ('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 #ifndef TOOLS_GN_TOKEN_H_ 5 #ifndef TOOLS_GN_TOKEN_H_
6 #define TOOLS_GN_TOKEN_H_ 6 #define TOOLS_GN_TOKEN_H_
7 7
8 #include "base/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "tools/gn/location.h" 9 #include "tools/gn/location.h"
10 10
(...skipping 27 matching lines...) Expand all
38 RIGHT_PAREN, 38 RIGHT_PAREN,
39 LEFT_BRACKET, 39 LEFT_BRACKET,
40 RIGHT_BRACKET, 40 RIGHT_BRACKET,
41 LEFT_BRACE, 41 LEFT_BRACE,
42 RIGHT_BRACE, 42 RIGHT_BRACE,
43 43
44 IF, 44 IF,
45 ELSE, 45 ELSE,
46 IDENTIFIER, // foo 46 IDENTIFIER, // foo
47 COMMA, // , 47 COMMA, // ,
48 COMMENT, // #...\n 48 UNCLASSIFIED_COMMENT, // #...\n, of unknown style (will be converted
49 // to one below)
50 LINE_COMMENT, // #...\n on a line alone.
51 SUFFIX_COMMENT, // #...\n on a line following other code.
49 52
50 UNCLASSIFIED_OPERATOR, // TODO(scottmg): This shouldn't be necessary. 53 UNCLASSIFIED_OPERATOR,
51 54
52 NUM_TYPES 55 NUM_TYPES
53 }; 56 };
54 57
55 Token(); 58 Token();
56 Token(const Location& location, Type t, const base::StringPiece& v); 59 Token(const Location& location, Type t, const base::StringPiece& v);
57 60
58 Type type() const { return type_; } 61 Type type() const { return type_; }
59 const base::StringPiece& value() const { return value_; } 62 const base::StringPiece& value() const { return value_; }
60 const Location& location() const { return location_; } 63 const Location& location() const { return location_; }
61 LocationRange range() const { 64 LocationRange range() const {
62 return LocationRange(location_, 65 return LocationRange(
63 Location(location_.file(), location_.line_number(), 66 location_,
64 location_.char_offset() + 67 Location(location_.file(),
65 static_cast<int>(value_.size()))); 68 location_.line_number(),
69 location_.char_offset() + static_cast<int>(value_.size()),
70 location_.byte() + static_cast<int>(value_.size())));
66 } 71 }
67 72
68 // Helper functions for comparing this token to something. 73 // Helper functions for comparing this token to something.
69 bool IsIdentifierEqualTo(const char* v) const; 74 bool IsIdentifierEqualTo(const char* v) const;
70 bool IsStringEqualTo(const char* v) const; 75 bool IsStringEqualTo(const char* v) const;
71 76
72 private: 77 private:
73 Type type_; 78 Type type_;
74 base::StringPiece value_; 79 base::StringPiece value_;
75 Location location_; 80 Location location_;
76 }; 81 };
77 82
78 #endif // TOOLS_GN_TOKEN_H_ 83 #endif // TOOLS_GN_TOKEN_H_
OLDNEW
« no previous file with comments | « tools/gn/string_utils.cc ('k') | tools/gn/tokenizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698