diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-10-22 15:54:46 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-10-22 15:54:46 -0300 |
commit | d742a193e57029d973aff0a5eb04d8ddd03fa0ff (patch) | |
tree | f0850c8f60997909952cbb1db3f499f066fb1188 /llex.c | |
parent | e4a38eb0e828e9589c391171e2e1904a3b9698e7 (diff) | |
download | lua-d742a193e57029d973aff0a5eb04d8ddd03fa0ff.tar.gz lua-d742a193e57029d973aff0a5eb04d8ddd03fa0ff.tar.bz2 lua-d742a193e57029d973aff0a5eb04d8ddd03fa0ff.zip |
Comments
Diffstat (limited to 'llex.c')
-rw-r--r-- | llex.c | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -254,9 +254,10 @@ static int read_numeral (LexState *ls, SemInfo *seminfo) { | |||
254 | 254 | ||
255 | 255 | ||
256 | /* | 256 | /* |
257 | ** reads a sequence '[=*[' or ']=*]', leaving the last bracket. | 257 | ** read a sequence '[=*[' or ']=*]', leaving the last bracket. If |
258 | ** If sequence is well formed, return its number of '='s + 2; otherwise, | 258 | ** sequence is well formed, return its number of '='s + 2; otherwise, |
259 | ** return 1 if there is no '='s or 0 otherwise (an unfinished '[==...'). | 259 | ** return 1 if it is a single bracket (no '='s and no 2nd bracket); |
260 | ** otherwise (an unfinished '[==...') return 0. | ||
260 | */ | 261 | */ |
261 | static size_t skip_sep (LexState *ls) { | 262 | static size_t skip_sep (LexState *ls) { |
262 | size_t count = 0; | 263 | size_t count = 0; |
@@ -481,34 +482,34 @@ static int llex (LexState *ls, SemInfo *seminfo) { | |||
481 | } | 482 | } |
482 | case '=': { | 483 | case '=': { |
483 | next(ls); | 484 | next(ls); |
484 | if (check_next1(ls, '=')) return TK_EQ; | 485 | if (check_next1(ls, '=')) return TK_EQ; /* '==' */ |
485 | else return '='; | 486 | else return '='; |
486 | } | 487 | } |
487 | case '<': { | 488 | case '<': { |
488 | next(ls); | 489 | next(ls); |
489 | if (check_next1(ls, '=')) return TK_LE; | 490 | if (check_next1(ls, '=')) return TK_LE; /* '<=' */ |
490 | else if (check_next1(ls, '<')) return TK_SHL; | 491 | else if (check_next1(ls, '<')) return TK_SHL; /* '<<' */ |
491 | else return '<'; | 492 | else return '<'; |
492 | } | 493 | } |
493 | case '>': { | 494 | case '>': { |
494 | next(ls); | 495 | next(ls); |
495 | if (check_next1(ls, '=')) return TK_GE; | 496 | if (check_next1(ls, '=')) return TK_GE; /* '>=' */ |
496 | else if (check_next1(ls, '>')) return TK_SHR; | 497 | else if (check_next1(ls, '>')) return TK_SHR; /* '>>' */ |
497 | else return '>'; | 498 | else return '>'; |
498 | } | 499 | } |
499 | case '/': { | 500 | case '/': { |
500 | next(ls); | 501 | next(ls); |
501 | if (check_next1(ls, '/')) return TK_IDIV; | 502 | if (check_next1(ls, '/')) return TK_IDIV; /* '//' */ |
502 | else return '/'; | 503 | else return '/'; |
503 | } | 504 | } |
504 | case '~': { | 505 | case '~': { |
505 | next(ls); | 506 | next(ls); |
506 | if (check_next1(ls, '=')) return TK_NE; | 507 | if (check_next1(ls, '=')) return TK_NE; /* '~=' */ |
507 | else return '~'; | 508 | else return '~'; |
508 | } | 509 | } |
509 | case ':': { | 510 | case ':': { |
510 | next(ls); | 511 | next(ls); |
511 | if (check_next1(ls, ':')) return TK_DBCOLON; | 512 | if (check_next1(ls, ':')) return TK_DBCOLON; /* '::' */ |
512 | else return ':'; | 513 | else return ':'; |
513 | } | 514 | } |
514 | case '"': case '\'': { /* short literal strings */ | 515 | case '"': case '\'': { /* short literal strings */ |
@@ -547,7 +548,7 @@ static int llex (LexState *ls, SemInfo *seminfo) { | |||
547 | return TK_NAME; | 548 | return TK_NAME; |
548 | } | 549 | } |
549 | } | 550 | } |
550 | else { /* single-char tokens (+ - / ...) */ | 551 | else { /* single-char tokens ('+', '*', '%', '{', '}', ...) */ |
551 | int c = ls->current; | 552 | int c = ls->current; |
552 | next(ls); | 553 | next(ls); |
553 | return c; | 554 | return c; |