OLD | NEW |
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 SUFFIX_COMMENT, // #...\n on a line following other code. | 51 SUFFIX_COMMENT, // #...\n on a line following other code. |
52 BLOCK_COMMENT, // #...\n line comment, but free-standing. | 52 BLOCK_COMMENT, // #...\n line comment, but free-standing. |
53 | 53 |
54 UNCLASSIFIED_OPERATOR, | 54 UNCLASSIFIED_OPERATOR, |
55 | 55 |
56 NUM_TYPES | 56 NUM_TYPES |
57 }; | 57 }; |
58 | 58 |
59 Token(); | 59 Token(); |
60 Token(const Location& location, Type t, const base::StringPiece& v); | 60 Token(const Location& location, Type t, const base::StringPiece& v); |
| 61 Token(const Token& other); |
61 | 62 |
62 Type type() const { return type_; } | 63 Type type() const { return type_; } |
63 const base::StringPiece& value() const { return value_; } | 64 const base::StringPiece& value() const { return value_; } |
64 const Location& location() const { return location_; } | 65 const Location& location() const { return location_; } |
65 void set_location(Location location) { location_ = location; } | 66 void set_location(Location location) { location_ = location; } |
66 LocationRange range() const { | 67 LocationRange range() const { |
67 return LocationRange( | 68 return LocationRange( |
68 location_, | 69 location_, |
69 Location(location_.file(), | 70 Location(location_.file(), |
70 location_.line_number(), | 71 location_.line_number(), |
71 location_.column_number() + static_cast<int>(value_.size()), | 72 location_.column_number() + static_cast<int>(value_.size()), |
72 location_.byte() + static_cast<int>(value_.size()))); | 73 location_.byte() + static_cast<int>(value_.size()))); |
73 } | 74 } |
74 | 75 |
75 // Helper functions for comparing this token to something. | 76 // Helper functions for comparing this token to something. |
76 bool IsIdentifierEqualTo(const char* v) const; | 77 bool IsIdentifierEqualTo(const char* v) const; |
77 bool IsStringEqualTo(const char* v) const; | 78 bool IsStringEqualTo(const char* v) const; |
78 | 79 |
79 private: | 80 private: |
80 Type type_; | 81 Type type_; |
81 base::StringPiece value_; | 82 base::StringPiece value_; |
82 Location location_; | 83 Location location_; |
83 }; | 84 }; |
84 | 85 |
85 #endif // TOOLS_GN_TOKEN_H_ | 86 #endif // TOOLS_GN_TOKEN_H_ |
OLD | NEW |