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_IN,
38         TK_OUT,
39         TK_INOUT,
40         TK_UNIFORM,
41         TK_CONST,
42         TK_FLAT,
43         TK_NOPERSPECTIVE,
44         TK_INLINE,
45         TK_NOINLINE,
46         TK_HASSIDEEFFECTS,
47         TK_STRUCT,
48         TK_LAYOUT,
49         TK_ENUM,
50         TK_CLASS,
51         TK_IDENTIFIER,
52         TK_DIRECTIVE,
53         TK_SECTION,
54         TK_LPAREN,
55         TK_RPAREN,
56         TK_LBRACE,
57         TK_RBRACE,
58         TK_LBRACKET,
59         TK_RBRACKET,
60         TK_DOT,
61         TK_COMMA,
62         TK_PLUSPLUS,
63         TK_MINUSMINUS,
64         TK_PLUS,
65         TK_MINUS,
66         TK_STAR,
67         TK_SLASH,
68         TK_PERCENT,
69         TK_SHL,
70         TK_SHR,
71         TK_BITWISEOR,
72         TK_BITWISEXOR,
73         TK_BITWISEAND,
74         TK_BITWISENOT,
75         TK_LOGICALOR,
76         TK_LOGICALXOR,
77         TK_LOGICALAND,
78         TK_LOGICALNOT,
79         TK_QUESTION,
80         TK_COLONCOLON,
81         TK_COLON,
82         TK_EQ,
83         TK_EQEQ,
84         TK_NEQ,
85         TK_GT,
86         TK_LT,
87         TK_GTEQ,
88         TK_LTEQ,
89         TK_PLUSEQ,
90         TK_MINUSEQ,
91         TK_STAREQ,
92         TK_SLASHEQ,
93         TK_PERCENTEQ,
94         TK_SHLEQ,
95         TK_SHREQ,
96         TK_BITWISEOREQ,
97         TK_BITWISEXOREQ,
98         TK_BITWISEANDEQ,
99         TK_SEMICOLON,
100         TK_ARROW,
101         TK_WHITESPACE,
102         TK_LINE_COMMENT,
103         TK_BLOCK_COMMENT,
104         TK_INVALID,
105         TK_NONE,
106     };
107 
TokenToken108     Token() : fKind(Kind::TK_NONE), fOffset(-1), fLength(-1) {}
109 
TokenToken110     Token(Kind kind, int32_t offset, int32_t length)
111             : fKind(kind), fOffset(offset), fLength(length) {}
112 
113     Kind fKind;
114     int fOffset;
115     int fLength;
116 };
117 
118 class Lexer {
119 public:
start(const char * text,int32_t length)120     void start(const char* text, int32_t length) {
121         fText = text;
122         fLength = length;
123         fOffset = 0;
124     }
125 
126     Token next();
127 
getCheckpoint()128     int32_t getCheckpoint() const { return fOffset; }
129 
rewindToCheckpoint(int32_t checkpoint)130     void rewindToCheckpoint(int32_t checkpoint) { fOffset = checkpoint; }
131 
132 private:
133     const char* fText;
134     int32_t fLength;
135     int32_t fOffset;
136 };
137 
138 }  // namespace SkSL
139 #endif
140