From 8321f6bfe30be3dcfce5eaff018acf7c560ce6f1 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Wed, 2 Jun 2010 00:03:07 -0400 Subject: [PATCH] making block comments require their own lines for delimiters. Issue 379. --- lib/lexer.js | 2 +- src/lexer.coffee | 2 +- test/test_comments.coffee | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/lexer.js b/lib/lexer.js index 77dcddec..14ce7da4 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -673,7 +673,7 @@ INTERPOLATION = /^\$([a-zA-Z_@]\w*(\.\w+)*)/; OPERATOR = /^([+\*&|\/\-%=<>:!?]+)([ \t]*)/; WHITESPACE = /^([ \t]+)/; - COMMENT = /^((\n?[ \t]*)?#{3}(?!#)\n*([\s\S]*?)\n*([ \t]*)#{3}|((\n?[ \t]*)?#[^\n]*)+)/; + COMMENT = /^((\n?[ \t]*)?#{3}(?!#)[ \t]*\n+([\s\S]*?)[ \t]*\n+[ \t]*#{3}|((\n?[ \t]*)?#[^\n]*)+)/; CODE = /^((-|=)>)/; MULTI_DENT = /^((\n([ \t]*))+)(\.)?/; LAST_DENTS = /\n([ \t]*)/g; diff --git a/src/lexer.coffee b/src/lexer.coffee index a8c9c44d..696425aa 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -490,7 +490,7 @@ HEREDOC : /^("{6}|'{6}|"{3}\n?([\s\S]*?)\n?([ \t]*)"{3}|'{3}\n?([\s\S]*?)\ INTERPOLATION : /^\$([a-zA-Z_@]\w*(\.\w+)*)/ OPERATOR : /^([+\*&|\/\-%=<>:!?]+)([ \t]*)/ WHITESPACE : /^([ \t]+)/ -COMMENT : /^((\n?[ \t]*)?#{3}(?!#)\n*([\s\S]*?)\n*([ \t]*)#{3}|((\n?[ \t]*)?#[^\n]*)+)/ +COMMENT : /^((\n?[ \t]*)?#{3}(?!#)[ \t]*\n+([\s\S]*?)[ \t]*\n+[ \t]*#{3}|((\n?[ \t]*)?#[^\n]*)+)/ CODE : /^((-|=)>)/ MULTI_DENT : /^((\n([ \t]*))+)(\.)?/ LAST_DENTS : /\n([ \t]*)/g diff --git a/test/test_comments.coffee b/test/test_comments.coffee index b334e4df..705f6cbd 100644 --- a/test/test_comments.coffee +++ b/test/test_comments.coffee @@ -59,3 +59,9 @@ ok test is 'test test test' This is a here-comment. Kind of like a heredoc. ### + +func: -> + ### + Another block comment. + ### + code \ No newline at end of file