Represents assigning to a global variable using an operator that isn’t ‘=`.
$target += value ^^^^^^^^^^^^^^^^
Represents the use of the ‘||=` operator for assignment to a global variable.
$target ||= value ^^^^^^^^^^^^^^^^^
Represents using a trailing comma to indicate an implicit rest parameter.
foo { |bar,| } ^ foo in [bar,] ^ for foo, in bar do end ^ foo, = bar ^
Represents writing to an instance variable in a context that doesn’t have an explicit value.
@foo, @bar = baz ^^^^ ^^^^
Represents the use of the ‘&&=` operator for assignment to a local variable.
target &&= value ^^^^^^^^^^^^^^^^
Represents assigning to a local variable using an operator that isn’t ‘=`.
target += value ^^^^^^^^^^^^^^^
Represents the use of the ‘||=` operator for assignment to a local variable.
target ||= value ^^^^^^^^^^^^^^^^
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.
Gem::StreamUI
implements a simple stream based user interface.
Find
mis-matched syntax based on lexical count
Used for detecting missing pairs of elements each keyword needs an end, each ‘{’ needs a ‘}’ etc.
Example:
left_right = LeftRightLexCount.new left_right.count_kw left_right.missing.first # => "end" left_right = LeftRightLexCount.new source = "{ a: b, c: d" # Note missing '}' LexAll.new(source: source).each do |lex| left_right.count_lex(lex) end left_right.missing.first # => "}"
Keeps track of what elements are in the queue in priority and also ensures that when one element engulfs/covers/eats another that the larger element evicts the smaller element
Holds elements in a priority heap on insert
Instead of constantly calling ‘sort!`, put the element where it belongs the first time around
Example:
queue = PriorityQueue.new queue << 33 queue << 44 queue << 1 puts queue.peek # => 44
Capture
parse errors from Ripper
Prism
returns the errors with their messages, but Ripper
does not. To get them we must make a custom subclass.
Example:
puts RipperErrors.new(" def foo").call.errors # => ["syntax error, unexpected end-of-input, expecting ';' or '\\n'"]
Used to construct C classes (CUnion
, CStruct
, etc)
Fiddle::Importer#struct
and Fiddle::Importer#union
wrap this functionality in an easy-to-use manner.
Helper methods for both Gem::Installer
and Gem::Uninstaller