---
src/compiler/scanner.re | 4 ++
src/compiler/test/comment | 93 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 97 insertions(+), 0 deletions(-)
diff --git a/src/compiler/scanner.re b/src/compiler/scanner.re
index 79c8681..951668b 100644
--- a/src/compiler/scanner.re
+++ b/src/compiler/scanner.re
@@ -58,7 +58,11 @@ int scan(struct scanner *s)
/*!re2c
[\x20\n\r\t] { goto std; }
+
"//"[^\n\x00]* { goto std; }
+ "/*"("*"*[^/\x00]|[^*\x00])*"*"+"/"
+ { goto std; }
+
[0-9]+ { return TOK_CONSTANT; }
[0-9]* "." [0-9]* { return TOK_CONSTANT; }
diff --git a/src/compiler/test/comment b/src/compiler/test/comment
index 51fc727..1bec66c 100755
--- a/src/compiler/test/comment
+++ b/src/compiler/test/comment
@@ -40,4 +40,97 @@ expect <<EOF
a = b
EOF
+#------------------------------------------------------------------------------
+
+ptest "comment: /* ... */" <<EOF
+a = b + c /* comment */
+d = e + f
+EOF
+expect <<EOF
+a = (+ b c)
+d = (+ e f)
+EOF
+
+#------------------------------------------------------------------------------
+
+ptest "comment: /* ... newline ... */" <<EOF
+a = b + c /* comment
+more */ d = e + f
+EOF
+expect <<EOF
+a = (+ b c)
+d = (+ e f)
+EOF
+
+#------------------------------------------------------------------------------
+
+ptest "comment: /* ... * ... */" <<EOF
+a = 1 /* comment * more */
+b = 2
+EOF
+expect <<EOF
+a = 1
+b = 2
+EOF
+
+#------------------------------------------------------------------------------
+
+ptest "comment: /* ... ** ... */" <<EOF
+a = 3 /* comment ** more */
+b = 4
+EOF
+expect <<EOF
+a = 3
+b = 4
+EOF
+
+#------------------------------------------------------------------------------
+
+ptest "comment: /* ... **/" <<EOF
+a = 5 /* comment **/
+b = 6
+EOF
+expect <<EOF
+a = 5
+b = 6
+EOF
+
+#------------------------------------------------------------------------------
+
+ptest "comment: /**/" <<EOF
+a = 7 /**/
+b = 8
+EOF
+expect <<EOF
+a = 7
+b = 8
+EOF
+
+#------------------------------------------------------------------------------
+
+ptest_fail "comment: /*/ (error)" <<EOF
+a = 9 /*/
+b = a
+EOF
+expect <<EOF
+FPVM: parse error
+EOF
+
+#------------------------------------------------------------------------------
+
+ptest_fail "comment: unterminated /* ... with newline" <<EOF
+a = b + c /* comment
+d = e + f
+EOF
+expect <<EOF
+FPVM: parse error
+EOF
+
+#------------------------------------------------------------------------------
+
+ptest_fail "comment: unterminated /* ... without newline" "a = b+c /* comment"
+expect <<EOF
+FPVM: parse error
+EOF
+
###############################################################################
--
1.7.1
_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkymist@Freenode