The top level node of any parse tree.
Represents the use of the ‘..` or `…` operators.
1..2 ^^^^ c if a =~ /left/ ... b =~ /right/ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Represents a required keyword parameter to a method, block, or lambda definition.
def a(b: ) ^^ end
Represents a required parameter to a method, block, or lambda definition.
def a(b) ^ end
Represents an expression modified with a rescue.
foo rescue nil ^^^^^^^^^^^^^^
Represents a rest parameter to a method, block, or lambda definition.
def a(*b) ^^ end
Represents the use of the ‘super` keyword with parentheses or arguments.
super() ^^^^^^^ super foo, bar ^^^^^^^^^^^^^^
This represents a location in the source.
This represents an error that was encountered during parsing.
This represents the result of a call to ::parse or ::parse_file. It contains the AST, any comments that were encounters, and any errors that were encountered.
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.
The error type thrown by all PStore
methods.
Indicates a failure to resolve a name or address.
Rinda
error base class
Raised when trying to use a canceled tuple.
Raised when trying to use an expired tuple.
RingProvider
uses a RingServer
advertised TupleSpace
as a name service. TupleSpace
clients can register themselves with the remote TupleSpace
and look up other provided services via the remote TupleSpace
.
Services are registered with a tuple of the format [:name, klass, DRbObject
, description].
Installs a gem along with all its dependencies from local and remote gems.
Raised when trying to activate a gem, and that gem does not exist on the system. Instead of rescuing from this class, make sure to rescue from the superclass Gem::LoadError
to catch all types of load errors.
Raised when there are conflicting gem specs loaded