implement line comments

This commit is contained in:
tocariimaa 2025-01-31 21:46:28 -03:00
parent 9e592c57d7
commit 873b691ca0

View file

@ -190,6 +190,19 @@ read_chr(LexState *ls)
return Some(MaybeChr, *ls->fwd++);
}
static MaybeChr
skip_line_comment(LexState *ls)
{
MaybeChr c;
do {
c = read_chr(ls);
if (!c.ok)
break;
++ls->lbegin;
} while (c.val != '\n');
return c;
}
static MaybeChr
skip_whitespace(LexState *ls)
{
@ -203,7 +216,9 @@ skip_whitespace(LexState *ls)
for (;;) {
c = read_chr(ls);
if (!c.ok)
return None(MaybeChr);
break;
if (c.val == '/' && peek(ls) == '/')
c = skip_line_comment(ls);
if (!ascii_isspace(c.val))
break;
++ls->lbegin;