Loading lib/jsduck/lexer.rb +7 −2 Original line number Diff line number Diff line Loading @@ -84,7 +84,8 @@ module JsDuck end # A slash "/" is a division operator if it follows: # - identifier (but not a keyword) # - identifier # - the "this" keyword # - number # - closing bracket ) # - closing square-bracket ] Loading @@ -93,7 +94,11 @@ module JsDuck if @tokens.last then type = @tokens.last[:type] value = @tokens.last[:value] if type == :ident || type == :number || value == ")" || value == "]" then if type == :ident || type == :number return false elsif type == :keyword && value == "this" return false elsif type == :operator && (value == ")" || value == "]") return false end end Loading test/tc_lexer.rb +9 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,15 @@ class TestLexer < Test::Unit::TestCase ]) end def test_division_after_this assert_tokens("this / 3", [ [:keyword, "this"], [:operator, "/"], [:number, 3] ]) end def test_strings d = '"' # double-quote s = "'" # single-quote Loading Loading
lib/jsduck/lexer.rb +7 −2 Original line number Diff line number Diff line Loading @@ -84,7 +84,8 @@ module JsDuck end # A slash "/" is a division operator if it follows: # - identifier (but not a keyword) # - identifier # - the "this" keyword # - number # - closing bracket ) # - closing square-bracket ] Loading @@ -93,7 +94,11 @@ module JsDuck if @tokens.last then type = @tokens.last[:type] value = @tokens.last[:value] if type == :ident || type == :number || value == ")" || value == "]" then if type == :ident || type == :number return false elsif type == :keyword && value == "this" return false elsif type == :operator && (value == ")" || value == "]") return false end end Loading
test/tc_lexer.rb +9 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,15 @@ class TestLexer < Test::Unit::TestCase ]) end def test_division_after_this assert_tokens("this / 3", [ [:keyword, "this"], [:operator, "/"], [:number, 3] ]) end def test_strings d = '"' # double-quote s = "'" # single-quote Loading