ruby_parser 3.5.0 → 3.6.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
  SHA1:
3
- metadata.gz: 5ca41acf88ce38e4b41f66711a3c1ebcceecabc8
4
- data.tar.gz: 92d9aa6618b103873d5aa3b15e651799416aad94
3
+ metadata.gz: fc83f0af1f2d5f783903eafe8a07f6509ea2b796
4
+ data.tar.gz: cdec9932c8de7c085557a5b581c7e450065f86a5
5
5
  SHA512:
6
- metadata.gz: 62dc4f09115003fe567001d472d2391df4a0ed7187841edca357e4378f18626903097f0434759f8d1ac4f9b384664240216207fbfe0813f72994a731ab78bdac
7
- data.tar.gz: 461857d0405eee3b2fd591aef07e61478274c003948e67a1cb193402304f39e450f4de5f21c10d2987ebb3b50b5ad226cc6c01ae0ebb7024f1d0ef2769bfaa95
6
+ metadata.gz: b847d6798ceac71dba5045e33b3e7a84d113ef0b513e767d24cd4edd27a18b43e29e47397813e970ff03d76080b32baa3e9c01af4a6568863f8595b6ba721e36
7
+ data.tar.gz: 277d8e78c6b52e0959f346515b043829af531105b51adb156f2f2b09fcee670fee97f48c9222a37d727f7005973ec86d168c9a05603b77cff42ea800cbec552b
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,13 @@
1
+ === 3.6.0 / 2014-04-23
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * Added new_string and switched all parsers to it.
6
+
7
+ * 1 bug fix:
8
+
9
+ * Fixed line numbers of nodes following multi-line strings. (presidentbeef)
10
+
1
11
  === 3.5.0 / 2014-03-24
2
12
 
3
13
  * 1 major enhancement:
data/lib/ruby18_parser.rb CHANGED
@@ -5145,7 +5145,7 @@ def _reduce_400(val, _values, result)
5145
5145
  end
5146
5146
 
5147
5147
  def _reduce_401(val, _values, result)
5148
- result = s(:str, val[0])
5148
+ result = new_string val
5149
5149
 
5150
5150
  result
5151
5151
  end
@@ -5244,7 +5244,7 @@ def _reduce_417(val, _values, result)
5244
5244
  end
5245
5245
 
5246
5246
  def _reduce_418(val, _values, result)
5247
- result = s(:str, val[0])
5247
+ result = new_string val
5248
5248
 
5249
5249
  result
5250
5250
  end
data/lib/ruby18_parser.y CHANGED
@@ -1471,7 +1471,7 @@ rule
1471
1471
  }
1472
1472
  | tSTRING
1473
1473
  {
1474
- result = s(:str, val[0])
1474
+ result = new_string val
1475
1475
  }
1476
1476
 
1477
1477
  xstring: tXSTRING_BEG xstring_contents tSTRING_END
@@ -1547,7 +1547,7 @@ xstring_contents: none
1547
1547
 
1548
1548
  string_content: tSTRING_CONTENT
1549
1549
  {
1550
- result = s(:str, val[0])
1550
+ result = new_string val
1551
1551
  }
1552
1552
  | tSTRING_DVAR
1553
1553
  {
data/lib/ruby19_parser.rb CHANGED
@@ -5426,7 +5426,7 @@ def _reduce_440(val, _values, result)
5426
5426
  end
5427
5427
 
5428
5428
  def _reduce_441(val, _values, result)
5429
- result = s(:str, val[0])
5429
+ result = new_string val
5430
5430
 
5431
5431
  result
5432
5432
  end
@@ -5537,7 +5537,7 @@ def _reduce_459(val, _values, result)
5537
5537
  end
5538
5538
 
5539
5539
  def _reduce_460(val, _values, result)
5540
- result = s(:str, val[0])
5540
+ result = new_string val
5541
5541
 
5542
5542
  result
5543
5543
  end
data/lib/ruby19_parser.y CHANGED
@@ -1593,7 +1593,7 @@ rule
1593
1593
  }
1594
1594
  | tSTRING
1595
1595
  {
1596
- result = s(:str, val[0])
1596
+ result = new_string val
1597
1597
  }
1598
1598
 
1599
1599
  xstring: tXSTRING_BEG xstring_contents tSTRING_END
@@ -1678,7 +1678,7 @@ regexp_contents: none
1678
1678
 
1679
1679
  string_content: tSTRING_CONTENT
1680
1680
  {
1681
- result = s(:str, val[0])
1681
+ result = new_string val
1682
1682
  }
1683
1683
  | tSTRING_DVAR
1684
1684
  {
data/lib/ruby20_parser.rb CHANGED
@@ -5752,7 +5752,7 @@ def _reduce_453(val, _values, result)
5752
5752
  end
5753
5753
 
5754
5754
  def _reduce_454(val, _values, result)
5755
- result = s(:str, val[0])
5755
+ result = new_string val
5756
5756
 
5757
5757
  result
5758
5758
  end
@@ -5923,7 +5923,7 @@ def _reduce_480(val, _values, result)
5923
5923
  end
5924
5924
 
5925
5925
  def _reduce_481(val, _values, result)
5926
- result = s(:str, val[0])
5926
+ result = new_string val
5927
5927
 
5928
5928
  result
5929
5929
  end
data/lib/ruby20_parser.y CHANGED
@@ -1680,7 +1680,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1680
1680
  }
