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.
48 UNCLASSIFIED_COMMENT
, // #...\n, of unknown style (will be converted
50 LINE_COMMENT
, // #...\n on a line alone.
51 SUFFIX_COMMENT
, // #...\n on a line following other code.
52 BLOCK_COMMENT
, // #...\n line comment, but free-standing.
54 UNCLASSIFIED_OPERATOR
,
60 Token(const Location
& location
, Type t
, const base::StringPiece
& v
);
62 Type
type() const { return type_
; }
63 const base::StringPiece
& value() const { return value_
; }
64 const Location
& location() const { return location_
; }
65 LocationRange
range() const {
68 Location(location_
.file(),
69 location_
.line_number(),
70 location_
.char_offset() + static_cast<int>(value_
.size()),
71 location_
.byte() + static_cast<int>(value_
.size())));
74 // Helper functions for comparing this token to something.
75 bool IsIdentifierEqualTo(const char* v
) const;
76 bool IsStringEqualTo(const char* v
) const;
80 base::StringPiece value_
;
84 #endif // TOOLS_GN_TOKEN_H_