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++);
|
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
|
static MaybeChr
|
||||||
skip_whitespace(LexState *ls)
|
skip_whitespace(LexState *ls)
|
||||||
{
|
{
|
||||||
|
@ -203,7 +216,9 @@ skip_whitespace(LexState *ls)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = read_chr(ls);
|
c = read_chr(ls);
|
||||||
if (!c.ok)
|
if (!c.ok)
|
||||||
return None(MaybeChr);
|
break;
|
||||||
|
if (c.val == '/' && peek(ls) == '/')
|
||||||
|
c = skip_line_comment(ls);
|
||||||
if (!ascii_isspace(c.val))
|
if (!ascii_isspace(c.val))
|
||||||
break;
|
break;
|
||||||
++ls->lbegin;
|
++ls->lbegin;
|
||||||
|
|
Loading…
Add table
Reference in a new issue