Loading lib/jsduck/lexer.rb +2 −2 Original line number Diff line number Diff line Loading @@ -127,12 +127,12 @@ module JsDuck elsif @input.check(/'/) return { :type => :string, :value => @input.scan(/'([^'\\]|\\.)*'/).sub(/^'(.*)'$/, "\\1") :value => @input.scan(/'([^'\\]|\\.)*'/m).sub(/^'(.*)'$/m, "\\1") } elsif @input.check(/"/) return { :type => :string, :value => @input.scan(/"([^"\\]|\\.)*"/).sub(/^"(.*)"$/, "\\1") :value => @input.scan(/"([^"\\]|\\.)*"/m).sub(/^"(.*)"$/m, "\\1") } elsif @input.check(/\//) # Several things begin with dash: Loading spec/lexer_spec.rb +8 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,14 @@ describe JsDuck::Lexer do it "when escaped single-quote inside single-quoted string" do lex(@s+@b+@s+@s + ' "blah"').should == [[:string, @b+@s], [:string, "blah"]] end it "when newlines escaped inside double-quoted string" do lex(@d+"A\\\nB"+@d).should == [[:string, "A\\\nB"]] end it "when newlines escaped inside single-quoted string" do lex(@s+"A\\\nB"+@s).should == [[:string, "A\\\nB"]] end end it "identifies $ as beginning of identifier" do Loading Loading
lib/jsduck/lexer.rb +2 −2 Original line number Diff line number Diff line Loading @@ -127,12 +127,12 @@ module JsDuck elsif @input.check(/'/) return { :type => :string, :value => @input.scan(/'([^'\\]|\\.)*'/).sub(/^'(.*)'$/, "\\1") :value => @input.scan(/'([^'\\]|\\.)*'/m).sub(/^'(.*)'$/m, "\\1") } elsif @input.check(/"/) return { :type => :string, :value => @input.scan(/"([^"\\]|\\.)*"/).sub(/^"(.*)"$/, "\\1") :value => @input.scan(/"([^"\\]|\\.)*"/m).sub(/^"(.*)"$/m, "\\1") } elsif @input.check(/\//) # Several things begin with dash: Loading
spec/lexer_spec.rb +8 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,14 @@ describe JsDuck::Lexer do it "when escaped single-quote inside single-quoted string" do lex(@s+@b+@s+@s + ' "blah"').should == [[:string, @b+@s], [:string, "blah"]] end it "when newlines escaped inside double-quoted string" do lex(@d+"A\\\nB"+@d).should == [[:string, "A\\\nB"]] end it "when newlines escaped inside single-quoted string" do lex(@s+"A\\\nB"+@s).should == [[:string, "A\\\nB"]] end end it "identifies $ as beginning of identifier" do Loading