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

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

Issue 21114002: Add initial prototype for the GN meta-buildsystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add owners and readme Created 7 years, 4 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/target_manager_unittest.cc ('k') | tools/gn/token.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef TOOLS_GN_TOKEN_H_
6 #define TOOLS_GN_TOKEN_H_
7
8 #include "base/strings/string_piece.h"
9 #include "tools/gn/location.h"
10
11 class Token {
12 public:
13 enum Type {
14 INVALID,
15 INTEGER, // 123
16 STRING, // "blah"
17 OPERATOR, // =, +=, -=, +, -, ==, !=, <=, >=, <, >
18 IDENTIFIER, // foo
19 SCOPER, // (, ), [, ], {, }
20 SEPARATOR, // ,
21 COMMENT // #...\n
22 };
23
24 Token();
25 Token(const Location& location, Type t, const base::StringPiece& v);
26
27 Type type() const { return type_; }
28 const base::StringPiece& value() const { return value_; }
29 const Location& location() const { return location_; }
30 LocationRange range() const {
31 return LocationRange(location_,
32 Location(location_.file(), location_.line_number(),
33 location_.char_offset() + value_.size()));
34 }
35
36 // Helper functions for comparing this token to something.
37 bool IsIdentifierEqualTo(const char* v) const;
38 bool IsOperatorEqualTo(const char* v) const;
39 bool IsScoperEqualTo(const char* v) const;
40 bool IsStringEqualTo(const char* v) const;
41
42 // For STRING tokens, returns the string value (no quotes at end, does
43 // unescaping).
44 std::string StringValue() const;
45
46 private:
47 Type type_;
48 base::StringPiece value_;
49 Location location_;
50 };
51
52 #endif // TOOLS_GN_TOKEN_H_
OLDNEW
« no previous file with comments | « tools/gn/target_manager_unittest.cc ('k') | tools/gn/token.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698