parser 2.7.0.4 → 2.7.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +18 -29
- data/CHANGELOG.md +53 -1
- data/README.md +6 -6
- data/Rakefile +2 -1
- data/doc/AST_FORMAT.md +54 -5
- data/lib/parser.rb +1 -0
- data/lib/parser/all.rb +1 -0
- data/lib/parser/ast/processor.rb +7 -0
- data/lib/parser/builders/default.rb +63 -14
- data/lib/parser/current.rb +13 -4
- data/lib/parser/diagnostic.rb +1 -1
- data/lib/parser/diagnostic/engine.rb +1 -2
- data/lib/parser/lexer.rl +7 -0
- data/lib/parser/messages.rb +15 -0
- data/lib/parser/meta.rb +2 -2
- data/lib/parser/ruby27.y +16 -5
- data/lib/parser/ruby28.y +3016 -0
- data/lib/parser/runner.rb +26 -2
- data/lib/parser/runner/ruby_rewrite.rb +2 -2
- data/lib/parser/source/buffer.rb +3 -1
- data/lib/parser/source/comment/associator.rb +14 -4
- data/lib/parser/source/map/endless_definition.rb +23 -0
- data/lib/parser/source/range.rb +16 -0
- data/lib/parser/source/tree_rewriter.rb +49 -12
- data/lib/parser/source/tree_rewriter/action.rb +96 -26
- data/lib/parser/tree_rewriter.rb +1 -2
- data/lib/parser/version.rb +1 -1
- data/parser.gemspec +2 -1
- data/test/helper.rb +25 -6
- data/test/parse_helper.rb +11 -17
- data/test/test_ast_processor.rb +32 -0
- data/test/test_base.rb +1 -1
- data/test/test_current.rb +2 -0
- data/test/test_diagnostic.rb +6 -7
- data/test/test_diagnostic_engine.rb +5 -8
- data/test/test_lexer.rb +17 -8
- data/test/test_meta.rb +12 -0
- data/test/test_parser.rb +260 -21
- data/test/test_runner_parse.rb +22 -1
- data/test/test_runner_rewrite.rb +1 -1
- data/test/test_source_buffer.rb +4 -1
- data/test/test_source_comment.rb +2 -2
- data/test/test_source_comment_associator.rb +47 -15
- data/test/test_source_map.rb +1 -2
- data/test/test_source_range.rb +29 -9
- data/test/test_source_rewriter.rb +4 -4
- data/test/test_source_rewriter_action.rb +2 -2
- data/test/test_source_tree_rewriter.rb +96 -6
- metadata +14 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bab855c4abc633b9ba13f855d816f20948ee539f27bea7878b574f4d0b3232f7
|
4
|
+
data.tar.gz: 929aa201a2c06738c6202c8efb2afd2dda77e630805738007c39f3b8274fa717
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78e2e37d1ef61d2c125c1462ecb2e48ab8f76a06fd97bcba28ea4acd5fa60f77a296f859fd6ad67a787027b7a9e62d0fc34bedc8c23522bce21213d1ca49d780
|
7
|
+
data.tar.gz: 07fa5ad8fe63b8503ced8fa0143062385f1d2f99e542f80cc32375269a9ad75f07cc2b0e00838232a71a9e797ba5cab28b661d8a58765f558e29353462641f06
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -2,50 +2,39 @@ dist: trusty
|
|
2
2
|
language: ruby
|
3
3
|
matrix:
|
4
4
|
include:
|
5
|
-
- name: 2.
|
6
|
-
rvm: 2.
|
5
|
+
- name: 2.4.10 / Parser tests
|
6
|
+
rvm: 2.4.10
|
7
7
|
script: bundle exec rake test_cov
|
8
|
-
- name: 2.
|
9
|
-
rvm: 2.
|
8
|
+
- name: 2.5.8 / Parser tests
|
9
|
+
rvm: 2.5.8
|
10
10
|
script: bundle exec rake test_cov
|
11
|
-
- name: 2.
|
12
|
-
rvm: 2.
|
11
|
+
- name: 2.6.6 / Parser tests
|
12
|
+
rvm: 2.6.6
|
13
13
|
script: bundle exec rake test_cov
|
14
|
-
- name: 2.
|
15
|
-
rvm: 2.
|
16
|
-
script: bundle exec rake test_cov
|
17
|
-
- name: 2.5.7 / Parser tests
|
18
|
-
rvm: 2.5.7
|
19
|
-
script: bundle exec rake test_cov
|
20
|
-
- name: 2.6.5 / Parser tests
|
21
|
-
rvm: 2.6.5
|
22
|
-
script: bundle exec rake test_cov
|
23
|
-
- name: 2.7.0 / Parser tests
|
24
|
-
rvm: 2.7.0
|
14
|
+
- name: 2.7.1 / Parser tests
|
15
|
+
rvm: 2.7.1
|
25
16
|
script: bundle exec rake test_cov
|
26
17
|
- name: ruby-head / Parser tests
|
27
18
|
rvm: ruby-head
|
28
19
|
script: bundle exec rake test_cov
|
29
20
|
- name: jruby-9.1.15.0 / Parser tests
|
30
21
|
rvm: jruby-9.1.15.0
|
31
|
-
script: bundle exec rake
|
32
|
-
- name:
|
33
|
-
rvm:
|
34
|
-
script: bundle exec rake
|
35
|
-
- name: 2.5.
|
36
|
-
rvm: 2.5.
|
22
|
+
script: bundle exec rake test
|
23
|
+
- name: truffleruby / Parser tests
|
24
|
+
rvm: truffleruby
|
25
|
+
script: bundle exec rake test
|
26
|
+
- name: 2.5.8 / Rubocop tests
|
27
|
+
rvm: 2.5.8
|
37
28
|
script: ./ci/run_rubocop_specs
|
38
|
-
- name: 2.6.
|
39
|
-
rvm: 2.6.
|
29
|
+
- name: 2.6.6 / Rubocop tests
|
30
|
+
rvm: 2.6.6
|
40
31
|
script: ./ci/run_rubocop_specs
|
41
|
-
- name: 2.7.
|
42
|
-
rvm: 2.7.
|
32
|
+
- name: 2.7.1 / Rubocop tests
|
33
|
+
rvm: 2.7.1
|
43
34
|
script: ./ci/run_rubocop_specs
|
44
35
|
allow_failures:
|
45
36
|
- rvm: ruby-head
|
46
|
-
- rvm: rbx-2
|
47
37
|
- script: ./ci/run_rubocop_specs
|
48
38
|
before_install:
|
49
|
-
- gem install bundler -v '< 2'
|
50
39
|
- bundle --version
|
51
40
|
- gem --version
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,61 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
-
Not released (2020-
|
4
|
+
Not released (2020-05-26)
|
5
5
|
-------------------------
|
6
6
|
|
7
|
+
API modifications:
|
8
|
+
* fixed all warnings. tests are running in verbose mode now. (#685) (Ilya Bylich)
|
9
|
+
|
10
|
+
Features implemented:
|
11
|
+
* ruby-[parse, rewrite]: add legacy switches (#699) (Marc-André Lafortune)
|
12
|
+
* Added Parser::Source::Range#to_range. (#697) (Ilya Bylich)
|
13
|
+
* ruby28.y: support rescue modifier in endless method definition. (#696) (Ilya Bylich)
|
14
|
+
* ruby28.y: unify kwrest and no-kwrest rules. (#694) (Ilya Bylich)
|
15
|
+
* ruby28.y: add right hand assignment (#682) (Vladimir Dementyev)
|
16
|
+
|
17
|
+
Bugs fixed:
|
18
|
+
* fix Comment.associate for postfix conditions/loops (#688) (Marc-André Lafortune)
|
19
|
+
|
20
|
+
v2.7.1.2 (2020-04-30)
|
21
|
+
---------------------
|
22
|
+
|
23
|
+
Features implemented:
|
24
|
+
* ruby28.y: endless method definition (#676) (Vladimir Dementyev)
|
25
|
+
* ruby28.y: branch parser (#677) (Vladimir Dementyev)
|
26
|
+
|
27
|
+
Bugs fixed:
|
28
|
+
* ruby27.y: reject invalid lvar in pattern matching (#680) (Vladimir Dementyev)
|
29
|
+
|
30
|
+
v2.7.1.1 (2020-04-15)
|
31
|
+
---------------------
|
32
|
+
|
33
|
+
Features implemented:
|
34
|
+
* Add Source::Range#eql? and hash (#675) (Marc-André Lafortune)
|
35
|
+
* Source::TreeRewriter: Add #merge, #merge! and #empty? (#674) (Marc-André Lafortune)
|
36
|
+
|
37
|
+
v2.7.1.0 (2020-04-03)
|
38
|
+
---------------------
|
39
|
+
|
40
|
+
API modifications:
|
41
|
+
* Bump ruby versions to 2.4.10, 2.5.8, 2.6.6, 2.7.1. (#665) (Ilya Bylich)
|
42
|
+
|
43
|
+
Features implemented:
|
44
|
+
* ruby27.y: allow newlines inside braced pattern. (#664) (Ilya Bylich)
|
45
|
+
* ruby27.y: Allow trailing comma in hash pattern (#661) (Koichi ITO)
|
46
|
+
|
47
|
+
v2.7.0.5 (2020-03-20)
|
48
|
+
---------------------
|
49
|
+
|
50
|
+
Features implemented:
|
51
|
+
* ruby27.y: fix array pattern with tail source map (#659) (Vladimir Dementyev)
|
52
|
+
|
53
|
+
Bugs fixed:
|
54
|
+
* builder.rb: fix constant_pattern source map (#660) (Vladimir Dementyev)
|
55
|
+
|
56
|
+
v2.7.0.4 (2020-03-02)
|
57
|
+
---------------------
|
58
|
+
|
7
59
|
Bugs fixed:
|
8
60
|
* lexer.rl: allow spaces before comments-before-leading-dot. (#654) (Ilya Bylich)
|
9
61
|
|
data/README.md
CHANGED
@@ -24,10 +24,11 @@ below for explanation of `emit_*` calls):
|
|
24
24
|
|
25
25
|
require 'parser/current'
|
26
26
|
# opt-in to most recent AST format:
|
27
|
-
Parser::Builders::Default.emit_lambda
|
28
|
-
Parser::Builders::Default.emit_procarg0
|
29
|
-
Parser::Builders::Default.emit_encoding
|
30
|
-
Parser::Builders::Default.emit_index
|
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
|
31
32
|
|
32
33
|
Parse a chunk of code:
|
33
34
|
|
@@ -58,8 +59,7 @@ Parse a chunk of code and display all diagnostics:
|
|
58
59
|
puts diag.render
|
59
60
|
end
|
60
61
|
|
61
|
-
buffer = Parser::Source::Buffer.new('(string)')
|
62
|
-
buffer.source = "foo *bar"
|
62
|
+
buffer = Parser::Source::Buffer.new('(string)', source: "foo *bar")
|
63
63
|
|
64
64
|
p parser.parse(buffer)
|
65
65
|
# (string):1:5: warning: `*' interpreted as argument prefix
|
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ task :default => [:test]
|
|
11
11
|
Rake::TestTask.new do |t|
|
12
12
|
t.libs = %w(test/ lib/)
|
13
13
|
t.test_files = FileList["test/**/test_*.rb"]
|
14
|
-
t.warning =
|
14
|
+
t.warning = true
|
15
15
|
end
|
16
16
|
|
17
17
|
task :test_cov do
|
@@ -32,6 +32,7 @@ GENERATED_FILES = %w(lib/parser/lexer.rb
|
|
32
32
|
lib/parser/ruby25.rb
|
33
33
|
lib/parser/ruby26.rb
|
34
34
|
lib/parser/ruby27.rb
|
35
|
+
lib/parser/ruby28.rb
|
35
36
|
lib/parser/macruby.rb
|
36
37
|
lib/parser/rubymotion.rb)
|
37
38
|
|
data/doc/AST_FORMAT.md
CHANGED
@@ -637,7 +637,7 @@ Format:
|
|
637
637
|
(masgn (mlhs (ivasgn :@a) (cvasgn :@@b)) (array (splat (lvar :c))))
|
638
638
|
"@a, @@b = *c"
|
639
639
|
|
640
|
-
(masgn (mlhs (
|
640
|
+
(masgn (mlhs (lvasgn :a) (mlhs (lvasgn :b)) (lvasgn :c)) (lvar :d))
|
641
641
|
"a, (b, c) = d"
|
642
642
|
|
643
643
|
(masgn (mlhs (send (self) :a=) (send (self) :[]= (int 1))) (lvar :a))
|
@@ -730,6 +730,28 @@ Format:
|
|
730
730
|
|
731
731
|
~~~
|
732
732
|
|
733
|
+
### Right-hand assignment
|
734
|
+
|
735
|
+
Format:
|
736
|
+
|
737
|
+
~~~
|
738
|
+
(rasgn (int 1) (lvasgn :a))
|
739
|
+
"1 => a"
|
740
|
+
~~~~~~ expression
|
741
|
+
~~ operator
|
742
|
+
~~~
|
743
|
+
|
744
|
+
#### Multiple right-hand assignment
|
745
|
+
|
746
|
+
Format:
|
747
|
+
|
748
|
+
~~~
|
749
|
+
(mrasgn (send (int 13) :divmod (int 5)) (mlhs (lvasgn :a) (lvasgn :b)))
|
750
|
+
"13.divmod(5) => a,b"
|
751
|
+
~~~~~~~~~~~~~~~~~~~ expression
|
752
|
+
^^ operator
|
753
|
+
~~~
|
754
|
+
|
733
755
|
## Class and module definition
|
734
756
|
|
735
757
|
### Module
|
@@ -802,6 +824,33 @@ Format:
|
|
802
824
|
~~~~~~~~~~~~~~~~~ expression
|
803
825
|
~~~
|
804
826
|
|
827
|
+
### "Endless" method
|
828
|
+
|
829
|
+
Format:
|
830
|
+
|
831
|
+
~~~
|
832
|
+
(def_e :foo (args) (int 42))
|
833
|
+
"def foo() = 42"
|
834
|
+
~~~ keyword
|
835
|
+
~~~ name
|
836
|
+
^ assignment
|
837
|
+
~~~~~~~~~~~~~~ expression
|
838
|
+
~~~
|
839
|
+
|
840
|
+
|
841
|
+
### "Endless" singleton method
|
842
|
+
|
843
|
+
Format:
|
844
|
+
|
845
|
+
~~~
|
846
|
+
(defs_e (self) :foo (args) (int 42))
|
847
|
+
"def self.foo() = 42"
|
848
|
+
~~~ keyword
|
849
|
+
~~~ name
|
850
|
+
^ assignment
|
851
|
+
~~~~~~~~~~~~~~~~~~~ expression
|
852
|
+
~~~
|
853
|
+
|
805
854
|
### Undefinition
|
806
855
|
|
807
856
|
Format:
|
@@ -2068,7 +2117,7 @@ so a single item match with comma gets interpreted as an array.
|
|
2068
2117
|
(array-pattern-with-tail
|
2069
2118
|
(match-var :foo))
|
2070
2119
|
"in foo,"
|
2071
|
-
|
2120
|
+
~~~~ expression
|
2072
2121
|
~~~
|
2073
2122
|
|
2074
2123
|
### Matching using hash pattern
|
@@ -2139,7 +2188,7 @@ Format:
|
|
2139
2188
|
"in X[^foo bar]"
|
2140
2189
|
~ begin (const-pattern)
|
2141
2190
|
~ end (const-pattern)
|
2142
|
-
|
2191
|
+
~~~~~~~~~~~~ expression (const-pattern)
|
2143
2192
|
~ name (const-pattern.const)
|
2144
2193
|
~ expression (const-pattern.const)
|
2145
2194
|
~~~
|
@@ -2157,7 +2206,7 @@ Format:
|
|
2157
2206
|
"in X[foo:, bar:]"
|
2158
2207
|
~ begin (const-pattern)
|
2159
2208
|
~ end (const-pattern)
|
2160
|
-
|
2209
|
+
~~~~~~~~~~~~~ expression (const-pattern)
|
2161
2210
|
~ name (const-pattern.const)
|
2162
2211
|
~ expression (const-pattern.const)
|
2163
2212
|
~~~
|
@@ -2173,7 +2222,7 @@ Format:
|
|
2173
2222
|
"in X[]"
|
2174
2223
|
~ begin (const-pattern)
|
2175
2224
|
~ end (const-pattern)
|
2176
|
-
|
2225
|
+
~~~ expression (const-pattern)
|
2177
2226
|
~ name (const-pattern.const)
|
2178
2227
|
~ expression (const-pattern.const)
|
2179
2228
|
~~ expression (const-pattern.array_pattern)
|
data/lib/parser.rb
CHANGED
@@ -46,6 +46,7 @@ module Parser
|
|
46
46
|
require 'parser/source/map/variable'
|
47
47
|
require 'parser/source/map/keyword'
|
48
48
|
require 'parser/source/map/definition'
|
49
|
+
require 'parser/source/map/endless_definition'
|
49
50
|
require 'parser/source/map/send'
|
50
51
|
require 'parser/source/map/index'
|
51
52
|
require 'parser/source/map/condition'
|
data/lib/parser/all.rb
CHANGED
data/lib/parser/ast/processor.rb
CHANGED
@@ -75,6 +75,9 @@ module Parser
|
|
75
75
|
alias on_mlhs process_regular_node
|
76
76
|
alias on_masgn process_regular_node
|
77
77
|
|
78
|
+
alias on_rasgn process_regular_node
|
79
|
+
alias on_mrasgn process_regular_node
|
80
|
+
|
78
81
|
def on_const(node)
|
79
82
|
scope_node, name = *node
|
80
83
|
|
@@ -159,6 +162,8 @@ module Parser
|
|
159
162
|
])
|
160
163
|
end
|
161
164
|
|
165
|
+
alias on_def_e on_def
|
166
|
+
|
162
167
|
def on_defs(node)
|
163
168
|
definee_node, name, args_node, body_node = *node
|
164
169
|
|
@@ -168,6 +173,8 @@ module Parser
|
|
168
173
|
])
|
169
174
|
end
|
170
175
|
|
176
|
+
alias on_defs_e on_defs
|
177
|
+
|
171
178
|
alias on_undef process_regular_node
|
172
179
|
alias on_alias process_regular_node
|
173
180
|
|
@@ -619,6 +619,15 @@ module Parser
|
|
619
619
|
binary_op_map(lhs, eql_t, rhs))
|
620
620
|
end
|
621
621
|
|
622
|
+
def rassign(lhs, assoc_t, rhs)
|
623
|
+
n(:rasgn, [lhs, rhs], binary_op_map(lhs, assoc_t, rhs))
|
624
|
+
end
|
625
|
+
|
626
|
+
def multi_rassign(lhs, assoc_t, rhs)
|
627
|
+
n(:mrasgn, [ lhs, rhs ],
|
628
|
+
binary_op_map(lhs, assoc_t, rhs))
|
629
|
+
end
|
630
|
+
|
622
631
|
#
|
623
632
|
# Class and module definition
|
624
633
|
#
|
@@ -652,19 +661,28 @@ module Parser
|
|
652
661
|
definition_map(def_t, nil, name_t, end_t))
|
653
662
|
end
|
654
663
|
|
664
|
+
def def_endless_method(def_t, name_t, args,
|
665
|
+
assignment_t, body)
|
666
|
+
n(:def_e, [ value(name_t).to_sym, args, body ],
|
667
|
+
endless_definition_map(def_t, nil, name_t, assignment_t, body))
|
668
|
+
end
|
669
|
+
|
655
670
|
def def_singleton(def_t, definee, dot_t,
|
656
671
|
name_t, args,
|
657
672
|
body, end_t)
|
658
|
-
|
659
|
-
when :int, :str, :dstr, :sym, :dsym,
|
660
|
-
:regexp, :array, :hash
|
673
|
+
return unless validate_definee(definee)
|
661
674
|
|
662
|
-
|
675
|
+
n(:defs, [ definee, value(name_t).to_sym, args, body ],
|
676
|
+
definition_map(def_t, dot_t, name_t, end_t))
|
677
|
+
end
|
663
678
|
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
679
|
+
def def_endless_singleton(def_t, definee, dot_t,
|
680
|
+
name_t, args,
|
681
|
+
assignment_t, body)
|
682
|
+
return unless validate_definee(definee)
|
683
|
+
|
684
|
+
n(:defs_e, [ definee, value(name_t).to_sym, args, body ],
|
685
|
+
endless_definition_map(def_t, dot_t, name_t, assignment_t, body))
|
668
686
|
end
|
669
687
|
|
670
688
|
def undef_method(undef_t, names)
|
@@ -1239,8 +1257,10 @@ module Parser
|
|
1239
1257
|
|
1240
1258
|
def match_var(name_t)
|
1241
1259
|
name = value(name_t).to_sym
|
1260
|
+
name_l = loc(name_t)
|
1242
1261
|
|
1243
|
-
|
1262
|
+
check_lvar_name(name, name_l)
|
1263
|
+
check_duplicate_pattern_variable(name, name_l)
|
1244
1264
|
@parser.static_env.declare(name)
|
1245
1265
|
|
1246
1266
|
n(:match_var, [ name ],
|
@@ -1253,6 +1273,7 @@ module Parser
|
|
1253
1273
|
expr_l = loc(name_t)
|
1254
1274
|
name_l = expr_l.adjust(end_pos: -1)
|
1255
1275
|
|
1276
|
+
check_lvar_name(name, name_l)
|
1256
1277
|
check_duplicate_pattern_variable(name, name_l)
|
1257
1278
|
@parser.static_env.declare(name)
|
1258
1279
|
|
@@ -1293,6 +1314,9 @@ module Parser
|
|
1293
1314
|
Source::Map::Variable.new(name_l, expr_l))
|
1294
1315
|
when :begin
|
1295
1316
|
match_hash_var_from_str(begin_t, string.children, end_t)
|
1317
|
+
else
|
1318
|
+
# we only can get here if there is an interpolation, e.g., ``in "#{ a }":`
|
1319
|
+
diagnostic :error, :pm_interp_in_var_name, nil, loc(begin_t).join(loc(end_t))
|
1296
1320
|
end
|
1297
1321
|
end
|
1298
1322
|
|
@@ -1318,7 +1342,7 @@ module Parser
|
|
1318
1342
|
|
1319
1343
|
trailing_comma = false
|
1320
1344
|
|
1321
|
-
|
1345
|
+
node_elements = elements.map do |element|
|
1322
1346
|
if element.type == :match_with_trailing_comma
|
1323
1347
|
trailing_comma = true
|
1324
1348
|
element.children.first
|
@@ -1329,17 +1353,22 @@ module Parser
|
|
1329
1353
|
end
|
1330
1354
|
|
1331
1355
|
node_type = trailing_comma ? :array_pattern_with_tail : :array_pattern
|
1332
|
-
|
1356
|
+
|
1357
|
+
n(node_type, node_elements,
|
1333
1358
|
collection_map(lbrack_t, elements, rbrack_t))
|
1334
1359
|
end
|
1335
1360
|
|
1336
|
-
def match_with_trailing_comma(match)
|
1337
|
-
n(:match_with_trailing_comma, [ match ],
|
1361
|
+
def match_with_trailing_comma(match, comma_t)
|
1362
|
+
n(:match_with_trailing_comma, [ match ], expr_map(match.loc.expression.join(loc(comma_t))))
|
1338
1363
|
end
|
1339
1364
|
|
1340
1365
|
def const_pattern(const, ldelim_t, pattern, rdelim_t)
|
1341
1366
|
n(:const_pattern, [const, pattern],
|
1342
|
-
|
1367
|
+
Source::Map::Collection.new(
|
1368
|
+
loc(ldelim_t), loc(rdelim_t),
|
1369
|
+
const.loc.expression.join(loc(rdelim_t))
|
1370
|
+
)
|
1371
|
+
)
|
1343
1372
|
end
|
1344
1373
|
|
1345
1374
|
def pin(pin_t, var)
|
@@ -1732,6 +1761,14 @@ module Parser
|
|
1732
1761
|
loc(end_t))
|
1733
1762
|
end
|
1734
1763
|
|
1764
|
+
def endless_definition_map(keyword_t, operator_t, name_t, assignment_t, body_e)
|
1765
|
+
body_l = body_e.loc.expression
|
1766
|
+
|
1767
|
+
Source::Map::EndlessDefinition.new(loc(keyword_t),
|
1768
|
+
loc(operator_t), loc(name_t),
|
1769
|
+
loc(assignment_t), body_l)
|
1770
|
+
end
|
1771
|
+
|
1735
1772
|
def send_map(receiver_e, dot_t, selector_t, begin_t=nil, args=[], end_t=nil)
|
1736
1773
|
if receiver_e
|
1737
1774
|
begin_l = receiver_e.loc.expression
|
@@ -1974,6 +2011,18 @@ module Parser
|
|
1974
2011
|
@parser.send :yyerror
|
1975
2012
|
end
|
1976
2013
|
end
|
2014
|
+
|
2015
|
+
def validate_definee(definee)
|
2016
|
+
case definee.type
|
2017
|
+
when :int, :str, :dstr, :sym, :dsym,
|
2018
|
+
:regexp, :array, :hash
|
2019
|
+
|
2020
|
+
diagnostic :error, :singleton_literal, nil, definee.loc.expression
|
2021
|
+
false
|
2022
|
+
else
|
2023
|
+
true
|
2024
|
+
end
|
2025
|
+
end
|
1977
2026
|
end
|
1978
2027
|
|
1979
2028
|
end
|