From 17ae669b30cb01d0404ced06b8e04525392fea0e Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Tue, 18 Feb 2014 17:24:08 +0900 Subject: [PATCH] support nested comments --- src/scan.l | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/scan.l b/src/scan.l index 7e0a64e3..90a62c51 100644 --- a/src/scan.l +++ b/src/scan.l @@ -57,11 +57,31 @@ infnan "+inf.0"|"-inf.0"|"+nan.0"|"-nan.0" /* bytevector */ %x BYTEVECTOR + /* block comment */ +%x BLOCK_COMMENT + %% [ \t\n\r] /* skip whitespace */ {comment} /* skip comment */ +"#|" { + BEGIN(BLOCK_COMMENT); + yylvalp->i = 0; +} +"#|" { + yylvalp->i++; +} +"|#" { + if (yylvalp->i == 0) + BEGIN(INITIAL); + else + yylvalp->i--; +} +. { + yymore(); +} + "#;" return tDATUM_COMMENT; "." return tDOT; "(" return tLPAREN;