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

Side by Side Diff: src/sksl/SkSLToken.h

Issue 1984363002: initial checkin of SkSL compiler (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fixed CMake build Created 4 years, 5 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
« no previous file with comments | « src/sksl/SkSLSPIRVCodeGenerator.cpp ('k') | src/sksl/SkSLUtil.h » ('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 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SKSL_TOKEN
9 #define SKSL_TOKEN
10
11 #include "SkSLPosition.h"
12 #include "SkSLUtil.h"
13
14 namespace SkSL {
15
16 /**
17 * Represents a lexical analysis token. Token is generally only used during the parse process, but
18 * Token::Kind is also used to represent operator kinds.
19 */
20 struct Token {
21 enum Kind {
22 END_OF_FILE,
23 IDENTIFIER,
24 INT_LITERAL,
25 FLOAT_LITERAL,
26 TRUE_LITERAL,
27 FALSE_LITERAL,
28 LPAREN,
29 RPAREN,
30 LBRACE,
31 RBRACE,
32 LBRACKET,
33 RBRACKET,
34 DOT,
35 COMMA,
36 PLUSPLUS,
37 MINUSMINUS,
38 PLUS,
39 MINUS,
40 STAR,
41 SLASH,
42 PERCENT,
43 SHL,
44 SHR,
45 BITWISEOR,
46 BITWISEXOR,
47 BITWISEAND,
48 LOGICALOR,
49 LOGICALXOR,
50 LOGICALAND,
51 NOT,
52 QUESTION,
53 COLON,
54 EQ,
55 EQEQ,
56 NEQ,
57 GT,
58 LT,
59 GTEQ,
60 LTEQ,
61 PLUSEQ,
62 MINUSEQ,
63 STAREQ,
64 SLASHEQ,
65 PERCENTEQ,
66 SHLEQ,
67 SHREQ,
68 BITWISEOREQ,
69 BITWISEXOREQ,
70 BITWISEANDEQ,
71 LOGICALOREQ,
72 LOGICALXOREQ,
73 LOGICALANDEQ,
74 SEMICOLON,
75 IF,
76 ELSE,
77 FOR,
78 WHILE,
79 DO,
80 RETURN,
81 BREAK,
82 CONTINUE,
83 DISCARD,
84 IN,
85 OUT,
86 INOUT,
87 CONST,
88 LOWP,
89 MEDIUMP,
90 HIGHP,
91 UNIFORM,
92 STRUCT,
93 LAYOUT,
94 DIRECTIVE,
95 PRECISION,
96 INVALID_TOKEN
97 };
98
99 static std::string OperatorName(Kind kind) {
100 switch (kind) {
101 case Token::PLUS: return "+";
102 case Token::MINUS: return "-";
103 case Token::STAR: return "*";
104 case Token::SLASH: return "/";
105 case Token::PERCENT: return "%";
106 case Token::SHL: return "<<";
107 case Token::SHR: return ">>";
108 case Token::LOGICALAND: return "&&";
109 case Token::LOGICALOR: return "||";
110 case Token::LOGICALXOR: return "^^";
111 case Token::BITWISEAND: return "&";
112 case Token::BITWISEOR: return "|";
113 case Token::BITWISEXOR: return "^";
114 case Token::EQ: return "=";
115 case Token::EQEQ: return "==";
116 case Token::NEQ: return "!=";
117 case Token::LT: return "<";
118 case Token::GT: return ">";
119 case Token::LTEQ: return "<=";
120 case Token::GTEQ: return ">=";
121 case Token::PLUSEQ: return "+=";
122 case Token::MINUSEQ: return "-=";
123 case Token::STAREQ: return "*=";
124 case Token::SLASHEQ: return "/=";
125 case Token::PERCENTEQ: return "%=";
126 case Token::SHLEQ: return "<<=";
127 case Token::SHREQ: return ">>=";
128 case Token::LOGICALANDEQ: return "&&=";
129 case Token::LOGICALOREQ: return "||=";
130 case Token::LOGICALXOREQ: return "^^=";
131 case Token::BITWISEANDEQ: return "&=";
132 case Token::BITWISEOREQ: return "|=";
133 case Token::BITWISEXOREQ: return "^=";
134 case Token::PLUSPLUS: return "++";
135 case Token::MINUSMINUS: return "--";
136 case Token::NOT: return "!";
137 default:
138 ABORT("unsupported operator: %d\n", kind);
139 }
140 }
141
142 Token() {
143 }
144
145 Token(Position position, Kind kind, std::string text)
146 : fPosition(position)
147 , fKind(kind)
148 , fText(std::move(text)) {}
149
150 Position fPosition;
151 Kind fKind;
152 std::string fText;
153 };
154
155 } // namespace
156 #endif
OLDNEW
« no previous file with comments | « src/sksl/SkSLSPIRVCodeGenerator.cpp ('k') | src/sksl/SkSLUtil.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698