support nested block comment

This commit is contained in:
Yuichi Nishiwaki 2014-06-25 21:38:11 +09:00
parent 1440a51ef8
commit ee82ee99d7
1 changed files with 9 additions and 4 deletions

View File

@ -63,6 +63,7 @@ static pic_value
read_block_comment(pic_state *pic, struct pic_port *port, char c)
{
char x, y;
int i;
UNUSED(pic);
UNUSED(c);
@ -70,12 +71,16 @@ read_block_comment(pic_state *pic, struct pic_port *port, char c)
x = next(port);
y = next(port);
while (! (x == '|' && y == '#')) {
i = 1;
while (x != EOF && y != EOF && i > 0) {
if (x == '|' && y == '#') {
i--;
}
if (x == '#' && y == '|') {
i++;
}
x = y;
y = next(port);
if (y == EOF) {
break;
}
}
return pic_undef_value();