| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QQMLJSKEYWORDS_P_H |
| 5 | #define QQMLJSKEYWORDS_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include "qqmljslexer_p.h" |
| 19 | |
| 20 | QT_BEGIN_NAMESPACE |
| 21 | |
| 22 | namespace QQmlJS { |
| 23 | |
| 24 | static inline int classify2(QStringView s, int parseModeFlags) { |
| 25 | if (s[0].unicode() == 'a') { |
| 26 | if (s[1].unicode() == 's') { |
| 27 | return Lexer::T_AS; |
| 28 | } |
| 29 | } |
| 30 | else if (s[0].unicode() == 'd') { |
| 31 | if (s[1].unicode() == 'o') { |
| 32 | return Lexer::T_DO; |
| 33 | } |
| 34 | } |
| 35 | else if (s[0].unicode() == 'i') { |
| 36 | if (s[1].unicode() == 'f') { |
| 37 | return Lexer::T_IF; |
| 38 | } |
| 39 | else if (s[1].unicode() == 'n') { |
| 40 | return Lexer::T_IN; |
| 41 | } |
| 42 | } |
| 43 | else if (s[0].unicode() == 'o') { |
| 44 | if (s[1].unicode() == 'n') { |
| 45 | return (parseModeFlags & Lexer::QmlMode) ? Lexer::T_ON : Lexer::T_IDENTIFIER; |
| 46 | } |
| 47 | else if (s[1].unicode() == 'f') { |
| 48 | return Lexer::T_OF; |
| 49 | } |
| 50 | } |
| 51 | return Lexer::T_IDENTIFIER; |
| 52 | } |
| 53 | |
| 54 | static inline int classify3(QStringView s, int parseModeFlags) { |
| 55 | if (s[0].unicode() == 'f') { |
| 56 | if (s[1].unicode() == 'o') { |
| 57 | if (s[2].unicode() == 'r') { |
| 58 | return Lexer::T_FOR; |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | else if (s[0].unicode() == 'g') { |
| 63 | if (s[1].unicode() == 'e') { |
| 64 | if (s[2].unicode() == 't') { |
| 65 | return Lexer::T_GET; |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | else if (s[0].unicode() == 'i') { |
| 70 | if (s[1].unicode() == 'n') { |
| 71 | if (s[2].unicode() == 't') { |
| 72 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_INT) : int(Lexer::T_IDENTIFIER); |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | else if (s[0].unicode() == 'l') { |
| 77 | if (s[1].unicode() == 'e') { |
| 78 | if (s[2].unicode() == 't') { |
| 79 | return int(Lexer::T_LET); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | else if (s[0].unicode() == 'n') { |
| 84 | if (s[1].unicode() == 'e') { |
| 85 | if (s[2].unicode() == 'w') { |
| 86 | return Lexer::T_NEW; |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | else if (s[0].unicode() == 's') { |
| 91 | if (s[1].unicode() == 'e') { |
| 92 | if (s[2].unicode() == 't') { |
| 93 | return Lexer::T_SET; |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | else if (s[0].unicode() == 't') { |
| 98 | if (s[1].unicode() == 'r') { |
| 99 | if (s[2].unicode() == 'y') { |
| 100 | return Lexer::T_TRY; |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | else if (s[0].unicode() == 'v') { |
| 105 | if (s[1].unicode() == 'a') { |
| 106 | if (s[2].unicode() == 'r') { |
| 107 | return Lexer::T_VAR; |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | return Lexer::T_IDENTIFIER; |
| 112 | } |
| 113 | |
| 114 | static inline int classify4(QStringView s, int parseModeFlags) { |
| 115 | if (s[0].unicode() == 'b') { |
| 116 | if (s[1].unicode() == 'y') { |
| 117 | if (s[2].unicode() == 't') { |
| 118 | if (s[3].unicode() == 'e') { |
| 119 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_BYTE) : int(Lexer::T_IDENTIFIER); |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | else if (s[0].unicode() == 'c') { |
| 125 | if (s[1].unicode() == 'a') { |
| 126 | if (s[2].unicode() == 's') { |
| 127 | if (s[3].unicode() == 'e') { |
| 128 | return Lexer::T_CASE; |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | else if (s[1].unicode() == 'h') { |
| 133 | if (s[2].unicode() == 'a') { |
| 134 | if (s[3].unicode() == 'r') { |
| 135 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_CHAR) : int(Lexer::T_IDENTIFIER); |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | else if (s[0].unicode() == 'e') { |
| 141 | if (s[1].unicode() == 'l') { |
| 142 | if (s[2].unicode() == 's') { |
| 143 | if (s[3].unicode() == 'e') { |
| 144 | return Lexer::T_ELSE; |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | else if (s[1].unicode() == 'n') { |
| 149 | if (s[2].unicode() == 'u') { |
| 150 | if (s[3].unicode() == 'm') { |
| 151 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_ENUM) : int(Lexer::T_RESERVED_WORD); |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | else if (s[0].unicode() == 'f') { |
| 157 | if (s[1].unicode() == 'r') { |
| 158 | if (s[2].unicode() == 'o') { |
| 159 | if (s[3].unicode() == 'm') { |
| 160 | return int(Lexer::T_FROM); |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | else if (s[0].unicode() == 'g') { |
| 166 | if (s[1].unicode() == 'o') { |
| 167 | if (s[2].unicode() == 't') { |
| 168 | if (s[3].unicode() == 'o') { |
| 169 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_GOTO) : int(Lexer::T_IDENTIFIER); |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | else if (s[0].unicode() == 'l') { |
| 175 | if (s[1].unicode() == 'o') { |
| 176 | if (s[2].unicode() == 'n') { |
| 177 | if (s[3].unicode() == 'g') { |
| 178 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_LONG) : int(Lexer::T_IDENTIFIER); |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | else if (s[0].unicode() == 'n') { |
| 184 | if (s[1].unicode() == 'u') { |
| 185 | if (s[2].unicode() == 'l') { |
| 186 | if (s[3].unicode() == 'l') { |
| 187 | return Lexer::T_NULL; |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | } |
| 192 | else if (s[0].unicode() == 't') { |
| 193 | if (s[1].unicode() == 'h') { |
| 194 | if (s[2].unicode() == 'i') { |
| 195 | if (s[3].unicode() == 's') { |
| 196 | return Lexer::T_THIS; |
| 197 | } |
| 198 | } |
| 199 | } |
| 200 | else if (s[1].unicode() == 'r') { |
| 201 | if (s[2].unicode() == 'u') { |
| 202 | if (s[3].unicode() == 'e') { |
| 203 | return Lexer::T_TRUE; |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | else if (s[0].unicode() == 'v') { |
| 209 | if (s[1].unicode() == 'o') { |
| 210 | if (s[2].unicode() == 'i') { |
| 211 | if (s[3].unicode() == 'd') { |
| 212 | return Lexer::T_VOID; |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | else if (s[0].unicode() == 'w') { |
| 218 | if (s[1].unicode() == 'i') { |
| 219 | if (s[2].unicode() == 't') { |
| 220 | if (s[3].unicode() == 'h') { |
| 221 | return Lexer::T_WITH; |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | return Lexer::T_IDENTIFIER; |
| 227 | } |
| 228 | |
| 229 | static inline int classify5(QStringView s, int parseModeFlags) { |
| 230 | if (s[0].unicode() == 'b') { |
| 231 | if (s[1].unicode() == 'r') { |
| 232 | if (s[2].unicode() == 'e') { |
| 233 | if (s[3].unicode() == 'a') { |
| 234 | if (s[4].unicode() == 'k') { |
| 235 | return Lexer::T_BREAK; |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | else if (s[0].unicode() == 'c') { |
| 242 | if (s[1].unicode() == 'a') { |
| 243 | if (s[2].unicode() == 't') { |
| 244 | if (s[3].unicode() == 'c') { |
| 245 | if (s[4].unicode() == 'h') { |
| 246 | return Lexer::T_CATCH; |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | else if (s[1].unicode() == 'l') { |
| 252 | if (s[2].unicode() == 'a') { |
| 253 | if (s[3].unicode() == 's') { |
| 254 | if (s[4].unicode() == 's') { |
| 255 | return Lexer::T_CLASS; |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | } |
| 260 | else if (s[1].unicode() == 'o') { |
| 261 | if (s[2].unicode() == 'n') { |
| 262 | if (s[3].unicode() == 's') { |
| 263 | if (s[4].unicode() == 't') { |
| 264 | return int(Lexer::T_CONST); |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | else if (s[0].unicode() == 'f') { |
| 271 | if (s[1].unicode() == 'a') { |
| 272 | if (s[2].unicode() == 'l') { |
| 273 | if (s[3].unicode() == 's') { |
| 274 | if (s[4].unicode() == 'e') { |
| 275 | return Lexer::T_FALSE; |
| 276 | } |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | else if (s[1].unicode() == 'i') { |
| 281 | if (s[2].unicode() == 'n') { |
| 282 | if (s[3].unicode() == 'a') { |
| 283 | if (s[4].unicode() == 'l') { |
| 284 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_FINAL) : int(Lexer::T_IDENTIFIER); |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | else if (s[1].unicode() == 'l') { |
| 290 | if (s[2].unicode() == 'o') { |
| 291 | if (s[3].unicode() == 'a') { |
| 292 | if (s[4].unicode() == 't') { |
| 293 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_FLOAT) : int(Lexer::T_IDENTIFIER); |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | else if (s[0].unicode() == 's') { |
| 300 | if (s[1].unicode() == 'h') { |
| 301 | if (s[2].unicode() == 'o') { |
| 302 | if (s[3].unicode() == 'r') { |
| 303 | if (s[4].unicode() == 't') { |
| 304 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_SHORT) : int(Lexer::T_IDENTIFIER); |
| 305 | } |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | else if (s[1].unicode() == 'u') { |
| 310 | if (s[2].unicode() == 'p') { |
| 311 | if (s[3].unicode() == 'e') { |
| 312 | if (s[4].unicode() == 'r') { |
| 313 | return int(Lexer::T_SUPER); |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | else if (s[0].unicode() == 't') { |
| 320 | if (s[1].unicode() == 'h') { |
| 321 | if (s[2].unicode() == 'r') { |
| 322 | if (s[3].unicode() == 'o') { |
| 323 | if (s[4].unicode() == 'w') { |
| 324 | return Lexer::T_THROW; |
| 325 | } |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | else if (s[0].unicode() == 'w') { |
| 331 | if (s[1].unicode() == 'h') { |
| 332 | if (s[2].unicode() == 'i') { |
| 333 | if (s[3].unicode() == 'l') { |
| 334 | if (s[4].unicode() == 'e') { |
| 335 | return Lexer::T_WHILE; |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | else if (s[0].unicode() == 'y') { |
| 342 | if (s[1].unicode() == 'i') { |
| 343 | if (s[2].unicode() == 'e') { |
| 344 | if (s[3].unicode() == 'l') { |
| 345 | if (s[4].unicode() == 'd') { |
| 346 | return (parseModeFlags & Lexer::YieldIsKeyword) ? Lexer::T_YIELD : Lexer::T_IDENTIFIER; |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | return Lexer::T_IDENTIFIER; |
| 353 | } |
| 354 | |
| 355 | static inline int classify6(QStringView s, int parseModeFlags) { |
| 356 | if (s[0].unicode() == 'd') { |
| 357 | if (s[1].unicode() == 'e') { |
| 358 | if (s[2].unicode() == 'l') { |
| 359 | if (s[3].unicode() == 'e') { |
| 360 | if (s[4].unicode() == 't') { |
| 361 | if (s[5].unicode() == 'e') { |
| 362 | return Lexer::T_DELETE; |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | } |
| 368 | else if (s[1].unicode() == 'o') { |
| 369 | if (s[2].unicode() == 'u') { |
| 370 | if (s[3].unicode() == 'b') { |
| 371 | if (s[4].unicode() == 'l') { |
| 372 | if (s[5].unicode() == 'e') { |
| 373 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_DOUBLE) : int(Lexer::T_IDENTIFIER); |
| 374 | } |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | else if (s[0].unicode() == 'e') { |
| 381 | if (s[1].unicode() == 'x') { |
| 382 | if (s[2].unicode() == 'p') { |
| 383 | if (s[3].unicode() == 'o') { |
| 384 | if (s[4].unicode() == 'r') { |
| 385 | if (s[5].unicode() == 't') { |
| 386 | return Lexer::T_EXPORT; |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | else if (s[0].unicode() == 'i') { |
| 394 | if (s[1].unicode() == 'm') { |
| 395 | if (s[2].unicode() == 'p') { |
| 396 | if (s[3].unicode() == 'o') { |
| 397 | if (s[4].unicode() == 'r') { |
| 398 | if (s[5].unicode() == 't') { |
| 399 | return Lexer::T_IMPORT; |
| 400 | } |
| 401 | } |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | } |
| 406 | else if (s[0].unicode() == 'n') { |
| 407 | if (s[1].unicode() == 'a') { |
| 408 | if (s[2].unicode() == 't') { |
| 409 | if (s[3].unicode() == 'i') { |
| 410 | if (s[4].unicode() == 'v') { |
| 411 | if (s[5].unicode() == 'e') { |
| 412 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_NATIVE) : int(Lexer::T_IDENTIFIER); |
| 413 | } |
| 414 | } |
| 415 | } |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | else if (s[0].unicode() == 'p') { |
| 420 | if (s[1].unicode() == 'u') { |
| 421 | if (s[2].unicode() == 'b') { |
| 422 | if (s[3].unicode() == 'l') { |
| 423 | if (s[4].unicode() == 'i') { |
| 424 | if (s[5].unicode() == 'c') { |
| 425 | return (parseModeFlags & Lexer::QmlMode) ? Lexer::T_PUBLIC : Lexer::T_IDENTIFIER; |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | } |
| 430 | } |
| 431 | else if (s[1].unicode() == 'r') { |
| 432 | if (s[2].unicode() == 'a') { |
| 433 | if (s[3].unicode() == 'g') { |
| 434 | if (s[4].unicode() == 'm') { |
| 435 | if (s[5].unicode() == 'a') { |
| 436 | return (parseModeFlags & Lexer::QmlMode) ? Lexer::T_PRAGMA : Lexer::T_IDENTIFIER; |
| 437 | } |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | } |
| 442 | } |
| 443 | else if (s[0].unicode() == 'r') { |
| 444 | if (s[1].unicode() == 'e') { |
| 445 | if (s[2].unicode() == 't') { |
| 446 | if (s[3].unicode() == 'u') { |
| 447 | if (s[4].unicode() == 'r') { |
| 448 | if (s[5].unicode() == 'n') { |
| 449 | return Lexer::T_RETURN; |
| 450 | } |
| 451 | } |
| 452 | } |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | else if (s[0].unicode() == 's') { |
| 457 | if ((parseModeFlags & Lexer::QmlMode) && s[1].unicode() == 'i') { |
| 458 | if (s[2].unicode() == 'g') { |
| 459 | if (s[3].unicode() == 'n') { |
| 460 | if (s[4].unicode() == 'a') { |
| 461 | if (s[5].unicode() == 'l') { |
| 462 | return Lexer::T_SIGNAL; |
| 463 | } |
| 464 | } |
| 465 | } |
| 466 | } |
| 467 | } |
| 468 | else if (s[1].unicode() == 't') { |
| 469 | if (s[2].unicode() == 'a') { |
| 470 | if (s[3].unicode() == 't') { |
| 471 | if (s[4].unicode() == 'i') { |
| 472 | if (s[5].unicode() == 'c') { |
| 473 | return (parseModeFlags & Lexer::StaticIsKeyword) ? int(Lexer::T_STATIC) : int(Lexer::T_IDENTIFIER); |
| 474 | } |
| 475 | } |
| 476 | } |
| 477 | } |
| 478 | } |
| 479 | else if (s[1].unicode() == 'w') { |
| 480 | if (s[2].unicode() == 'i') { |
| 481 | if (s[3].unicode() == 't') { |
| 482 | if (s[4].unicode() == 'c') { |
| 483 | if (s[5].unicode() == 'h') { |
| 484 | return Lexer::T_SWITCH; |
| 485 | } |
| 486 | } |
| 487 | } |
| 488 | } |
| 489 | } |
| 490 | } |
| 491 | else if (s[0].unicode() == 't') { |
| 492 | if (s[1].unicode() == 'h') { |
| 493 | if (s[2].unicode() == 'r') { |
| 494 | if (s[3].unicode() == 'o') { |
| 495 | if (s[4].unicode() == 'w') { |
| 496 | if (s[5].unicode() == 's') { |
| 497 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_THROWS) : int(Lexer::T_IDENTIFIER); |
| 498 | } |
| 499 | } |
| 500 | } |
| 501 | } |
| 502 | } |
| 503 | else if (s[1].unicode() == 'y') { |
| 504 | if (s[2].unicode() == 'p') { |
| 505 | if (s[3].unicode() == 'e') { |
| 506 | if (s[4].unicode() == 'o') { |
| 507 | if (s[5].unicode() == 'f') { |
| 508 | return Lexer::T_TYPEOF; |
| 509 | } |
| 510 | } |
| 511 | } |
| 512 | } |
| 513 | } |
| 514 | } |
| 515 | return Lexer::T_IDENTIFIER; |
| 516 | } |
| 517 | |
| 518 | static inline int classify7(QStringView s, int parseModeFlags) { |
| 519 | if (s[0].unicode() == 'b') { |
| 520 | if (s[1].unicode() == 'o') { |
| 521 | if (s[2].unicode() == 'o') { |
| 522 | if (s[3].unicode() == 'l') { |
| 523 | if (s[4].unicode() == 'e') { |
| 524 | if (s[5].unicode() == 'a') { |
| 525 | if (s[6].unicode() == 'n') { |
| 526 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_BOOLEAN) : int(Lexer::T_IDENTIFIER); |
| 527 | } |
| 528 | } |
| 529 | } |
| 530 | } |
| 531 | } |
| 532 | } |
| 533 | } |
| 534 | else if (s[0].unicode() == 'd') { |
| 535 | if (s[1].unicode() == 'e') { |
| 536 | if (s[2].unicode() == 'f') { |
| 537 | if (s[3].unicode() == 'a') { |
| 538 | if (s[4].unicode() == 'u') { |
| 539 | if (s[5].unicode() == 'l') { |
| 540 | if (s[6].unicode() == 't') { |
| 541 | return Lexer::T_DEFAULT; |
| 542 | } |
| 543 | } |
| 544 | } |
| 545 | } |
| 546 | } |
| 547 | } |
| 548 | } |
| 549 | else if (s[0].unicode() == 'e') { |
| 550 | if (s[1].unicode() == 'x') { |
| 551 | if (s[2].unicode() == 't') { |
| 552 | if (s[3].unicode() == 'e') { |
| 553 | if (s[4].unicode() == 'n') { |
| 554 | if (s[5].unicode() == 'd') { |
| 555 | if (s[6].unicode() == 's') { |
| 556 | return Lexer::T_EXTENDS; |
| 557 | } |
| 558 | } |
| 559 | } |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | else if (s[0].unicode() == 'f') { |
| 565 | if (s[1].unicode() == 'i') { |
| 566 | if (s[2].unicode() == 'n') { |
| 567 | if (s[3].unicode() == 'a') { |
| 568 | if (s[4].unicode() == 'l') { |
| 569 | if (s[5].unicode() == 'l') { |
| 570 | if (s[6].unicode() == 'y') { |
| 571 | return Lexer::T_FINALLY; |
| 572 | } |
| 573 | } |
| 574 | } |
| 575 | } |
| 576 | } |
| 577 | } |
| 578 | } |
| 579 | else if (s[0].unicode() == 'p') { |
| 580 | if (s[1].unicode() == 'a') { |
| 581 | if (s[2].unicode() == 'c') { |
| 582 | if (s[3].unicode() == 'k') { |
| 583 | if (s[4].unicode() == 'a') { |
| 584 | if (s[5].unicode() == 'g') { |
| 585 | if (s[6].unicode() == 'e') { |
| 586 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_PACKAGE) : int(Lexer::T_IDENTIFIER); |
| 587 | } |
| 588 | } |
| 589 | } |
| 590 | } |
| 591 | } |
| 592 | } |
| 593 | else if (s[1].unicode() == 'r') { |
| 594 | if (s[2].unicode() == 'i') { |
| 595 | if (s[3].unicode() == 'v') { |
| 596 | if (s[4].unicode() == 'a') { |
| 597 | if (s[5].unicode() == 't') { |
| 598 | if (s[6].unicode() == 'e') { |
| 599 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_PRIVATE) : int(Lexer::T_IDENTIFIER); |
| 600 | } |
| 601 | } |
| 602 | } |
| 603 | } |
| 604 | } |
| 605 | } |
| 606 | } |
| 607 | return Lexer::T_IDENTIFIER; |
| 608 | } |
| 609 | |
| 610 | static inline int classify8(QStringView s, int parseModeFlags) { |
| 611 | if (s[0].unicode() == 'a') { |
| 612 | if (s[1].unicode() == 'b') { |
| 613 | if (s[2].unicode() == 's') { |
| 614 | if (s[3].unicode() == 't') { |
| 615 | if (s[4].unicode() == 'r') { |
| 616 | if (s[5].unicode() == 'a') { |
| 617 | if (s[6].unicode() == 'c') { |
| 618 | if (s[7].unicode() == 't') { |
| 619 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_ABSTRACT) : int(Lexer::T_IDENTIFIER); |
| 620 | } |
| 621 | } |
| 622 | } |
| 623 | } |
| 624 | } |
| 625 | } |
| 626 | } |
| 627 | } |
| 628 | else if (s[0].unicode() == 'c') { |
| 629 | if (s[1].unicode() == 'o') { |
| 630 | if (s[2].unicode() == 'n') { |
| 631 | if (s[3].unicode() == 't') { |
| 632 | if (s[4].unicode() == 'i') { |
| 633 | if (s[5].unicode() == 'n') { |
| 634 | if (s[6].unicode() == 'u') { |
| 635 | if (s[7].unicode() == 'e') { |
| 636 | return Lexer::T_CONTINUE; |
| 637 | } |
| 638 | } |
| 639 | } |
| 640 | } |
| 641 | } |
| 642 | } |
| 643 | } |
| 644 | } |
| 645 | else if (s[0].unicode() == 'd') { |
| 646 | if (s[1].unicode() == 'e') { |
| 647 | if (s[2].unicode() == 'b') { |
| 648 | if (s[3].unicode() == 'u') { |
| 649 | if (s[4].unicode() == 'g') { |
| 650 | if (s[5].unicode() == 'g') { |
| 651 | if (s[6].unicode() == 'e') { |
| 652 | if (s[7].unicode() == 'r') { |
| 653 | return Lexer::T_DEBUGGER; |
| 654 | } |
| 655 | } |
| 656 | } |
| 657 | } |
| 658 | } |
| 659 | } |
| 660 | } |
| 661 | } |
| 662 | else if (s[0].unicode() == 'f') { |
| 663 | if (s[1].unicode() == 'u') { |
| 664 | if (s[2].unicode() == 'n') { |
| 665 | if (s[3].unicode() == 'c') { |
| 666 | if (s[4].unicode() == 't') { |
| 667 | if (s[5].unicode() == 'i') { |
| 668 | if (s[6].unicode() == 'o') { |
| 669 | if (s[7].unicode() == 'n') { |
| 670 | return Lexer::T_FUNCTION; |
| 671 | } |
| 672 | } |
| 673 | } |
| 674 | } |
| 675 | } |
| 676 | } |
| 677 | } |
| 678 | } |
| 679 | else if ((parseModeFlags & Lexer::QmlMode) && s[0].unicode() == 'p') { |
| 680 | if (s[1].unicode() == 'r') { |
| 681 | if (s[2].unicode() == 'o') { |
| 682 | if (s[3].unicode() == 'p') { |
| 683 | if (s[4].unicode() == 'e') { |
| 684 | if (s[5].unicode() == 'r') { |
| 685 | if (s[6].unicode() == 't') { |
| 686 | if (s[7].unicode() == 'y') { |
| 687 | return Lexer::T_PROPERTY; |
| 688 | } |
| 689 | } |
| 690 | } |
| 691 | } |
| 692 | } |
| 693 | } |
| 694 | } |
| 695 | } |
| 696 | else if ((parseModeFlags & Lexer::QmlMode) && s[0].unicode() == 'r') { |
| 697 | if (s[1].unicode() == 'e') { |
| 698 | if (s[2].unicode() == 'a') { |
| 699 | if (s[3].unicode() == 'd') { |
| 700 | if (s[4].unicode() == 'o') { |
| 701 | if (s[5].unicode() == 'n') { |
| 702 | if (s[6].unicode() == 'l') { |
| 703 | if (s[7].unicode() == 'y') { |
| 704 | return Lexer::T_READONLY; |
| 705 | } |
| 706 | } |
| 707 | } |
| 708 | } |
| 709 | } |
| 710 | } else if (s[2].unicode() == 'q') { |
| 711 | if (s[3].unicode() == 'u') { |
| 712 | if (s[4].unicode() == 'i') { |
| 713 | if (s[5].unicode() == 'r') { |
| 714 | if (s[6].unicode() == 'e') { |
| 715 | if (s[7].unicode() == 'd') { |
| 716 | return Lexer::T_REQUIRED; |
| 717 | } |
| 718 | } |
| 719 | } |
| 720 | } |
| 721 | } |
| 722 | } |
| 723 | } |
| 724 | } |
| 725 | else if (s[0].unicode() == 'v') { |
| 726 | if (s[1].unicode() == 'o') { |
| 727 | if (s[2].unicode() == 'l') { |
| 728 | if (s[3].unicode() == 'a') { |
| 729 | if (s[4].unicode() == 't') { |
| 730 | if (s[5].unicode() == 'i') { |
| 731 | if (s[6].unicode() == 'l') { |
| 732 | if (s[7].unicode() == 'e') { |
| 733 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_VOLATILE) : int(Lexer::T_IDENTIFIER); |
| 734 | } |
| 735 | } |
| 736 | } |
| 737 | } |
| 738 | } |
| 739 | } |
| 740 | } |
| 741 | } |
| 742 | return Lexer::T_IDENTIFIER; |
| 743 | } |
| 744 | |
| 745 | static inline int classify9(QStringView s, int parseModeFlags) { |
| 746 | if (s[0].unicode() == 'i') { |
| 747 | if (s[1].unicode() == 'n') { |
| 748 | if (s[2].unicode() == 't') { |
| 749 | if (s[3].unicode() == 'e') { |
| 750 | if (s[4].unicode() == 'r') { |
| 751 | if (s[5].unicode() == 'f') { |
| 752 | if (s[6].unicode() == 'a') { |
| 753 | if (s[7].unicode() == 'c') { |
| 754 | if (s[8].unicode() == 'e') { |
| 755 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_INTERFACE) : int(Lexer::T_IDENTIFIER); |
| 756 | } |
| 757 | } |
| 758 | } |
| 759 | } |
| 760 | } |
| 761 | } |
| 762 | } |
| 763 | } |
| 764 | } |
| 765 | else if (s[0].unicode() == 'p') { |
| 766 | if (s[1].unicode() == 'r') { |
| 767 | if (s[2].unicode() == 'o') { |
| 768 | if (s[3].unicode() == 't') { |
| 769 | if (s[4].unicode() == 'e') { |
| 770 | if (s[5].unicode() == 'c') { |
| 771 | if (s[6].unicode() == 't') { |
| 772 | if (s[7].unicode() == 'e') { |
| 773 | if (s[8].unicode() == 'd') { |
| 774 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_PROTECTED) : int(Lexer::T_IDENTIFIER); |
| 775 | } |
| 776 | } |
| 777 | } |
| 778 | } |
| 779 | } |
| 780 | } |
| 781 | } |
| 782 | } |
| 783 | } |
| 784 | else if (s[0].unicode() == 't') { |
| 785 | if (s[1].unicode() == 'r') { |
| 786 | if (s[2].unicode() == 'a') { |
| 787 | if (s[3].unicode() == 'n') { |
| 788 | if (s[4].unicode() == 's') { |
| 789 | if (s[5].unicode() == 'i') { |
| 790 | if (s[6].unicode() == 'e') { |
| 791 | if (s[7].unicode() == 'n') { |
| 792 | if (s[8].unicode() == 't') { |
| 793 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_TRANSIENT) : int(Lexer::T_IDENTIFIER); |
| 794 | } |
| 795 | } |
| 796 | } |
| 797 | } |
| 798 | } |
| 799 | } |
| 800 | } |
| 801 | } |
| 802 | } |
| 803 | else if (s[0].unicode() == 'c') { |
| 804 | if (s[1].unicode() == 'o') { |
| 805 | if (s[2].unicode() == 'm') { |
| 806 | if (s[3].unicode() == 'p') { |
| 807 | if (s[4].unicode() == 'o') { |
| 808 | if (s[5].unicode() == 'n') { |
| 809 | if (s[6].unicode() == 'e') { |
| 810 | if (s[7].unicode() == 'n') { |
| 811 | if (s[8].unicode() == 't') { |
| 812 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_COMPONENT) : int(Lexer::T_IDENTIFIER); |
| 813 | } |
| 814 | } |
| 815 | } |
| 816 | } |
| 817 | } |
| 818 | } |
| 819 | } |
| 820 | } |
| 821 | } |
| 822 | return Lexer::T_IDENTIFIER; |
| 823 | } |
| 824 | |
| 825 | static inline int classify10(QStringView s, int parseModeFlags) { |
| 826 | if (s[0].unicode() == 'i') { |
| 827 | if (s[1].unicode() == 'm') { |
| 828 | if (s[2].unicode() == 'p') { |
| 829 | if (s[3].unicode() == 'l') { |
| 830 | if (s[4].unicode() == 'e') { |
| 831 | if (s[5].unicode() == 'm') { |
| 832 | if (s[6].unicode() == 'e') { |
| 833 | if (s[7].unicode() == 'n') { |
| 834 | if (s[8].unicode() == 't') { |
| 835 | if (s[9].unicode() == 's') { |
| 836 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_IMPLEMENTS) : int(Lexer::T_IDENTIFIER); |
| 837 | } |
| 838 | } |
| 839 | } |
| 840 | } |
| 841 | } |
| 842 | } |
| 843 | } |
| 844 | } |
| 845 | } |
| 846 | else if (s[1].unicode() == 'n') { |
| 847 | if (s[2].unicode() == 's') { |
| 848 | if (s[3].unicode() == 't') { |
| 849 | if (s[4].unicode() == 'a') { |
| 850 | if (s[5].unicode() == 'n') { |
| 851 | if (s[6].unicode() == 'c') { |
| 852 | if (s[7].unicode() == 'e') { |
| 853 | if (s[8].unicode() == 'o') { |
| 854 | if (s[9].unicode() == 'f') { |
| 855 | return Lexer::T_INSTANCEOF; |
| 856 | } |
| 857 | } |
| 858 | } |
| 859 | } |
| 860 | } |
| 861 | } |
| 862 | } |
| 863 | } |
| 864 | } |
| 865 | } |
| 866 | return Lexer::T_IDENTIFIER; |
| 867 | } |
| 868 | |
| 869 | static inline int classify12(QStringView s, int parseModeFlags) { |
| 870 | if (s[0].unicode() == 's') { |
| 871 | if (s[1].unicode() == 'y') { |
| 872 | if (s[2].unicode() == 'n') { |
| 873 | if (s[3].unicode() == 'c') { |
| 874 | if (s[4].unicode() == 'h') { |
| 875 | if (s[5].unicode() == 'r') { |
| 876 | if (s[6].unicode() == 'o') { |
| 877 | if (s[7].unicode() == 'n') { |
| 878 | if (s[8].unicode() == 'i') { |
| 879 | if (s[9].unicode() == 'z') { |
| 880 | if (s[10].unicode() == 'e') { |
| 881 | if (s[11].unicode() == 'd') { |
| 882 | return (parseModeFlags & Lexer::QmlMode) ? int(Lexer::T_SYNCHRONIZED) : int(Lexer::T_IDENTIFIER); |
| 883 | } |
| 884 | } |
| 885 | } |
| 886 | } |
| 887 | } |
| 888 | } |
| 889 | } |
| 890 | } |
| 891 | } |
| 892 | } |
| 893 | } |
| 894 | } |
| 895 | return Lexer::T_IDENTIFIER; |
| 896 | } |
| 897 | |
| 898 | int Lexer::classify(QStringView s, int parseModeFlags) { |
| 899 | switch (s.size()) { |
| 900 | case 2: return classify2(s, parseModeFlags); |
| 901 | case 3: return classify3(s, parseModeFlags); |
| 902 | case 4: return classify4(s, parseModeFlags); |
| 903 | case 5: return classify5(s, parseModeFlags); |
| 904 | case 6: return classify6(s, parseModeFlags); |
| 905 | case 7: return classify7(s, parseModeFlags); |
| 906 | case 8: return classify8(s, parseModeFlags); |
| 907 | case 9: return classify9(s, parseModeFlags); |
| 908 | case 10: return classify10(s, parseModeFlags); |
| 909 | case 12: return classify12(s, parseModeFlags); |
| 910 | default: return Lexer::T_IDENTIFIER; |
| 911 | } // switch |
| 912 | } |
| 913 | |
| 914 | } // namespace QQmlJS |
| 915 | |
| 916 | QT_END_NAMESPACE |
| 917 | |
| 918 | #endif // QQMLJSKEYWORDS_P_H |
| 919 | |