1 /** 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ES2PANDA_PARSER_INCLUDE_TOKEN_TYPE_H 17 #define ES2PANDA_PARSER_INCLUDE_TOKEN_TYPE_H 18 19 namespace panda::es2panda::lexer { 20 21 enum class TokenType { 22 EOS, 23 24 LITERAL_IDENT, 25 LITERAL_STRING, 26 LITERAL_NUMBER, 27 LITERAL_REGEXP, 28 LITERAL_TRUE, 29 LITERAL_FALSE, 30 LITERAL_NULL, 31 32 // Keep this order 33 PUNCTUATOR_NULLISH_COALESCING, 34 PUNCTUATOR_LOGICAL_OR, 35 PUNCTUATOR_LOGICAL_AND, 36 PUNCTUATOR_BITWISE_OR, 37 PUNCTUATOR_BITWISE_XOR, 38 PUNCTUATOR_BITWISE_AND, 39 PUNCTUATOR_EQUAL, 40 PUNCTUATOR_NOT_EQUAL, 41 PUNCTUATOR_STRICT_EQUAL, 42 PUNCTUATOR_NOT_STRICT_EQUAL, 43 PUNCTUATOR_LESS_THAN, 44 PUNCTUATOR_LESS_THAN_EQUAL, 45 PUNCTUATOR_GREATER_THAN, 46 PUNCTUATOR_GREATER_THAN_EQUAL, 47 PUNCTUATOR_LEFT_SHIFT, 48 PUNCTUATOR_RIGHT_SHIFT, 49 PUNCTUATOR_UNSIGNED_RIGHT_SHIFT, 50 PUNCTUATOR_PLUS, 51 PUNCTUATOR_MINUS, 52 PUNCTUATOR_MULTIPLY, 53 PUNCTUATOR_DIVIDE, 54 PUNCTUATOR_MOD, 55 KEYW_IN, 56 KEYW_INSTANCEOF, 57 PUNCTUATOR_EXPONENTIATION, 58 59 PUNCTUATOR_LEFT_PARENTHESIS, 60 PUNCTUATOR_RIGHT_PARENTHESIS, 61 PUNCTUATOR_LEFT_BRACE, 62 PUNCTUATOR_RIGHT_BRACE, 63 PUNCTUATOR_PERIOD, 64 PUNCTUATOR_PERIOD_PERIOD_PERIOD, 65 PUNCTUATOR_PERIOD_QUESTION, 66 PUNCTUATOR_COMMA, 67 PUNCTUATOR_COLON, 68 PUNCTUATOR_SEMI_COLON, 69 PUNCTUATOR_LEFT_SQUARE_BRACKET, 70 PUNCTUATOR_RIGHT_SQUARE_BRACKET, 71 PUNCTUATOR_QUESTION_MARK, 72 PUNCTUATOR_QUESTION_DOT, 73 PUNCTUATOR_TILDE, 74 PUNCTUATOR_EXCLAMATION_MARK, 75 PUNCTUATOR_PLUS_PLUS, 76 PUNCTUATOR_MINUS_MINUS, 77 PUNCTUATOR_SUBSTITUTION, 78 PUNCTUATOR_UNSIGNED_RIGHT_SHIFT_EQUAL, 79 PUNCTUATOR_RIGHT_SHIFT_EQUAL, 80 PUNCTUATOR_LEFT_SHIFT_EQUAL, 81 PUNCTUATOR_PLUS_EQUAL, 82 PUNCTUATOR_MINUS_EQUAL, 83 PUNCTUATOR_MULTIPLY_EQUAL, 84 PUNCTUATOR_DIVIDE_EQUAL, 85 PUNCTUATOR_MOD_EQUAL, 86 PUNCTUATOR_BITWISE_AND_EQUAL, 87 PUNCTUATOR_BITWISE_OR_EQUAL, 88 PUNCTUATOR_BITWISE_XOR_EQUAL, 89 PUNCTUATOR_LOGICAL_AND_EQUAL, 90 PUNCTUATOR_LOGICAL_OR_EQUAL, 91 PUNCTUATOR_LOGICAL_NULLISH_EQUAL, 92 PUNCTUATOR_EXPONENTIATION_EQUAL, 93 PUNCTUATOR_ARROW, 94 PUNCTUATOR_BACK_TICK, 95 PUNCTUATOR_HASH_MARK, 96 PUNCTUATOR_AT, 97 98 /* contextual keywords */ 99 KEYW_GET, 100 KEYW_SET, 101 KEYW_OF, 102 KEYW_FROM, 103 KEYW_AS, 104 KEYW_META, 105 KEYW_REQUIRE, 106 KEYW_ABSTRACT, 107 108 /* reserved keywords */ 109 FIRST_KEYW, 110 KEYW_ANY = FIRST_KEYW, 111 KEYW_AWAIT, 112 KEYW_BIGINT, 113 KEYW_BOOLEAN, 114 KEYW_BREAK, 115 KEYW_CASE, 116 KEYW_CATCH, 117 KEYW_CLASS, 118 KEYW_CONST, 119 KEYW_CONTINUE, 120 KEYW_DEBUGGER, 121 KEYW_DEFAULT, 122 KEYW_DELETE, 123 KEYW_DO, 124 KEYW_ELSE, 125 KEYW_ENUM, 126 KEYW_EXPORT, 127 KEYW_EXTENDS, 128 KEYW_FINALLY, 129 KEYW_FOR, 130 KEYW_FUNCTION, 131 KEYW_IF, 132 KEYW_IMPORT, 133 KEYW_NEVER, 134 KEYW_NEW, 135 KEYW_NULL, 136 KEYW_NUMBER, 137 KEYW_OBJECT, 138 KEYW_REGEXP, 139 KEYW_RETURN, 140 KEYW_STRING, 141 KEYW_SUPER, 142 KEYW_SWITCH, 143 KEYW_SYMBOL, 144 KEYW_THIS, 145 KEYW_THROW, 146 KEYW_TYPE, 147 KEYW_TRY, 148 KEYW_TYPEOF, 149 KEYW_UNDEFINED, 150 KEYW_UNKNOWN, 151 KEYW_VAR, 152 KEYW_VOID, 153 KEYW_WHILE, 154 KEYW_WITH, 155 156 KEYW_ASYNC, 157 KEYW_READONLY, 158 KEYW_KEYOF, 159 KEYW_UNIQUE, 160 KEYW_MODULE, 161 KEYW_NAMESPACE, 162 KEYW_GLOBAL, 163 KEYW_INFER, 164 KEYW_DECLARE, 165 KEYW_IS, 166 KEYW_ASSERTS, 167 KEYW_ARGUMENTS, 168 KEYW_EVAL, 169 KEYW_STATIC, 170 171 /* strict mode future reserved keywords */ 172 KEYW_PRIVATE, 173 KEYW_PROTECTED, 174 KEYW_PUBLIC, 175 KEYW_IMPLEMENTS, 176 KEYW_INTERFACE, 177 KEYW_PACKAGE, 178 179 /* context dependent future */ 180 KEYW_LET, 181 KEYW_YIELD, 182 }; 183 184 const char *TokenToString(TokenType type); 185 186 } // namespace panda::es2panda::lexer 187 188 #endif 189