parser 2.5.3.0 → 2.6.0.0

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
  SHA256:
3
- metadata.gz: 77bd0a20c41d5920ff53bc78caad94a0c2fc7d713ae9e6c2eeaf25e007b4eb87
4
- data.tar.gz: e172d0fc395b41eefe2a4e2e522c62729ba7ba6ccbcf7c4caffe9a3d644d09dc
3
+ metadata.gz: c4603be64062f43f204650161874219f6a1250d81dd11705ca39482e7b70e968
4
+ data.tar.gz: 4ac43b4edcd13c7ac53d801533492999a5786138f485c9d06b9fa5329635790a
5
5
  SHA512:
6
- metadata.gz: 07a1e0b7f53363979ca9a9a4601982adc897f82d7aad0dde87219c9510e4dd2f81a0b1d2bdb9c74ca60ea46f44a36c515caa7f009876dbbb2ab0f38046e4ab8e
7
- data.tar.gz: cf89632cc8124a50e6d0964a527738f2deb98978f7caa66609d04e438c5daafafa30ba5cfd9b30a18f50b32e9319f6c478178267465eaa6385e222b1bf831dc3
6
+ metadata.gz: 770c2d3e8eca4f64081b10d6053e9576ec795fdb0605b5282dfd0b312fa2de71e04478177a3458a2e0fa36d1f484654f72b642658df91fa997388bff0ef07af3
7
+ data.tar.gz: 81fecd3087121fbee6e26dfc09d9cabc5449f237379e514dc88852fd85d1dd6f6189435fca1817409341b4eb505c6016afefb85e48c4170f930223480a85e8de
@@ -1,21 +1,45 @@
1
1
  dist: trusty
2
2
  language: ruby
3
- rvm:
4
- - 2.0.0
5
- - 2.2.9
6
- - 2.3.6
7
- - 2.4.3
8
- - 2.5.0
9
- - ruby-head
10
- - jruby-9.1.15.0
11
- - rbx-2
12
3
  matrix:
13
- allow_failures:
14
- - rvm: ruby-head
15
- - rvm: rbx-2
4
+ include:
5
+ - name: 2.0.0 / Parser tests
6
+ rvm: 2.0.0
7
+ script: bundle exec rake test_cov
8
+ - name: 2.2.10 / Parser tests
9
+ rvm: 2.2.10
10
+ script: bundle exec rake test_cov
11
+ - name: 2.3.8 / Parser tests
12
+ rvm: 2.3.8
13
+ script: bundle exec rake test_cov
14
+ - name: 2.4.5 / Parser tests
15
+ rvm: 2.4.5
16
+ script: bundle exec rake test_cov
17
+ - name: 2.5.3 / Parser tests
18
+ rvm: 2.5.3
19
+ script: bundle exec rake test_cov
20
+ - name: 2.6.0 / Parser tests
21
+ rvm: 2.6.0
22
+ script: bundle exec rake test_cov
23
+ - name: ruby-head / Parser tests
24
+ rvm: ruby-head
25
+ script: bundle exec rake test_cov
26
+ - name: jruby-9.1.15.0 / Parser tests
27
+ rvm: jruby-9.1.15.0
28
+ script: bundle exec rake test_cov
29
+ - name: rbx-2 / Parser tests
30
+ rvm: rbx-2
31
+ script: bundle exec rake test_cov
32
+ - name: 2.5.3 / Rubocop tests
33
+ rvm: 2.5.3
34
+ script: ./ci/run_rubocop_specs
35
+ - name: 2.6.0 / Rubocop tests
36
+ rvm: 2.6.0
37
+ script: ./ci/run_rubocop_specs
38
+ allow_failures:
39
+ - rvm: ruby-head
40
+ - rvm: rbx-2
41
+ - script: ./ci/run_rubocop_specs
16
42
  before_install:
