Commit f2665553 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Allow $ as beginning character for identifier.

parent 397074f7
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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,
+8 −0
Original line number Diff line number Diff line
@@ -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