support nested comments

This commit is contained in:
Yuichi Nishiwaki 2014-02-18 17:24:08 +09:00
parent a078266c2d
commit 17ae669b30
1 changed files with 20 additions and 0 deletions

View File

@ -57,11 +57,31 @@ infnan "+inf.0"|"-inf.0"|"+nan.0"|"-nan.0"
/* bytevector */ /* bytevector */
%x BYTEVECTOR %x BYTEVECTOR
/* block comment */
%x BLOCK_COMMENT
%% %%
[ \t\n\r] /* skip whitespace */ [ \t\n\r] /* skip whitespace */
{comment} /* skip comment */ {comment} /* skip comment */
"#|" {
BEGIN(BLOCK_COMMENT);
yylvalp->i = 0;
}
<BLOCK_COMMENT>"#|" {
yylvalp->i++;
}
<BLOCK_COMMENT>"|#" {
if (yylvalp->i == 0)
BEGIN(INITIAL);
else
yylvalp->i--;
}
<BLOCK_COMMENT>. {
yymore();
}
"#;" return tDATUM_COMMENT; "#;" return tDATUM_COMMENT;
"." return tDOT; "." return tDOT;
"(" return tLPAREN; "(" return tLPAREN;