aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/sksl.flex
blob: c5d5ec34d0afdfb32a45a6837fb08c8acbf8b200 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/*

    This file is IGNORED during the build process!

    As this file is updated so infrequently and flex is not universally present on build machines,
    the lex.sksl.c file must be manually regenerated if you make any changes to this file. Just run:

        flex sksl.flex

    You will have to manually add a copyright notice to the top of lex.sksl.c.

*/

%option prefix="sksl"
%option reentrant
%option yylineno
%option never-interactive
%option nounistd

DIGIT  [0-9]
LETTER [a-zA-Z_$]

%%

{DIGIT}*"."{DIGIT}+([eE][+-]?{DIGIT}+)? { return SkSL::Token::FLOAT_LITERAL; }

{DIGIT}+"."{DIGIT}*([eE][+-]?{DIGIT}+)? { return SkSL::Token::FLOAT_LITERAL; }

{DIGIT}+([eE][+-]?{DIGIT}+) { return SkSL::Token::FLOAT_LITERAL; }

{DIGIT}+ { return SkSL::Token::INT_LITERAL; }

"0x"[0-9a-fA-F]+ { return SkSL::Token::INT_LITERAL; }

true { return SkSL::Token::TRUE_LITERAL; }

false { return SkSL::Token::FALSE_LITERAL; }

if { return SkSL::Token::IF; }

@if { return SkSL::Token::STATIC_IF; }

else { return SkSL::Token::ELSE; }

for { return SkSL::Token::FOR; }

while { return SkSL::Token::WHILE; }

do { return SkSL::Token::DO; }

switch { return SkSL::Token::SWITCH; }

@switch { return SkSL::Token::STATIC_SWITCH; }

case { return SkSL::Token::CASE; }

default { return SkSL::Token::DEFAULT; }

break { return SkSL::Token::BREAK; }

continue { return SkSL::Token::CONTINUE; }

discard { return SkSL::Token::DISCARD; }

return { return SkSL::Token::RETURN; }

in { return SkSL::Token::IN; }

out { return SkSL::Token::OUT; }

inout { return SkSL::Token::INOUT; }

uniform { return SkSL::Token::UNIFORM; }

const { return SkSL::Token::CONST; }

lowp { return SkSL::Token::LOWP; }

mediump { return SkSL::Token::MEDIUMP; }

highp { return SkSL::Token::HIGHP; }

flat { return SkSL::Token::FLAT; }

noperspective { return SkSL::Token::NOPERSPECTIVE; }

readonly { return SkSL::Token::READONLY; }

writeonly { return SkSL::Token::WRITEONLY; }

coherent { return SkSL::Token::COHERENT; }

volatile { return SkSL::Token::VOLATILE; }

restrict { return SkSL::Token::RESTRICT; }

buffer { return SkSL::Token::BUFFER; }

sk_has_side_effects { return SkSL::Token::HASSIDEEFFECTS; }

struct { return SkSL::Token::STRUCT; }

layout { return SkSL::Token::LAYOUT; }

precision { return SkSL::Token::PRECISION; }

{LETTER}({DIGIT}|{LETTER})* { return SkSL::Token::IDENTIFIER; }

"#"{LETTER}({DIGIT}|{LETTER})* { return SkSL::Token::DIRECTIVE; }

"(" { return SkSL::Token::LPAREN; }

")" { return SkSL::Token::RPAREN; }

"{" { return SkSL::Token::LBRACE; }

"}" { return SkSL::Token::RBRACE; }

"[" { return SkSL::Token::LBRACKET; }

"]" { return SkSL::Token::RBRACKET; }

"." { return SkSL::Token::DOT; }

"," { return SkSL::Token::COMMA; }

"++" { return SkSL::Token::PLUSPLUS; }

"--" { return SkSL::Token::MINUSMINUS; }

"+" { return SkSL::Token::PLUS; }

"-" { return SkSL::Token::MINUS; }

"*" { return SkSL::Token::STAR; }

"/" { return SkSL::Token::SLASH; }

"%" { return SkSL::Token::PERCENT; }

"<<" { return SkSL::Token::SHL; }

">>" { return SkSL::Token::SHR; }

"|" { return SkSL::Token::BITWISEOR; }

"^" { return SkSL::Token::BITWISEXOR; }

"&" { return SkSL::Token::BITWISEAND; }

"~" { return SkSL::Token::BITWISENOT; }

"||" { return SkSL::Token::LOGICALOR; }

"^^" { return SkSL::Token::LOGICALXOR; }

"&&" { return SkSL::Token::LOGICALAND; }

"!" { return SkSL::Token::LOGICALNOT; }

"?" { return SkSL::Token::QUESTION; }

":" { return SkSL::Token::COLON; }

"=" { return SkSL::Token::EQ; }

"==" { return SkSL::Token::EQEQ; }

"!=" { return SkSL::Token::NEQ; }

">" { return SkSL::Token::GT; }

"<" { return SkSL::Token::LT; }

">=" { return SkSL::Token::GTEQ; }

"<=" { return SkSL::Token::LTEQ; }

"+=" { return SkSL::Token::PLUSEQ; }

"-=" { return SkSL::Token::MINUSEQ; }

"*=" { return SkSL::Token::STAREQ; }

"/=" { return SkSL::Token::SLASHEQ; }

"%=" { return SkSL::Token::PERCENTEQ; }

"<<=" { return SkSL::Token::SHLEQ; }

">>=" { return SkSL::Token::SHREQ; }

"|=" { return SkSL::Token::BITWISEOREQ; }

"^=" { return SkSL::Token::BITWISEXOREQ; }

"&=" { return SkSL::Token::BITWISEANDEQ; }

"||=" { return SkSL::Token::LOGICALOREQ; }

"^^=" { return SkSL::Token::LOGICALXOREQ; }

"&&=" { return SkSL::Token::LOGICALANDEQ; }

";" { return SkSL::Token::SEMICOLON; }

"//".* /* line comment */

"/*"([^*]|"*"[^/])*"*/" /* block comment */

[ \t\r\n]+  /* whitespace */

.    { return SkSL::Token::INVALID_TOKEN; }

%%

int skslwrap(yyscan_t scanner) {
    return 1; // terminate
}