1681
1681
  | tSTRING
1682
1682
  {
1683
- result = s(:str, val[0])
1683
+ result = new_string val
1684
1684
  }
1685
1685
 
1686
1686
  xstring: tXSTRING_BEG xstring_contents tSTRING_END
@@ -1813,7 +1813,7 @@ regexp_contents: none
1813
1813
 
1814
1814
  string_content: tSTRING_CONTENT
1815
1815
  {
1816
- result = s(:str, val[0])
1816
+ result = new_string val
1817
1817
  }
1818
1818
  | tSTRING_DVAR
1819
1819
  {
data/lib/ruby21_parser.rb CHANGED
@@ -5805,7 +5805,7 @@ def _reduce_452(val, _values, result)
5805
5805
  end
5806
5806
 
5807
5807
  def _reduce_453(val, _values, result)
5808
- result = s(:str, val[0])
5808
+ result = new_string val
5809
5809
 
5810
5810
  result
5811
5811
  end
@@ -5976,7 +5976,7 @@ def _reduce_479(val, _values, result)
5976
5976
  end
5977
5977
 
5978
5978
  def _reduce_480(val, _values, result)
5979
- result = s(:str, val[0])
5979
+ result = new_string val
5980
5980
 
5981
5981
  result
5982
5982
  end
data/lib/ruby21_parser.y CHANGED
@@ -1681,7 +1681,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1681
1681
  }
1682
1682
  | tSTRING
1683
1683
  {
1684
- result = s(:str, val[0])
1684
+ result = new_string val
1685
1685
  }
1686
1686
 
1687
1687
  xstring: tXSTRING_BEG xstring_contents tSTRING_END
@@ -1814,7 +1814,7 @@ regexp_contents: none
1814
1814
 
1815
1815
  string_content: tSTRING_CONTENT
1816
1816
  {
1817
- result = s(:str, val[0])
1817
+ result = new_string val
1818
1818
  }
1819
1819
  | tSTRING_DVAR
