Skip to content

Commit 5d76922

Browse files
Earlopainmatzbot
authored andcommitted
[ruby/prism] Remove Prism.lex_ripper
Since `on_sp` is emitted, it doesn't do a whole lot anymore. This leaves one incompatibility for code like `"x#$%"` Ripper confuses this for bare interpolation with a global, but `$%` is not a valid global name. Still, it emits two string tokens in such a case. It doesn't make sense for prism to work around this bug, so the affected files are added as excludes. Since the only usage of this method makes sense for testing in prism itself, the method is removed instead of deprecated. ruby/prism@31be379f98
1 parent fa3e3d1 commit 5d76922

File tree

5 files changed

+4
-69
lines changed

5 files changed

+4
-69
lines changed

lib/prism.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ module Prism
2020
autoload :DSL, "prism/dsl"
2121
autoload :InspectVisitor, "prism/inspect_visitor"
2222
autoload :LexCompat, "prism/lex_compat"
23-
autoload :LexRipper, "prism/lex_ripper"
2423
autoload :MutationCompiler, "prism/mutation_compiler"
2524
autoload :Pack, "prism/pack"
2625
autoload :Pattern, "prism/pattern"
@@ -35,7 +34,6 @@ module Prism
3534
# private here.
3635

3736
private_constant :LexCompat
38-
private_constant :LexRipper
3937

4038
# Raised when requested to parse as the currently running Ruby version but Prism has no support for it.
4139
class CurrentVersionError < ArgumentError
@@ -68,15 +66,6 @@ def self.lex_compat(source, **options)
6866
LexCompat.new(source, **options).result # steep:ignore
6967
end
7068

71-
# :call-seq:
72-
# Prism::lex_ripper(source) -> Array
73-
#
74-
# This wraps the result of Ripper.lex. It produces almost exactly the
75-
# same tokens. Raises SyntaxError if the syntax in source is invalid.
76-
def self.lex_ripper(source)
77-
LexRipper.new(source).result # steep:ignore
78-
end
79-
8069
# :call-seq:
8170
# Prism::load(source, serialized, freeze) -> ParseResult
8271
#

lib/prism/lex_ripper.rb

Lines changed: 0 additions & 55 deletions
This file was deleted.

lib/prism/prism.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ Gem::Specification.new do |spec|
7777
"lib/prism/ffi.rb",
7878
"lib/prism/inspect_visitor.rb",
7979
"lib/prism/lex_compat.rb",
80-
"lib/prism/lex_ripper.rb",
8180
"lib/prism/mutation_compiler.rb",
8281
"lib/prism/node_ext.rb",
8382
"lib/prism/node.rb",

test/prism/bom_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
return if RUBY_ENGINE != "ruby"
66

77
require_relative "test_helper"
8+
require "ripper"
89

910
module Prism
1011
class BOMTest < TestCase
@@ -53,7 +54,7 @@ def test_string
5354

5455
def assert_bom(source)
5556
bommed = "\xEF\xBB\xBF#{source}"
56-
assert_equal Prism.lex_ripper(bommed), Prism.lex_compat(bommed).value
57+
assert_equal Ripper.lex(bommed), Prism.lex_compat(bommed).value
5758
end
5859
end
5960
end

test/prism/lex_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
return if !(RUBY_ENGINE == "ruby" && RUBY_VERSION >= "3.2.0")
44

55
require_relative "test_helper"
6+
require "ripper"
67

78
module Prism
89
class LexTest < TestCase
@@ -49,7 +50,7 @@ def test_parse_lex_file
4950
if RUBY_VERSION >= "3.3"
5051
def test_lex_compare
5152
prism = Prism.lex_compat(File.read(__FILE__), version: "current").value
52-
ripper = Prism.lex_ripper(File.read(__FILE__))
53+
ripper = Ripper.lex(File.read(__FILE__))
5354
assert_equal(ripper, prism)
5455
end
5556
end

0 commit comments

Comments
 (0)