Skip to content
Browse files

- 1.9: Fixed parsing of unary plus on literals. (whitequark)

       - 1.9: Fixed lexing of "0o". (whitequark)

[git-p4: depot-paths = "//src/ruby_parser/dev/": change = 8085]
  • Loading branch information...
1 parent 90abb39 commit 1d19aa1f53aaa25abc8bf8c2dc2b458ff70b8ca2 @zenspider zenspider committed Dec 19, 2012
Showing with 13 additions and 7 deletions.
  1. +1 −5 lib/ruby19_parser.y
  2. +5 −2 lib/ruby_lexer.rb
  3. +7 −0 test/test_ruby_parser.rb
View
6 lib/ruby19_parser.y
@@ -671,11 +671,7 @@ rule
}
| tUPLUS arg
{
- if val[1][0] == :lit then
- result = val[1]
- else
- result = new_call val[1], :"+@"
- end
+ result = new_call val[1], :"+@"
}
| tUMINUS arg
{
View
7 lib/ruby_lexer.rb
@@ -188,7 +188,7 @@ def heredoc_identifier # 51 lines
self.string_buffer = []
case
- when src.scan(/(-?)(['"`])(.*?)\2/) then
+ when src.scan(/(-?)([\'\"\`])(.*?)\2/) then
term = src[2]
func |= STR_FUNC_INDENT unless src[1].empty?
func |= case term
@@ -200,7 +200,7 @@ def heredoc_identifier # 51 lines
STR_XQUOTE
end
string_buffer << src[3]
- when src.scan(/-?(['"`])(?!\1*\Z)/) then
+ when src.scan(/-?([\'\"\`])(?!\1*\Z)/) then
rb_compile_error "unterminated here document identifier"
when src.scan(/(-?)(\w+)/) then
term = '"'
@@ -249,6 +249,9 @@ def initialize v = 18
def int_with_base base
rb_compile_error "Invalid numeric format" if src.matched =~ /__/
+ rb_compile_error "numeric literal without digits" if
+ ruby19 and src.matched =~ /0o/i
+
self.yacc_value = src.matched.to_i(base)
return :tINTEGER
end
View
7 test/test_ruby_parser.rb
@@ -1764,4 +1764,11 @@ def test_thingy
rb = "f::(42)"
assert_parse rb, pt
end
+
+ def test_unary_plus_on_literal
+ rb = "+:a"
+ pt = s(:call, s(:lit, :a), :+@)
+
+ assert_parse rb, pt
+ end
end

0 comments on commit 1d19aa1

Please sign in to comment.
Something went wrong with that request. Please try again.