parser 2.7.1.5 → 3.0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/lib/parser/all.rb +1 -0
  3. data/lib/parser/ast/processor.rb +3 -0
  4. data/lib/parser/base.rb +1 -0
  5. data/lib/parser/builders/default.rb +126 -13
  6. data/lib/parser/context.rb +4 -0
  7. data/lib/parser/current.rb +16 -7
  8. data/lib/parser/current_arg_stack.rb +5 -2
  9. data/lib/parser/lexer.rb +872 -802
  10. data/lib/parser/max_numparam_stack.rb +12 -4
  11. data/lib/parser/messages.rb +1 -0
  12. data/lib/parser/meta.rb +4 -3
  13. data/lib/parser/ruby18.rb +6 -2
  14. data/lib/parser/ruby27.rb +3763 -3704
  15. data/lib/parser/ruby28.rb +8047 -0
  16. data/lib/parser/ruby30.rb +3657 -3649
  17. data/lib/parser/ruby31.rb +8226 -0
  18. data/lib/parser/runner.rb +6 -1
  19. data/lib/parser/source/buffer.rb +50 -27
  20. data/lib/parser/source/comment.rb +13 -0
  21. data/lib/parser/source/comment/associator.rb +17 -4
  22. data/lib/parser/source/tree_rewriter.rb +27 -0
  23. data/lib/parser/static_environment.rb +4 -0
  24. data/lib/parser/variables_stack.rb +4 -0
  25. data/lib/parser/version.rb +1 -1
  26. data/parser.gemspec +1 -20
  27. metadata +8 -95
  28. data/.travis.yml +0 -41
  29. data/.yardopts +0 -21
  30. data/CHANGELOG.md +0 -1137
  31. data/CONTRIBUTING.md +0 -17
  32. data/Gemfile +0 -10
  33. data/README.md +0 -309
  34. data/Rakefile +0 -167
  35. data/ci/run_rubocop_specs +0 -14
  36. data/doc/AST_FORMAT.md +0 -2284
  37. data/doc/CUSTOMIZATION.md +0 -37
  38. data/doc/INTERNALS.md +0 -21
  39. data/doc/css/.gitkeep +0 -0
  40. data/doc/css/common.css +0 -68
  41. data/lib/parser/lexer.rl +0 -2550
  42. data/lib/parser/macruby.y +0 -2208
  43. data/lib/parser/ruby18.y +0 -1936
  44. data/lib/parser/ruby19.y +0 -2185
  45. data/lib/parser/ruby20.y +0 -2363
  46. data/lib/parser/ruby21.y +0 -2364
  47. data/lib/parser/ruby22.y +0 -2371
  48. data/lib/parser/ruby23.y +0 -2377
  49. data/lib/parser/ruby24.y +0 -2415
  50. data/lib/parser/ruby25.y +0 -2412
  51. data/lib/parser/ruby26.y +0 -2420
  52. data/lib/parser/ruby27.y +0 -2949
  53. data/lib/parser/ruby30.y +0 -3048
  54. data/lib/parser/rubymotion.y +0 -2192
  55. data/test/bug_163/fixtures/input.rb +0 -5
  56. data/test/bug_163/fixtures/output.rb +0 -5
  57. data/test/bug_163/rewriter.rb +0 -20
  58. data/test/helper.rb +0 -103
  59. data/test/parse_helper.rb +0 -328
  60. data/test/racc_coverage_helper.rb +0 -133
  61. data/test/test_ast_processor.rb +0 -32
  62. data/test/test_base.rb +0 -31
  63. data/test/test_current.rb +0 -31
  64. data/test/test_diagnostic.rb +0 -95
  65. data/test/test_diagnostic_engine.rb +0 -59
  66. data/test/test_encoding.rb +0 -99
  67. data/test/test_lexer.rb +0 -3617
  68. data/test/test_lexer_stack_state.rb +0 -78
  69. data/test/test_meta.rb +0 -12
  70. data/test/test_parse_helper.rb +0 -83
  71. data/test/test_parser.rb +0 -9986
  72. data/test/test_runner_parse.rb +0 -56
  73. data/test/test_runner_rewrite.rb +0 -47
  74. data/test/test_source_buffer.rb +0 -165
  75. data/test/test_source_comment.rb +0 -36
  76. data/test/test_source_comment_associator.rb +0 -399
  77. data/test/test_source_map.rb +0 -14
  78. data/test/test_source_range.rb +0 -192
  79. data/test/test_source_rewriter.rb +0 -541
  80. data/test/test_source_rewriter_action.rb +0 -46
  81. data/test/test_source_tree_rewriter.rb +0 -361
  82. data/test/test_static_environment.rb +0 -45
  83. data/test/using_tree_rewriter/fixtures/input.rb +0 -3
  84. data/test/using_tree_rewriter/fixtures/output.rb +0 -3
  85. 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,309 +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
