parser 2.2.0.1 → 2.2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f269b1e2401ffe3b9b35319fec5accc3378dfe5e
4
- data.tar.gz: 66bff4c72a39532d0a008dc2c45bf597ec9a397a
3
+ metadata.gz: a7ee3b62efb93509bd26984f67ccef404ed4436a
4
+ data.tar.gz: 3997b9e8dfa9ad2acd372d363e4e30094889bda1
5
5
  SHA512:
6
- metadata.gz: c05ff7923a950a07a0b202a2a393e4bdc7bf4b8235d5e5517599fbc634b544b82fd24b1ce74e34ae0131d68c982fb7044af6428acd3f62aa580d1a038bb03b63
7
- data.tar.gz: 19e74008c7cc99b59811266fd590db6870f6e52ce44077f0430d8a065efc44f0c5bab8b64b77ca3dc52cf431f8e59db7329be2f70dbf191a375e189be06bec11
6
+ metadata.gz: faf5d3ced213d86629ab6bc357a97d32e9fda555e8077743abfe9c340d85608362dd2ff2ca61e6ebf6a990d7d64d5130c5f89dd7feb33b9cf1ac85979d76728d
7
+ data.tar.gz: d36bbe80d4b3d150a408db67765f154eaee25fd44b49b969e2d54a4d0b4bd7b702f8116836f21f6923952ace7539c8ed504e985bfc5dae9c725567882b983b43
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Parser
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/parser.png)](http://badge.fury.io/rb/parser)
3
+ [![Gem Version](https://badge.fury.io/rb/parser.png)](https://badge.fury.io/rb/parser)
4
4
  [![Build Status](https://travis-ci.org/whitequark/parser.png?branch=master)](https://travis-ci.org/whitequark/parser)
5
5
  [![Code Climate](https://codeclimate.com/github/whitequark/parser.png)](https://codeclimate.com/github/whitequark/parser)
6
6
  [![Coverage Status](https://coveralls.io/repos/whitequark/parser/badge.png?branch=master)](https://coveralls.io/r/whitequark/parser)
@@ -41,7 +41,7 @@ Access the AST's source map:
41
41
  p Parser::CurrentRuby.parse("2 + 2").loc.selector.source
42
42
  # "+"
43
43
 
44
- Traverse the AST: see the documentation for [gem ast](http://whitequark.github.io/ast/).
44
+ Traverse the AST: see the documentation for [gem ast](https://whitequark.github.io/ast/).
45
45
 
46
46
  Parse a chunk of code and display all diagnostics:
47
47
 
@@ -98,27 +98,26 @@ with Parser:
98
98
  * Precise source location reporting.
99
99
  * [Documented](doc/AST_FORMAT.md) AST format which is convenient to work with.
100
100
  * A simple interface and a powerful, tweakable one.
101
- * Parses 1.8, 1.9, 2.0, 2.1 and 2.2 (preliminary) syntax with backwards-compatible
101
+ * Parses 1.8, 1.9, 2.0, 2.1 and 2.2 syntax with backwards-compatible
102
102
  AST formats.
103
103
  * [Rewriting][rewriting] support.
104
104
  * Parsing error recovery.
105
105
  * Improved [clang-like][] diagnostic messages with location information.
106
106
  * Written in pure Ruby, runs on MRI 1.8.7 or >=1.9.2, JRuby and Rubinius in 1.8
107
107
  and 1.9 mode.
108
- * Only two runtime dependencies: the gems [ast][] and [slop][].
108
+ * Only one runtime dependency: the [ast][] gem.
109
109
  * [Insane][insane-lexer] Ruby lexer rewritten from scratch in Ragel.
110
110
  * 100% test coverage for Bison grammars (except error recovery).
111
111
  * Readable, commented source code.
112
112
 
113
113
  [clang-like]: http://clang.llvm.org/diagnostics.html
114
- [ast]: http://rubygems.org/gems/ast
115
- [slop]: http://rubygems.org/gems/slop
114
+ [ast]: https://rubygems.org/gems/ast
116
115
  [insane-lexer]: http://whitequark.org/blog/2013/04/01/ruby-hacking-guide-ch-11-finite-state-lexer/
117
116
  [rewriting]: http://whitequark.org/blog/2013/04/26/lets-play-with-ruby-code/
118
117
 
119
118
  ## Documentation
120
119
 
121
- Documentation for parser is available [online](http://whitequark.github.io/parser/).
120
+ Documentation for parser is available [online](https://whitequark.github.io/parser/).
122
121
 
123
122
  ### Node names
124
123
 
@@ -210,7 +209,7 @@ Adding support for the following Ruby MRI features in Parser would needlessly co
210
209
 
211
210
  Parser has been extensively tested; in particular, it parses almost entire [Rubygems][rg] corpus. For every issue, a breakdown of affected gems is offered.
212
211
 
213
- [rg]: http://rubygems.org
212
+ [rg]: https://rubygems.org
214
213
 
215
214
  ### Void value expressions
216
215
 
@@ -264,9 +263,9 @@ No known code is affected by this issue.
264
263
  ## Acknowledgements
265
264
 
266
265
  The lexer testsuite is derived from
267
- [ruby\_parser](http://github.com/seattlerb/ruby_parser).
266
+ [ruby\_parser](https://github.com/seattlerb/ruby_parser).
268
267
 
269
- The Bison parser rules are derived from [Ruby MRI](http://github.com/ruby/ruby)
268
+ The Bison parser rules are derived from [Ruby MRI](https://github.com/ruby/ruby)
270
269
  parse.y.
271
270
 
272
271
  ## Contributing
data/lib/parser/runner.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'benchmark'
2
2
  require 'find'
3
- require 'slop'
3
+ require 'optparse'
4
4
 
5
5
  require 'parser'
6
6
 
@@ -12,16 +12,16 @@ module Parser
12
12
  end
13
13
 
14
14
  def initialize
15
- @slop = Slop.new(:strict => true)
16
- @parser_class = nil
17
- @parser = nil
18
- @files = []
19
- @fragments = []
15
+ @option_parser = OptionParser.new { |opts| setup_option_parsing(opts) }
16
+ @parser_class = nil
17
+ @parser = nil
18
+ @files = []
19
+ @fragments = []
20
+ @warnings = false
21
+ @benchmark = false
20
22
 
21
23
  @source_count = 0
22
24
  @source_size = 0
23
-
24
- setup_option_parsing
25
25
  end
26
26
 
27
27
  def execute(options)
@@ -37,11 +37,11 @@ module Parser
37
37
  raise NotImplementedError, "implement #{self.class}##{__callee__}"
38
38
  end
39
39
 
40
- def setup_option_parsing
41
- @slop.banner "Usage: #{runner_name} [options] FILE|DIRECTORY..."
40
+ def setup_option_parsing(opts)
41
+ opts.banner = "Usage: #{runner_name} [options] FILE|DIRECTORY..."
42
42
 
43
- @slop.on 'h', 'help', 'Display this help message and exit', :tail => true do
44
- puts @slop.help
43
+ opts.on_tail '-h', '--help', 'Display this help message and exit' do
44
+ puts opts.help
45
45
  puts <<-HELP
46
46
 
47
47
  If you specify a DIRECTORY, then all *.rb files are fetched
@@ -52,47 +52,51 @@ module Parser
52
52
  exit
53
53
  end
54
54
 
55
- @slop.on 'V', 'version', 'Output version information and exit', :tail => true do
55
+ opts.on_tail '-V', '--version', 'Output version information and exit' do
56
56
  puts "#{runner_name} based on parser version #{Parser::VERSION}"
57
57
  exit
58
58
  end
59
59
 
60
- @slop.on '18', 'Parse as Ruby 1.8.7 would' do
60
+ opts.on '--18', 'Parse as Ruby 1.8.7 would' do
61
61
  require 'parser/ruby18'
62
62
  @parser_class = Parser::Ruby18
63
63
  end
64
64
 
65
- @slop.on '19', 'Parse as Ruby 1.9.3 would' do
65
+ opts.on '--19', 'Parse as Ruby 1.9.3 would' do
66
66
  require 'parser/ruby19'
67
67
  @parser_class = Parser::Ruby19
68
68
  end
69
69
 
70
- @slop.on '20', 'Parse as Ruby 2.0 would' do
70
+ opts.on '--20', 'Parse as Ruby 2.0 would' do
71
71
  require 'parser/ruby20'
72
72
  @parser_class = Parser::Ruby20
73
73
  end
74
74
 
75
- @slop.on '21', 'Parse as Ruby 2.1 would' do
75
+ opts.on '--21', 'Parse as Ruby 2.1 would' do
76
76
  require 'parser/ruby21'
77
77
  @parser_class = Parser::Ruby21
78
78
  end
79
79
 
80
- @slop.on '22', 'Parse as Ruby 2.2 would' do
80
+ opts.on '--22', 'Parse as Ruby 2.2 would' do
81
81
  require 'parser/ruby22'
82
82
  @parser_class = Parser::Ruby22
83
83
  end
84
84
 
85
- @slop.on 'w', 'warnings', 'Enable warnings'
85
+ opts.on '-w', '--warnings', 'Enable warnings' do |w|
86
+ @warnings = w
87
+ end
86
88
 
87
- @slop.on 'B', 'benchmark', 'Benchmark the processor'
89
+ opts.on '-B', '--benchmark', 'Benchmark the processor' do |b|
90
+ @benchmark = b
91
+ end
88
92
 
89
- @slop.on 'e=', 'Process a fragment of Ruby code' do |fragment|
93
+ opts.on '-e fragment', 'Process a fragment of Ruby code' do |fragment|
90
94
  @fragments << fragment
91
95
  end
92
96
  end
93
97
 
94
98
  def parse_options(options)
95
- @slop.parse!(options)
99
+ @option_parser.parse!(options)
96
100
 
97
101
  # Slop has just removed recognized options from `options`.
98
102
  options.each do |file_or_dir|
@@ -120,7 +124,7 @@ module Parser
120
124
  @parser = @parser_class.new
121
125
 
122
126
  @parser.diagnostics.all_errors_are_fatal = true
123
- @parser.diagnostics.ignore_warnings = !@slop.warnings?
127
+ @parser.diagnostics.ignore_warnings = !@warnings
124
128
 
125
129
  @parser.diagnostics.consumer = lambda do |diagnostic|
126
130
  puts(diagnostic.render)
@@ -138,7 +142,7 @@ module Parser
138
142
  process_files
139
143
  end
140
144
 
141
- if @slop.benchmark?
145
+ if @benchmark
142
146
  report_with_time(parsing_time)
143
147
  end
144
148
  end
@@ -89,18 +89,26 @@ module Parser
89
89
  end
90
90
  end
91
91
 
92
+ def initialize
93
+ super
94
+
95
+ @locate = false
96
+ end
97
+
92
98
  private
93
99
 
94
100
  def runner_name
95
101
  'ruby-parse'
96
102
  end
97
103
 
98
- def setup_option_parsing
99
- super
104
+ def setup_option_parsing(opts)
105
+ super(opts)
100
106
 
101
- @slop.on 'L', 'locate', 'Explain how source maps for AST nodes are laid out'
107
+ opts.on '-L', '--locate', 'Explain how source maps for AST nodes are laid out' do |v|
108
+ @locate = v
109
+ end
102
110
 
103
- @slop.on 'E', 'explain', 'Explain how the source is tokenized' do
111
+ opts.on '-E', '--explain', 'Explain how the source is tokenized' do
104
112
  ENV['RACC_DEBUG'] = '1'
105
113
 
106
114
  Lexer.send :include, Lexer::Explanation
@@ -118,9 +126,9 @@ module Parser
118
126
  def process(buffer)
119
127
  ast = @parser.parse(buffer)
120
128
 
121
- if @slop.locate?
129
+ if @locate
122
130
  LocationProcessor.new.process(ast)
123
- elsif !@slop.benchmark?
131
+ elsif !@benchmark
124
132
  p ast
125
133
  end
126
134
  end
@@ -17,14 +17,14 @@ module Parser
17
17
  'ruby-rewrite'
18
18
  end
19
19
 
20
- def setup_option_parsing
21
- super
20
+ def setup_option_parsing(opts)
21
+ super(opts)
22
22
 
23
- @slop.on 'l=', 'load=', 'Load a rewriter' do |file|
23
+ opts.on '-l file', '--load', 'Load a rewriter' do |file|
24
24
  load_and_discover(file)
25
25
  end
26
26
 
27
- @slop.on 'm', 'modify', 'Assume rewriters normally modify AST' do
27
+ opts.on '-m', '--modify', 'Assume rewriters normally modify AST' do
28
28
  @modify = true
29
29
  end
30
30
  end
@@ -1,3 +1,3 @@
1
1
  module Parser
2
- VERSION = '2.2.0.1'
2
+ VERSION = '2.2.0.2'
3
3
  end
data/parser.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ['whitequark@whitequark.org']
10
10
  spec.description = 'A Ruby parser written in pure Ruby.'
11
11
  spec.summary = spec.description
12
- spec.homepage = 'http://github.com/whitequark/parser'
12
+ spec.homepage = 'https://github.com/whitequark/parser'
13
13
  spec.license = 'MIT'
14
14
  spec.has_rdoc = 'yard'
15
15
 
@@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ['lib']
27
27
 
28
28
  spec.add_dependency 'ast', ['>= 1.1', '< 3.0']
29
- spec.add_dependency 'slop', ['~> 3.4', '>= 3.4.5']
30
29
 
31
30
  spec.add_development_dependency 'bundler', '~> 1.2'
32
31
  spec.add_development_dependency 'rake', '~> 10.0'
data/test/test_current.rb CHANGED
@@ -14,8 +14,10 @@ class TestCurrent < Minitest::Test
14
14
  assert_equal Parser::Ruby21, Parser::CurrentRuby
15
15
  when /^2\.2\.\d+/
16
16
  assert_equal Parser::Ruby22, Parser::CurrentRuby
17
+ when /^2\.3\.\d+/
18
+ assert_equal Parser::Ruby22, Parser::CurrentRuby
17
19
  else
18
- flunk "Update test_parser_current for #{RUBY_VERSION}"
20
+ flunk "Update test_current for #{RUBY_VERSION}"
19
21
  end
20
22
  end
21
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0.1
4
+ version: 2.2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Zotov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-27 00:00:00.000000000 Z
11
+ date: 2015-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast
@@ -30,26 +30,6 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '3.0'
33
- - !ruby/object:Gem::Dependency
34
- name: slop
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '3.4'
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 3.4.5
43
- type: :runtime
44
- prerelease: false
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: '3.4'
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 3.4.5
53
33
  - !ruby/object:Gem::Dependency
54
34
  name: bundler
55
35
  requirement: !ruby/object:Gem::Requirement
@@ -351,7 +331,7 @@ files:
351
331
  - test/test_source_rewriter.rb
352
332
  - test/test_source_rewriter_action.rb
353
333
  - test/test_static_environment.rb
354
- homepage: http://github.com/whitequark/parser
334
+ homepage: https://github.com/whitequark/parser
355
335
  licenses:
356
336
  - MIT
357
337
  metadata: {}
@@ -371,7 +351,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
371
351
  version: '0'
372
352
  requirements: []
373
353
  rubyforge_project:
374
- rubygems_version: 2.4.2
354
+ rubygems_version: 2.4.1
375
355
  signing_key:
376
356
  specification_version: 4
377
357
  summary: A Ruby parser written in pure Ruby.