parser 2.6.0.0 → 3.1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/lib/parser/all.rb +3 -0
  3. data/lib/parser/ast/processor.rb +48 -1
  4. data/lib/parser/base.rb +30 -6
  5. data/lib/parser/builders/default.rb +670 -38
  6. data/lib/parser/context.rb +24 -26
  7. data/lib/parser/current.rb +36 -9
  8. data/lib/parser/current_arg_stack.rb +46 -0
  9. data/lib/parser/diagnostic/engine.rb +1 -2
  10. data/lib/parser/diagnostic.rb +1 -1
  11. data/lib/parser/lexer/dedenter.rb +58 -49
  12. data/lib/parser/lexer/explanation.rb +1 -1
  13. data/lib/parser/lexer.rb +13837 -11893
  14. data/lib/parser/macruby.rb +2544 -2489
  15. data/lib/parser/max_numparam_stack.rb +56 -0
  16. data/lib/parser/messages.rb +78 -44
  17. data/lib/parser/meta.rb +13 -3
  18. data/lib/parser/ruby18.rb +2313 -2259
  19. data/lib/parser/ruby19.rb +2537 -2488
  20. data/lib/parser/ruby20.rb +2724 -2673
  21. data/lib/parser/ruby21.rb +2766 -2727
  22. data/lib/parser/ruby22.rb +2683 -2628
  23. data/lib/parser/ruby23.rb +2796 -2755
  24. data/lib/parser/ruby24.rb +2812 -2771
  25. data/lib/parser/ruby25.rb +2703 -2670
  26. data/lib/parser/ruby26.rb +2794 -2747
  27. data/lib/parser/ruby27.rb +7914 -0
  28. data/lib/parser/ruby28.rb +8047 -0
  29. data/lib/parser/ruby30.rb +8096 -0
  30. data/lib/parser/ruby31.rb +8354 -0
  31. data/lib/parser/rubymotion.rb +2527 -2485
  32. data/lib/parser/runner/ruby_parse.rb +2 -2
  33. data/lib/parser/runner/ruby_rewrite.rb +2 -2
  34. data/lib/parser/runner.rb +36 -2
  35. data/lib/parser/source/buffer.rb +53 -28
  36. data/lib/parser/source/comment/associator.rb +31 -8
  37. data/lib/parser/source/comment.rb +14 -1
  38. data/lib/parser/source/map/method_definition.rb +25 -0
  39. data/lib/parser/source/range.rb +19 -3
  40. data/lib/parser/source/tree_rewriter/action.rb +137 -28
  41. data/lib/parser/source/tree_rewriter.rb +144 -14
  42. data/lib/parser/static_environment.rb +23 -0
  43. data/lib/parser/tree_rewriter.rb +3 -3
  44. data/lib/parser/variables_stack.rb +36 -0
  45. data/lib/parser/version.rb +1 -1
  46. data/lib/parser.rb +4 -0
  47. data/parser.gemspec +12 -19
  48. metadata +34 -99
  49. data/.gitignore +0 -32
  50. data/.travis.yml +0 -45
  51. data/.yardopts +0 -21
  52. data/CHANGELOG.md +0 -943
  53. data/CONTRIBUTING.md +0 -17
  54. data/Gemfile +0 -10
  55. data/README.md +0 -301
  56. data/Rakefile +0 -165
  57. data/ci/run_rubocop_specs +0 -14
  58. data/doc/AST_FORMAT.md +0 -1735
  59. data/doc/CUSTOMIZATION.md +0 -37
  60. data/doc/INTERNALS.md +0 -21
  61. data/doc/css/.gitkeep +0 -0
  62. data/doc/css/common.css +0 -68
  63. data/lib/parser/lexer.rl +0 -2383
  64. data/lib/parser/macruby.y +0 -2198
  65. data/lib/parser/ruby18.y +0 -1934
  66. data/lib/parser/ruby19.y +0 -2175
  67. data/lib/parser/ruby20.y +0 -2353
  68. data/lib/parser/ruby21.y +0 -2357
  69. data/lib/parser/ruby22.y +0 -2364
  70. data/lib/parser/ruby23.y +0 -2370
  71. data/lib/parser/ruby24.y +0 -2408
  72. data/lib/parser/ruby25.y +0 -2405
  73. data/lib/parser/ruby26.y +0 -2413
  74. data/lib/parser/rubymotion.y +0 -2182
  75. data/test/bug_163/fixtures/input.rb +0 -5
  76. data/test/bug_163/fixtures/output.rb +0 -5
  77. data/test/bug_163/rewriter.rb +0 -20
  78. data/test/helper.rb +0 -52
  79. data/test/parse_helper.rb +0 -315
  80. data/test/racc_coverage_helper.rb +0 -133
  81. data/test/test_base.rb +0 -31
  82. data/test/test_current.rb +0 -27
  83. data/test/test_diagnostic.rb +0 -96
  84. data/test/test_diagnostic_engine.rb +0 -62
  85. data/test/test_encoding.rb +0 -99
  86. data/test/test_lexer.rb +0 -3543
  87. data/test/test_lexer_stack_state.rb +0 -78
  88. data/test/test_parse_helper.rb +0 -80
  89. data/test/test_parser.rb +0 -7087
  90. data/test/test_runner_rewrite.rb +0 -47
  91. data/test/test_source_buffer.rb +0 -162
  92. data/test/test_source_comment.rb +0 -36
  93. data/test/test_source_comment_associator.rb +0 -367
  94. data/test/test_source_map.rb +0 -15
  95. data/test/test_source_range.rb +0 -172
  96. data/test/test_source_rewriter.rb +0 -541
  97. data/test/test_source_rewriter_action.rb +0 -46
  98. data/test/test_source_tree_rewriter.rb +0 -173
  99. data/test/test_static_environment.rb +0 -45
  100. data/test/using_tree_rewriter/fixtures/input.rb +0 -3
  101. data/test/using_tree_rewriter/fixtures/output.rb +0 -3
  102. data/test/using_tree_rewriter/using_tree_rewriter.rb +0 -9
