parser 2.6.2.1 → 2.6.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '079e9a23e1c61dbd3964edff00120c9d9df0993aee3b1a0070a64c1b717a1450'
4
- data.tar.gz: f42199a0777690e615515ca481ee2bf56aa3c5090d9702e65ae19c1db8fb499a
3
+ metadata.gz: bceee2aee10ca7b86d7fb0e29f985b0b1848425b3d256af84e5dd324046ab2f7
4
+ data.tar.gz: 9ea970432bb2dc6dc68320baf39d7f24d928c45fc8ca236c14ed4c7c8db4d29e
5
5
  SHA512:
6
- metadata.gz: ca3de4d39f2c9e67366c22c9a2c5640efcbbee28cb3b0ed030425de55806dd03580d9111195eb9e66f65189638ee5935adb94441a4018e2e0901c66d450e18a7
7
- data.tar.gz: c29b708ab12eef3c14f2f472b152e1adf090481a3127a10c9bdb4a24cb34849e4f00bbdf14f97e71916157dce66c6d74faa9658603a95db82e246c92d68bf15b
6
+ metadata.gz: 577db299468896bb4dec4ca23dc14d78e58dd41dd323219de110e70ad2c691d6a9d3563339c1c4dcded9e7aaa69df5227f80ed1565f910d562928cf64c0936b4
7
+ data.tar.gz: 28c3a2a9e40727a71ac9255f1ad076ff86d2b60652eb4ac81719645c2542c3be0c818862003eae32b13c983397b86e023d9c0177f495dd45299845f1902871d5
@@ -17,8 +17,8 @@ matrix:
17
17
  - name: 2.5.5 / Parser tests
18
18
  rvm: 2.5.5
19
19
  script: bundle exec rake test_cov
20
- - name: 2.6.2 / Parser tests
21
- rvm: 2.6.2
20
+ - name: 2.6.3 / Parser tests
21
+ rvm: 2.6.3
22
22
  script: bundle exec rake test_cov
23
23
  - name: ruby-head / Parser tests
24
24
  rvm: ruby-head
@@ -32,8 +32,8 @@ matrix:
32
32
  - name: 2.5.5 / Rubocop tests
33
33
  rvm: 2.5.5
34
34
  script: ./ci/run_rubocop_specs
35
- - name: 2.6.2 / Rubocop tests
36
- rvm: 2.6.2
35
+ - name: 2.6.3 / Rubocop tests
36
+ rvm: 2.6.3
37
37
  script: ./ci/run_rubocop_specs
38
38
  allow_failures:
39
39
  - rvm: ruby-head
@@ -1,9 +1,15 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
- Not released (2019-04-05)
4
+ Not released (2019-04-28)
5
5
  -------------------------
6
6
 
