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