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
3 // found in the LICENSE file.
5 #ifndef TOOLS_GN_TOKEN_H_
6 #define TOOLS_GN_TOKEN_H_
8 #include "base/strings/string_piece.h"
9 #include "tools/gn/location.h"
17 TRUE_TOKEN, // Not "TRUE" to avoid collisions with #define in windows.h.
49 UNCLASSIFIED_OPERATOR, // TODO(scottmg): This shouldn't be necessary.
55 Token(const Location& location, Type t, const base::StringPiece& v);
57 Type type() const { return type_; }
58 const base::StringPiece& value() const { return value_; }
59 const Location& location() const { return location_; }
60 LocationRange range() const {
61 return LocationRange(location_,
62 Location(location_.file(), location_.line_number(),
63 location_.char_offset() +
64 static_cast<int>(value_.size())));
67 // Helper functions for comparing this token to something.
68 bool IsIdentifierEqualTo(const char* v) const;
69 bool IsStringEqualTo(const char* v) const;
71 // For STRING tokens, returns the string value (no quotes at end, does
73 std::string StringValue() const;
77 base::StringPiece value_;
81 #endif // TOOLS_GN_TOKEN_H_