about summary refs log tree commit diff
path: root/src/boot
diff options
context:
space:
mode:
authorMatt Brubeck <mbrubeck@limpet.net>2010-07-08 17:01:25 +0800
committerGraydon Hoare <graydon@pobox.com>2010-07-08 22:43:15 +0800
commit244ea680820c205461ad5af979c0a722372e6dc6 (patch)
tree45d4da70ea8f68b84105bfdac48f8556519fb14e /src/boot
parent115e14a32c1940a4868ae8633039a296450740ea (diff)
downloadrust-244ea680820c205461ad5af979c0a722372e6dc6.tar.gz
rust-244ea680820c205461ad5af979c0a722372e6dc6.zip
Issue 66: Multi-line comments
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/fe/lexer.mll15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/boot/fe/lexer.mll b/src/boot/fe/lexer.mll
index 6430821de15..090da25f854 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           }