implement line comments
This commit is contained in:
parent
9e592c57d7
commit
873b691ca0
1 changed files with 16 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue