From e68c69ceb1f5b33762708763c396d8e6e316c829 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 14 Nov 2013 17:31:40 +0900 Subject: [PATCH] support datum comment --- src/parse.y | 20 +++++++++++++++++++- src/scan.l | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/parse.y b/src/parse.y index 94adcac9..23d4307b 100644 --- a/src/parse.y +++ b/src/parse.y @@ -43,6 +43,7 @@ void yylex_destroy(); pic_value datum; } +%token tDATUM_COMMENT %token tLPAREN tRPAREN tLBRACKET tRBRACKET tDOT tVPAREN %token tQUOTE tQUASIQUOTE tUNQUOTE tUNQUOTE_SPLICING %token tINT tBOOLEAN @@ -67,7 +68,7 @@ program p->incomp = true; p->value = pic_undef_value(); } -| /* empty line */ + | /* empty line */ { p->value = pic_nil_value(); } @@ -82,6 +83,10 @@ program_data { $$ = pic_cons(p->pic, $1, $2); } + | tDATUM_COMMENT datum + { + $$ = pic_nil_value(); + } ; incomplete_program_data @@ -92,6 +97,10 @@ incomplete_program_data datum : simple_datum | compound_datum + | tDATUM_COMMENT datum datum + { + $$ = $3; + } ; simple_datum @@ -150,6 +159,10 @@ list_data { $$ = pic_nil_value(); } + | tDATUM_COMMENT datum + { + $$ = pic_nil_value(); + } | datum tDOT datum { $$ = pic_cons(p->pic, $1, $3); @@ -172,6 +185,10 @@ vector_data { $$ = pic_nil_value(); } + | tDATUM_COMMENT datum + { + $$ = pic_nil_value(); + } | datum vector_data { $$ = pic_cons(p->pic, $1, $2); @@ -202,6 +219,7 @@ incomplete_datum | tLBRACKET incomplete_data | tVPAREN incomplete_data | incomplete_abbrev + | tDATUM_COMMENT ; incomplete_tail diff --git a/src/scan.l b/src/scan.l index 94294f62..55475c3b 100644 --- a/src/scan.l +++ b/src/scan.l @@ -41,6 +41,7 @@ infnan "+inf.0"|"-inf.0"|"+nan.0"|"-nan.0" [ \t\n\r] /* skip whitespace */ {comment} /* skip comment */ +"#;" return tDATUM_COMMENT; "." return tDOT; "(" return tLPAREN; ")" return tRPAREN;