1 | /* |
2 | * Copyright 2017 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 | ******************** This file was generated by sksllex. Do not edit. ******************* |
9 | *****************************************************************************************/ |
10 | #ifndef SKSL_Lexer |
11 | #define SKSL_Lexer |
12 | #include <cstddef> |
13 | #include <cstdint> |
14 | namespace SkSL { |
15 | |
16 | struct Token { |
17 | enum class Kind { |
18 | TK_END_OF_FILE, |
19 | TK_FLOAT_LITERAL, |
20 | TK_INT_LITERAL, |
21 | TK_TRUE_LITERAL, |
22 | TK_FALSE_LITERAL, |
23 | TK_IF, |
24 | TK_STATIC_IF, |
25 | TK_ELSE, |
26 | TK_FOR, |
27 | TK_WHILE, |
28 | TK_DO, |
29 | TK_SWITCH, |
30 | TK_STATIC_SWITCH, |
31 | TK_CASE, |
32 | TK_DEFAULT, |
33 | TK_BREAK, |
34 | TK_CONTINUE, |
35 | TK_DISCARD, |
36 | TK_RETURN, |
37 | TK_NULL_LITERAL, |
38 | TK_IN, |
39 | TK_OUT, |
40 | TK_INOUT, |
41 | TK_UNIFORM, |
42 | TK_CONST, |
43 | TK_FLAT, |
44 | TK_NOPERSPECTIVE, |
45 | TK_READONLY, |
46 | TK_WRITEONLY, |
47 | TK_COHERENT, |
48 | TK_VOLATILE, |
49 | TK_RESTRICT, |
50 | TK_BUFFER, |
51 | TK_HASSIDEEFFECTS, |
52 | TK_PLS, |
53 | TK_PLSIN, |
54 | TK_PLSOUT, |
55 | TK_VARYING, |
56 | TK_STRUCT, |
57 | TK_LAYOUT, |
58 | TK_PRECISION, |
59 | TK_ENUM, |
60 | TK_CLASS, |
61 | TK_IDENTIFIER, |
62 | TK_DIRECTIVE, |
63 | TK_SECTION, |
64 | TK_LPAREN, |
65 | TK_RPAREN, |
66 | TK_LBRACE, |
67 | TK_RBRACE, |
68 | TK_LBRACKET, |
69 | TK_RBRACKET, |
70 | TK_DOT, |
71 | TK_COMMA, |
72 | TK_PLUSPLUS, |
73 | TK_MINUSMINUS, |
74 | TK_PLUS, |
75 | TK_MINUS, |
76 | TK_STAR, |
77 | TK_SLASH, |
78 | TK_PERCENT, |
79 | TK_SHL, |
80 | TK_SHR, |
81 | TK_BITWISEOR, |
82 | TK_BITWISEXOR, |
83 | TK_BITWISEAND, |
84 | TK_BITWISENOT, |
85 | TK_LOGICALOR, |
86 | TK_LOGICALXOR, |
87 | TK_LOGICALAND, |
88 | TK_LOGICALNOT, |
89 | TK_QUESTION, |
90 | TK_COLONCOLON, |
91 | TK_COLON, |
92 | TK_EQ, |
93 | TK_EQEQ, |
94 | TK_NEQ, |
95 | TK_GT, |
96 | TK_LT, |
97 | TK_GTEQ, |
98 | TK_LTEQ, |
99 | TK_PLUSEQ, |
100 | TK_MINUSEQ, |
101 | TK_STAREQ, |
102 | TK_SLASHEQ, |
103 | TK_PERCENTEQ, |
104 | TK_SHLEQ, |
105 | TK_SHREQ, |
106 | TK_BITWISEOREQ, |
107 | TK_BITWISEXOREQ, |
108 | TK_BITWISEANDEQ, |
109 | TK_LOGICALOREQ, |
110 | TK_LOGICALXOREQ, |
111 | TK_LOGICALANDEQ, |
112 | TK_SEMICOLON, |
113 | TK_ARROW, |
114 | TK_WHITESPACE, |
115 | , |
116 | , |
117 | TK_INVALID, |
118 | }; |
119 | |
120 | Token() : fKind(Kind::TK_INVALID), fOffset(-1), fLength(-1) {} |
121 | |
122 | Token(Kind kind, int32_t offset, int32_t length) |
123 | : fKind(kind), fOffset(offset), fLength(length) {} |
124 | |
125 | Kind fKind; |
126 | int fOffset; |
127 | int fLength; |
128 | }; |
129 | |
130 | class Lexer { |
131 | public: |
132 | void start(const char* text, int32_t length) { |
133 | fText = text; |
134 | fLength = length; |
135 | fOffset = 0; |
136 | } |
137 | |
138 | Token next(); |
139 | |
140 | private: |
141 | const char* fText; |
142 | int32_t fLength; |
143 | int32_t fOffset; |
144 | }; |
145 | |
146 | } // namespace SkSL |
147 | #endif |
148 | |