Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/prism.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module Prism
# Raised when requested to parse as the currently running Ruby version but Prism has no support for it.
class CurrentVersionError < ArgumentError
# Initialize a new exception for the given ruby version string.
#--
#
#: (String version) -> void
def initialize(version)
message = +"invalid version: Requested to parse as `version: 'current'`; "
Expand All @@ -69,7 +69,7 @@ def initialize(version)
# resembles the return value of Ripper.lex.
#
# For supported options, see Prism.parse.
#--
#
#: (String source, **untyped options) -> LexCompat::Result
def self.lex_compat(source, **options)
LexCompat.new(source, **options).result # steep:ignore
Expand All @@ -79,7 +79,7 @@ def self.lex_compat(source, **options)
# load(source, serialized, freeze) -> ParseResult
#
# Load the serialized AST using the source as a reference into a tree.
#--
#
#: (String source, String serialized, ?bool freeze) -> ParseResult
def self.load(source, serialized, freeze = false)
Serialize.load_parse(source, serialized, freeze)
Expand All @@ -89,7 +89,7 @@ def self.load(source, serialized, freeze = false)
# returns the Prism node representing it. On CRuby, this uses node_id for
# an exact match. On other implementations, it falls back to best-effort
# matching by source location line number.
#--
#
#: (Method | UnboundMethod | Proc | Thread::Backtrace::Location callable) -> Node?
def self.find(callable)
NodeFind.find(callable)
Expand Down
38 changes: 19 additions & 19 deletions lib/prism/desugar_compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def initialize(node, default_source, read_class, write_class, **arguments)
end

# Desugar `x &&= y` to `x && x = y`
#--
#
#: () -> node
def compile
and_node(
Expand Down Expand Up @@ -59,7 +59,7 @@ def initialize(node, default_source, read_class, write_class, **arguments)
end

# Desugar `x ||= y` to `defined?(x) ? x : x = y`
#--
#
#: () -> node
def compile
if_node(
Expand Down Expand Up @@ -116,7 +116,7 @@ def initialize(node, default_source, read_class, write_class, **arguments)
end

# Desugar `x += y` to `x = x + y`
#--
#
#: () -> node
def compile
binary_operator_loc = node.binary_operator_loc.chop
Expand Down Expand Up @@ -166,7 +166,7 @@ def initialize(node, default_source, read_class, write_class, **arguments)
end

# Desugar `x ||= y` to `x || x = y`
#--
#
#: () -> node
def compile
or_node(
Expand Down Expand Up @@ -300,7 +300,7 @@ class DesugarCompiler < MutationCompiler
# becomes
#
# `@@foo && @@foo = bar`
#--
#
#: (ClassVariableAndWriteNode node) -> node
def visit_class_variable_and_write_node(node)
node.desugar
Expand All @@ -311,7 +311,7 @@ def visit_class_variable_and_write_node(node)
# becomes
#
# `defined?(@@foo) ? @@foo : @@foo = bar`
#--
#
#: (ClassVariableOrWriteNode node) -> node
def visit_class_variable_or_write_node(node)
node.desugar
Expand All @@ -322,7 +322,7 @@ def visit_class_variable_or_write_node(node)
# becomes
#
# `@@foo = @@foo + bar`
#--
#
#: (ClassVariableOperatorWriteNode node) -> node
def visit_class_variable_operator_write_node(node)
node.desugar
Expand All @@ -333,7 +333,7 @@ def visit_class_variable_operator_write_node(node)
# becomes
#
# `Foo && Foo = bar`
#--
#
#: (ConstantAndWriteNode node) -> node
def visit_constant_and_write_node(node)
node.desugar
Expand All @@ -344,7 +344,7 @@ def visit_constant_and_write_node(node)
# becomes
#
# `defined?(Foo) ? Foo : Foo = bar`
#--
#
#: (ConstantOrWriteNode node) -> node
def visit_constant_or_write_node(node)
node.desugar
Expand All @@ -355,7 +355,7 @@ def visit_constant_or_write_node(node)
# becomes
#
# `Foo = Foo + bar`
#--
#
#: (ConstantOperatorWriteNode node) -> node
def visit_constant_operator_write_node(node)
node.desugar
Expand All @@ -366,7 +366,7 @@ def visit_constant_operator_write_node(node)
# becomes
#
# `$foo && $foo = bar`
#--
#
#: (GlobalVariableAndWriteNode node) -> node
def visit_global_variable_and_write_node(node)
node.desugar
Expand All @@ -377,7 +377,7 @@ def visit_global_variable_and_write_node(node)
# becomes
#
# `defined?($foo) ? $foo : $foo = bar`
#--
#
#: (GlobalVariableOrWriteNode node) -> node
def visit_global_variable_or_write_node(node)
node.desugar
Expand All @@ -388,7 +388,7 @@ def visit_global_variable_or_write_node(node)
# becomes
#
# `$foo = $foo + bar`
#--
#
#: (GlobalVariableOperatorWriteNode node) -> node
def visit_global_variable_operator_write_node(node)
node.desugar
Expand All @@ -399,7 +399,7 @@ def visit_global_variable_operator_write_node(node)
# becomes
#
# `@foo && @foo = bar`
#--
#
#: (InstanceVariableAndWriteNode node) -> node
def visit_instance_variable_and_write_node(node)
node.desugar
Expand All @@ -410,7 +410,7 @@ def visit_instance_variable_and_write_node(node)
# becomes
#
# `@foo || @foo = bar`
#--
#
#: (InstanceVariableOrWriteNode node) -> node
def visit_instance_variable_or_write_node(node)
node.desugar
Expand All @@ -421,7 +421,7 @@ def visit_instance_variable_or_write_node(node)
# becomes
#
# `@foo = @foo + bar`
#--
#
#: (InstanceVariableOperatorWriteNode node) -> node
def visit_instance_variable_operator_write_node(node)
node.desugar
Expand All @@ -432,7 +432,7 @@ def visit_instance_variable_operator_write_node(node)
# becomes
#
# `foo && foo = bar`
#--
#
#: (LocalVariableAndWriteNode node) -> node
def visit_local_variable_and_write_node(node)
node.desugar
Expand All @@ -443,7 +443,7 @@ def visit_local_variable_and_write_node(node)
# becomes
#
# `foo || foo = bar`
#--
#
#: (LocalVariableOrWriteNode node) -> node
def visit_local_variable_or_write_node(node)
node.desugar
Expand All @@ -454,7 +454,7 @@ def visit_local_variable_or_write_node(node)
# becomes
#
# `foo = foo + bar`
#--
#
#: (LocalVariableOperatorWriteNode node) -> node
def visit_local_variable_operator_write_node(node)
node.desugar
Expand Down
6 changes: 3 additions & 3 deletions lib/prism/lex_compat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ class Result < Prism::Result
attr_reader :value #: Array[lex_compat_token]

# Create a new lex compat result object with the given values.
#--
#
#: (Array[lex_compat_token] value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, bool continuable, Source source) -> void
def initialize(value, comments, magic_comments, data_loc, errors, warnings, continuable, source)
@value = value
super(comments, magic_comments, data_loc, errors, warnings, continuable, source)
end

# Implement the hash pattern matching interface for Result.
#--
#
#: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
def deconstruct_keys(keys) # :nodoc:
super.merge!(value: value)
Expand Down Expand Up @@ -572,7 +572,7 @@ def to_a

# Here we will split between the two types of heredocs and return the
# object that will store their tokens.
#--
#
#: (lex_compat_token opening) -> (PlainHeredoc | DashHeredoc | DedentingHeredoc)
def self.build(opening)
case opening[2][2]
Expand Down
Loading