Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 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> |
Ethan Nicholas | 6823b50 | 2021-06-15 11:42:07 -0400 | [diff] [blame] | 14 | #include "include/core/SkStringView.h" |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 15 | namespace SkSL { |
| 16 | |
| 17 | struct Token { |
Ethan Nicholas | 5a9e7fb | 2020-04-17 12:45:51 -0400 | [diff] [blame] | 18 | enum class Kind { |
| 19 | TK_END_OF_FILE, |
| 20 | TK_FLOAT_LITERAL, |
| 21 | TK_INT_LITERAL, |
| 22 | TK_TRUE_LITERAL, |
| 23 | TK_FALSE_LITERAL, |
| 24 | TK_IF, |
| 25 | TK_STATIC_IF, |
| 26 | TK_ELSE, |
| 27 | TK_FOR, |
| 28 | TK_WHILE, |
| 29 | TK_DO, |
| 30 | TK_SWITCH, |
| 31 | TK_STATIC_SWITCH, |
| 32 | TK_CASE, |
| 33 | TK_DEFAULT, |
| 34 | TK_BREAK, |
| 35 | TK_CONTINUE, |
| 36 | TK_DISCARD, |
| 37 | TK_RETURN, |
Ethan Nicholas | 5a9e7fb | 2020-04-17 12:45:51 -0400 | [diff] [blame] | 38 | TK_IN, |
| 39 | TK_OUT, |
| 40 | TK_INOUT, |
| 41 | TK_UNIFORM, |
| 42 | TK_CONST, |
| 43 | TK_FLAT, |
| 44 | TK_NOPERSPECTIVE, |
Ethan Nicholas | f3c8f5d | 2020-08-20 13:09:14 +0000 | [diff] [blame] | 45 | TK_INLINE, |
John Stiles | 0dd1a77 | 2021-03-09 22:14:27 -0500 | [diff] [blame] | 46 | TK_NOINLINE, |
Ethan Nicholas | 5a9e7fb | 2020-04-17 12:45:51 -0400 | [diff] [blame] | 47 | TK_HASSIDEEFFECTS, |
Ethan Nicholas | 5a9e7fb | 2020-04-17 12:45:51 -0400 | [diff] [blame] | 48 | TK_STRUCT, |
| 49 | TK_LAYOUT, |
John Stiles | b6a7319 | 2021-07-20 15:32:21 -0400 | [diff] [blame] | 50 | TK_HIGHP, |
| 51 | TK_MEDIUMP, |
| 52 | TK_LOWP, |
John Stiles | 44899a2 | 2021-08-12 23:05:50 -0400 | [diff] [blame] | 53 | TK_ES3, |
Ethan Nicholas | 5a9e7fb | 2020-04-17 12:45:51 -0400 | [diff] [blame] | 54 | TK_IDENTIFIER, |
| 55 | TK_DIRECTIVE, |
Ethan Nicholas | 5a9e7fb | 2020-04-17 12:45:51 -0400 | [diff] [blame] | 56 | TK_LPAREN, |
| 57 | TK_RPAREN, |
| 58 | TK_LBRACE, |
| 59 | TK_RBRACE, |
| 60 | TK_LBRACKET, |
| 61 | TK_RBRACKET, |
| 62 | TK_DOT, |
| 63 | TK_COMMA, |
| 64 | TK_PLUSPLUS, |
| 65 | TK_MINUSMINUS, |
| 66 | TK_PLUS, |
| 67 | TK_MINUS, |
| 68 | TK_STAR, |
| 69 | TK_SLASH, |
| 70 | TK_PERCENT, |
| 71 | TK_SHL, |
| 72 | TK_SHR, |
| 73 | TK_BITWISEOR, |
| 74 | TK_BITWISEXOR, |
| 75 | TK_BITWISEAND, |
| 76 | TK_BITWISENOT, |
| 77 | TK_LOGICALOR, |
| 78 | TK_LOGICALXOR, |
| 79 | TK_LOGICALAND, |
| 80 | TK_LOGICALNOT, |
| 81 | TK_QUESTION, |
Ethan Nicholas | 5a9e7fb | 2020-04-17 12:45:51 -0400 | [diff] [blame] | 82 | TK_COLON, |
| 83 | TK_EQ, |
| 84 | TK_EQEQ, |
| 85 | TK_NEQ, |
| 86 | TK_GT, |
| 87 | TK_LT, |
| 88 | TK_GTEQ, |
| 89 | TK_LTEQ, |
| 90 | TK_PLUSEQ, |
| 91 | TK_MINUSEQ, |
| 92 | TK_STAREQ, |
| 93 | TK_SLASHEQ, |
| 94 | TK_PERCENTEQ, |
| 95 | TK_SHLEQ, |
| 96 | TK_SHREQ, |
| 97 | TK_BITWISEOREQ, |
| 98 | TK_BITWISEXOREQ, |
| 99 | TK_BITWISEANDEQ, |
Ethan Nicholas | 5a9e7fb | 2020-04-17 12:45:51 -0400 | [diff] [blame] | 100 | TK_SEMICOLON, |
| 101 | TK_ARROW, |
| 102 | TK_WHITESPACE, |
| 103 | TK_LINE_COMMENT, |
| 104 | TK_BLOCK_COMMENT, |
| 105 | TK_INVALID, |
John Stiles | 7cbb09c2 | 2021-01-07 16:07:00 -0500 | [diff] [blame] | 106 | TK_NONE, |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 107 | }; |
| 108 | |
Ethan Nicholas | 5fad2b88 | 2021-09-27 10:39:18 -0400 | [diff] [blame^] | 109 | Token() {} |
| 110 | Token(Kind kind, int32_t offset, int32_t length, int32_t line) |
| 111 | : fKind(kind), fOffset(offset), fLength(length), fLine(line) {} |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 112 | |
Ethan Nicholas | 5fad2b88 | 2021-09-27 10:39:18 -0400 | [diff] [blame^] | 113 | Kind fKind = Kind::TK_NONE; |
| 114 | int32_t fOffset = -1; |
| 115 | int32_t fLength = -1; |
| 116 | int32_t fLine = -1; |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 117 | }; |
| 118 | |
| 119 | class Lexer { |
| 120 | public: |
Ethan Nicholas | 6823b50 | 2021-06-15 11:42:07 -0400 | [diff] [blame] | 121 | void start(skstd::string_view text) { |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 122 | fText = text; |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 123 | fOffset = 0; |
Ethan Nicholas | 5fad2b88 | 2021-09-27 10:39:18 -0400 | [diff] [blame^] | 124 | fLine = 1; |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | Token next(); |
| 128 | |
Ethan Nicholas | 5fad2b88 | 2021-09-27 10:39:18 -0400 | [diff] [blame^] | 129 | struct Checkpoint { |
| 130 | int32_t fOffset; |
| 131 | int32_t fLine; |
| 132 | }; |
John Stiles | cc6961b | 2021-01-22 09:49:45 -0500 | [diff] [blame] | 133 | |
Ethan Nicholas | 5fad2b88 | 2021-09-27 10:39:18 -0400 | [diff] [blame^] | 134 | Checkpoint getCheckpoint() const { return {fOffset, fLine}; } |
| 135 | |
| 136 | void rewindToCheckpoint(Checkpoint checkpoint) { |
| 137 | fOffset = checkpoint.fOffset; |
| 138 | fLine = checkpoint.fLine; |
| 139 | } |
John Stiles | cc6961b | 2021-01-22 09:49:45 -0500 | [diff] [blame] | 140 | |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 141 | private: |
Ethan Nicholas | 6823b50 | 2021-06-15 11:42:07 -0400 | [diff] [blame] | 142 | skstd::string_view fText; |
Ethan Nicholas | c7735f1 | 2018-08-03 11:48:20 -0400 | [diff] [blame] | 143 | int32_t fOffset; |
Ethan Nicholas | 5fad2b88 | 2021-09-27 10:39:18 -0400 | [diff] [blame^] | 144 | int32_t fLine; |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 145 | }; |
| 146 | |
Brian Osman | 3c35842 | 2020-03-23 10:44:12 -0400 | [diff] [blame] | 147 | } // namespace SkSL |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 148 | #endif |