parser 3.2.2.3 → 3.3.0.5
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/lib/parser/all.rb +1 -0
- data/lib/parser/builders/default.rb +37 -10
- data/lib/parser/current.rb +14 -5
- data/lib/parser/lexer/literal.rb +16 -1
- data/lib/parser/lexer-F0.rb +295 -243
- data/lib/parser/lexer-F1.rb +444 -383
- data/lib/parser/macruby.rb +2 -2
- data/lib/parser/messages.rb +46 -41
- data/lib/parser/ruby18.rb +2 -2
- data/lib/parser/ruby19.rb +2 -2
- data/lib/parser/ruby20.rb +2 -2
- data/lib/parser/ruby21.rb +2 -2
- data/lib/parser/ruby22.rb +2 -2
- data/lib/parser/ruby23.rb +2 -2
- data/lib/parser/ruby24.rb +2 -2
- data/lib/parser/ruby25.rb +2 -2
- data/lib/parser/ruby26.rb +2 -2
- data/lib/parser/ruby27.rb +2 -2
- data/lib/parser/ruby30.rb +2 -2
- data/lib/parser/ruby31.rb +2 -2
- data/lib/parser/ruby32.rb +2 -2
- data/lib/parser/ruby33.rb +6782 -6897
- data/lib/parser/ruby34.rb +12589 -0
- data/lib/parser/rubymotion.rb +2 -2
- data/lib/parser/runner.rb +5 -0
- data/lib/parser/source/comment/associator.rb +7 -7
- data/lib/parser/static_environment.rb +12 -0
- data/lib/parser/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6522bb3594d6cc37d08b4b3dc827c4796933a368ac8518e9e3aa036795359819
|
4
|
+
data.tar.gz: 65e8a84d3efef60da0460b2270a3127b8bb92534797a003c29de33a9caa538a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ff8c442f2d7638629a2cbefae2b0432bec189cb7846c62217da0bc5709559bd93b870af4bf061d4998067955c7649ee531910f7e13a4902ba02a329bbc171b3
|
7
|
+
data.tar.gz: d97e4af8e9c64bad8aaf4a76d9359a30683f8528de3727522b0bc73c25259a796051c708c1b1489ce7b4dbf336e0835897795364c4db8c0a819c632d32cc48aa
|
data/lib/parser/all.rb
CHANGED
@@ -594,7 +594,13 @@ module Parser
|
|
594
594
|
end
|
595
595
|
|
596
596
|
def gvar(token)
|
597
|
-
|
597
|
+
gvar_name = value(token)
|
598
|
+
|
599
|
+
if gvar_name.start_with?('$0') && gvar_name.length > 2
|
600
|
+
diagnostic :error, :gvar_name, { :name => gvar_name }, loc(token)
|
601
|
+
end
|
602
|
+
|
603
|
+
n(:gvar, [ gvar_name.to_sym ],
|
598
604
|
variable_map(token))
|
599
605
|
end
|
600
606
|
|
@@ -654,6 +660,13 @@ module Parser
|
|
654
660
|
end
|
655
661
|
|
656
662
|
unless @parser.static_env.declared?(name)
|
663
|
+
if @parser.version == 33 &&
|
664
|
+
name == :it &&
|
665
|
+
@parser.context.in_block &&
|
666
|
+
!@parser.max_numparam_stack.has_ordinary_params?
|
667
|
+
diagnostic :warning, :ambiguous_it_call, nil, node.loc.expression
|
668
|
+
end
|
669
|
+
|
657
670
|
return n(:send, [ nil, name ],
|
658
671
|
var_send_map(node))
|
659
672
|
end
|
@@ -1690,24 +1703,34 @@ module Parser
|
|
1690
1703
|
cond
|
1691
1704
|
end
|
1692
1705
|
|
1693
|
-
when :and, :or
|
1706
|
+
when :and, :or
|
1694
1707
|
lhs, rhs = *cond
|
1695
1708
|
|
1696
|
-
|
1697
|
-
when :irange then :iflipflop
|
1698
|
-
when :erange then :eflipflop
|
1699
|
-
end
|
1700
|
-
|
1701
|
-
if [:and, :or].include?(cond.type) &&
|
1702
|
-
@parser.version == 18
|
1709
|
+
if @parser.version == 18
|
1703
1710
|
cond
|
1704
1711
|
else
|
1705
|
-
cond.updated(type, [
|
1712
|
+
cond.updated(cond.type, [
|
1706
1713
|
check_condition(lhs),
|
1707
1714
|
check_condition(rhs)
|
1708
1715
|
])
|
1709
1716
|
end
|
1710
1717
|
|
1718
|
+
when :irange, :erange
|
1719
|
+
lhs, rhs = *cond
|
1720
|
+
|
1721
|
+
type = case cond.type
|
1722
|
+
when :irange then :iflipflop
|
1723
|
+
when :erange then :eflipflop
|
1724
|
+
end
|
1725
|
+
|
1726
|
+
lhs_condition = check_condition(lhs) unless lhs.nil?
|
1727
|
+
rhs_condition = check_condition(rhs) unless rhs.nil?
|
1728
|
+
|
1729
|
+
return cond.updated(type, [
|
1730
|
+
lhs_condition,
|
1731
|
+
rhs_condition
|
1732
|
+
])
|
1733
|
+
|
1711
1734
|
when :regexp
|
1712
1735
|
n(:match_current_line, [ cond ], expr_map(cond.loc.expression))
|
1713
1736
|
|
@@ -2245,6 +2268,10 @@ module Parser
|
|
2245
2268
|
|
2246
2269
|
def static_regexp_node(node)
|
2247
2270
|
if node.type == :regexp
|
2271
|
+
if @parser.version >= 33 && node.children[0..-2].any? { |child| child.type != :str }
|
2272
|
+
return nil
|
2273
|
+
end
|
2274
|
+
|
2248
2275
|
parts, options = node.children[0..-2], node.children[-1]
|
2249
2276
|
static_regexp(parts, options)
|
2250
2277
|
end
|
data/lib/parser/current.rb
CHANGED
@@ -102,7 +102,7 @@ module Parser
|
|
102
102
|
CurrentRuby = Ruby31
|
103
103
|
|
104
104
|
when /^3\.2\./
|
105
|
-
current_version = '3.2.
|
105
|
+
current_version = '3.2.3'
|
106
106
|
if RUBY_VERSION != current_version
|
107
107
|
warn_syntax_deviation 'parser/ruby32', current_version
|
108
108
|
end
|
@@ -111,7 +111,7 @@ module Parser
|
|
111
111
|
CurrentRuby = Ruby32
|
112
112
|
|
113
113
|
when /^3\.3\./
|
114
|
-
current_version = '3.3.0
|
114
|
+
current_version = '3.3.0'
|
115
115
|
if RUBY_VERSION != current_version
|
116
116
|
warn_syntax_deviation 'parser/ruby33', current_version
|
117
117
|
end
|
@@ -119,10 +119,19 @@ module Parser
|
|
119
119
|
require 'parser/ruby33'
|
120
120
|
CurrentRuby = Ruby33
|
121
121
|
|
122
|
+
when /^3\.4\./
|
123
|
+
current_version = '3.4.0'
|
124
|
+
if RUBY_VERSION != current_version
|
125
|
+
warn_syntax_deviation 'parser/ruby34', current_version
|
126
|
+
end
|
127
|
+
|
128
|
+
require 'parser/ruby34'
|
129
|
+
CurrentRuby = Ruby34
|
130
|
+
|
122
131
|
else # :nocov:
|
123
132
|
# Keep this in sync with released Ruby.
|
124
|
-
warn_syntax_deviation 'parser/
|
125
|
-
require 'parser/
|
126
|
-
CurrentRuby =
|
133
|
+
warn_syntax_deviation 'parser/ruby33', '3.3.x'
|
134
|
+
require 'parser/ruby33'
|
135
|
+
CurrentRuby = Ruby33
|
127
136
|
end
|
128
137
|
end
|
data/lib/parser/lexer/literal.rb
CHANGED
@@ -5,6 +5,8 @@ module Parser
|
|
5
5
|
|
6
6
|
class Lexer::Literal
|
7
7
|
DELIMITERS = { '(' => ')', '[' => ']', '{' => '}', '<' => '>' }
|
8
|
+
SPACE = ' '.ord
|
9
|
+
TAB = "\t".ord
|
8
10
|
|
9
11
|
TYPES = {
|
10
12
|
# type start token interpolate?
|
@@ -234,7 +236,20 @@ module Parser
|
|
234
236
|
protected
|
235
237
|
|
236
238
|
def delimiter?(delimiter)
|
237
|
-
if
|
239
|
+
if heredoc?
|
240
|
+
# This heredoc is valid:
|
241
|
+
# <<~E
|
242
|
+
# E
|
243
|
+
# and this:
|
244
|
+
# <<~E
|
245
|
+
# E
|
246
|
+
# but this one is not:
|
247
|
+
# <<~' E'
|
248
|
+
# E
|
249
|
+
# because there are not enough leading spaces in the closing delimiter.
|
250
|
+
delimiter.end_with?(@end_delim) &&
|
251
|
+
delimiter.sub(/#{Regexp.escape(@end_delim)}\z/, '').bytes.all? { |c| c == SPACE || c == TAB }
|
252
|
+
elsif @indent
|
238
253
|
@end_delim == delimiter.lstrip
|
239
254
|
else
|
240
255
|
@end_delim == delimiter
|