MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / llex

Function llex

3rd/lua-5.4.3/src/llex.c:445–562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443
444
445static int llex (LexState *ls, SemInfo *seminfo) {
446 luaZ_resetbuffer(ls->buff);
447 for (;;) {
448 switch (ls->current) {
449 case '\n': case '\r': { /* line breaks */
450 inclinenumber(ls);
451 break;
452 }
453 case ' ': case '\f': case '\t': case '\v': { /* spaces */
454 next(ls);
455 break;
456 }
457 case '-': { /* '-' or '--' (comment) */
458 next(ls);
459 if (ls->current != '-') return '-';
460 /* else is a comment */
461 next(ls);
462 if (ls->current == '[') { /* long comment? */
463 size_t sep = skip_sep(ls);
464 luaZ_resetbuffer(ls->buff); /* 'skip_sep' may dirty the buffer */
465 if (sep >= 2) {
466 read_long_string(ls, NULL, sep); /* skip long comment */
467 luaZ_resetbuffer(ls->buff); /* previous call may dirty the buff. */
468 break;
469 }
470 }
471 /* else short comment */
472 while (!currIsNewline(ls) && ls->current != EOZ)
473 next(ls); /* skip until end of line (or end of file) */
474 break;
475 }
476 case '[': { /* long string or simply '[' */
477 size_t sep = skip_sep(ls);
478 if (sep >= 2) {
479 read_long_string(ls, seminfo, sep);
480 return TK_STRING;
481 }
482 else if (sep == 0) /* '[=...' missing second bracket? */
483 lexerror(ls, "invalid long string delimiter", TK_STRING);
484 return '[';
485 }
486 case '=': {
487 next(ls);
488 if (check_next1(ls, '=')) return TK_EQ; /* '==' */
489 else return '=';
490 }
491 case '<': {
492 next(ls);
493 if (check_next1(ls, '=')) return TK_LE; /* '<=' */
494 else if (check_next1(ls, '<')) return TK_SHL; /* '<<' */
495 else return '<';
496 }
497 case '>': {
498 next(ls);
499 if (check_next1(ls, '=')) return TK_GE; /* '>=' */
500 else if (check_next1(ls, '>')) return TK_SHR; /* '>>' */
501 else return '>';
502 }

Callers 2

luaX_nextFunction · 0.85
luaX_lookaheadFunction · 0.85

Calls 9

inclinenumberFunction · 0.85
nextFunction · 0.85
skip_sepFunction · 0.85
read_long_stringFunction · 0.85
lexerrorFunction · 0.85
check_next1Function · 0.85
read_stringFunction · 0.85
read_numeralFunction · 0.85
luaX_newstringFunction · 0.85

Tested by

no test coverage detected