17
- - gem install bundler
18
- - bundle --version
19
- - gem --version
20
- script:
21
- - bundle exec rake test_cov
43
+ - gem install bundler
44
+ - bundle --version
45
+ - gem --version
@@ -1,8 +1,17 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
- Not released (2018-10-29)
5
- -------------------------
4
+ v2.6.0.0 (2019-01-16)
5
+ ---------------------
6
+
7
+ API modifications:
8
+ * 2.6.0 was released, unmark is as -dev. (#538) (Ilya Bylich)
9
+
10
+ Bugs fixed:
11
+ * Fix parsing of "\\\n" escaped sequences in various literals. (#539) (Ilya Bylich)
12
+
13
+ v2.5.3.0 (2018-10-29)
14
+ ---------------------
6
15
 
7
16
  Bugs fixed:
8
17
  * lexer.rl: Fix parsing of 'm :key => m do; m() do end; end'. (#526) (Ilya Bylich)
@@ -0,0 +1,14 @@
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
@@ -66,7 +66,7 @@ module Parser
66
66
  CurrentRuby = Ruby25
67
67
 
68
68
  when /^2\.6\./
69
- current_version = '2.6.0-dev'
69
+ current_version = '2.6.0'
70
70
  if RUBY_VERSION != current_version
71
71
  warn_syntax_deviation 'parser/ruby26', current_version
72
72
  end
@@ -894,27 +894,27 @@ class Parser::Lexer
894
894
  end
895
895
  else
896
896
  # It does not. So this is an actual escape sequence, yay!
897
- if current_literal.regexp?
897
+ if current_literal.squiggly_heredoc? && escaped_char == "\n".freeze
898
+ # Squiggly heredocs like
899
+ # <<~-HERE
900
+ # 1\
901
+ # 2
902
+ # HERE
903
+ # treat '\' as a line continuation, but still dedent the body, so the heredoc above becomes "12\n".
904
+ # This information is emitted as is, without escaping,
905
+ # later this escape sequence (\\\n) gets handled manually in the Lexer::Dedenter
906
+ current_literal.extend_string(tok, @ts, @te)
907
+ elsif current_literal.supports_line_continuation_via_slash? && escaped_char == "\n".freeze
908
+ # Heredocs, regexp and a few other types of literals support line
909
+ # continuation via \\\n sequence. The code like
910
+ # "a\
911
+ # b"
912
+ # must be parsed as "ab"
913
+ current_literal.extend_string(tok.gsub("\\\n".freeze, ''.freeze), @ts, @te)
914
+ elsif current_literal.regexp?
898
915
  # Regular expressions should include escape sequences in their
899
- # escaped form. On the other hand, escaped newlines are removed.
916
+ # escaped form. On the other hand, escaped newlines are removed (in cases like "\\C-\\\n\\M-x")
900
917
  current_literal.extend_string(tok.gsub("\\\n".freeze, ''.freeze), @ts, @te)
901
- elsif current_literal.heredoc? && escaped_char == "\n".freeze
902
- if current_literal.squiggly_heredoc?
903
- # Squiggly heredocs like
904
- # <<~-HERE
905
- # 1\
906
- # 2
907
- # HERE
908
- # treat '\' as a line continuation, but still dedent the body, so the heredoc above becomes "12\n".
909
- # This information is emitted as is, without escaping,
910
- # later this escape sequence (\\n) gets handled manually in the Lexer::Dedenter
911
- current_literal.extend_string(tok, @ts, @te)
912
- else
913
- # Plain heredocs also parse \\n as a line continuation,
914
- # but they don't need to know that there was originally a newline in the
915
- # code, so we escape it and emit as " 1 2\n"
916
- current_literal.extend_string(tok.gsub("\\\n".freeze, ''.freeze), @ts, @te)
917
- end
918
918
  else
919
919
  current_literal.extend_string(@escape || tok, @ts, @te)
920
920
  end
@@ -227,6 +227,10 @@ module Parser
227
227
  end
228
228
  end
229
229
 
230
+ def supports_line_continuation_via_slash?
231
+ !words? && @interpolate
232
+ end
233
+
230
234
  protected
231
235
 
232
236
  def delimiter?(delimiter)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parser
4
- VERSION = '2.5.3.0'
4
+ VERSION = '2.6.0.0'
5
5
  end
@@ -12,7 +12,6 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = spec.description
13
13
  spec.homepage = 'https://github.com/whitequark/parser'
14
14
  spec.license = 'MIT'
15
- spec.has_rdoc = 'yard'
16
15
 
17
16
  spec.files = `git ls-files`.split + %w(
18
17
  lib/parser/lexer.rb
@@ -7052,4 +7052,36 @@ class TestParser < Minitest::Test
7052
7052
  %q{},
7053
7053
  ALL_VERSIONS)
7054
7054
  end
7055
+
7056
+ def test_parser_slash_slash_n_escaping_in_literals
7057
+ [
7058
+ ["'", "'", s(:dstr, s(:str, "a\\\n"), s(:str, "b")) ],
7059
+ ["<<-'HERE'\n", "\nHERE", s(:dstr, s(:str, "a\\\n"), s(:str, "b\n"))],
7060
+ ["%q{", "}", s(:dstr, s(:str, "a\\\n"), s(:str, "b")) ],
7061
+ ['"', '"', s(:str, "ab") ],
7062
+ ["<<-\"HERE\"\n", "\nHERE", s(:str, "ab\n") ],
7063
+ ["%{", "}", s(:str, "ab") ],
7064
+ ["%Q{", "}", s(:str, "ab") ],
7065
+ ["%w{", "}", s(:array, s(:str, "a\nb")) ],
7066
+ ["%W{", "}", s(:array, s(:str, "a\nb")) ],
7067
+ ["%i{", "}", s(:array, s(:sym, :"a\nb")) ],
7068
+ ["%I{", "}", s(:array, s(:sym, :"a\nb")) ],
7069
+ [":'", "'", s(:dsym, s(:str, "a\\\n"), s(:str, "b")) ],
7070
+ ["%s{", "}", s(:dsym, s(:str, "a\\\n"), s(:str, "b")) ],
7071
+ [':"', '"', s(:sym, :ab) ],
7072
+ ['/', '/', s(:regexp, s(:str, "ab"), s(:regopt)) ],
7073
+ ['%r{', '}', s(:regexp, s(:str, "ab"), s(:regopt)) ],
7074
+ ['%x{', '}', s(:xstr, s(:str, "ab")) ],
7075
+ ['`', '`', s(:xstr, s(:str, "ab")) ],
7076
+ ["<<-`HERE`\n", "\nHERE", s(:xstr, s(:str, "ab\n")) ],
7077
+ ].each do |literal_s, literal_e, expected|
7078
+ source = literal_s + "a\\\nb" + literal_e
7079
+
7080
+ assert_parses(
7081
+ expected,
7082
+ source,
7083
+ %q{},
7084
+ SINCE_2_0)
7085
+ end
7086
+ end
7055
7087
  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.5.3.0
4
+ version: 2.6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - whitequark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-29 00:00:00.000000000 Z
11
+ date: 2019-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast
@@ -170,6 +170,7 @@ files:
170
170
  - Rakefile
171
171
  - bin/ruby-parse
172
172
  - bin/ruby-rewrite
173
+ - ci/run_rubocop_specs
173
174
  - doc/AST_FORMAT.md
174
175
  - doc/CUSTOMIZATION.md
175
176
  - doc/INTERNALS.md