| 461 | |
| 462 | |
| 463 | static int llex(LexState *ls, SemInfo *seminfo) { |
| 464 | luaZ_resetbuffer(ls->buff); |
| 465 | for (;;) { |
| 466 | switch (ls->current) { |
| 467 | case '\n': case '\r': { /* line breaks */ |
| 468 | inclinenumber(ls); |
| 469 | break; |
| 470 | } |
| 471 | case ' ': case '\f': case '\t': case '\v': { /* spaces */ |
| 472 | next(ls); |
| 473 | break; |
| 474 | } |
| 475 | case '-': { /* '-' or '--' (comment) */ |
| 476 | next(ls); |
| 477 | if (ls->current != '-') return '-'; |
| 478 | /* else is a comment */ |
| 479 | next(ls); |
| 480 | if (ls->current == '[') { /* long comment? */ |
| 481 | int sep = skip_sep(ls); |
| 482 | luaZ_resetbuffer(ls->buff); /* 'skip_sep' may dirty the buffer */ |
| 483 | if (sep >= 0) { |
| 484 | read_long_string(ls, nullptr, sep); /* skip long comment */ |
| 485 | luaZ_resetbuffer(ls->buff); /* previous call may dirty the buff. */ |
| 486 | break; |
| 487 | } |
| 488 | } |
| 489 | /* else short comment */ |
| 490 | while (!currIsNewline(ls) && ls->current != EOZ) |
| 491 | next(ls); /* skip until end of line (or end of file) */ |
| 492 | break; |
| 493 | } |
| 494 | case '[': { /* long string or simply '[' */ |
| 495 | int sep = skip_sep(ls); |
| 496 | if (sep >= 0) { |
| 497 | read_long_string(ls, seminfo, sep); |
| 498 | return TK_STRING; |
| 499 | } |
| 500 | else if (sep != -1) /* '[=...' missing second bracket */ |
| 501 | lexerror(ls, "invalid long string delimiter", TK_STRING); |
| 502 | return '['; |
| 503 | } |
| 504 | case '=': { |
| 505 | next(ls); |
| 506 | if (check_next1(ls, '=')) return TK_EQ; |
| 507 | else return '='; |
| 508 | } |
| 509 | case '<': { |
| 510 | next(ls); |
| 511 | if (check_next1(ls, '=')) return TK_LE; |
| 512 | else if (check_next1(ls, '<')) return TK_SHL; |
| 513 | else return '<'; |
| 514 | } |
| 515 | case '>': { |
| 516 | next(ls); |
| 517 | if (check_next1(ls, '=')) return TK_GE; |
| 518 | else if (check_next1(ls, '>')) return TK_SHR; |
| 519 | else return '>'; |
| 520 | } |
no test coverage detected