7
+ Features implemented:
8
+ * ruby27.y: Added beginless ranges support. (#570) (Ilya Bylich)
9
+
10
+ v2.6.2.1 (2019-04-05)
11
+ ---------------------
12
+
7
13
  API modifications:
8
14
  * Bump 2.4 branch to 2.4.6. (#569) (Ilya Bylich)
9
15
  * Lexer should know about current parsing context. (#566) (Ilya Bylich)
@@ -339,6 +339,22 @@ Format:
339
339
  ~~~~ expression
340
340
  ~~~
341
341
 
342
+ ### Beginless (2.7)
343
+
344
+ Format:
345
+
346
+ ~~~
347
+ (irange nil (int 1))
348
+ "..1"
349
+ ~~ operator
350
+ ~~~ expression
351
+
352
+ (erange nil (int 1))
353
+ "...1"
354
+ ~~~ operator
355
+ ~~~~ expression
356
+ ~~~
357
+
342
358
  ## Access
343
359
 
344
360
  ### Self
@@ -1394,10 +1394,12 @@ module Parser
1394
1394
  end
1395
1395
 
1396
1396
  def range_map(start_e, op_t, end_e)
1397
- if end_e
1397
+ if start_e && end_e
1398
1398
  expr_l = join_exprs(start_e, end_e)
1399
- else
1399
+ elsif start_e
1400
1400
  expr_l = start_e.loc.expression.join(loc(op_t))
1401
+ elsif end_e
1402
+ expr_l = loc(op_t).join(end_e.loc.expression)
1401
1403
  end
1402
1404
 
1403
1405
  Source::Map::Operator.new(loc(op_t), expr_l)
@@ -66,7 +66,7 @@ module Parser
66
66
  CurrentRuby = Ruby25
67
67
 
68
68
  when /^2\.6\./
69
- current_version = '2.6.2'
69
+ current_version = '2.6.3'
70
70
  if RUBY_VERSION != current_version
71
71
  warn_syntax_deviation 'parser/ruby26', current_version
72
72
  end
@@ -1910,6 +1910,31 @@ class Parser::Lexer
1910
1910
  fbreak;
1911
1911
  };
1912
1912
 
1913
+ #
1914
+ # RUBY 2.7 BEGINLESS RANGE
1915
+
1916
+ '..'
1917
+ => {
1918
+ if @version >= 27
1919
+ emit(:tBDOT2)
1920
+ else
1921
+ emit(:tDOT2)
1922
+ end
1923
+
1924
+ fnext expr_beg; fbreak;
1925
+ };
1926
+
1927
+ '...'
1928
+ => {
1929
+ if @version >= 27
1930
+ emit(:tBDOT3)
1931
+ else
1932
+ emit(:tDOT3)
1933
+ end
1934
+
1935
+ fnext expr_beg; fbreak;
1936
+ };
1937
+
1913
1938
  #
1914
1939
  # CONTEXT-DEPENDENT VARIABLE LOOKUP OR COMMAND INVOCATION
1915
1940
  #
@@ -1893,7 +1893,7 @@ regexp_contents: # nothing
1893
1893
  result = @builder.symbol(val[0])
1894
1894
  }
1895
1895
 
1896
- dsym: tSYMBEG xstring_contents tSTRING_END
1896
+ dsym: tSYMBEG string_contents tSTRING_END
1897
1897
  {
1898
1898
  @lexer.state = :expr_end
1899
1899
  result = @builder.symbol_compose(val[0], val[1], val[2])
@@ -17,7 +17,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
17
17
  tWORDS_BEG tQWORDS_BEG tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DBEG
18
18
  tSTRING_DVAR tSTRING_END tSTRING_DEND tSTRING tSYMBOL
19
19
  tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA tLAMBEG tCHARACTER
20
- tRATIONAL tIMAGINARY tLABEL_END tANDDOT tMETHREF
20
+ tRATIONAL tIMAGINARY tLABEL_END tANDDOT tMETHREF tBDOT2 tBDOT3
21
21
 
22
22
  prechigh
23
23
  right tBANG tTILDE tUPLUS
@@ -32,7 +32,7 @@ prechigh
32
32
  nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
33
33
  left tANDOP
34
34
  left tOROP
35
- nonassoc tDOT2 tDOT3
35
+ nonassoc tDOT2 tDOT3 tBDOT2 tBDOT3
36
36
  right tEH tCOLON
37
37
  left kRESCUE_MOD
38
38
  right tEQL tOP_ASGN
@@ -670,6 +670,14 @@ rule
670
670
  {
671
671
  result = @builder.range_exclusive(val[0], val[1], nil)
672
672
  }
673
+ | tBDOT2 arg
674
+ {
675
+ result = @builder.range_inclusive(nil, val[0], val[1])
676
+ }
677
+ | tBDOT3 arg
678
+ {
679
+ result = @builder.range_exclusive(nil, val[0], val[1])
680
+ }
673
681
  | arg tPLUS arg
674
682
  {
675
683
  result = @builder.binary_op(val[0], val[1], val[2])
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parser
4
- VERSION = '2.6.2.1'
4
+ VERSION = '2.6.3.0'
5
5
  end
@@ -852,6 +852,42 @@ class TestParser < Minitest::Test
852
852
  SINCE_2_6)
853
853
  end
854
854
 
855
+ def test_beginless_range_before_27
856
+ assert_diagnoses(
857
+ [:error, :unexpected_token, { :token => 'tDOT2' }],
858
+ %q{..42},
859
+ %q{^^ location},
860
+ ALL_VERSIONS - SINCE_2_7
861
+ )
862
+
863
+ assert_diagnoses(
864
+ [:error, :unexpected_token, { :token => 'tDOT3' }],
865
+ %q{...42},
866
+ %q{^^^ location},
867
+ ALL_VERSIONS - SINCE_2_7
868
+ )
869
+ end
870
+
871
+ def test_beginless_range
872
+ assert_parses(
873
+ s(:irange, nil,
874
+ s(:int, 100)),
875
+ %q{..100},
876
+ %q{~~~~~ expression
877
+ |~~ operator},
878
+ SINCE_2_7
879
+ )
880
+
881
+ assert_parses(
882
+ s(:erange, nil,
883
+ s(:int, 100)),
884
+ %q{...100},
885
+ %q{~~~~~~ expression
886
+ |~~~ operator},
887
+ SINCE_2_7
888
+ )
889
+ end
890
+
855
891
  #
856
892
  # Access
857
893
  #
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.6.2.1
4
+ version: 2.6.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - whitequark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-05 00:00:00.000000000 Z
11
+ date: 2019-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast