Skip to content

Commit

Permalink
Support for C-style comments
Browse files Browse the repository at this point in the history
Thanks to @KRodinn and RvP
  • Loading branch information
Xottab-DUTY committed Mar 17, 2019
1 parent fd85fb0 commit 6378093
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/lj_lex.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,27 @@ static LexToken lex_scan(LexState *ls, TValue *tv)
while (!lex_iseol(ls) && ls->c != LEX_EOF)
lex_next(ls);
continue;
case '/': /* C-style comments */
lex_next(ls);
if (ls->c == '/') { /* Short comment "//.*\n". */
while (!lex_iseol(ls) && ls->c != LEX_EOF)
lex_next(ls);
continue;
} else if (ls->c == '*') { /* Long comment /* =*[...]=* */
lex_next(ls);
while (ls->c != LEX_EOF) {
if (ls->c == '*') {
lex_next(ls);
if (ls->c == '/') {
lex_next(ls);
break;
}
}
lex_next(ls);
}
continue;
}
return '/';
case '[': {
int sep = lex_skipeq(ls);
if (sep >= 0) {
Expand Down

0 comments on commit 6378093

Please sign in to comment.