parser 2.5.3.0 → 2.6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +41 -17
- data/CHANGELOG.md +11 -2
- data/ci/run_rubocop_specs +14 -0
- data/lib/parser/current.rb +1 -1
- data/lib/parser/lexer.rl +19 -19
- data/lib/parser/lexer/literal.rb +4 -0
- data/lib/parser/version.rb +1 -1
- data/parser.gemspec +0 -1
- data/test/test_parser.rb +32 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4603be64062f43f204650161874219f6a1250d81dd11705ca39482e7b70e968
|
4
|
+
data.tar.gz: 4ac43b4edcd13c7ac53d801533492999a5786138f485c9d06b9fa5329635790a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 770c2d3e8eca4f64081b10d6053e9576ec795fdb0605b5282dfd0b312fa2de71e04478177a3458a2e0fa36d1f484654f72b642658df91fa997388bff0ef07af3
|
7
|
+
data.tar.gz: 81fecd3087121fbee6e26dfc09d9cabc5449f237379e514dc88852fd85d1dd6f6189435fca1817409341b4eb505c6016afefb85e48c4170f930223480a85e8de
|
data/.travis.yml
CHANGED
@@ -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
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
script:
|
21
|
-
- bundle exec rake test_cov
|
43
|
+
- gem install bundler
|
44
|
+
- bundle --version
|
45
|
+
- gem --version
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
-
|
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
|
data/lib/parser/current.rb
CHANGED
data/lib/parser/lexer.rl
CHANGED
@@ -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.
|
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
|
data/lib/parser/lexer/literal.rb
CHANGED
data/lib/parser/version.rb
CHANGED
data/parser.gemspec
CHANGED
data/test/test_parser.rb
CHANGED
@@ -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.
|
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:
|
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
|