diff --git a/compiler/lex.c b/compiler/lex.c index d967bdb..d4b0950 100644 --- a/compiler/lex.c +++ b/compiler/lex.c @@ -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;