Loading lib/jsduck/lexer.rb +6 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,12 @@ module JsDuck :type => KEYWORDS[value] ? :keyword : :ident, :value => value } elsif @input.check(/\$/) value = @input.scan(/\$\w*/) @tokens << { :type => :ident, :value => value } elsif @input.check(/\/\*\*/) @tokens << { :type => :doc_comment, Loading spec/lexer_spec.rb +8 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,14 @@ describe JsDuck::Lexer do lex("alert(5.)")[2].should == [:number, 5.0] end it "identifies $ as beginning of identifier" do lex("$1a").should == [[:ident, "$1a"]] end it "allows $ as a name of identifier" do lex("$ = 3")[0].should == [:ident, "$"] end it "ignores one-line comments" do lex("a // foo\n b").should == [[:ident, "a"], [:ident, "b"]] end Loading Loading
lib/jsduck/lexer.rb +6 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,12 @@ module JsDuck :type => KEYWORDS[value] ? :keyword : :ident, :value => value } elsif @input.check(/\$/) value = @input.scan(/\$\w*/) @tokens << { :type => :ident, :value => value } elsif @input.check(/\/\*\*/) @tokens << { :type => :doc_comment, Loading
spec/lexer_spec.rb +8 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,14 @@ describe JsDuck::Lexer do lex("alert(5.)")[2].should == [:number, 5.0] end it "identifies $ as beginning of identifier" do lex("$1a").should == [[:ident, "$1a"]] end it "allows $ as a name of identifier" do lex("$ = 3")[0].should == [:ident, "$"] end it "ignores one-line comments" do lex("a // foo\n b").should == [[:ident, "a"], [:ident, "b"]] end Loading