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