| 336 | |
| 337 | |
| 338 | static int llex (LexState *ls, SemInfo *seminfo) { |
| 339 | luaZ_resetbuffer(ls->buff); |
| 340 | for (;;) { |
| 341 | switch (ls->current) { |
| 342 | case '\n': |
| 343 | case '\r': { |
| 344 | inclinenumber(ls); |
| 345 | continue; |
| 346 | } |
| 347 | case '-': { |
| 348 | next(ls); |
| 349 | if (ls->current != '-') return '-'; |
| 350 | /* else is a comment */ |
| 351 | next(ls); |
| 352 | if (ls->current == '[') { |
| 353 | size_t sep = skip_sep(ls); |
| 354 | luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */ |
| 355 | if (sep >= 2) { |
| 356 | read_long_string(ls, NULL, sep); /* long comment */ |
| 357 | luaZ_resetbuffer(ls->buff); |
| 358 | continue; |
| 359 | } |
| 360 | } |
| 361 | /* else short comment */ |
| 362 | while (!currIsNewline(ls) && ls->current != EOZ) |
| 363 | next(ls); |
| 364 | continue; |
| 365 | } |
| 366 | case '[': { |
| 367 | size_t sep = skip_sep(ls); |
| 368 | if (sep >= 2) { |
| 369 | read_long_string(ls, seminfo, sep); |
| 370 | return TK_STRING; |
| 371 | } |
| 372 | else if (sep == 0) /* '[=...' missing second bracket */ |
| 373 | luaX_lexerror(ls, "invalid long string delimiter", TK_STRING); |
| 374 | return '['; |
| 375 | } |
| 376 | case '=': { |
| 377 | next(ls); |
| 378 | if (ls->current != '=') return '='; |
| 379 | else { next(ls); return TK_EQ; } |
| 380 | } |
| 381 | case '<': { |
| 382 | next(ls); |
| 383 | if (ls->current != '=') return '<'; |
| 384 | else { next(ls); return TK_LE; } |
| 385 | } |
| 386 | case '>': { |
| 387 | next(ls); |
| 388 | if (ls->current != '=') return '>'; |
| 389 | else { next(ls); return TK_GE; } |
| 390 | } |
| 391 | case '~': { |
| 392 | next(ls); |
| 393 | if (ls->current != '=') return '~'; |
| 394 | else { next(ls); return TK_NE; } |
| 395 | } |
no test coverage detected