ripper_ruby_parser 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -57,6 +57,16 @@ module RipperRubyParser
57
57
  super
58
58
  end
59
59
 
60
+ def on_embexpr_beg *args
61
+ @in_symbol = false
62
+ super
63
+ end
64
+
65
+ def on_dyna_symbol *args
66
+ @in_symbol = false
67
+ super
68
+ end
69
+
60
70
  def on_parse_error *args
61
71
  raise SyntaxError.new(*args)
62
72
  end
@@ -80,10 +90,9 @@ module RipperRubyParser
80
90
  private
81
91
 
82
92
  def commentize name, exp
93
+ raise "Comment stack empty in #{name} event" if @comment_stack.empty?
83
94
  tok, comment = @comment_stack.pop
84
95
  unless tok == name
85
- p @comment_stack
86
- p [tok, comment]
87
96
  raise "Expected on_#{tok} event, got on_#{name}"
88
97
  end
89
98
  if comment.nil?
@@ -1,3 +1,3 @@
1
1
  module RipperRubyParser
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
@@ -70,6 +70,44 @@ describe RipperRubyParser::CommentingSexpBuilder do
70
70
  [:const_ref, [:@const, "Foo", [1, 7]]],
71
71
  [:bodystmt, [[:void_stmt]], nil, nil, nil]]]]]
72
72
  end
73
+
74
+ it "is not confused by a symbol containing a keyword" do
75
+ result = parse_with_builder ":class; def foo; end"
76
+ result.must_equal [:program,
77
+ [[:symbol_literal, [:symbol, [:@kw, "class", [1, 1]]]],
78
+ [:comment,
79
+ "",
80
+ [:def,
81
+ [:@ident, "foo", [1, 12]],
82
+ [:params, nil, nil, nil, nil, nil],
83
+ [:bodystmt, [[:void_stmt]], nil, nil, nil]]]]]
84
+ end
85
+
86
+ it "is not confused by a dynamic symbol" do
87
+ result = parse_with_builder ":'foo'; def bar; end"
88
+ result.must_equal [:program,
89
+ [[:dyna_symbol, [[:@tstring_content, "foo", [1, 2]]]],
90
+ [:comment,
91
+ "",
92
+ [:def,
93
+ [:@ident, "bar", [1, 12]],
94
+ [:params, nil, nil, nil, nil, nil],
95
+ [:bodystmt, [[:void_stmt]], nil, nil, nil]]]]]
96
+ end
97
+
98
+ it "is not confused by a dynamic symbol containing a class definition" do
99
+ result = parse_with_builder ":\"foo\#{class Bar;end}\""
100
+ result.must_equal [:program,
101
+ [[:dyna_symbol,
102
+ [[:@tstring_content, "foo", [1, 2]],
103
+ [:string_embexpr,
104
+ [[:comment,
105
+ "",
106
+ [:class,
107
+ [:const_ref, [:@const, "Bar", [1, 13]]],
108
+ nil,
109
+ [:bodystmt, [[:void_stmt]], nil, nil, nil]]]]]]]]]
110
+ end
73
111
  end
74
112
  end
75
113
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ripper_ruby_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-08 00:00:00.000000000 Z
12
+ date: 2012-06-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sexp_processor
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 2.11.2
37
+ version: 3.0.1
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 2.11.2
45
+ version: 3.0.1
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rake
48
48
  requirement: !ruby/object:Gem::Requirement