parser 1.3.4 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/parser/base.rb +0 -1
- data/lib/parser/builders/default.rb +15 -10
- data/lib/parser/lexer.rl +1 -1
- data/lib/parser/source/map/send.rb +3 -1
- data/lib/parser/version.rb +1 -1
- data/test/test_parser.rb +28 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aeb1a643a1e50280d971697fce43dd37ef01179a
|
4
|
+
data.tar.gz: f50c9ceeba38d5fdcf3b5d9c13fcd2c32425d805
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d75b85fd7a2628ef8eac25c419b8c313e6983d431e9afe40050449d99d15f48509d8f1b4e08b8b1a1659abd089d2f9111046b8afb2ada27e3897643a98ed8a6
|
7
|
+
data.tar.gz: 98a3cbf81cbd31ea822a29c6f87ba544c397955befb74f86a611a943447eb13a1708d2fd0e52f2c00bbf748f5d1808f18008e8b3a1c0c78d744048a81df1b963
|
data/lib/parser/base.rb
CHANGED
@@ -115,7 +115,6 @@ module Parser
|
|
115
115
|
token_name = token_to_str(error_token_id)
|
116
116
|
_, location = error_value
|
117
117
|
|
118
|
-
# TODO add "expected: ..." here
|
119
118
|
message = ERRORS[:unexpected_token] % { :token => token_name }
|
120
119
|
@diagnostics.process(
|
121
120
|
Diagnostic.new(:error, message, location))
|
@@ -544,16 +544,16 @@ module Parser
|
|
544
544
|
lparen_t=nil, args=[], rparen_t=nil)
|
545
545
|
if selector_t.nil?
|
546
546
|
n(:send, [ receiver, :call, *args ],
|
547
|
-
send_map(receiver, nil, lparen_t, args, rparen_t))
|
547
|
+
send_map(receiver, dot_t, nil, lparen_t, args, rparen_t))
|
548
548
|
else
|
549
549
|
n(:send, [ receiver, value(selector_t).to_sym, *args ],
|
550
|
-
send_map(receiver, selector_t, lparen_t, args, rparen_t))
|
550
|
+
send_map(receiver, dot_t, selector_t, lparen_t, args, rparen_t))
|
551
551
|
end
|
552
552
|
end
|
553
553
|
|
554
554
|
def call_lambda(lambda_t)
|
555
555
|
n(:send, [ nil, :lambda ],
|
556
|
-
send_map(nil, lambda_t))
|
556
|
+
send_map(nil, nil, lambda_t))
|
557
557
|
end
|
558
558
|
|
559
559
|
def block(method_call, begin_t, args, body, end_t)
|
@@ -579,7 +579,7 @@ module Parser
|
|
579
579
|
|
580
580
|
# Incomplete method call.
|
581
581
|
n(:send, [ receiver, method_name ],
|
582
|
-
send_map(receiver, selector_t))
|
582
|
+
send_map(receiver, dot_t, selector_t))
|
583
583
|
end
|
584
584
|
|
585
585
|
def index(receiver, lbrack_t, indexes, rbrack_t)
|
@@ -994,7 +994,7 @@ module Parser
|
|
994
994
|
loc(end_t))
|
995
995
|
end
|
996
996
|
|
997
|
-
def send_map(receiver_e, selector_t, begin_t=nil, args=[], end_t=nil)
|
997
|
+
def send_map(receiver_e, dot_t, selector_t, begin_t=nil, args=[], end_t=nil)
|
998
998
|
if receiver_e
|
999
999
|
begin_l = receiver_e.src.expression
|
1000
1000
|
elsif selector_t
|
@@ -1009,17 +1009,20 @@ module Parser
|
|
1009
1009
|
end_l = loc(selector_t)
|
1010
1010
|
end
|
1011
1011
|
|
1012
|
-
Source::Map::Send.new(loc(
|
1012
|
+
Source::Map::Send.new(loc(dot_t), loc(selector_t),
|
1013
|
+
loc(begin_t), loc(end_t),
|
1013
1014
|
begin_l.join(end_l))
|
1014
1015
|
end
|
1015
1016
|
|
1016
1017
|
def var_send_map(variable_e)
|
1017
|
-
Source::Map::Send.new(variable_e.src.expression,
|
1018
|
+
Source::Map::Send.new(nil, variable_e.src.expression,
|
1019
|
+
nil, nil,
|
1018
1020
|
variable_e.src.expression)
|
1019
1021
|
end
|
1020
1022
|
|
1021
1023
|
def send_binary_op_map(lhs_e, selector_t, rhs_e)
|
1022
|
-
Source::Map::Send.new(loc(selector_t),
|
1024
|
+
Source::Map::Send.new(nil, loc(selector_t),
|
1025
|
+
nil, nil,
|
1023
1026
|
join_exprs(lhs_e, rhs_e))
|
1024
1027
|
end
|
1025
1028
|
|
@@ -1030,12 +1033,14 @@ module Parser
|
|
1030
1033
|
expr_l = loc(selector_t).join(arg_e.src.expression)
|
1031
1034
|
end
|
1032
1035
|
|
1033
|
-
Source::Map::Send.new(loc(selector_t),
|
1036
|
+
Source::Map::Send.new(nil, loc(selector_t),
|
1037
|
+
nil, nil,
|
1034
1038
|
expr_l)
|
1035
1039
|
end
|
1036
1040
|
|
1037
1041
|
def send_index_map(receiver_e, lbrack_t, rbrack_t)
|
1038
|
-
Source::Map::Send.new(loc(lbrack_t).join(loc(rbrack_t)),
|
1042
|
+
Source::Map::Send.new(nil, loc(lbrack_t).join(loc(rbrack_t)),
|
1043
|
+
nil, nil,
|
1039
1044
|
receiver_e.src.expression.join(loc(rbrack_t)))
|
1040
1045
|
end
|
1041
1046
|
|
data/lib/parser/lexer.rl
CHANGED
@@ -2,12 +2,14 @@ module Parser
|
|
2
2
|
module Source
|
3
3
|
|
4
4
|
class Map::Send < Map
|
5
|
+
attr_reader :dot
|
5
6
|
attr_reader :selector
|
6
7
|
attr_reader :operator
|
7
8
|
attr_reader :begin
|
8
9
|
attr_reader :end
|
9
10
|
|
10
|
-
def initialize(selector_l, begin_l, end_l, expression_l)
|
11
|
+
def initialize(dot_l, selector_l, begin_l, end_l, expression_l)
|
12
|
+
@dot = dot_l
|
11
13
|
@selector = selector_l
|
12
14
|
@begin, @end = begin_l, end_l
|
13
15
|
|
data/lib/parser/version.rb
CHANGED
data/test/test_parser.rb
CHANGED
@@ -2370,18 +2370,21 @@ class TestParser < MiniTest::Unit::TestCase
|
|
2370
2370
|
s(:send, s(:lvar, :foo), :fun),
|
2371
2371
|
%q{foo.fun},
|
2372
2372
|
%q{ ~~~ selector
|
2373
|
+
| ^ dot
|
2373
2374
|
|~~~~~~~ expression})
|
2374
2375
|
|
2375
2376
|
assert_parses(
|
2376
2377
|
s(:send, s(:lvar, :foo), :fun),
|
2377
2378
|
%q{foo::fun},
|
2378
2379
|
%q{ ~~~ selector
|
2380
|
+
| ^^ dot
|
2379
2381
|
|~~~~~~~~ expression})
|
2380
2382
|
|
2381
2383
|
assert_parses(
|
2382
2384
|
s(:send, s(:lvar, :foo), :Fun),
|
2383
2385
|
%q{foo::Fun()},
|
2384
2386
|
%q{ ~~~ selector
|
2387
|
+
| ^^ dot
|
2385
2388
|
|~~~~~~~~~~ expression})
|
2386
2389
|
end
|
2387
2390
|
|
@@ -2390,18 +2393,21 @@ class TestParser < MiniTest::Unit::TestCase
|
|
2390
2393
|
s(:send, s(:lvar, :foo), :fun, s(:lvar, :bar)),
|
2391
2394
|
%q{foo.fun bar},
|
2392
2395
|
%q{ ~~~ selector
|
2396
|
+
| ^ dot
|
2393
2397
|
|~~~~~~~~~~~ expression})
|
2394
2398
|
|
2395
2399
|
assert_parses(
|
2396
2400
|
s(:send, s(:lvar, :foo), :fun, s(:lvar, :bar)),
|
2397
2401
|
%q{foo::fun bar},
|
2398
2402
|
%q{ ~~~ selector
|
2403
|
+
| ^^ dot
|
2399
2404
|
|~~~~~~~~~~~~ expression})
|
2400
2405
|
|
2401
2406
|
assert_parses(
|
2402
2407
|
s(:send, s(:lvar, :foo), :Fun, s(:lvar, :bar)),
|
2403
2408
|
%q{foo::Fun bar},
|
2404
2409
|
%q{ ~~~ selector
|
2410
|
+
| ^^ dot
|
2405
2411
|
|~~~~~~~~~~~~ expression})
|
2406
2412
|
end
|
2407
2413
|
|
@@ -2442,6 +2448,7 @@ class TestParser < MiniTest::Unit::TestCase
|
|
2442
2448
|
:fun, s(:lvar, :bar)),
|
2443
2449
|
%q{meth 1 do end.fun bar},
|
2444
2450
|
%q{ ~~~ selector
|
2451
|
+
| ^ dot
|
2445
2452
|
|~~~~~~~~~~~~~~~~~~~~~ expression})
|
2446
2453
|
|
2447
2454
|
assert_parses(
|
@@ -2452,6 +2459,7 @@ class TestParser < MiniTest::Unit::TestCase
|
|
2452
2459
|
:fun, s(:lvar, :bar)),
|
2453
2460
|
%q{meth 1 do end.fun(bar)},
|
2454
2461
|
%q{ ~~~ selector
|
2462
|
+
| ^ dot
|
2455
2463
|
| ^ begin
|
2456
2464
|
| ^ end
|
2457
2465
|
|~~~~~~~~~~~~~~~~~~~~~~ expression})
|
@@ -2464,6 +2472,7 @@ class TestParser < MiniTest::Unit::TestCase
|
|
2464
2472
|
:fun, s(:lvar, :bar)),
|
2465
2473
|
%q{meth 1 do end::fun bar},
|
2466
2474
|
%q{ ~~~ selector
|
2475
|
+
| ^^ dot
|
2467
2476
|
|~~~~~~~~~~~~~~~~~~~~~~ expression})
|
2468
2477
|
|
2469
2478
|
assert_parses(
|
@@ -2476,6 +2485,7 @@ class TestParser < MiniTest::Unit::TestCase
|
|
2476
2485
|
%q{ ~~~ selector
|
2477
2486
|
| ^ begin
|
2478
2487
|
| ^ end
|
2488
|
+
| ^^ dot
|
2479
2489
|
|~~~~~~~~~~~~~~~~~~~~~~~ expression})
|
2480
2490
|
|
2481
2491
|
assert_parses(
|
@@ -2739,20 +2749,33 @@ class TestParser < MiniTest::Unit::TestCase
|
|
2739
2749
|
s(:send, s(:lvar, :foo), :a=, s(:int, 1)),
|
2740
2750
|
%q{foo.a = 1},
|
2741
2751
|
%q{ ~ selector
|
2752
|
+
| ^ dot
|
2742
2753
|
| ^ operator
|
2743
2754
|
|~~~~~~~~~ expression})
|
2744
2755
|
|
2745
2756
|
assert_parses(
|
2746
2757
|
s(:send, s(:lvar, :foo), :a=, s(:int, 1)),
|
2747
|
-
|
2758
|
+
%q{foo::a = 1},
|
2759
|
+
%q{ ~ selector
|
2760
|
+
| ^^ dot
|
2761
|
+
| ^ operator
|
2762
|
+
|~~~~~~~~~~ expression})
|
2748
2763
|
|
2749
2764
|
assert_parses(
|
2750
2765
|
s(:send, s(:lvar, :foo), :A=, s(:int, 1)),
|
2751
|
-
|
2766
|
+
%q{foo.A = 1},
|
2767
|
+
%q{ ~ selector
|
2768
|
+
| ^ dot
|
2769
|
+
| ^ operator
|
2770
|
+
|~~~~~~~~~ expression})
|
2752
2771
|
|
2753
2772
|
assert_parses(
|
2754
2773
|
s(:cdecl, s(:lvar, :foo), :A, s(:int, 1)),
|
2755
|
-
|
2774
|
+
%q{foo::A = 1},
|
2775
|
+
%q{ ~ name
|
2776
|
+
| ^^ double_colon
|
2777
|
+
| ^ operator
|
2778
|
+
|~~~~~~~~~~ expression})
|
2756
2779
|
end
|
2757
2780
|
|
2758
2781
|
def test_send_index
|
@@ -2848,6 +2871,7 @@ class TestParser < MiniTest::Unit::TestCase
|
|
2848
2871
|
%q{foo.(1)},
|
2849
2872
|
%q{ ^ begin
|
2850
2873
|
| ^ end
|
2874
|
+
| ^ dot
|
2851
2875
|
|~~~~~~~ expression},
|
2852
2876
|
ALL_VERSIONS - %w(1.8))
|
2853
2877
|
|
@@ -2857,6 +2881,7 @@ class TestParser < MiniTest::Unit::TestCase
|
|
2857
2881
|
%q{foo::(1)},
|
2858
2882
|
%q{ ^ begin
|
2859
2883
|
| ^ end
|
2884
|
+
| ^^ dot
|
2860
2885
|
|~~~~~~~~ expression},
|
2861
2886
|
ALL_VERSIONS - %w(1.8))
|
2862
2887
|
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: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Zotov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ast
|