Releases: ruby/prism
Releases · ruby/prism
v0.15.0
Added
BackReferenceReadNode#name
is now provided.Index{Operator,And,Or}WriteNode
are introduced, split out fromCall{Operator,And,Or}WriteNode
when the method is[]
.
Changed
- Ensure
PM_NODE_FLAG_COMMON_MASK
into a constant expression to fix compile errors. super(&arg)
is now fixed.- Ensure the last encoding flag on regular expressions wins.
- Fix the common whitespace calculation when embedded expressions begin on a line.
- Capture groups in regular expressions now scan the unescaped version to get the correct local variables.
*
and&
are added to the local table when...
is found in the parameters of a method definition.
v0.14.0
Added
- Syntax errors are added for invalid lambda local semicolon placement.
- Lambda locals are now checked for duplicate names.
- Destructured parameters are now checked for duplicate names.
Constant{Read,Path,PathTarget}Node#full_name
andConstant{Read,Path,PathTarget}Node#full_name_parts
are added to walk constant paths for you to find the full name of the constant.- Syntax errors are added when assigning to a numbered parameter.
Node::type
is added, which matches theNode#type
API.- Magic comments are now parsed as part of the parsing process and a new field is added in the form of
ParseResult#magic_comments
to access them.
Changed
- BREAKING:
Call*Node#name
methods now return symbols instead of strings. - BREAKING: For loops now have their index value considered as part of the body, so depths of local variable assignments will be increased by 1.
- Tilde heredocs now split up their lines into multiple string nodes to make them easier to dedent.
v0.13.0
Added
BEGIN {}
blocks are only allowed at the top-level, and will now provide a syntax error if they are not.- Numbered parameters are not allowed in block parameters, and will now provide a syntax error if they are.
- Many more Ruby modules and classes are now documented. Also, many have been moved into their own files and autoloaded so that initial boot time of the gem is much faster.
PM_TOKEN_METHOD_NAME
is introduced, used to indicate an identifier that if definitely a method name because it has an!
or?
at the end.- In the C API, arrays, assocs, and hashes now can have the
PM_NODE_FLAG_STATIC_LITERAL
flag attached if they can be compiled statically. This is used in CRuby, for example, to determine if aduphash
/duparray
instruction can be used as opposed to anewhash
/newarray
. Node#type
is introduced, which returns a symbol representing the type of the node. This is useful for case comparisons when you have to compare against multiple types.
Changed
- BREAKING: Everything has been renamed to
prism
instead ofyarp
. Theyp_
/YP_
prefix in the C API has been changed topm_
/PM_
. For the most part, everything should be find/replaceable. - BREAKING:
BlockArgumentNode
nodes now go into theblock
field onCallNode
nodes, in addition to theBlockNode
nodes that used to be there. Hopefully this makes it more consistent to compile/deal with in general, but it does mean it can be a surprising breaking change. - Escaped whitespace in
%w
lists is now properly unescaped. Node#pretty_print
now respects pretty print indentation.Dispatcher
was previously firing_leave
events in the incorrect order. This has now been fixed.- BREAKING:
Visitor
has now been split intoVisitor
andCompiler
. The visitor visits nodes but doesn't return anything from the visit methods. It is suitable for taking action based on the tree, but not manipulating the tree itself. TheCompiler
visits nodes and returns the computed value up the tree. It is suitable for compiling the tree into another format. As such,MutationVisitor
has been renamed toMutationCompiler
.
v0.12.0
Added
RegularExpressionNode#options
andInterpolatedRegularExpressionNode#options
are now provided. These return integers that match up to theRegexp#options
API.- Greatly improved
Node#inspect
andNode#pretty_print
APIs. MatchLastLineNode
andInterpolatedMatchLastLineNode
are introduced to represent using a regular expression as the predicate of anif
orunless
statement.IntegerNode
now has a base flag on it.- Heredocs that were previously
InterpolatedStringNode
andInterpolatedXStringNode
nodes without any actual interpolation are nowStringNode
andXStringNode
, respectively. StringNode
now has afrozen?
flag on it, which respects thefrozen_string_literal
magic comment.- Numbered parameters are now supported, and are properly represented using
LocalVariableReadNode
nodes. ImplicitNode
is introduced, which wraps implicit calls, local variable reads, or constant reads in omitted hash values.YARP::Dispatcher
is introduced, which provides a way for multiple objects to listen for certain events on the AST while it is being walked. This is effectively a way to implement a more efficient visitor pattern when you have many different uses for the AST.
Changed
- BREAKING: Flags fields are now marked as private, to ensure we can change their implementation under the hood. Actually querying should be through the accessor methods.
- BREAKING:
AliasNode
is now split intoAliasMethodNode
andAliasGlobalVariableNode
. - Method definitions on local variables is now correctly handled.
- Unary minus precedence has been fixed.
- Concatenating character literals with string literals is now fixed.
- Many more invalid syntaxes are now properly rejected.
- BREAKING: Comments now no longer include their trailing newline.
v0.11.0
Added
Node#inspect
is much improved.YARP::Pattern
is introduced, which can construct procs to match against nodes.BlockLocalVariableNode
is introduced to take the place of the locations array onBlockParametersNode
.ParseResult#attach_comments!
is now provided to attach comments to locations in the tree.MultiTargetNode
is introduced as the target of multi writes and for loops.Node#comment_targets
is introduced to return the list of objects that can have attached comments.
Changed
- BREAKING:
GlobalVariable*Node#name
now returns a symbol. - BREAKING:
Constant*Node#name
now returns a symbol. - BREAKING:
BlockParameterNode
,KeywordParameterNode
,KeywordRestParameterNode
,RestParameterNode
,DefNode
all have theirname
methods returning symbols now. - BREAKING:
ClassNode#name
andModuleNode#name
now return symbols. - BREAKING:
Location#end_column
is now exclusive instead of inclusive. Location#slice
now returns a properly encoded string.CallNode#operator_loc
is nowCallNode#call_operator_loc
.CallOperatorAndWriteNode
is renamed toCallAndWriteNode
and its structure has changed.CallOperatorOrWriteNode
is renamed toCallOrWriteNode
and its structure has changed.
v0.10.0
Added
InstanceVariable*Node
andClassVariable*Node
objects now have theirname
returning a Symbol. This is because they are now part of the constant pool.NumberedReferenceReadNode
now has anumber
field, which returns an Integer.
Changed
- BREAKING: Various
operator_id
andconstant_id
fields have been renamed tooperator
andname
, respectively. See 09d0a144 for details. %w
,%W
,%i
,%I
,%q
, and%Q
literals can now span around the contents of a heredoc.- BREAKING: All of the public C APIs that accept the source string now accept
const uint8_t *
as opposed toconst char *
.
v0.9.0
Added
- Regular expressions can now be bound by
\n
,\r
, and a combination of\r\n
. - Strings delimited by
%
,%q
, and%Q
can now be bound by\n
,\r
, and a combination of\r\n
. IntegerNode#value
now returns the value of the integer as a RubyInteger
.FloatNode#value
now returns the value of the float as a RubyFloat
.RationalNode#value
now returns the value of the rational as a RubyRational
.ImaginaryNode#value
now returns the value of the imaginary as a RubyComplex
.ClassNode#name
is now a string that returns the name of just the class, without the namespace.ModuleNode#name
is now a string that returns the name of just the module, without the namespace.- Regular expressions and strings found after a heredoc declaration but before the heredoc body are now parsed correctly.
- The serialization API now supports shared strings, which should help reduce the size of the serialized AST.
*Node#copy
is introduced, which returns a copy of the node with the given overrides.Location#copy
is introduced, which returns a copy of the location with the given overrides.DesugarVisitor
is introduced, which provides a simpler AST for use in tools that want to process fewer node types.{ClassVariable,Constant,ConstantPath,GlobalVariable,InstanceVariable,LocalVariable}TargetNode
are introduced. These nodes represent the target of writes in locations where a value cannot be provided, like a multi write or a rescue reference.UntilNode#closing_loc
andWhileNode#closing_loc
are now provided.Location#join
is now provided, which joins two locations together.YARP::parse_lex
andYARP::parse_lex_file
are introduced to parse and lex in one result.
Changed
- When there is a magic encoding comment, the encoding of the first token's source string is now properly reencoded.
- Constants followed by unary
&
are now properly parsed as a call with a passed block argument. - Escaping multi-byte characters in a string literal will now properly escape the entire character.
YARP.lex_compat
now has more accurate behavior when a byte-order mark is present in the file.- BREAKING:
AndWriteNode
,OrWriteNode
, andOperatorWriteNode
have been split back up into their0.7.0
versions. - We now properly support spaces between the
encoding
and=
/:
in a magic encoding comment. - We now properly parse
-> foo: bar do end
.
v0.8.0
Added
- Some performance improvements when converting from the C AST to the Ruby AST.
- Two rust crates have been added:
yarp-sys
andyarp
. They are as yet unpublished.
Changed
- Escaped newlines in strings and heredocs are now handled more correctly.
- Dedenting heredocs that result in empty string nodes will now drop those string nodes from the list.
- Beginless and endless ranges in conditional expressions now properly form a flip flop node.
%
at the end of files no longer crashes.- Location information has been corrected for
if/elsif
chains that have noelse
. __END__
at the very end of the file was previously parsed as an identifier, but is now correct.- BREAKING: Nodes that reference
&&=
,||=
, and other writing operators have been consolidated. Previously, they were separate individual nodes. Now they are a tree with the target being the left-hand side and the value being the right-hand side with a joiningAndWriteNode
,OrWriteNode
, orOperatorWriteNode
in the middle. This impacts all of the nodes that match this pattern:{ClassVariable,Constant,ConstantPath,GlobalVariable,InstanceVariable,LocalVariable}Operator{And,Or,}WriteNode
. - BREAKING:
BlockParametersNode
,ClassNode
,DefNode
,LambdaNode
,ModuleNode
,ParenthesesNode
, andSingletonClassNode
have had theirstatements
field renamed tobody
to give a hint that it might not be aStatementsNode
(it could also be aBeginNode
).
v0.7.0
Added
- We now have an explicit
FlipFlopNode
. It has the same flags asRangeNode
. - We now have a syntax error when implicit and explicit blocks are passed to a method call.
Node#slice
is now implemented, for retrieving the slice of the source code corresponding to a node.- We now support the
utf8-mac
encoding. - Predicate methods have been added for nodes that have flags. For example
CallNode#safe_navigation?
andRangeNode#exclude_end?
. - The gem now functions on JRuby and TruffleRuby, thanks to a new FFI backend.
- Comments are now part of the serialization API.
Changed
- Autotools has been removed from the build system, so when the gem is installed it will no longer need to go through a configure step.
- The AST for
foo = *bar
has changed to have an explicit array on the right hand side, rather than a splat node. This is more consistent with how other parsers handle this. RangeNodeFlags
has been renamed toRangeFlags
.- Unary minus on number literals is now parsed as part of the literal, rather than a call to a unary operator. This is more consistent with how other parsers handle this.