MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / llex

Function llex

third-party/lua-5.5.0/src/llex.c:467–585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465
466
467static 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 }

Callers 2

luaX_nextFunction · 0.70
luaX_lookaheadFunction · 0.70

Calls 9

anchorstrFunction · 0.85
inclinenumberFunction · 0.70
skip_sepFunction · 0.70
read_long_stringFunction · 0.70
lexerrorFunction · 0.70
check_next1Function · 0.70
read_stringFunction · 0.70
read_numeralFunction · 0.70
luaS_newlstrFunction · 0.70

Tested by

no test coverage detected