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

Function llex

third-party/lua-5.3.5/src/llex.c:429–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427
428
429static int llex (LexState *ls, SemInfo *seminfo) {
430 luaZ_resetbuffer(ls->buff);
431 for (;;) {
432 switch (ls->current) {
433 case '\n': case '\r': { /* line breaks */
434 inclinenumber(ls);
435 break;
436 }
437 case ' ': case '\f': case '\t': case '\v': { /* spaces */
438 next(ls);
439 break;
440 }
441 case '-': { /* '-' or '--' (comment) */
442 next(ls);
443 if (ls->current != '-') return '-';
444 /* else is a comment */
445 next(ls);
446 if (ls->current == '[') { /* long comment? */
447 int sep = skip_sep(ls);
448 luaZ_resetbuffer(ls->buff); /* 'skip_sep' may dirty the buffer */
449 if (sep >= 0) {
450 read_long_string(ls, NULL, sep); /* skip long comment */
451 luaZ_resetbuffer(ls->buff); /* previous call may dirty the buff. */
452 break;
453 }
454 }
455 /* else short comment */
456 while (!currIsNewline(ls) && ls->current != EOZ)
457 next(ls); /* skip until end of line (or end of file) */
458 break;
459 }
460 case '[': { /* long string or simply '[' */
461 int sep = skip_sep(ls);
462 if (sep >= 0) {
463 read_long_string(ls, seminfo, sep);
464 return TK_STRING;
465 }
466 else if (sep != -1) /* '[=...' missing second bracket */
467 lexerror(ls, "invalid long string delimiter", TK_STRING);
468 return '[';
469 }
470 case '=': {
471 next(ls);
472 if (check_next1(ls, '=')) return TK_EQ;
473 else return '=';
474 }
475 case '<': {
476 next(ls);
477 if (check_next1(ls, '=')) return TK_LE;
478 else if (check_next1(ls, '<')) return TK_SHL;
479 else return '<';
480 }
481 case '>': {
482 next(ls);
483 if (check_next1(ls, '=')) return TK_GE;
484 else if (check_next1(ls, '>')) return TK_SHR;
485 else return '>';
486 }

Callers 2

luaX_nextFunction · 0.70
luaX_lookaheadFunction · 0.70

Calls 8

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
luaX_newstringFunction · 0.70

Tested by

no test coverage detected