1820
1820
  {
data/lib/ruby_lexer.rb CHANGED
@@ -73,6 +73,7 @@ class RubyLexer
73
73
  attr_accessor :command_state
74
74
  attr_accessor :last_state
75
75
  attr_accessor :cond
76
+ attr_accessor :extra_lineno
76
77
 
77
78
  ##
78
79
  # Additional context surrounding tokens that both the lexer and
@@ -184,7 +185,6 @@ class RubyLexer
184
185
  if c != "\n" then
185
186
  return :tSTRING_CONTENT, string_buffer.join.delete("\r")
186
187
  else
187
- self.lineno += 1
188
188
  string_buffer << scan(/\n/)
189
189
  end
190
190
 
@@ -839,6 +839,7 @@ class RubyLexer
839
839
  self.space_seen = false
840
840
  self.string_nest = 0
841
841
  self.token = nil
842
+ self.extra_lineno = 0
842
843
 
843
844
  self.cmdarg = RubyParserStuff::StackState.new(:cmdarg)
844
845
  self.cond = RubyParserStuff::StackState.new(:cond)
@@ -1002,6 +1003,8 @@ class RubyLexer
1002
1003
  def unescape s
1003
1004
  r = ESCAPES[s]
1004
1005
 
1006
+ self.extra_lineno -= 1 if r && s == "n"
1007
+
1005
1008
  return r if r
1006
1009
 
1007
1010
  x = case s
data/lib/ruby_lexer.rex CHANGED
@@ -123,7 +123,7 @@ rule
123
123
  | /\>\>/ { result :arg_state, :tRSHFT, ">>" }
124
124
  | /\>/ { result :arg_state, :tGT, ">" }
125
125
 
126
- : /`/
126
+ : /\`/
127
127
  | expr_fname? /\`/ { result(:expr_end, :tBACK_REF2, "`") }
128
128
  | expr_dot? /\`/ { result((command_state ? :expr_cmdarg : :expr_arg), :tBACK_REF2, "`") }
129
129
  | /\`/ { string STR_XQUOTE, '`'; result(nil, :tXSTRING_BEG, "`") }
@@ -1,6 +1,6 @@
1
1
  #--
2
2
  # This file is automatically generated. Do not modify it.
3
- # Generated by: oedipus_lex version 2.2.0.
3
+ # Generated by: oedipus_lex version 2.2.1.
4
4
  # Source: lib/ruby_lexer.rex
5
5
  #++
6
6
 
@@ -214,7 +214,7 @@ class RubyLexer
214
214
  when text = ss.scan(/\>/) then
215
215
  action { result :arg_state, :tGT, ">" }
216
216
  end # group />/
217
- when ss.check(/`/) then
217
+ when ss.check(/\`/) then
218
218
  case
219
219
  when expr_fname? && (text = ss.scan(/\`/)) then
220
220
  action { result(:expr_end, :tBACK_REF2, "`") }
@@ -222,7 +222,7 @@ class RubyLexer
222
222
  action { result((command_state ? :expr_cmdarg : :expr_arg), :tBACK_REF2, "`") }
223
223
  when text = ss.scan(/\`/) then
224
224
  action { string STR_XQUOTE, '`'; result(nil, :tXSTRING_BEG, "`") }
225
- end # group /`/
225
+ end # group /\`/
226
226
  when text = ss.scan(/\?/) then
227
227
  process_questionmark text
228
228
  when ss.check(/&/) then
@@ -312,5 +312,5 @@ class RubyLexer
312
312
  self.state = token.last if token && token.first == :state
313
313
 
314
314
  token
315
- end # def _next_token
315
+ end # def next_token
316
316
  end # class
@@ -91,7 +91,7 @@ class RPStringScanner < StringScanner
91
91
  end
92
92
 
93
93
  module RubyParserStuff
94
- VERSION = "3.5.0" unless constants.include? "VERSION" # SIGH
94
+ VERSION = "3.6.0" unless constants.include? "VERSION" # SIGH
95
95
 
96
96
  attr_accessor :lexer, :in_def, :in_single, :file
97
97
  attr_reader :env, :comments
@@ -830,6 +830,14 @@ module RubyParserStuff
830
830
  result
831
831
  end
832
832
 
833
+ def new_string val
834
+ str = val[0]
835
+ result = s(:str, str)
836
+ self.lexer.lineno += str.count("\n") + self.lexer.extra_lineno
837
+ self.lexer.extra_lineno = 0
838
+ result
839
+ end
840
+
833
841
  def new_super args
834
842
  if args && args.node_type == :block_pass then
835
843
  s(:super, args)
@@ -720,6 +720,23 @@ module TestRubyParserShared
720
720
  assert_parse rb, pt
721
721
  end
722
722
 
723
+ def test_parse_line_dstr_newline
724
+ skip "dstr line numbers are just gonna be screwed for a while..."
725
+
726
+ rb = <<-'CODE'
727
+ "a\n#{
728
+ }"
729
+ true
730
+ CODE
731
+
732
+ pt = s(:block,
733
+ s(:dstr, "a\n",
734
+ s(:evstr)).line(1),
735
+ s(:true).line(3))
736
+
737
+ assert_parse rb, pt
738
+ end
739
+
723
740
  def test_parse_line_heredoc_evstr
724
741
  skip "heredoc line numbers are just gonna be screwed for a while..."
725
742
 
@@ -732,6 +749,15 @@ module TestRubyParserShared
732
749
  assert_parse rb, pt
733
750
  end
734
751
 
752
+ def test_parse_line_multiline_str
753
+ rb = "\"a\nb\"\n1"
754
+ pt = s(:block,
755
+ s(:str, "a\nb").line(1),
756
+ s(:lit, 1).line(3)).line(1)
757
+
758
+ assert_parse rb, pt
759
+ end
760
+
735
761
  def test_parse_line_iter_call_parens
736
762
  rb = "f(a) do |x, y|\n x + y\nend"
737
763
 
@@ -818,6 +844,15 @@ module TestRubyParserShared
818
844
  assert_equal 3, result.if.return.lit.line
819
845
  end
820
846
 
847
+ def test_parse_line_str_with_newline_escape
848
+ rb = 'a("\n", true)'
849
+ pt = s(:call, nil, :a,
850
+ s(:str, "\n").line(1),
851
+ s(:true).line(1))
852
+
853
+ assert_parse rb, pt
854
+ end
855
+
821
856
  def test_parse_line_trailing_newlines
822
857
  rb = "a \nb"
823
858
  pt = s(:block,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.0
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -29,7 +29,7 @@ cert_chain:
29
29
  Y4evBVezr3SjXz08vPqRO5YRdO3zfeMT8gBjRqZjWJGMZ2lD4XNfrs7eky74CyZw
30
30
  xx3n58i0lQkBE1EpKE0lFu/y
31
31
  -----END CERTIFICATE-----
32
- date: 2014-03-25 00:00:00.000000000 Z
32
+ date: 2014-04-23 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: sexp_processor
@@ -121,14 +121,14 @@ dependencies:
121
121
  requirements:
122
122
  - - ~>
123
123
  - !ruby/object:Gem::Version
124
- version: '3.10'
124
+ version: '3.12'
125
125
  type: :development
126
126
  prerelease: false
127
127
  version_requirements: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ~>
130
130
  - !ruby/object:Gem::Version
131
- version: '3.10'
131
+ version: '3.12'
132
132
  description: |-
133
133
  ruby_parser (RP) is a ruby parser written in pure ruby (utilizing
134
134
  racc--which does by default use a C extension). RP's output is
metadata.gz.sig CHANGED
Binary file