diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/prism.rb | 54 | ||||
-rw-r--r-- | lib/prism/debug.rb | 12 | ||||
-rw-r--r-- | lib/prism/desugar_compiler.rb | 2 | ||||
-rw-r--r-- | lib/prism/ffi.rb | 116 | ||||
-rw-r--r-- | lib/prism/lex_compat.rb | 16 | ||||
-rw-r--r-- | lib/prism/node_ext.rb | 4 | ||||
-rw-r--r-- | lib/prism/node_inspector.rb | 2 | ||||
-rw-r--r-- | lib/prism/pack.rb | 2 | ||||
-rw-r--r-- | lib/prism/parse_result.rb | 10 | ||||
-rw-r--r-- | lib/prism/parse_result/comments.rb | 2 | ||||
-rw-r--r-- | lib/prism/parse_result/newlines.rb | 2 | ||||
-rw-r--r-- | lib/prism/pattern.rb | 26 | ||||
-rw-r--r-- | lib/prism/prism.gemspec | 138 | ||||
-rw-r--r-- | lib/prism/ripper_compat.rb | 10 |
14 files changed, 198 insertions, 198 deletions
diff --git a/lib/prism.rb b/lib/prism.rb index 4d111b072f..b45098480a 100644 --- a/lib/prism.rb +++ b/lib/prism.rb @@ -1,25 +1,25 @@ # frozen_string_literal: true -module YARP - # There are many files in YARP that are templated to handle every node type, +module Prism + # There are many files in prism that are templated to handle every node type, # which means the files can end up being quite large. We autoload them to make # our require speed faster since consuming libraries are unlikely to use all # of these features. - autoload :BasicVisitor, "yarp/visitor" - autoload :Compiler, "yarp/compiler" - autoload :Debug, "yarp/debug" - autoload :DesugarCompiler, "yarp/desugar_compiler" - autoload :Dispatcher, "yarp/dispatcher" - autoload :DSL, "yarp/dsl" - autoload :LexCompat, "yarp/lex_compat" - autoload :LexRipper, "yarp/lex_compat" - autoload :MutationCompiler, "yarp/mutation_compiler" - autoload :NodeInspector, "yarp/node_inspector" - autoload :RipperCompat, "yarp/ripper_compat" - autoload :Pack, "yarp/pack" - autoload :Pattern, "yarp/pattern" - autoload :Serialize, "yarp/serialize" - autoload :Visitor, "yarp/visitor" + autoload :BasicVisitor, "prism/visitor" + autoload :Compiler, "prism/compiler" + autoload :Debug, "prism/debug" + autoload :DesugarCompiler, "prism/desugar_compiler" + autoload :Dispatcher, "prism/dispatcher" + autoload :DSL, "prism/dsl" + autoload :LexCompat, "prism/lex_compat" + autoload :LexRipper, "prism/lex_compat" + autoload :MutationCompiler, "prism/mutation_compiler" + autoload :NodeInspector, "prism/node_inspector" + autoload :RipperCompat, "prism/ripper_compat" + autoload :Pack, "prism/pack" + autoload :Pattern, "prism/pattern" + autoload :Serialize, "prism/serialize" + autoload :Visitor, "prism/visitor" # Some of these constants are not meant to be exposed, so marking them as # private here. @@ -47,18 +47,18 @@ module YARP end end -require_relative "yarp/node" -require_relative "yarp/node_ext" -require_relative "yarp/parse_result" -require_relative "yarp/parse_result/comments" -require_relative "yarp/parse_result/newlines" +require_relative "prism/node" +require_relative "prism/node_ext" +require_relative "prism/parse_result" +require_relative "prism/parse_result/comments" +require_relative "prism/parse_result/newlines" -# This is a Ruby implementation of the YARP parser. If we're running on CRuby -# and we haven't explicitly set the YARP_FFI_BACKEND environment variable, then +# This is a Ruby implementation of the prism parser. If we're running on CRuby +# and we haven't explicitly set the PRISM_FFI_BACKEND environment variable, then # it's going to require the built library. Otherwise, it's going to require a # module that uses FFI to call into the library. -if RUBY_ENGINE == "ruby" and !ENV["YARP_FFI_BACKEND"] - require "yarp/yarp" +if RUBY_ENGINE == "ruby" and !ENV["PRISM_FFI_BACKEND"] + require "prism/prism" else - require_relative "yarp/ffi" + require_relative "prism/ffi" end diff --git a/lib/prism/debug.rb b/lib/prism/debug.rb index 39df1e838c..9c6756ff35 100644 --- a/lib/prism/debug.rb +++ b/lib/prism/debug.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module YARP +module Prism # This module is used for testing and debugging and is not meant to be used by # consumers of this library. module Debug @@ -77,11 +77,11 @@ module YARP end end - # For the given source, parses with YARP and returns a list of all of the + # For the given source, parses with prism and returns a list of all of the # sets of local variables that were encountered. - def self.yarp_locals(source) + def self.prism_locals(source) locals = [] - stack = [YARP.parse(source).value] + stack = [Prism.parse(source).value] while (node = stack.pop) case node @@ -91,7 +91,7 @@ module YARP params = node.parameters params = params&.parameters unless node.is_a?(DefNode) - # YARP places parameters in the same order that they appear in the + # prism places parameters in the same order that they appear in the # source. CRuby places them in the order that they need to appear # according to their own internal calling convention. We mimic that # order here so that we can compare properly. @@ -147,7 +147,7 @@ module YARP end def self.newlines(source) - YARP.parse(source).source.offsets + Prism.parse(source).source.offsets end def self.parse_serialize_file(filepath) diff --git a/lib/prism/desugar_compiler.rb b/lib/prism/desugar_compiler.rb index b86e8518c6..232c6ecb37 100644 --- a/lib/prism/desugar_compiler.rb +++ b/lib/prism/desugar_compiler.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module YARP +module Prism # DesugarCompiler is a compiler that desugars Ruby code into a more primitive # form. This is useful for consumers that want to deal with fewer node types. class DesugarCompiler < MutationCompiler diff --git a/lib/prism/ffi.rb b/lib/prism/ffi.rb index 82643be808..3ff1875611 100644 --- a/lib/prism/ffi.rb +++ b/lib/prism/ffi.rb @@ -6,7 +6,7 @@ require "rbconfig" require "ffi" -module YARP +module Prism BACKEND = :FFI module LibRubyParser @@ -35,13 +35,13 @@ module YARP def self.load_exported_functions_from(header, *functions) File.foreach(File.expand_path("../../include/#{header}", __dir__)) do |line| # We only want to attempt to load exported functions. - next unless line.start_with?("YP_EXPORTED_FUNCTION ") + next unless line.start_with?("PRISM_EXPORTED_FUNCTION ") # We only want to load the functions that we are interested in. next unless functions.any? { |function| line.include?(function) } # Parse the function declaration. - unless /^YP_EXPORTED_FUNCTION (?<return_type>.+) (?<name>\w+)\((?<arg_types>.+)\);$/ =~ line + unless /^PRISM_EXPORTED_FUNCTION (?<return_type>.+) (?<name>\w+)\((?<arg_types>.+)\);$/ =~ line raise "Could not parse #{line}" end @@ -67,35 +67,35 @@ module YARP end load_exported_functions_from( - "yarp.h", - "yp_version", - "yp_parse_serialize", - "yp_lex_serialize", - "yp_parse_lex_serialize" + "prism.h", + "pm_version", + "pm_parse_serialize", + "pm_lex_serialize", + "pm_parse_lex_serialize" ) load_exported_functions_from( - "yarp/util/yp_buffer.h", - "yp_buffer_sizeof", - "yp_buffer_init", - "yp_buffer_value", - "yp_buffer_length", - "yp_buffer_free" + "prism/util/pm_buffer.h", + "pm_buffer_sizeof", + "pm_buffer_init", + "pm_buffer_value", + "pm_buffer_length", + "pm_buffer_free" ) load_exported_functions_from( - "yarp/util/yp_string.h", - "yp_string_mapped_init", - "yp_string_free", - "yp_string_source", - "yp_string_length", - "yp_string_sizeof" + "prism/util/pm_string.h", + "pm_string_mapped_init", + "pm_string_free", + "pm_string_source", + "pm_string_length", + "pm_string_sizeof" ) - # This object represents a yp_buffer_t. We only use it as an opaque pointer, - # so it doesn't need to know the fields of yp_buffer_t. - class YPBuffer - SIZEOF = LibRubyParser.yp_buffer_sizeof + # This object represents a pm_buffer_t. We only use it as an opaque pointer, + # so it doesn't need to know the fields of pm_buffer_t. + class PrismBuffer + SIZEOF = LibRubyParser.pm_buffer_sizeof attr_reader :pointer @@ -104,11 +104,11 @@ module YARP end def value - LibRubyParser.yp_buffer_value(pointer) + LibRubyParser.pm_buffer_value(pointer) end def length - LibRubyParser.yp_buffer_length(pointer) + LibRubyParser.pm_buffer_length(pointer) end def read @@ -121,19 +121,19 @@ module YARP pointer = FFI::MemoryPointer.new(SIZEOF) begin - raise unless LibRubyParser.yp_buffer_init(pointer) + raise unless LibRubyParser.pm_buffer_init(pointer) yield new(pointer) ensure - LibRubyParser.yp_buffer_free(pointer) + LibRubyParser.pm_buffer_free(pointer) pointer.free end end end - # This object represents a yp_string_t. We only use it as an opaque pointer, + # This object represents a pm_string_t. We only use it as an opaque pointer, # so it doesn't have to be an FFI::Struct. - class YPString - SIZEOF = LibRubyParser.yp_string_sizeof + class PrismString + SIZEOF = LibRubyParser.pm_string_sizeof attr_reader :pointer @@ -142,93 +142,93 @@ module YARP end def source - LibRubyParser.yp_string_source(pointer) + LibRubyParser.pm_string_source(pointer) end def length - LibRubyParser.yp_string_length(pointer) + LibRubyParser.pm_string_length(pointer) end def read source.read_string(length) end - # Yields a yp_string_t pointer to the given block. + # Yields a pm_string_t pointer to the given block. def self.with(filepath, &block) pointer = FFI::MemoryPointer.new(SIZEOF) begin - raise unless LibRubyParser.yp_string_mapped_init(pointer, filepath) + raise unless LibRubyParser.pm_string_mapped_init(pointer, filepath) yield new(pointer) ensure - LibRubyParser.yp_string_free(pointer) + LibRubyParser.pm_string_free(pointer) pointer.free end end end def self.dump_internal(source, source_size, filepath) - YPBuffer.with do |buffer| + PrismBuffer.with do |buffer| metadata = [filepath.bytesize, filepath.b, 0].pack("LA*L") if filepath - yp_parse_serialize(source, source_size, buffer.pointer, metadata) + pm_parse_serialize(source, source_size, buffer.pointer, metadata) buffer.read end end end # Mark the LibRubyParser module as private as it should only be called through - # the YARP module. + # the prism module. private_constant :LibRubyParser - # The version constant is set by reading the result of calling yp_version. - VERSION = LibRubyParser.yp_version.read_string + # The version constant is set by reading the result of calling pm_version. + VERSION = LibRubyParser.pm_version.read_string - # Mirror the YARP.dump API by using the serialization API. + # Mirror the Prism.dump API by using the serialization API. def self.dump(code, filepath = nil) LibRubyParser.dump_internal(code, code.bytesize, filepath) end - # Mirror the YARP.dump_file API by using the serialization API. + # Mirror the Prism.dump_file API by using the serialization API. def self.dump_file(filepath) - LibRubyParser::YPString.with(filepath) do |string| + LibRubyParser::PrismString.with(filepath) do |string| LibRubyParser.dump_internal(string.source, string.length, filepath) end end - # Mirror the YARP.lex API by using the serialization API. + # Mirror the Prism.lex API by using the serialization API. def self.lex(code, filepath = nil) - LibRubyParser::YPBuffer.with do |buffer| - LibRubyParser.yp_lex_serialize(code, code.bytesize, filepath, buffer.pointer) + LibRubyParser::PrismBuffer.with do |buffer| + LibRubyParser.pm_lex_serialize(code, code.bytesize, filepath, buffer.pointer) Serialize.load_tokens(Source.new(code), buffer.read) end end - # Mirror the YARP.lex_file API by using the serialization API. + # Mirror the Prism.lex_file API by using the serialization API. def self.lex_file(filepath) - LibRubyParser::YPString.with(filepath) do |string| + LibRubyParser::PrismString.with(filepath) do |string| lex(string.read, filepath) end end - # Mirror the YARP.parse API by using the serialization API. + # Mirror the Prism.parse API by using the serialization API. def self.parse(code, filepath = nil) - YARP.load(code, dump(code, filepath)) + Prism.load(code, dump(code, filepath)) end - # Mirror the YARP.parse_file API by using the serialization API. This uses + # Mirror the Prism.parse_file API by using the serialization API. This uses # native strings instead of Ruby strings because it allows us to use mmap when # it is available. def self.parse_file(filepath) - LibRubyParser::YPString.with(filepath) do |string| + LibRubyParser::PrismString.with(filepath) do |string| parse(string.read, filepath) end end - # Mirror the YARP.parse_lex API by using the serialization API. + # Mirror the Prism.parse_lex API by using the serialization API. def self.parse_lex(code, filepath = nil) - LibRubyParser::YPBuffer.with do |buffer| + LibRubyParser::PrismBuffer.with do |buffer| metadata = [filepath.bytesize, filepath.b, 0].pack("LA*L") if filepath - LibRubyParser.yp_parse_lex_serialize(code, code.bytesize, buffer.pointer, metadata) + LibRubyParser.pm_parse_lex_serialize(code, code.bytesize, buffer.pointer, metadata) source = Source.new(code) loader = Serialize::Loader.new(source, buffer.read) @@ -242,9 +242,9 @@ module YARP end end - # Mirror the YARP.parse_lex_file API by using the serialization API. + # Mirror the Prism.parse_lex_file API by using the serialization API. def self.parse_lex_file(filepath) - LibRubyParser::YPString.with(filepath) do |string| + LibRubyParser::PrismString.with(filepath) do |string| parse_lex(string.read, filepath) end end diff --git a/lib/prism/lex_compat.rb b/lib/prism/lex_compat.rb index 720ac2b59b..afc0f3b605 100644 --- a/lib/prism/lex_compat.rb +++ b/lib/prism/lex_compat.rb @@ -2,14 +2,14 @@ require "delegate" -module YARP - # This class is responsible for lexing the source using YARP and then +module Prism + # This class is responsible for lexing the source using prism and then # converting those tokens to be compatible with Ripper. In the vast majority # of cases, this is a one-to-one mapping of the token type. Everything else # generally lines up. However, there are a few cases that require special # handling. class LexCompat - # This is a mapping of YARP token types to Ripper token types. This is a + # This is a mapping of prism token types to Ripper token types. This is a # many-to-one mapping because we split up our token types, whereas Ripper # tends to group them. RIPPER = { @@ -339,8 +339,8 @@ module YARP # Heredocs that are dedenting heredocs are a little more complicated. # Ripper outputs on_ignored_sp tokens for the whitespace that is being - # removed from the output. YARP only modifies the node itself and keeps - # the token the same. This simplifies YARP, but makes comparing against + # removed from the output. prism only modifies the node itself and keeps + # the token the same. This simplifies prism, but makes comparing against # Ripper much harder because there is a length mismatch. # # Fortunately, we already have to pull out the heredoc tokens in order to @@ -563,7 +563,7 @@ module YARP state = :default heredoc_stack = [[]] - result = YARP.lex(source, @filepath) + result = Prism.lex(source, @filepath) result_value = result.value previous_state = nil @@ -650,7 +650,7 @@ module YARP IgnoredNewlineToken.new([[lineno, column], event, value, lex_state]) when :on_regexp_end # On regex end, Ripper scans and then sets end state, so the ripper - # lexed output is begin, when it should be end. YARP sets lex state + # lexed output is begin, when it should be end. prism sets lex state # correctly to end state, but we want to be able to compare against # Ripper's lexed state. So here, if it's a regexp end token, we # output the state as the previous state, solely for the sake of @@ -706,7 +706,7 @@ module YARP # The order in which tokens appear in our lexer is different from the # order that they appear in Ripper. When we hit the declaration of a - # heredoc in YARP, we skip forward and lex the rest of the content of + # heredoc in prism, we skip forward and lex the rest of the content of # the heredoc before going back and lexing at the end of the heredoc # identifier. # diff --git a/lib/prism/node_ext.rb b/lib/prism/node_ext.rb index 760b3d75df..08d9e9f36a 100644 --- a/lib/prism/node_ext.rb +++ b/lib/prism/node_ext.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -# Here we are reopening the YARP module to provide methods on nodes that aren't +# Here we are reopening the prism module to provide methods on nodes that aren't # templated and are meant as convenience methods. -module YARP +module Prism class FloatNode < Node # Returns the value of the node as a Ruby Float. def value diff --git a/lib/prism/node_inspector.rb b/lib/prism/node_inspector.rb index c09840a471..be5b3532db 100644 --- a/lib/prism/node_inspector.rb +++ b/lib/prism/node_inspector.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module YARP +module Prism # This object is responsible for generating the output for the inspect method # implementations of child nodes. class NodeInspector diff --git a/lib/prism/pack.rb b/lib/prism/pack.rb index 83f5569923..5c5f0a34fe 100644 --- a/lib/prism/pack.rb +++ b/lib/prism/pack.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module YARP +module Prism module Pack %i[ SPACE diff --git a/lib/prism/parse_result.rb b/lib/prism/parse_result.rb index 2d9d855b86..fafa1ae15f 100644 --- a/lib/prism/parse_result.rb +++ b/lib/prism/parse_result.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module YARP +module Prism # This represents a source of Ruby code that has been parsed. It is used in # conjunction with locations to allow them to resolve line numbers and source # ranges. @@ -71,7 +71,7 @@ module YARP # Returns a string representation of this location. def inspect - "#<YARP::Location @start_offset=#{@start_offset} @length=#{@length} start_line=#{start_line}>" + "#<Prism::Location @start_offset=#{@start_offset} @length=#{@length} start_line=#{start_line}>" end # The source code that this location represents. @@ -162,7 +162,7 @@ module YARP end def inspect - "#<YARP::Comment @type=#{@type.inspect} @location=#{@location.inspect}>" + "#<Prism::Comment @type=#{@type.inspect} @location=#{@location.inspect}>" end end @@ -180,7 +180,7 @@ module YARP end def inspect - "#<YARP::ParseError @message=#{@message.inspect} @location=#{@location.inspect}>" + "#<Prism::ParseError @message=#{@message.inspect} @location=#{@location.inspect}>" end end @@ -198,7 +198,7 @@ module YARP end def inspect - "#<YARP::ParseWarning @message=#{@message.inspect} @location=#{@location.inspect}>" + "#<Prism::ParseWarning @message=#{@message.inspect} @location=#{@location.inspect}>" end end diff --git a/lib/prism/parse_result/comments.rb b/lib/prism/parse_result/comments.rb index 88240609b1..fba0b1a5aa 100644 --- a/lib/prism/parse_result/comments.rb +++ b/lib/prism/parse_result/comments.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module YARP +module Prism class ParseResult # When we've parsed the source, we have both the syntax tree and the list of # comments that we found in the source. This class is responsible for diff --git a/lib/prism/parse_result/newlines.rb b/lib/prism/parse_result/newlines.rb index d16600afd0..334f3f2a69 100644 --- a/lib/prism/parse_result/newlines.rb +++ b/lib/prism/parse_result/newlines.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module YARP +module Prism class ParseResult # The :line tracepoint event gets fired whenever the Ruby VM encounters an # expression on a new line. The types of expressions that can trigger this diff --git a/lib/prism/pattern.rb b/lib/prism/pattern.rb index f7519137e4..3d7d5bea70 100644 --- a/lib/prism/pattern.rb +++ b/lib/prism/pattern.rb @@ -1,24 +1,24 @@ # frozen_string_literal: true -module YARP +module Prism # A pattern is an object that wraps a Ruby pattern matching expression. The # expression would normally be passed to an `in` clause within a `case` # expression or a rightward assignment expression. For example, in the # following snippet: # # case node - # in ConstantPathNode[ConstantReadNode[name: :YARP], ConstantReadNode[name: :Pattern]] + # in ConstantPathNode[ConstantReadNode[name: :Prism], ConstantReadNode[name: :Pattern]] # end # # the pattern is the `ConstantPathNode[...]` expression. # # The pattern gets compiled into an object that responds to #call by running - # the #compile method. This method itself will run back through YARP to + # the #compile method. This method itself will run back through Prism to # parse the expression into a tree, then walk the tree to generate the # necessary callable objects. For example, if you wanted to compile the # expression above into a callable, you would: # - # callable = YARP::Pattern.new("ConstantPathNode[ConstantReadNode[name: :YARP], ConstantReadNode[name: :Pattern]]").compile + # callable = Prism::Pattern.new("ConstantPathNode[ConstantReadNode[name: :Prism], ConstantReadNode[name: :Pattern]]").compile # callable.call(node) # # The callable object returned by #compile is guaranteed to respond to #call @@ -32,7 +32,7 @@ module YARP # # If the query given to the initializer cannot be compiled into a valid # matcher (either because of a syntax error or because it is using syntax we - # do not yet support) then a YARP::Pattern::CompilationError will be + # do not yet support) then a Prism::Pattern::CompilationError will be # raised. class Pattern # Raised when the query given to a pattern is either invalid Ruby syntax or @@ -40,15 +40,15 @@ module YARP class CompilationError < StandardError def initialize(repr) super(<<~ERROR) - YARP was unable to compile the pattern you provided into a usable + prism was unable to compile the pattern you provided into a usable expression. It failed on to understand the node represented by: #{repr} Note that not all syntax supported by Ruby's pattern matching syntax - is also supported by YARP's patterns. If you're using some syntax + is also supported by prism's patterns. If you're using some syntax that you believe should be supported, please open an issue on - GitHub at https://github.com/ruby/yarp/issues/new. + GitHub at https://github.com/ruby/prism/issues/new. ERROR end end @@ -61,7 +61,7 @@ module YARP end def compile - result = YARP.parse("case nil\nin #{query}\nend") + result = Prism.parse("case nil\nin #{query}\nend") compile_node(result.value.statements.body.last.conditions.last.pattern) end @@ -126,11 +126,11 @@ module YARP combine_or(compile_node(node.left), compile_node(node.right)) end - # in YARP::ConstantReadNode + # in Prism::ConstantReadNode def compile_constant_path_node(node) parent = node.parent - if parent.is_a?(ConstantReadNode) && parent.slice == "YARP" + if parent.is_a?(ConstantReadNode) && parent.slice == "Prism" compile_node(node.child) else compile_error(node) @@ -142,8 +142,8 @@ module YARP def compile_constant_read_node(node) value = node.slice - if YARP.const_defined?(value, false) - clazz = YARP.const_get(value) + if Prism.const_defined?(value, false) + clazz = Prism.const_get(value) ->(other) { clazz === other } elsif Object.const_defined?(value, false) diff --git a/lib/prism/prism.gemspec b/lib/prism/prism.gemspec index d1a7bbbbcf..af2555247f 100644 --- a/lib/prism/prism.gemspec +++ b/lib/prism/prism.gemspec @@ -1,13 +1,13 @@ # frozen_string_literal: true Gem::Specification.new do |spec| - spec.name = "yarp" + spec.name = "prism" spec.version = "0.12.0" spec.authors = ["Shopify"] spec.email = ["[email protected]"] - spec.summary = "Yet Another Ruby Parser" - spec.homepage = "https://github.com/ruby/yarp" + spec.summary = "Prism Ruby parser" + spec.homepage = "https://github.com/ruby/prism" spec.license = "MIT" spec.required_ruby_version = ">= 3.0.0" @@ -33,59 +33,59 @@ Gem::Specification.new do |spec| "docs/ruby_api.md", "docs/serialization.md", "docs/testing.md", - "ext/yarp/api_node.c", - "ext/yarp/api_pack.c", - "ext/yarp/extension.c", - "ext/yarp/extension.h", - "include/yarp.h", - "include/yarp/ast.h", - "include/yarp/defines.h", - "include/yarp/diagnostic.h", - "include/yarp/enc/yp_encoding.h", - "include/yarp/node.h", - "include/yarp/pack.h", - "include/yarp/parser.h", - "include/yarp/regexp.h", - "include/yarp/unescape.h", - "include/yarp/util/yp_buffer.h", - "include/yarp/util/yp_char.h", - "include/yarp/util/yp_constant_pool.h", - "include/yarp/util/yp_list.h", - "include/yarp/util/yp_memchr.h", - "include/yarp/util/yp_newline_list.h", - "include/yarp/util/yp_state_stack.h", - "include/yarp/util/yp_string.h", - "include/yarp/util/yp_string_list.h", - "include/yarp/util/yp_strpbrk.h", - "include/yarp/version.h", - "lib/yarp.rb", - "lib/yarp/compiler.rb", - "lib/yarp/debug.rb", - "lib/yarp/desugar_compiler.rb", - "lib/yarp/dispatcher.rb", - "lib/yarp/dsl.rb", - "lib/yarp/ffi.rb", - "lib/yarp/lex_compat.rb", - "lib/yarp/mutation_compiler.rb", - "lib/yarp/node.rb", - "lib/yarp/node_ext.rb", - "lib/yarp/node_inspector.rb", - "lib/yarp/pack.rb", - "lib/yarp/parse_result.rb", - "lib/yarp/pattern.rb", - "lib/yarp/ripper_compat.rb", - "lib/yarp/serialize.rb", - "lib/yarp/parse_result/comments.rb", - "lib/yarp/parse_result/newlines.rb", - "lib/yarp/visitor.rb", + "ext/prism/api_node.c", + "ext/prism/api_pack.c", + "ext/prism/extension.c", + "ext/prism/extension.h", + "include/prism.h", + "include/prism/ast.h", + "include/prism/defines.h", + "include/prism/diagnostic.h", + "include/prism/enc/pm_encoding.h", + "include/prism/node.h", + "include/prism/pack.h", + "include/prism/parser.h", + "include/prism/regexp.h", + "include/prism/unescape.h", + "include/prism/util/pm_buffer.h", + "include/prism/util/pm_char.h", + "include/prism/util/pm_constant_pool.h", + "include/prism/util/pm_list.h", + "include/prism/util/pm_memchr.h", + "include/prism/util/pm_newline_list.h", + "include/prism/util/pm_state_stack.h", + "include/prism/util/pm_string.h", + "include/prism/util/pm_string_list.h", + "include/prism/util/pm_strpbrk.h", + "include/prism/version.h", + "lib/prism.rb", + "lib/prism/compiler.rb", + "lib/prism/debug.rb", + "lib/prism/desugar_compiler.rb", + "lib/prism/dispatcher.rb", + "lib/prism/dsl.rb", + "lib/prism/ffi.rb", + "lib/prism/lex_compat.rb", + "lib/prism/mutation_compiler.rb", + "lib/prism/node.rb", + "lib/prism/node_ext.rb", + "lib/prism/node_inspector.rb", + "lib/prism/pack.rb", + "lib/prism/parse_result.rb", + "lib/prism/pattern.rb", + "lib/prism/ripper_compat.rb", + "lib/prism/serialize.rb", + "lib/prism/parse_result/comments.rb", + "lib/prism/parse_result/newlines.rb", + "lib/prism/visitor.rb", "src/diagnostic.c", - "src/enc/yp_big5.c", - "src/enc/yp_euc_jp.c", - "src/enc/yp_gbk.c", - "src/enc/yp_shift_jis.c", - "src/enc/yp_tables.c", - "src/enc/yp_unicode.c", - "src/enc/yp_windows_31j.c", + "src/enc/pm_big5.c", + "src/enc/pm_euc_jp.c", + "src/enc/pm_gbk.c", + "src/enc/pm_shift_jis.c", + "src/enc/pm_tables.c", + "src/enc/pm_unicode.c", + "src/enc/pm_windows_31j.c", "src/node.c", "src/pack.c", "src/prettyprint.c", @@ -93,21 +93,21 @@ Gem::Specification.new do |spec| "src/serialize.c", "src/token_type.c", "src/unescape.c", - "src/util/yp_buffer.c", - "src/util/yp_char.c", - "src/util/yp_constant_pool.c", - "src/util/yp_list.c", - "src/util/yp_memchr.c", - "src/util/yp_newline_list.c", - "src/util/yp_state_stack.c", - "src/util/yp_string.c", - "src/util/yp_string_list.c", - "src/util/yp_strncasecmp.c", - "src/util/yp_strpbrk.c", - "src/yarp.c", - "yarp.gemspec", + "src/util/pm_buffer.c", + "src/util/pm_char.c", + "src/util/pm_constant_pool.c", + "src/util/pm_list.c", + "src/util/pm_memchr.c", + "src/util/pm_newline_list.c", + "src/util/pm_state_stack.c", + "src/util/pm_string.c", + "src/util/pm_string_list.c", + "src/util/pm_strncasecmp.c", + "src/util/pm_strpbrk.c", + "src/prism.c", + "prism.gemspec", ] - spec.extensions = ["ext/yarp/extconf.rb"] + spec.extensions = ["ext/prism/extconf.rb"] spec.metadata["allowed_push_host"] = "https://rubygems.org" end diff --git a/lib/prism/ripper_compat.rb b/lib/prism/ripper_compat.rb index c76f3fd07a..e0064196ea 100644 --- a/lib/prism/ripper_compat.rb +++ b/lib/prism/ripper_compat.rb @@ -2,14 +2,14 @@ require "ripper" -module YARP - # This class is meant to provide a compatibility layer between YARP and +module Prism + # This class is meant to provide a compatibility layer between prism and # Ripper. It functions by parsing the entire tree first and then walking it # and executing each of the Ripper callbacks as it goes. # # This class is going to necessarily be slower than the native Ripper API. It - # is meant as a stopgap until developers migrate to using YARP. It is also - # meant as a test harness for the YARP parser. + # is meant as a stopgap until developers migrate to using prism. It is also + # meant as a test harness for the prism parser. class RipperCompat # This class mirrors the ::Ripper::SexpBuilder subclass of ::Ripper that # returns the arrays of [type, *children]. @@ -156,7 +156,7 @@ module YARP end def result - @result ||= YARP.parse(source) + @result ||= Prism.parse(source) end def _dispatch0; end |