Results for: "Data"

Represents a hash pattern in pattern matching.

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

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

Represents the use of an assignment operator on a call to ‘[]`.

foo.bar[baz] += value
^^^^^^^^^^^^^^^^^^^^^

Represents assigning to an index.

foo[bar], = 1
^^^^^^^^

begin
rescue => foo[bar]
          ^^^^^^^^
end

for foo[bar] in baz do end
    ^^^^^^^^

Represents the use of the ‘&&=` operator for assignment to an instance variable.

@target &&= value
^^^^^^^^^^^^^^^^^

Represents the use of the ‘||=` operator for assignment to an instance variable.

@target ||= value
^^^^^^^^^^^^^^^^^

Represents referencing an instance variable.

@foo
^^^^

Represents writing to an instance variable.

@foo = 1
^^^^^^^^

Represents a regular expression literal that contains interpolation.

/foo #{bar} baz/
^^^^^^^^^^^^^^^^

Represents a string literal that contains interpolation.

"foo #{bar} baz"
^^^^^^^^^^^^^^^^

Represents a symbol literal that contains interpolation.

:"foo #{bar} baz"
^^^^^^^^^^^^^^^^^

Represents an xstring literal that contains interpolation.

`foo #{bar} baz`
^^^^^^^^^^^^^^^^

Represents using a lambda literal (not the lambda method call).

->(value) { value * 2 }
^^^^^^^^^^^^^^^^^^^^^^^

Represents assigning to a local variable using an operator that isn’t ‘=`.

target += value
^^^^^^^^^^^^^^^

Represents writing to a local variable in a context that doesn’t have an explicit value.

foo, bar = baz
^^^  ^^^

Represents a regular expression literal used in the predicate of a conditional to implicitly match against the last line read by an IO object.

if /foo/i then end
   ^^^^^^

Represents the use of the ‘=>` operator.

foo => bar
^^^^^^^^^^

Represents writing local variables using a regular expression match with named capture groups.

/(?<foo>bar)/ =~ baz
^^^^^^^^^^^^^^^^^^^^

Represents a multi-target expression.

a, (b, c) = 1, 2, 3
   ^^^^^^

Represents a rational number literal.

1.0r
^^^^

Represents the use of the splat operator.

[*a]
 ^^

This represents a location in the source.

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: :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 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 = 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 with a single argument, which is the node to match against. It also is guaranteed to respond to ===, which means it itself can be used in a ‘case` expression, as in:

case node
when callable
end

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 Prism::Pattern::CompilationError will be raised.

Note: This integration is not finished, and therefore still has many inconsistencies with Ripper. If you’d like to help out, pull requests would be greatly appreciated!

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 prism. It is also meant as a test harness for the prism parser.

To use this class, you treat ‘Prism::RipperCompat` effectively as you would treat the `Ripper` class.

Rinda error base class

Templates are used to match tuples in Rinda.

Search took: 8ms  ·  Total Results: 1843