github.com/nuvolaris/goja@v0.0.0-20230825100449-967811910c6d/token/token_const.go (about) 1 package token 2 3 const ( 4 _ Token = iota 5 6 ILLEGAL 7 EOF 8 COMMENT 9 10 STRING 11 NUMBER 12 13 PLUS // + 14 MINUS // - 15 MULTIPLY // * 16 EXPONENT // ** 17 SLASH // / 18 REMAINDER // % 19 20 AND // & 21 OR // | 22 EXCLUSIVE_OR // ^ 23 SHIFT_LEFT // << 24 SHIFT_RIGHT // >> 25 UNSIGNED_SHIFT_RIGHT // >>> 26 27 ADD_ASSIGN // += 28 SUBTRACT_ASSIGN // -= 29 MULTIPLY_ASSIGN // *= 30 EXPONENT_ASSIGN // **= 31 QUOTIENT_ASSIGN // /= 32 REMAINDER_ASSIGN // %= 33 34 AND_ASSIGN // &= 35 OR_ASSIGN // |= 36 EXCLUSIVE_OR_ASSIGN // ^= 37 SHIFT_LEFT_ASSIGN // <<= 38 SHIFT_RIGHT_ASSIGN // >>= 39 UNSIGNED_SHIFT_RIGHT_ASSIGN // >>>= 40 41 LOGICAL_AND // && 42 LOGICAL_OR // || 43 COALESCE // ?? 44 INCREMENT // ++ 45 DECREMENT // -- 46 47 EQUAL // == 48 STRICT_EQUAL // === 49 LESS // < 50 GREATER // > 51 ASSIGN // = 52 NOT // ! 53 54 BITWISE_NOT // ~ 55 56 NOT_EQUAL // != 57 STRICT_NOT_EQUAL // !== 58 LESS_OR_EQUAL // <= 59 GREATER_OR_EQUAL // >= 60 61 LEFT_PARENTHESIS // ( 62 LEFT_BRACKET // [ 63 LEFT_BRACE // { 64 COMMA // , 65 PERIOD // . 66 67 RIGHT_PARENTHESIS // ) 68 RIGHT_BRACKET // ] 69 RIGHT_BRACE // } 70 SEMICOLON // ; 71 COLON // : 72 QUESTION_MARK // ? 73 QUESTION_DOT // ?. 74 ARROW // => 75 ELLIPSIS // ... 76 BACKTICK // ` 77 78 PRIVATE_IDENTIFIER 79 80 // tokens below (and only them) are syntactically valid identifiers 81 82 IDENTIFIER 83 KEYWORD 84 BOOLEAN 85 NULL 86 87 IF 88 IN 89 OF 90 DO 91 92 VAR 93 FOR 94 NEW 95 TRY 96 97 THIS 98 ELSE 99 CASE 100 VOID 101 WITH 102 103 CONST 104 WHILE 105 BREAK 106 CATCH 107 THROW 108 CLASS 109 SUPER 110 111 RETURN 112 TYPEOF 113 DELETE 114 SWITCH 115 116 DEFAULT 117 FINALLY 118 EXTENDS 119 120 FUNCTION 121 CONTINUE 122 DEBUGGER 123 124 INSTANCEOF 125 126 ESCAPED_RESERVED_WORD 127 // Non-reserved keywords below 128 129 LET 130 STATIC 131 ASYNC 132 AWAIT 133 YIELD 134 ) 135 136 var token2string = [...]string{ 137 ILLEGAL: "ILLEGAL", 138 EOF: "EOF", 139 COMMENT: "COMMENT", 140 KEYWORD: "KEYWORD", 141 STRING: "STRING", 142 BOOLEAN: "BOOLEAN", 143 NULL: "NULL", 144 NUMBER: "NUMBER", 145 IDENTIFIER: "IDENTIFIER", 146 PRIVATE_IDENTIFIER: "PRIVATE_IDENTIFIER", 147 PLUS: "+", 148 MINUS: "-", 149 EXPONENT: "**", 150 MULTIPLY: "*", 151 SLASH: "/", 152 REMAINDER: "%", 153 AND: "&", 154 OR: "|", 155 EXCLUSIVE_OR: "^", 156 SHIFT_LEFT: "<<", 157 SHIFT_RIGHT: ">>", 158 UNSIGNED_SHIFT_RIGHT: ">>>", 159 ADD_ASSIGN: "+=", 160 SUBTRACT_ASSIGN: "-=", 161 MULTIPLY_ASSIGN: "*=", 162 EXPONENT_ASSIGN: "**=", 163 QUOTIENT_ASSIGN: "/=", 164 REMAINDER_ASSIGN: "%=", 165 AND_ASSIGN: "&=", 166 OR_ASSIGN: "|=", 167 EXCLUSIVE_OR_ASSIGN: "^=", 168 SHIFT_LEFT_ASSIGN: "<<=", 169 SHIFT_RIGHT_ASSIGN: ">>=", 170 UNSIGNED_SHIFT_RIGHT_ASSIGN: ">>>=", 171 LOGICAL_AND: "&&", 172 LOGICAL_OR: "||", 173 COALESCE: "??", 174 INCREMENT: "++", 175 DECREMENT: "--", 176 EQUAL: "==", 177 STRICT_EQUAL: "===", 178 LESS: "<", 179 GREATER: ">", 180 ASSIGN: "=", 181 NOT: "!", 182 BITWISE_NOT: "~", 183 NOT_EQUAL: "!=", 184 STRICT_NOT_EQUAL: "!==", 185 LESS_OR_EQUAL: "<=", 186 GREATER_OR_EQUAL: ">=", 187 LEFT_PARENTHESIS: "(", 188 LEFT_BRACKET: "[", 189 LEFT_BRACE: "{", 190 COMMA: ",", 191 PERIOD: ".", 192 RIGHT_PARENTHESIS: ")", 193 RIGHT_BRACKET: "]", 194 RIGHT_BRACE: "}", 195 SEMICOLON: ";", 196 COLON: ":", 197 QUESTION_MARK: "?", 198 QUESTION_DOT: "?.", 199 ARROW: "=>", 200 ELLIPSIS: "...", 201 BACKTICK: "`", 202 IF: "if", 203 IN: "in", 204 OF: "of", 205 DO: "do", 206 VAR: "var", 207 LET: "let", 208 FOR: "for", 209 NEW: "new", 210 TRY: "try", 211 THIS: "this", 212 ELSE: "else", 213 CASE: "case", 214 VOID: "void", 215 WITH: "with", 216 ASYNC: "async", 217 AWAIT: "await", 218 YIELD: "yield", 219 CONST: "const", 220 WHILE: "while", 221 BREAK: "break", 222 CATCH: "catch", 223 THROW: "throw", 224 CLASS: "class", 225 SUPER: "super", 226 RETURN: "return", 227 TYPEOF: "typeof", 228 DELETE: "delete", 229 SWITCH: "switch", 230 STATIC: "static", 231 DEFAULT: "default", 232 FINALLY: "finally", 233 EXTENDS: "extends", 234 FUNCTION: "function", 235 CONTINUE: "continue", 236 DEBUGGER: "debugger", 237 INSTANCEOF: "instanceof", 238 } 239 240 var keywordTable = map[string]_keyword{ 241 "if": { 242 token: IF, 243 }, 244 "in": { 245 token: IN, 246 }, 247 "do": { 248 token: DO, 249 }, 250 "var": { 251 token: VAR, 252 }, 253 "for": { 254 token: FOR, 255 }, 256 "new": { 257 token: NEW, 258 }, 259 "try": { 260 token: TRY, 261 }, 262 "this": { 263 token: THIS, 264 }, 265 "else": { 266 token: ELSE, 267 }, 268 "case": { 269 token: CASE, 270 }, 271 "void": { 272 token: VOID, 273 }, 274 "with": { 275 token: WITH, 276 }, 277 "async": { 278 token: ASYNC, 279 }, 280 "while": { 281 token: WHILE, 282 }, 283 "break": { 284 token: BREAK, 285 }, 286 "catch": { 287 token: CATCH, 288 }, 289 "throw": { 290 token: THROW, 291 }, 292 "return": { 293 token: RETURN, 294 }, 295 "typeof": { 296 token: TYPEOF, 297 }, 298 "delete": { 299 token: DELETE, 300 }, 301 "switch": { 302 token: SWITCH, 303 }, 304 "default": { 305 token: DEFAULT, 306 }, 307 "finally": { 308 token: FINALLY, 309 }, 310 "function": { 311 token: FUNCTION, 312 }, 313 "continue": { 314 token: CONTINUE, 315 }, 316 "debugger": { 317 token: DEBUGGER, 318 }, 319 "instanceof": { 320 token: INSTANCEOF, 321 }, 322 "const": { 323 token: CONST, 324 }, 325 "class": { 326 token: CLASS, 327 }, 328 "enum": { 329 token: KEYWORD, 330 futureKeyword: true, 331 }, 332 "export": { 333 token: KEYWORD, 334 futureKeyword: true, 335 }, 336 "extends": { 337 token: EXTENDS, 338 }, 339 "import": { 340 token: KEYWORD, 341 futureKeyword: true, 342 }, 343 "super": { 344 token: SUPER, 345 }, 346 /* 347 "implements": { 348 token: KEYWORD, 349 futureKeyword: true, 350 strict: true, 351 }, 352 "interface": { 353 token: KEYWORD, 354 futureKeyword: true, 355 strict: true, 356 },*/ 357 "let": { 358 token: LET, 359 strict: true, 360 }, 361 /*"package": { 362 token: KEYWORD, 363 futureKeyword: true, 364 strict: true, 365 }, 366 "private": { 367 token: KEYWORD, 368 futureKeyword: true, 369 strict: true, 370 }, 371 "protected": { 372 token: KEYWORD, 373 futureKeyword: true, 374 strict: true, 375 }, 376 "public": { 377 token: KEYWORD, 378 futureKeyword: true, 379 strict: true, 380 },*/ 381 "static": { 382 token: STATIC, 383 strict: true, 384 }, 385 "await": { 386 token: AWAIT, 387 }, 388 "yield": { 389 token: YIELD, 390 }, 391 "false": { 392 token: BOOLEAN, 393 }, 394 "true": { 395 token: BOOLEAN, 396 }, 397 "null": { 398 token: NULL, 399 }, 400 }