Merge pull request #65 from rgrove/master.

Add support for multi-line comments
This commit is contained in:
Yehuda Katz
2011-05-03 18:58:50 -07:00
2 changed files with 11 additions and 1 deletions
+10
View File
@@ -80,6 +80,10 @@ describe "Parser" do
pad("{{! '#{comment}' }}")
end
def multiline_comment(comment)
pad("{{! '\n#{comment}\n' }}")
end
def content(string)
pad("CONTENT[ '#{string}' ]")
end
@@ -160,6 +164,12 @@ describe "Parser" do
end
end
it "parses a multi-line comment" do
ast_for("{{!\nthis is a multi-line comment\n}}").should == program do
multiline_comment "this is a multi-line comment"
end
end
it "parses an inverse section" do
ast_for("{{#foo}} bar {{^}} baz {{/foo}}").should == program do
block do
+1 -1
View File
@@ -13,7 +13,7 @@
<mu>"{{"\s*"else" { return 'OPEN_INVERSE'; }
<mu>"{{{" { return 'OPEN_UNESCAPED'; }
<mu>"{{&" { return 'OPEN_UNESCAPED'; }
<mu>"{{!".*?"}}" { yytext = yytext.substr(3,yyleng-5); this.begin("INITIAL"); return 'COMMENT'; }
<mu>"{{!"[\s\S]*?"}}" { yytext = yytext.substr(3,yyleng-5); this.begin("INITIAL"); return 'COMMENT'; }
<mu>"{{" { return 'OPEN'; }
<mu>"=" { return 'EQUALS'; }