- Parser::Builders::Default.emit_arg_inside_procarg0 = true
32
- Parser::Builders::Default.emit_forward_arg = true
33
-
34
- Parse a chunk of code:
35
-
36
- p Parser::CurrentRuby.parse("2 + 2")
37
- # (send
38
- # (int 2) :+
39
- # (int 2))
40
-
41
- Access the AST's source map:
42
-
43
- p Parser::CurrentRuby.parse("2 + 2").loc
44
- # #<Parser::Source::Map::Send:0x007fe5a1ac2388
45
- # @dot=nil,
46
- # @begin=nil,
47
- # @end=nil,
48
- # @selector=#<Source::Range (string) 2...3>,
49
- # @expression=#<Source::Range (string) 0...5>>
50
-
51
- p Parser::CurrentRuby.parse("2 + 2").loc.selector.source
52
- # "+"
53
-
54
- Traverse the AST: see the documentation for [gem ast](https://whitequark.github.io/ast/).
55
-
56
- Parse a chunk of code and display all diagnostics:
57
-
58
- parser = Parser::CurrentRuby.new
59
- parser.diagnostics.consumer = lambda do |diag|
60
- puts diag.render
61
- end
62
-
63
- buffer = Parser::Source::Buffer.new('(string)', source: "foo *bar")
64
-
65
- p parser.parse(buffer)
66
- # (string):1:5: warning: `*' interpreted as argument prefix
67
- # foo *bar
68
- # ^
69
- # (send nil :foo
70
- # (splat
71
- # (send nil :bar)))
72
-
73
- If you reuse the same parser object for multiple `#parse` runs, you need to
74
- `#reset` it.
75
-
76
- You can also use the `ruby-parse` utility (it's bundled with the gem) to play
77
- with Parser:
78
-
79
- $ ruby-parse -L -e "2+2"
80
- (send
81
- (int 2) :+
82
- (int 2))
83
- 2+2
84
- ~ selector
85
- ~~~ expression
86
- (int 2)
87
- 2+2
88
- ~ expression
89
- (int 2)
90
- 2+2
91
-
92
- $ ruby-parse -E -e "2+2"
93
- 2+2
94
- ^ tINTEGER 2 expr_end [0 <= cond] [0 <= cmdarg]
95
- 2+2
96
- ^ tPLUS "+" expr_beg [0 <= cond] [0 <= cmdarg]
97
- 2+2
98
- ^ tINTEGER 2 expr_end [0 <= cond] [0 <= cmdarg]
99
- 2+2
100
- ^ false "$eof" expr_end [0 <= cond] [0 <= cmdarg]
101
- (send
102
- (int 2) :+
103
- (int 2))
104
-
105
- ## Features
106
-
107
- * Precise source location reporting.
108
- * [Documented](doc/AST_FORMAT.md) AST format which is convenient to work with.
109
- * A simple interface and a powerful, tweakable one.
110
- * Parses 1.8, 1.9, 2.0, 2.1, 2.2 and 2.3 syntax with backwards-compatible
111
- AST formats.
112
- * Parses MacRuby and RubyMotion syntax extensions.
113
- * [Rewriting][rewriting] support.
114
- * Parsing error recovery.
115
- * Improved [clang-like][] diagnostic messages with location information.
116
- * Written in pure Ruby, runs on MRI >=2.0.0, JRuby and Rubinius (and historically, all versions of Ruby since 1.8)
117
- * Only one runtime dependency: the [ast][] gem.
118
- * [Insane][insane-lexer] Ruby lexer rewritten from scratch in Ragel.
119
- * 100% test coverage for Bison grammars (except error recovery).
120
- * Readable, commented source code.
121
-
122
- [clang-like]: http://clang.llvm.org/diagnostics.html
123
- [ast]: https://rubygems.org/gems/ast
124
- [insane-lexer]: http://whitequark.org/blog/2013/04/01/ruby-hacking-guide-ch-11-finite-state-lexer/
125
- [rewriting]: http://whitequark.org/blog/2013/04/26/lets-play-with-ruby-code/
126
-
127
- ## Documentation
128
-
129
- Documentation for Parser is available [online](https://whitequark.github.io/parser/).
130
-
131
- ### Node names
132
-
133
- Several Parser nodes seem to be confusing enough to warrant a dedicated README section.
134
-
135
- #### (block)
136
-
137
- 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:
138
-
139
- ```
140
- $ ruby-parse -e 'foo { |x| x + 2 }'
141
- (block
142
- (send nil :foo)
143
- (args
144
- (arg :x))
145
- (send
146
- (lvar :x) :+
147
- (int 2)))
148
- ```
149
-
150
- #### (begin) and (kwbegin)
151
-
152
- **TL;DR: Unless you perform rewriting, treat `(begin)` and `(kwbegin)` as the same node type.**
153
-
154
- 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:
155
-
156
- * `foo; bar`: without delimiters
157
- * `(foo; bar)`: parenthesized
158
- * `begin foo; bar; end`: grouped with `begin` keyword
159
- * `def x; foo; bar; end`: grouped inside a method definition
160
-
161
- and so on.
162
-
163
- ```
164
- $ ruby-parse -e '(foo; bar)'
165
- (begin
166
- (send nil :foo)
167
- (send nil :bar))
168
- $ ruby-parse -e 'def x; foo; bar end'
169
- (def :x
170
- (args)
171
- (begin
172
- (send nil :foo)
173
- (send nil :bar)))
174
- ```
175
-
176
- 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:
177
-
178
- ```
179
- begin
180
- body
181
- end while condition
182
- ```
183
-
184
- 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.
185
-
186
- [postloop]: http://rosettacode.org/wiki/Loops/Do-while#Ruby
187
-
188
- ```
189
- $ ruby-parse -e 'begin foo end while cond'
190
- (while-post
191
- (send nil :cond)
192
- (kwbegin
193
- (send nil :foo)))
194
- $ ruby-parse -e 'foo while cond'
195
- (while
196
- (send nil :cond)
197
- (send nil :foo))
198
- $ ruby-parse -e '(foo) while cond'
199
- (while
200
- (send nil :cond)
201
- (begin
202
- (send nil :foo)))
203
- ```
204
-
205
- (Parser also needs the `(kwbegin)` node type internally, and it is highly problematic to map it back to `(begin)`.)
206
-
207
- ## Backwards compatibility
208
-
209
- Parser does _not_ use semantic versioning. Parser versions are structured as `x.y.z.t`,
210
- where `x.y.z` indicates the most recent supported Ruby release (support for every
211
- Ruby release that is chronologically earlier is implied), and `t` is a monotonically
212
- increasing number.
213
-
214
- The public API of Parser as well as the AST format (as listed in the documentation)
215
- are considered stable forever, although support for old Ruby versions may be removed
216
- at some point.
217
-
218
- Sometimes it is necessary to modify the format of AST nodes that are already being emitted
219
- in a way that would break existing applications. To avoid such breakage, applications
220
- must opt-in to these modifications; without explicit opt-in, Parser will continue to emit
221
- the old AST node format. The most recent set of opt-ins is specified in
222
- the [usage section](#usage) of this README.
223
-
224
- ## Compatibility with Ruby MRI
225
-
226
- 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.
227
-
228
- 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.
229
-
230
- 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.
231
-
232
- ## Compatibility with MacRuby and RubyMotion
233
-
234
- 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.
235
-
236
- ## Known issues
237
-
238
- Adding support for the following Ruby MRI features in Parser would needlessly complicate it, and as they all are very specific and rarely occurring corner cases, this is not done.
239
-
240
- Parser has been extensively tested; in particular, it parses almost entire [Rubygems][rg] corpus. For every issue, a breakdown of affected gems is offered.
241
-
242
- [rg]: https://rubygems.org
243
-
244
- ### Void value expressions
245
-
246
- Ruby MRI prohibits so-called "void value expressions". For a description
247
- of what a void value expression is, see [this
248
- gist](https://gist.github.com/JoshCheek/5625007) and [this Parser
249
- issue](https://github.com/whitequark/parser/issues/72).
250
-
251
- It is unknown whether any gems are affected by this issue.
252
-
253
- ### Invalid characters inside comments and literals
254
-
255
- 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.
256
-
257
- As of 2013-07-25, there are about 180 affected gems.
258
-
259
- ### \u escape in 1.8 mode
260
-
261
- 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.
262
-
263
- As of 2013-07-25, affected gems are: activerdf, activerdf_net7, fastreader, gkellog-reddy.
264
-
265
- ### Dollar-dash
266
-
267
- (This one is so obscure I couldn't even think of a saner name for this issue.) Pre-2.1 Ruby allows
268
- to specify a global variable named `$-`. Ruby 2.1 and later treat it as a syntax error. Parser
269
- follows 2.1 behavior.
270
-
271
- No known code is affected by this issue.
272
-
273
- ### EOF characters after embedded documents before 2.7
274
-
275
- Code like `"=begin\n""=end\0"` is invalid for all versions of Ruby before 2.7. Ruby 2.7 and later parses it
276
- normally. Parser follows 2.7 behavior.
277
-
278
- It is unknown whether any gems are affected by this issue.
279
-
280
- ## Contributors
281
-
282
- * [whitequark][]
283
- * Markus Schirp ([mbj][])
284
- * Yorick Peterse ([yorickpeterse][])
285
- * Magnus Holm ([judofyr][])
286
- * Bozhidar Batsov ([bbatsov][])
287
-
288
- [whitequark]: https://github.com/whitequark
289
- [mbj]: https://github.com/mbj
290
- [yorickpeterse]: https://github.com/yorickpeterse
291
- [judofyr]: https://github.com/judofyr
292
- [bbatsov]: https://github.com/bbatsov
293
-
294
- ## Acknowledgements
295
-
296
- The lexer testsuite is derived from
297
- [ruby\_parser](https://github.com/seattlerb/ruby_parser).
298
-
299
- The Bison parser rules are derived from [Ruby MRI](https://github.com/ruby/ruby)
300
- parse.y.
301
-
302
- ## Contributing
303
-
304
- 1. Make sure you have [Ragel ~> 6.7](http://www.complang.org/ragel/) installed
305
- 2. Fork it
306
- 3. Create your feature branch (`git checkout -b my-new-feature`)
307
- 4. Commit your changes (`git commit -am 'Add some feature'`)
308
- 5. Push to the branch (`git push origin my-new-feature`)
309
- 6. Create new Pull Request
data/Rakefile DELETED
@@ -1,167 +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 = true
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/ruby27.rb
35
- lib/parser/ruby30.rb
36
- lib/parser/macruby.rb
37
- lib/parser/rubymotion.rb)
38
-
39
- CLEAN.include(GENERATED_FILES)
40
-
41
- ENCODING_COMMENT = "# -*- encoding:utf-8; warn-indent:false; frozen_string_literal: true -*-\n"
42
-
43
- desc 'Generate the Ragel lexer and Racc parser.'
44
- task :generate => GENERATED_FILES do
45
- Rake::Task[:ragel_check].invoke
46
- GENERATED_FILES.each do |filename|
47
- content = File.read(filename)
48
- content = ENCODING_COMMENT + content unless content.start_with?(ENCODING_COMMENT)
49
-
50
- File.open(filename, 'w') do |io|
51
- io.write content
52
- end
53
- end
54
- end
55
-
56
- task :regenerate => [:clean, :generate]
57
-
58
- desc 'Generate the Ragel lexer and Racc parser in release mode.'
59
- task :generate_release => [:clean_env, :regenerate]
60
-
61
- task :clean_env do
62
- ENV.delete 'RACC_DEBUG'
63
- end
64
-
65
- task :ragel_check do
66
- require 'cliver'
67
- Cliver.assert('ragel', '~> 6.7')
68
- end
69
-
70
- desc 'Generate YARD documentation'
71
- task :yard => :generate do
72
- sh('yard doc')
73
- end
74
-
75
- PAGES_REPO = 'git@github.com:whitequark/parser'
76
-
77
- desc "Build and deploy documentation to GitHub pages"
78
- task :pages do
79
- system "git clone #{PAGES_REPO} gh-temp/ -b gh-pages; rm gh-temp/* -rf; touch gh-temp/.nojekyll" or abort
80
- system "yardoc -o gh-temp/;" or abort
81
- system "cd gh-temp/; git add -A; git commit -m 'Updated pages.'; git push -f origin gh-pages" or abort
82
- FileUtils.rm_rf 'gh-temp'
83
- end
84
-
85
- desc 'Generate Changelog'
86
- task :changelog do
87
- fs = "\u{fffd}"
88
- format = "%d#{fs}%s#{fs}%an#{fs}%ai"
89
-
90
- # Format: version => { commit-class => changes }
91
- changelog = Hash.new do |hash, version|
92
- hash[version] = Hash.new do |hash, klass|
93
- hash[klass] = []
94
- end
95
- end
96
-
97
- branch = `git describe HEAD --all`.strip.gsub(/.+\/([^\/]+)$/, '\1')
98
-
99
- IO.popen("git log --pretty='#{format}' " \
100
- "remotes/origin/2.0 remotes/origin/2.1 remotes/origin/2.2 #{branch}", 'r') do |io|
101
- current_version = nil
102
-
103
- io.each_line do |line|
104
- version, message, author, date = line.
105
- match(/^(?: \((.*)\))?#{fs}(.*)#{fs}(.*)#{fs}(.*)$/o).captures
106
- date = Date.parse(date)
107
-
108
- current_version = "#{$1} (#{date})" if version =~ /(v[\d\w.]+)/
109
- current_version = "Not released (#{date})" \
110
- if version =~ /(^| |\/)#{Regexp.escape branch}$/ && !branch.start_with?('v')
111
-
112
- next if current_version.nil?
113
- changelog[current_version] # add a hash
114
-
115
- next if message !~ /^[+*-]/
116
- changelog[current_version][message[0]] << "#{message[1..-1]} (#{author})"
117
- end
118
- end
119
-
120
- commit_classes = {
121
- '*' => 'API modifications:',
122
- '+' => 'Features implemented:',
123
- '-' => 'Bugs fixed:',
124
- }
125
-
126
- File.open('CHANGELOG.md', 'w') do |io|
127
- io.puts 'Changelog'
128
- io.puts '========='
129
- io.puts
130
-
131
- changelog.each do |version, commits|
132
- next if commits.empty?
133
- io.puts version
134
- io.puts '-' * version.length
135
- io.puts
136
-
137
- commit_classes.each do |sigil, description|
138
- next unless commits[sigil].any?
139
-
140
- io.puts description
141
- commits[sigil].uniq.each do |commit|
142
- io.puts " * #{commit.gsub('<', '\<').lstrip}"
143
- end
144
- io.puts
145
- end
146
- end
147
- end
148
-
149
- sh('git commit CHANGELOG.md -m "Update changelog." || true')
150
- end
151
-
152
- rule '.rb' => '.rl' do |t|
153
- sh "ragel -F1 -R #{t.source} -o #{t.name}"
154
- end
155
-
156
- rule '.rb' => '.y' do |t|
157
- opts = [ "--superclass=Parser::Base",
158
- t.source,
159
- "-o", t.name
160
- ]
161
- opts << "--no-line-convert" unless ENV['RACC_DEBUG']
162
- opts << "--debug" if ENV['RACC_DEBUG']
163
-
164
- sh "racc", *opts
165
- end
166
-
167
- task :test => [:generate]