• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <cstdint>
13 #include <string_view>
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_BAD_OCTAL,
22         TK_TRUE_LITERAL,
23         TK_FALSE_LITERAL,
24         TK_IF,
25         TK_ELSE,
26         TK_FOR,
27         TK_WHILE,
28         TK_DO,
29         TK_SWITCH,
30         TK_CASE,
31         TK_DEFAULT,
32         TK_BREAK,
33         TK_CONTINUE,
34         TK_DISCARD,
35         TK_RETURN,
36         TK_IN,
37         TK_OUT,
38         TK_INOUT,
39         TK_UNIFORM,
40         TK_CONST,
41         TK_FLAT,
42         TK_NOPERSPECTIVE,
43         TK_INLINE,
44         TK_NOINLINE,
45         TK_PURE,
46         TK_READONLY,
47         TK_WRITEONLY,
48         TK_BUFFER,
49         TK_STRUCT,
50         TK_LAYOUT,
51         TK_HIGHP,
52         TK_MEDIUMP,
53         TK_LOWP,
54         TK_ES3,
55         TK_EXPORT,
56         TK_WORKGROUP,
57         TK_RESERVED,
58         TK_PRIVATE_IDENTIFIER,
59         TK_IDENTIFIER,
60         TK_DIRECTIVE,
61         TK_LPAREN,
62         TK_RPAREN,
63         TK_LBRACE,
64         TK_RBRACE,
65         TK_LBRACKET,
66         TK_RBRACKET,
67         TK_DOT,
68         TK_COMMA,
69         TK_PLUSPLUS,
70         TK_MINUSMINUS,
71         TK_PLUS,
72         TK_MINUS,
73         TK_STAR,
74         TK_SLASH,
75         TK_PERCENT,
76         TK_SHL,
77         TK_SHR,
78         TK_BITWISEOR,
79         TK_BITWISEXOR,
80         TK_BITWISEAND,
81         TK_BITWISENOT,
82         TK_LOGICALOR,
83         TK_LOGICALXOR,
84         TK_LOGICALAND,
85         TK_LOGICALNOT,
86         TK_QUESTION,
87         TK_COLON,
88         TK_EQ,
89         TK_EQEQ,
90         TK_NEQ,
91         TK_GT,
92         TK_LT,
93         TK_GTEQ,
94         TK_LTEQ,
95         TK_PLUSEQ,
96         TK_MINUSEQ,
97         TK_STAREQ,
98         TK_SLASHEQ,
99         TK_PERCENTEQ,
100         TK_SHLEQ,
101         TK_SHREQ,
102         TK_BITWISEOREQ,
103         TK_BITWISEXOREQ,
104         TK_BITWISEANDEQ,
105         TK_SEMICOLON,
106         TK_WHITESPACE,
107         TK_LINE_COMMENT,
108         TK_BLOCK_COMMENT,
109         TK_INVALID,
110         TK_NONE,
111     };
112 
TokenToken113     Token() {}
TokenToken114     Token(Kind kind, int32_t offset, int32_t length)
115             : fKind(kind), fOffset(offset), fLength(length) {}
116 
117     Kind fKind = Kind::TK_NONE;
118     int32_t fOffset = -1;
119     int32_t fLength = -1;
120 };
121 
122 class Lexer {
123 public:
start(std::string_view text)124     void start(std::string_view text) {
125         fText = text;
126         fOffset = 0;
127     }
128 
129     Token next();
130 
131     struct Checkpoint {
132         int32_t fOffset;
133     };
134 
getCheckpoint()135     Checkpoint getCheckpoint() const { return {fOffset}; }
136 
rewindToCheckpoint(Checkpoint checkpoint)137     void rewindToCheckpoint(Checkpoint checkpoint) { fOffset = checkpoint.fOffset; }
138 
139 private:
140     std::string_view fText;
141     int32_t fOffset;
142 };
143 
144 }  // namespace SkSL
145 #endif
146