From 244ea680820c205461ad5af979c0a722372e6dc6 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Thu, 8 Jul 2010 17:01:25 +0800 Subject: Issue 66: Multi-line comments --- src/boot/fe/lexer.mll | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/boot') diff --git a/src/boot/fe/lexer.mll b/src/boot/fe/lexer.mll index 6430821d..090da25f 100644 --- a/src/boot/fe/lexer.mll +++ b/src/boot/fe/lexer.mll @@ -139,7 +139,7 @@ rule token = parse <- (bump_line lexbuf.Lexing.lex_curr_p); token lexbuf } | "//" [^'\n']* { token lexbuf } - +| "/*" { comment 1 lexbuf } | '+' { PLUS } | '-' { MINUS } | '*' { STAR } @@ -362,3 +362,16 @@ and bracequote buf depth = parse | [^'\\' '{' '}']+ { let s = Lexing.lexeme lexbuf in Buffer.add_string buf s; bracequote buf depth lexbuf } + + +and comment depth = parse + + '/' '*' { comment (depth+1) lexbuf } + +| '*' '/' { if depth = 1 + then token lexbuf + else comment (depth-1) lexbuf } + +| '*' [^'{'] { comment depth lexbuf } +| '/' [^'*'] { comment depth lexbuf } +| [^'/' '*']+ { comment depth lexbuf } -- cgit v1.2.3