Flutter Engine
The Flutter Engine
SkSLLexer.h
Go to the documentation of this file.
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>
14namespace SkSL {
15
16struct 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_PIXELLOCAL,
58 TK_RESERVED,
59 TK_PRIVATE_IDENTIFIER,
60 TK_IDENTIFIER,
61 TK_DIRECTIVE,
62 TK_LPAREN,
63 TK_RPAREN,
64 TK_LBRACE,
65 TK_RBRACE,
66 TK_LBRACKET,
67 TK_RBRACKET,
68 TK_DOT,
69 TK_COMMA,
70 TK_PLUSPLUS,
71 TK_MINUSMINUS,
72 TK_PLUS,
73 TK_MINUS,
74 TK_STAR,
75 TK_SLASH,
76 TK_PERCENT,
77 TK_SHL,
78 TK_SHR,
79 TK_BITWISEOR,
80 TK_BITWISEXOR,
81 TK_BITWISEAND,
82 TK_BITWISENOT,
83 TK_LOGICALOR,
84 TK_LOGICALXOR,
85 TK_LOGICALAND,
86 TK_LOGICALNOT,
87 TK_QUESTION,
88 TK_COLON,
89 TK_EQ,
90 TK_EQEQ,
91 TK_NEQ,
92 TK_GT,
93 TK_LT,
94 TK_GTEQ,
95 TK_LTEQ,
96 TK_PLUSEQ,
97 TK_MINUSEQ,
98 TK_STAREQ,
99 TK_SLASHEQ,
100 TK_PERCENTEQ,
101 TK_SHLEQ,
102 TK_SHREQ,
103 TK_BITWISEOREQ,
104 TK_BITWISEXOREQ,
105 TK_BITWISEANDEQ,
106 TK_SEMICOLON,
107 TK_WHITESPACE,
108 TK_LINE_COMMENT,
109 TK_BLOCK_COMMENT,
110 TK_INVALID,
111 TK_NONE,
112 };
113
114 Token() {}
115 Token(Kind kind, int32_t offset, int32_t length)
116 : fKind(kind), fOffset(offset), fLength(length) {}
117
119 int32_t fOffset = -1;
120 int32_t fLength = -1;
121};
122
123class Lexer {
124public:
125 void start(std::string_view text) {
126 fText = text;
127 fOffset = 0;
128 }
129
130 Token next();
131
132 struct Checkpoint {
133 int32_t fOffset;
134 };
135
136 Checkpoint getCheckpoint() const { return {fOffset}; }
137
138 void rewindToCheckpoint(Checkpoint checkpoint) { fOffset = checkpoint.fOffset; }
139
140private:
141 std::string_view fText;
142 int32_t fOffset;
143};
144
145} // namespace SkSL
146#endif
Checkpoint getCheckpoint() const
Definition: SkSLLexer.h:136
void rewindToCheckpoint(Checkpoint checkpoint)
Definition: SkSLLexer.h:138
void start(std::string_view text)
Definition: SkSLLexer.h:125
Token next()
Definition: SkSLLexer.cpp:800
size_t length
std::u16string text
SeparatedVector2 offset
int32_t fOffset
Definition: SkSLLexer.h:119
Kind fKind
Definition: SkSLLexer.h:118
int32_t fLength
Definition: SkSLLexer.h:120
Token(Kind kind, int32_t offset, int32_t length)
Definition: SkSLLexer.h:115