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

Side by Side Diff: mojom/lexer.h

Issue 1432613003: Remove unused lexer code. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 | « mojom/BUILD.gn ('k') | mojom/lexer.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 2015 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 MOJO_PUBLIC_TOOLS_BINDINGS_MOJOM_CPP_LEXER_H_
6 #define MOJO_PUBLIC_TOOLS_BINDINGS_MOJOM_CPP_LEXER_H_
7
8 #include <cstddef>
9 #include <string>
10 #include <vector>
11
12 #include "base/macros.h"
13
14 namespace mojo {
15 namespace mojom {
16
17 enum class TokenType {
18 // Errors
19 ERROR_UNKNOWN,
20 ERROR_ILLEGAL_CHAR,
21 ERROR_UNTERMINATED_STRING_LITERAL,
22
23 // Punctuators and Separators
24 LPAREN,
25 RPAREN,
26 LBRACKET,
27 RBRACKET,
28 LBRACE,
29 RBRACE,
30 LANGLE,
31 RANGLE,
32 SEMI,
33 COMMA,
34 DOT,
35 MINUS,
36 PLUS,
37 AMP,
38 QSTN,
39 EQUALS,
40 RESPONSE,
41
42 // Identifiers
43 IDENTIFIER,
44
45 // Keywords
46 IMPORT,
47 MODULE,
48 STRUCT,
49 UNION,
50 INTERFACE,
51 ENUM,
52 CONST,
53 TRUE,
54 FALSE,
55 DEFAULT,
56
57 // Constants
58 INT_CONST_DEC,
59 INT_CONST_HEX,
60 FLOAT_CONST,
61 ORDINAL,
62 STRING_LITERAL,
63
64 // TODO(azani): Check that all tokens were implemented.
65 // TODO(azani): Error out on octal.
66 };
67
68 struct Token {
69 Token();
70 ~Token();
71
72 bool error() const {
73 return (token_type == TokenType::ERROR_ILLEGAL_CHAR ||
74 token_type == TokenType::ERROR_UNTERMINATED_STRING_LITERAL ||
75 token_type == TokenType::ERROR_UNKNOWN);
76 }
77
78 TokenType token_type;
79 std::string token;
80 size_t char_pos;
81 size_t line_no;
82 size_t line_pos;
83 };
84
85 // Accepts the text of a mojom file and returns the ordered list of tokens
86 // found in the file.
87 std::vector<Token> Tokenize(const std::string& source);
88
89 } // namespace mojom
90 } // namespace mojo
91
92 #endif // MOJO_PUBLIC_TOOLS_BINDINGS_MOJOM_CPP_LEXER_H_
OLDNEW
« no previous file with comments | « mojom/BUILD.gn ('k') | mojom/lexer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698