data/CONTRIBUTING.md DELETED
@@ -1,17 +0,0 @@
1
- Contributing to Parser
2
- ----------------------
3
-
4
- Parser employs a script to extract information from VCS (git) log and form a Changelog file. Thus, each commit which affects the public API in any way must be marked with one of the following sigils, or characters at the beginning of line:
5
-
6
- * `-` for bugfixes. For example: `- lexer.rl: fixed lexing of "alias $foo $bar".`
7
- * `+` for features. For example: `+ Implemented Parser::Rewriter, a module for non-intrusive rewriting of source code.`
8
- * `*` for miscellaneous changes. For example: `* Converted measurement units from metric to imperial.`
9
-
10
- Versioning
11
- ----------
12
-
13
- Parser is versioned as follows:
14
- * The version starts with the most recent Ruby version that Parser supports (which should be also the most recent released Ruby version).
15
- * After that, a `.x` is appended, where `x` is incremented for every change.
16
-
17
- No breaking changes to API will be ever made, except for changes that correct behavior which did not match documentation or Ruby MRI behavior.
data/Gemfile DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in parser.gemspec
6
- gemspec
7
-
8
- # Workaround for bug in Bundler on JRuby
9
- # See https://github.com/bundler/bundler/issues/4157
10
- gem 'ast', '>= 1.1', '< 3.0'
data/README.md DELETED
@@ -1,301 +0,0 @@
1
- # Parser
2
-
3
- [![Gem Version](https://badge.fury.io/rb/parser.svg)](https://badge.fury.io/rb/parser)
4
- [![Build Status](https://travis-ci.org/whitequark/parser.svg?branch=master)](https://travis-ci.org/whitequark/parser)
5
-
6
- _Parser_ is a production-ready Ruby parser written in pure Ruby. It recognizes as
7
- much or more code than Ripper, Melbourne, JRubyParser or ruby\_parser, and
8
- is vastly more convenient to use.
9
-
10
- You can also use [unparser](https://github.com/mbj/unparser) to produce
11
- equivalent source code from Parser's ASTs.
12
-
13
- Sponsored by [Evil Martians](http://evilmartians.com).
14
- MacRuby and RubyMotion support sponsored by [CodeClimate](http://codeclimate.com).
15
-
16
- ## Installation
17
-
18
- $ gem install parser
19
-
20
- ## Usage
21
-
22
- Load Parser (see the [backwards compatibility](#backwards-compatibility) section
23
- below for explanation of `emit_*` calls):
24
-
25
- require 'parser/current'
26
- # opt-in to most recent AST format:
27
- Parser::Builders::Default.emit_lambda = true
28
- Parser::Builders::Default.emit_procarg0 = true
29
- Parser::Builders::Default.emit_encoding = true
30
- Parser::Builders::Default.emit_index = true
31
-
32
- Parse a chunk of code:
33
-
34
- p Parser::CurrentRuby.parse("2 + 2")
35
- # (send
36
- # (int 2) :+
37
- # (int 2))
38
-
39
- Access the AST's source map:
40
-
41
- p Parser::CurrentRuby.parse("2 + 2").loc
42
- # #<Parser::Source::Map::Send:0x007fe5a1ac2388
43
- # @dot=nil,
44
- # @begin=nil,
45
- # @end=nil,
46
- # @selector=#<Source::Range (string) 2...3>,
47
- # @expression=#<Source::Range (string) 0...5>>
48
-
49
- p Parser::CurrentRuby.parse("2 + 2").loc.selector.source
50
- # "+"
51
-
52
- Traverse the AST: see the documentation for [gem ast](https://whitequark.github.io/ast/).
53
-
54
- Parse a chunk of code and display all diagnostics:
55
-
56
- parser = Parser::CurrentRuby.new
57
- parser.diagnostics.consumer = lambda do |diag|
58
- puts diag.render
59
- end
60
-
61
- buffer = Parser::Source::Buffer.new('(string)')
62
- buffer.source = "foo *bar"
63
-
64
- p parser.parse(buffer)
65
- # (string):1:5: warning: `*' interpreted as argument prefix
66
- # foo *bar
67
- # ^
68
- # (send nil :foo
69
- # (splat
70
- # (send nil :bar)))
71
-
72
- If you reuse the same parser object for multiple `#parse` runs, you need to
73
- `#reset` it.
74
-
75
- You can also use the `ruby-parse` utility (it's bundled with the gem) to play
76
- with Parser:
77
-
78
- $ ruby-parse -L -e "2+2"
79
- (send
80
- (int 2) :+
81
- (int 2))
82
- 2+2
83
- ~ selector
84
- ~~~ expression
85
- (int 2)
86
- 2+2
87
- ~ expression
88
- (int 2)
89
- 2+2
90
-
91
- $ ruby-parse -E -e "2+2"
92
- 2+2
93
- ^ tINTEGER 2 expr_end [0 <= cond] [0 <= cmdarg]
94
- 2+2
95
- ^ tPLUS "+" expr_beg [0 <= cond] [0 <= cmdarg]
96
- 2+2
97
- ^ tINTEGER 2 expr_end [0 <= cond] [0 <= cmdarg]
98
- 2+2
99
- ^ false "$eof" expr_end [0 <= cond] [0 <= cmdarg]
100
- (send
101
- (int 2) :+
102
- (int 2))
103
-
104
- ## Features
105
-
106
- * Precise source location reporting.
107
- * [Documented](doc/AST_FORMAT.md) AST format which is convenient to work with.
108
- * A simple interface and a powerful, tweakable one.
109
- * Parses 1.8, 1.9, 2.0, 2.1, 2.2 and 2.3 syntax with backwards-compatible
110
- AST formats.
111
- * Parses MacRuby and RubyMotion syntax extensions.
112
- * [Rewriting][rewriting] support.
113
- * Parsing error recovery.
114
- * Improved [clang-like][] diagnostic messages with location information.
115
- * Written in pure Ruby, runs on MRI >=2.0.0, JRuby and Rubinius (and historically, all versions of Ruby since 1.8)
116
- * Only one runtime dependency: the [ast][] gem.
117
- * [Insane][insane-lexer] Ruby lexer rewritten from scratch in Ragel.
118
- * 100% test coverage for Bison grammars (except error recovery).
119
- * Readable, commented source code.
120
-
121
- [clang-like]: http://clang.llvm.org/diagnostics.html
122
- [ast]: https://rubygems.org/gems/ast
123
- [insane-lexer]: http://whitequark.org/blog/2013/04/01/ruby-hacking-guide-ch-11-finite-state-lexer/
124
- [rewriting]: http://whitequark.org/blog/2013/04/26/lets-play-with-ruby-code/
125
-
126
- ## Documentation
127
-
128
- Documentation for Parser is available [online](https://whitequark.github.io/parser/).
129
-
130
- ### Node names
131
-
132
- Several Parser nodes seem to be confusing enough to warrant a dedicated README section.
133
-
134
- #### (block)
135
-
136
- The `(block)` node passes a Ruby block, that is, a closure, to a method call represented by its first child, a `(send)`, `(super)` or `(zsuper)` node. To demonstrate:
137
-
138
- ```
139
- $ ruby-parse -e 'foo { |x| x + 2 }'
140
- (block
141
- (send nil :foo)
142
- (args
143
- (arg :x))
144
- (send
145
- (lvar :x) :+
146
- (int 2)))
147
- ```
148
-
149
- #### (begin) and (kwbegin)
150
-
151
- **TL;DR: Unless you perform rewriting, treat `(begin)` and `(kwbegin)` as the same node type.**
152
-
153
- Both `(begin)` and `(kwbegin)` nodes represent compound statements, that is, several expressions which are executed sequentally and the value of the last one is the value of entire compound statement. They may take several forms in the source code:
154
-
155
- * `foo; bar`: without delimiters
156
- * `(foo; bar)`: parenthesized
157
- * `begin foo; bar; end`: grouped with `begin` keyword
158
- * `def x; foo; bar; end`: grouped inside a method definition
159
-
160
- and so on.
161
-
162
- ```
163
- $ ruby-parse -e '(foo; bar)'
164
- (begin
165
- (send nil :foo)
166
- (send nil :bar))
167
- $ ruby-parse -e 'def x; foo; bar end'
168
- (def :x
169
- (args)
170
- (begin
171
- (send nil :foo)
172
- (send nil :bar)))
173
- ```
174
-
175
- Note that, despite its name, `kwbegin` node only has tangential relation to the `begin` keyword. Normally, Parser AST is semantic, that is, if two constructs look differently but behave identically, they get parsed to the same node. However, there exists a peculiar construct called post-loop in Ruby:
176
-
177
- ```
178
- begin
179
- body
180
- end while condition
181
- ```
182
-
183
- This specific syntactic construct, that is, keyword `begin..end` block followed by a postfix `while`, [behaves][postloop] very unlike other similar constructs, e.g. `(body) while condition`. While the body itself is wrapped into a `while-post` node, Parser also supports rewriting, and in that context it is important to not accidentally convert one kind of loop into another.
184
-
185
- [postloop]: http://rosettacode.org/wiki/Loops/Do-while#Ruby
186
-
187
- ```
188
- $ ruby-parse -e 'begin foo end while cond'
189
- (while-post
190
- (send nil :cond)
191
- (kwbegin
192
- (send nil :foo)))
193
- $ ruby-parse -e 'foo while cond'
194
- (while
195
- (send nil :cond)
196
- (send nil :foo))
197
- $ ruby-parse -e '(foo) while cond'
198
- (while
199
- (send nil :cond)
200
- (begin
201
- (send nil :foo)))
202
- ```
203
-
204
- (Parser also needs the `(kwbegin)` node type internally, and it is highly problematic to map it back to `(begin)`.)
205
-
206
- ## Backwards compatibility
207
-
208
- Parser does _not_ use semantic versioning. Parser versions are structured as `x.y.z.t`,
209
- where `x.y.z` indicates the most recent supported Ruby release (support for every
210
- Ruby release that is chronologically earlier is implied), and `t` is a monotonically
211
- increasing number.
212
-
213
- The public API of Parser as well as the AST format (as listed in the documentation)
214
- are considered stable forever, although support for old Ruby versions may be removed
215
- at some point.
216
-
217
- Sometimes it is necessary to modify the format of AST nodes that are already being emitted
218
- in a way that would break existing applications. To avoid such breakage, applications
219
- must opt-in to these modifications; without explicit opt-in, Parser will continue to emit
220
- the old AST node format. The most recent set of opt-ins is specified in
221
- the [usage section](#usage) of this README.
222
-
223
- ## Compatibility with Ruby MRI
224
-
225
- Unfortunately, Ruby MRI often changes syntax in patchlevel versions. This has happened, at least, for every release since 1.9; for example, commits [c5013452](https://github.com/ruby/ruby/commit/c501345218dc5fb0fae90d56a0c6fd19d38df5bb) and [04bb9d6b](https://github.com/ruby/ruby/commit/04bb9d6b75a55d4000700769eead5a5cb942c25b) were backported all the way from HEAD to 1.9. Moreover, there is no simple way to track these changes.
226
-
227
- This policy makes it all but impossible to make Parser precisely compatible with the Ruby MRI parser. Indeed, at September 2014, it would be necessary to maintain and update ten different parsers together with their lexer quirks in order to be able to emulate any given released Ruby MRI version.
228
-
229
- As a result, Parser chooses a different path: the `parser/rubyXY` parsers recognize the syntax of the latest minor version of Ruby MRI X.Y at the time of the gem release.
230
-
231
- ## Compatibility with MacRuby and RubyMotion
232
-
233
- Parser implements the MacRuby 0.12 and RubyMotion mid-2015 parsers precisely. However, the lexers of these have been forked off Ruby MRI and independently maintained for some time, and because of that, Parser may accept some code that these upstream implementations are unable to parse.
234
-
235
- ## Known issues
236
-
237
- Adding support for the following Ruby MRI features in Parser would needlessly complicate it, and as they all are very specific and rarely occuring corner cases, this is not done.
238
-
239
- Parser has been extensively tested; in particular, it parses almost entire [Rubygems][rg] corpus. For every issue, a breakdown of affected gems is offered.
240
-
241
- [rg]: https://rubygems.org
242
-
243
- ### Void value expressions
244
-
245
- Ruby MRI prohibits so-called "void value expressions". For a description
246
- of what a void value expression is, see [this
247
- gist](https://gist.github.com/JoshCheek/5625007) and [this Parser
248
- issue](https://github.com/whitequark/parser/issues/72).
249
-
250
- It is unknown whether any gems are affected by this issue.
251
-
252
- ### Invalid characters inside comments and literals
253
-
254
- Ruby MRI permits arbitrary non-7-bit byte sequences to appear in comments, as well as in string or symbol literals in form of escape sequences, regardless of source encoding. Parser requires all source code, including the expanded escape sequences, to consist of valid byte sequences in the source encoding that are convertible to UTF-8.
255
-
256
- As of 2013-07-25, there are about 180 affected gems.
257
-
258
- ### \u escape in 1.8 mode
259
-
260
- Ruby MRI 1.8 permits to specify a bare `\u` escape sequence in a string; it treats it like `u`. Ruby MRI 1.9 and later treat `\u` as a prefix for Unicode escape sequence and do not allow it to appear bare. Parser follows 1.9+ behavior.
261
-
262
- As of 2013-07-25, affected gems are: activerdf, activerdf_net7, fastreader, gkellog-reddy.
263
-
264
- ### Dollar-dash
265
-
266
- (This one is so obscure I couldn't even think of a saner name for this issue.) Pre-2.1 Ruby allows
267
- to specify a global variable named `$-`. Ruby 2.1 and later treat it as a syntax error. Parser
268
- follows 2.1 behavior.
269
-
270
- No known code is affected by this issue.
271
-
272
- ## Contributors
273
-
274
- * [whitequark][]
275
- * Markus Schirp ([mbj][])
276
- * Yorick Peterse ([yorickpeterse][])
277
- * Magnus Holm ([judofyr][])
278
- * Bozhidar Batsov ([bbatsov][])
279
-
280
- [whitequark]: https://github.com/whitequark
281
- [mbj]: https://github.com/mbj
282
- [yorickpeterse]: https://github.com/yorickpeterse
283
- [judofyr]: https://github.com/judofyr
284
- [bbatsov]: https://github.com/bbatsov
285
-
286
- ## Acknowledgements
287
-
288
- The lexer testsuite is derived from
289
- [ruby\_parser](https://github.com/seattlerb/ruby_parser).
290
-
291
- The Bison parser rules are derived from [Ruby MRI](https://github.com/ruby/ruby)
292
- parse.y.
293
-
294
- ## Contributing
295
-
296
- 1. Make sure you have [Ragel ~> 6.7](http://www.complang.org/ragel/) installed
297
- 2. Fork it
298
- 3. Create your feature branch (`git checkout -b my-new-feature`)
299
- 4. Commit your changes (`git commit -am 'Add some feature'`)
300
- 5. Push to the branch (`git push origin my-new-feature`)
301
- 6. Create new Pull Request
data/Rakefile DELETED
@@ -1,165 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/gem_tasks'
5
- require 'rake/testtask'
6
- require 'rake/clean'
7
- require 'date'
8
-
9
- task :default => [:test]
10
-
11
- Rake::TestTask.new do |t|
12
- t.libs = %w(test/ lib/)
13
- t.test_files = FileList["test/**/test_*.rb"]
14
- t.warning = false
15
- end
16
-
17
- task :test_cov do
18
- ENV['COVERAGE'] = '1'
19
- Rake::Task['test'].invoke
20
- end
21
-
22
- task :build => [:generate_release, :changelog]
23
-
24
- GENERATED_FILES = %w(lib/parser/lexer.rb
25
- lib/parser/ruby18.rb
26
- lib/parser/ruby19.rb
27
- lib/parser/ruby20.rb
28
- lib/parser/ruby21.rb
29
- lib/parser/ruby22.rb
30
- lib/parser/ruby23.rb
31
- lib/parser/ruby24.rb
32
- lib/parser/ruby25.rb
33
- lib/parser/ruby26.rb
34
- lib/parser/macruby.rb
35
- lib/parser/rubymotion.rb)
36
-
37
- CLEAN.include(GENERATED_FILES)
38
-
39
- ENCODING_COMMENT = "# -*- encoding:utf-8; warn-indent:false; frozen_string_literal: true -*-\n"
40
-
41
- desc 'Generate the Ragel lexer and Racc parser.'
42
- task :generate => GENERATED_FILES do
43
- Rake::Task[:ragel_check].invoke
44
- GENERATED_FILES.each do |filename|
45
- content = File.read(filename)
46
- content = ENCODING_COMMENT + content unless content.start_with?(ENCODING_COMMENT)
47
-
48
- File.open(filename, 'w') do |io|
49
- io.write content
50
- end
51
- end
52
- end
53
-
54
- task :regenerate => [:clean, :generate]
55
-
56
- desc 'Generate the Ragel lexer and Racc parser in release mode.'
57
- task :generate_release => [:clean_env, :regenerate]
58
-
59
- task :clean_env do
60
- ENV.delete 'RACC_DEBUG'
61
- end
62
-
63
- task :ragel_check do
64
- require 'cliver'
65
- Cliver.assert('ragel', '~> 6.7')
66
- end
67
-
68
- desc 'Generate YARD documentation'
69
- task :yard => :generate do
70
- sh('yard doc')
71
- end
72
-
73
- PAGES_REPO = 'git@github.com:whitequark/parser'
74
-
75
- desc "Build and deploy documentation to GitHub pages"
76
- task :pages do
77
- system "git clone #{PAGES_REPO} gh-temp/ -b gh-pages; rm gh-temp/* -rf; touch gh-temp/.nojekyll" or abort
78
- system "yardoc -o gh-temp/;" or abort
79
- system "cd gh-temp/; git add -A; git commit -m 'Updated pages.'; git push -f origin gh-pages" or abort
80
- FileUtils.rm_rf 'gh-temp'
81
- end
82
-
83
- desc 'Generate Changelog'
84
- task :changelog do
85
- fs = "\u{fffd}"
86
- format = "%d#{fs}%s#{fs}%an#{fs}%ai"
87
-
88
- # Format: version => { commit-class => changes }
89
- changelog = Hash.new do |hash, version|
90
- hash[version] = Hash.new do |hash, klass|
91
- hash[klass] = []
92
- end
93
- end
94
-
95
- branch = `git describe HEAD --all`.strip.gsub(/.+\/([^\/]+)$/, '\1')
96
-
97
- IO.popen("git log --pretty='#{format}' " \
98
- "remotes/origin/2.0 remotes/origin/2.1 remotes/origin/2.2 #{branch}", 'r') do |io|
99
- current_version = nil
100
-
101
- io.each_line do |line|
102
- version, message, author, date = line.
103
- match(/^(?: \((.*)\))?#{fs}(.*)#{fs}(.*)#{fs}(.*)$/o).captures
104
- date = Date.parse(date)
105
-
106
- current_version = "#{$1} (#{date})" if version =~ /(v[\d\w.]+)/
107
- current_version = "Not released (#{date})" \
108
- if version =~ /(^| |\/)#{Regexp.escape branch}$/ && !branch.start_with?('v')
109
-
110
- next if current_version.nil?
111
- changelog[current_version] # add a hash
112
-
113
- next if message !~ /^[+*-]/
114
- changelog[current_version][message[0]] << "#{message[1..-1]} (#{author})"
115
- end
116
- end
117
-
118
- commit_classes = {
119
- '*' => 'API modifications:',
120
- '+' => 'Features implemented:',
121
- '-' => 'Bugs fixed:',
122
- }
123
-
124
- File.open('CHANGELOG.md', 'w') do |io|
125
- io.puts 'Changelog'
126
- io.puts '========='
127
- io.puts
128
-
129
- changelog.each do |version, commits|
130
- next if commits.empty?
131
- io.puts version
132
- io.puts '-' * version.length
133
- io.puts
134
-
135
- commit_classes.each do |sigil, description|
136
- next unless commits[sigil].any?
137
-
138
- io.puts description
139
- commits[sigil].uniq.each do |commit|
140
- io.puts " * #{commit.gsub('<', '\<').lstrip}"
141
- end
142
- io.puts
143
- end
144
- end
145
- end
146
-
147
- sh('git commit CHANGELOG.md -m "Update changelog." || true')
148
- end
149
-
150
- rule '.rb' => '.rl' do |t|
151
- sh "ragel -F1 -R #{t.source} -o #{t.name}"
152
- end
153
-
154
- rule '.rb' => '.y' do |t|
155
- opts = [ "--superclass=Parser::Base",
156
- t.source,
157
- "-o", t.name
158
- ]
159
- opts << "--no-line-convert" unless ENV['RACC_DEBUG']
160
- opts << "--debug" if ENV['RACC_DEBUG']
161
-
162
- sh "racc", *opts
163
- end
164
-
165
- task :test => [:generate]
data/ci/run_rubocop_specs DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -eux
4
-
5
- bundle install
6
- rake generate
7
-
8
- git clone https://github.com/rubocop-hq/rubocop.git --depth=1
9
- cd rubocop
10
- export BUNDLE_GEMFILE=Gemfile
11
- echo "gem 'parser', path: '../'" > Gemfile.local
12
-
13
- bundle install
14
- bundle exec rake spec