Permalink
Browse files

one less src.pos modification

fixed empty =begin/end
[git-p4: depot-paths = "//src/ruby_parser/dev/": change = 5953]
  • Loading branch information...
1 parent 5d832ba commit bc25807b7d066aa88d5201698187b348b6f481ce @zenspider zenspider committed Nov 11, 2010
Showing with 12 additions and 3 deletions.
  1. +3 −3 lib/ruby_lexer.rb
  2. +9 −0 test/test_ruby_parser.rb
View
@@ -231,7 +231,7 @@ def int_with_base base
end
def lex_state= o
- raise "wtf?" unless Symbol === o
+ raise "wtf\?" unless Symbol === o
@lex_state = o
end
@@ -655,7 +655,7 @@ def yylex # 826 lines
self.lineno = nil
c = src.matched
if c == '#' then
- src.unread c # ok
+ src.pos -= 1
while src.scan(/\s*#.*(\n+|\z)/) do
@comments << src.matched.gsub(/^ +#/, '#').gsub(/^ +$/, '')
@@ -723,7 +723,7 @@ def yylex # 826 lines
self.fix_arg_lex_state
tok = self.yacc_value = src.matched
return TOKENS[tok]
- elsif src.was_begin_of_line and src.scan(/\=begin(?=\s)/) then
+ elsif src.scan(/\=begin(?=\s)/) then
# @comments << '=' << src.matched
@comments << src.matched
View
@@ -175,6 +175,15 @@ def test_do_bug # TODO: rename
assert_equal pt, @processor.parse(rb)
end
+ def test_bug_comment_eq_begin
+ rb = "\n\n#\n=begin\nblah\n=end\n\n"
+ pt = nil
+ exp = rb[2..-1]
+
+ assert_equal pt, @processor.parse(rb)
+ assert_equal exp, @processor.lexer.comments
+ end
+
def test_dstr_evstr
rb = "\"#\{'a'}#\{b}\""
pt = s(:dstr, "a", s(:evstr, s(:call, nil, :b, s(:arglist))))

0 comments on commit bc25807

Please sign in to comment.