Results for: "partition"

Raises when the given argument word can’t be completed uniquely.

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.

The dispatcher class fires events for nodes that are found while walking an AST to all registered listeners. It’s useful for performing different types of analysis on the AST while only having to walk the tree once.

To use the dispatcher, you would first instantiate it and register listeners for the events you’re interested in:

class OctalListener
  def on_integer_node_enter(node)
    if node.octal? && !node.slice.start_with?("0o")
      warn("Octal integers should be written with the 0o prefix")
    end
  end
end

listener = OctalListener.new
dispatcher = Prism::Dispatcher.new
dispatcher.register(listener, :on_integer_node_enter)

Then, you can walk any number of trees and dispatch events to the listeners:

result = Prism.parse("001 + 002 + 003")
dispatcher.dispatch(result.value)

Optionally, you can also use ‘#dispatch_once` to dispatch enter and leave events for a single node without recursing further down the tree. This can be useful in circumstances where you want to reuse the listeners you already have registers but want to stop walking the tree at a certain point.

integer = result.value.statements.body.first.receiver.receiver
dispatcher.dispatch_once(integer)

This visitor is responsible for composing the strings that get returned by the various inspect methods defined on each of the nodes.

No documentation available

Represents the use of the ‘alias` keyword to alias a global variable.

alias $foo $bar
^^^^^^^^^^^^^^^

Represents a set of arguments to a method or a keyword.

return foo, bar, baz
       ^^^^^^^^^^^^^

Represents an array literal. This can be a regular array using brackets or a special array using % like %w or %i.

[1, 2, 3]
^^^^^^^^^

Represents a block argument using ‘&`.

bar(&args)
^^^^^^^^^^

Represents a block local variable.

a { |; b| }
       ^

Represents the use of the ‘&&=` operator on a call.

foo.bar &&= value
^^^^^^^^^^^^^^^^^

Represents the use of an assignment operator on a call.

foo.bar += baz
^^^^^^^^^^^^^^

Represents the use of the ‘||=` operator on a call.

foo.bar ||= value
^^^^^^^^^^^^^^^^^

Represents assigning to a method call.

foo.bar, = 1
^^^^^^^

begin
rescue => foo.bar
          ^^^^^^^
end

for foo.bar in baz do end
    ^^^^^^^

Represents assigning to a local variable in pattern matching.

foo => [bar => baz]
       ^^^^^^^^^^^^

Represents referencing a class variable.

@@foo
^^^^^

Represents referencing a constant.

Foo
^^^

Represents an interpolated variable.

"foo #@bar"
     ^^^^^

Represents a find pattern in pattern matching.

foo in *bar, baz, *qux
       ^^^^^^^^^^^^^^^

foo in [*bar, baz, *qux]
       ^^^^^^^^^^^^^^^^^

foo in Foo(*bar, baz, *qux)
       ^^^^^^^^^^^^^^^^^^^^

Represents the use of the ‘super` keyword without parentheses or arguments.

super
^^^^^

Represents referencing a global variable.

$foo
^^^^

Represents a hash pattern in pattern matching.

foo => { a: 1, b: 2 }
       ^^^^^^^^^^^^^^

foo => { a: 1, b: 2, **c }
       ^^^^^^^^^^^^^^^^^^^

Represents an imaginary number literal.

1.0i
^^^^

Represents a node that is implicitly being added to the tree but doesn’t correspond directly to a node in the source.

{ foo: }
  ^^^^

{ Foo: }
  ^^^^

foo in { bar: }
         ^^^^

Represents using a trailing comma to indicate an implicit rest parameter.

foo { |bar,| }
          ^

foo in [bar,]
           ^

for foo, in bar do end
       ^

foo, = bar
   ^
Search took: 23ms  ·  Total Results: 4702