Represents `alias to from` statement.
Fields:
-
to (
Node
)Target of the
alias
.Sym("foo")
node foralias :foo :bar
-
from (
Node
)Source of the
alias
.Sym("bar")
node foralias :foo :bar
-
keyword_l (
Loc
)Location of the
alias
keywordalias foo bar ~~~~~
-
expression_l (
Loc
)Location of the full expression
alias foo bar ~~~~~~~~~~~~~
Represents `foo && bar` (or `foo and bar`) statement.
Fields:
-
lhs (
Node
)Left hand statament of the
&&
operation.Lvar("foo")
node forfoo && bar
-
rhs (
Node
)Right hand statement of the
&&
operation.Lvar("bar")
node forfoo && bar
-
operator_l (
Loc
)Location of the
&&
(orand
) operatora && b ~~
-
expression_l (
Loc
)Location of the full expression
a && b ~~~~~~
Represents `a &&= 1` statement.
Fields:
-
recv (
Node
)Receiver of the
&&=
operation.Lvasgn("a")
node fora &&= 1
-
value (
Node
)Right hand statement of assignment
Int("1")
node fora &&= 1
-
operator_l (
Loc
)Location of the
&&=
operatora &&= 1 ~~~
-
expression_l (
Loc
)Location of the full expression
a &&= 1 ~~~~~~~
Represents a positional required block/method argument.
`a` in `def m(a); end` or `proc { |a| }`
Fields:
-
name (
Str
)Name of the argument
-
expression_l (
Loc
)Location of the full expression
def m(argument); end ~~~~~~~~
Represents an arguments list
`Args(vec![Arg("a"), Optarg("b", Int("1"))])` in `def m(a, b = 1); end`
Fields:
-
args (
Nodes
)List of arguments
-
expression_l (
Loc
)Location of the full expression
def m(a, b = 1, c:, &blk); end ~~~~~~~~~~~~~~~~~~~~
-
begin_l (
MaybeLoc
)Location of the open parenthesis
def m(a, b = 1, c:, &blk); end ~
None
for code likedef m; end
ordef m arg; end
-
end_l (
MaybeLoc
)Location of the closing parenthesis
def m(a, b = 1, c:, &blk); end ~
None
for code likedef m; end
ordef m arg; end
Represents an array literal
Fields:
-
elements (
Nodes
)A list of elements
-
begin_l (
MaybeLoc
)Location of the open bracket
[1, 2, 3] ~
-
end_l (
MaybeLoc
)Location of the closing bracket
[1, 2, 3] ~
-
expression_l (
Loc
)Location of the full expression
[1, 2, 3] ~~~~~~~~~
Represents an array pattern used in pattern matching
Fields:
-
elements (
Nodes
)A list of elements
-
begin_l (
MaybeLoc
)Location of the open bracket
[1, ^a, 3 => foo] ~
None
for pattern like1, 2
without brackets -
end_l (
MaybeLoc
)Location of the closing bracket
[1, ^a, 3 => foo] ~
None
for pattern like1, 2
without brackets -
expression_l (
Loc
)Location of the full expression
[1, ^a, 3 => foo] ~~~~~~~~~~~~~~~~~
Represents an array pattern *with trailing comma* used in pattern matching
It's slightly different from `ArrayPattern`, trailing comma at the end works as `, *`
Fields:
-
elements (
Nodes
)A list of elements
-
begin_l (
MaybeLoc
)Location of the open bracket
[1, ^a, 3 => foo,] ~
None
for pattern like1, 2,
without brackets -
end_l (
MaybeLoc
)Location of the closing bracket
[1, ^a, 3 => foo,] ~
None
for pattern like1, 2,
without brackets -
expression_l (
Loc
)Location of the full expression
[1, ^a, 3 => foo,] ~~~~~~~~~~~~~~~~~~
Represents special global variables:
1. `` $` ``
2. `$&`
3. `$'`
4. `$+`
Fields:
-
name (
Str
)Name of the variable (
"$+"
for$+
) -
expression_l (
Loc
)Location of the full expression
$+ ~~
Represents compound statement (i.e. a multi-statement)
Basically all blocks of code are wrapped into `Begin` node (e.g. method/block body, rescue/ensure handler etc)
Fields:
-
statements (
Nodes
)A list of statements
-
begin_l (
MaybeLoc
)Begin of the block
(1; 2) ~
None
if the block of code is "implicit", likeif true; 1; 2; end
-
end_l (
MaybeLoc
)End of the block
(1; 2) ~
None
if the block of code is "implicit", likeif true; 1; 2; end
-
expression_l (
Loc
)Location of the full expression
(1; 2) ~~~~~~
Represents a Ruby block that is passed to a method (`proc { |foo| bar }`)
Fields:
-
call (
Node
)Method call that takes a block
Send("foo")
infoo {}
-
args (
MaybeNode
)A list of argument that block takes
vec![ Arg("a"), Optarg("b", Int("1")) ]
forproc { |a, b = 1| }
None
if the block takes no arguments -
body (
MaybeNode
)Block body,
None
if block has no body. -
begin_l (
Loc
)Location of the open brace
proc { } ~
-
end_l (
Loc
)Location of the closing brace
proc { } ~
-
expression_l (
Loc
)Location of the full expression
proc { } ~~~~~~~~
Represents a `&blk` argument in the method definition (but not in the method call, see `BlockPass`)
Fields:
-
name (
MaybeStr
)Name of the argument,
String("foo")
fordef m(&foo)
-
operator_l (
Loc
)Location of the
&
operatordef m(&foo); end ~
-
name_l (
MaybeLoc
)Location of the name
def m(&foo); end ~~~
-
expression_l (
Loc
)Location of the full expression
def m(&foo); end ~~~~
Represents a `&blk` argument of the method call (but not of the method definition, see `BlockArg`)
Fields:
-
value (
MaybeNode
)Value that is converted to a block
Int("1")
infoo(&1)
(yes, it's possible) -
operator_l (
Loc
)Location of the
&
operatorfoo(&blk) ~
-
expression_l (
Loc
)Location of the full expression
foo(&bar) ~~~~
Represents a `break` keyword (with optional argument)
Fields:
-
args (
Nodes
)A list of arguments
-
keyword_l (
Loc
)Location of the
break
keywordbreak :foo ~~~~~
-
expression_l (
Loc
)Location of the full expression
break(:foo) ~~~~~~~~~~~
Represents a `case` statement (for pattern matching see `CaseMatch` node)
Fields:
-
expr (
MaybeNode
)Expression given to
case
,Int("1")
forcase 1; end
None
for code likecase when pattern end
-
when_bodies (
Nodes
)A list of
When
nodes (each haspatterns
andbody
) -
else_body (
MaybeNode
)Body of the
else
branch,None
if there's noelse
branch -
keyword_l (
Loc
)Location of the
case
keywordcase 1; end ~~~~
-
else_l (
MaybeLoc
)Location of the
else
keywordcase 1; else; end ~~~~
None
if there's noelse
branch -
end_l (
Loc
)Location of the
end
keywordcase 1; end ~~~
-
expression_l (
Loc
)Location of the full expression
case 1; end ~~~~~~~~~~~
Represents a `case` statement used for pattern matching (for regular `case` see `Case` node)
Fields:
-
expr (
Node
)Expression given to
case
,Int("1")
forcase 1; in 1; end
None
for code likecase in pattern end
-
in_bodies (
Nodes
)A list of
InPattern
nodes (each haspattern
,guard
andbody
) -
else_body (
MaybeNode
)Body of the
else
branch,None
if there's noelse
branch -
keyword_l (
Loc
)Location of the
case
keywordcase 1; in 2; end ~~~~
-
else_l (
MaybeLoc
)Location of the
else
keywordcase 1; in 2; else; end ~~~~
None
if there's noelse
branch -
end_l (
Loc
)Location of the
end
keywordcase 1; in 2; end ~~~
-
expression_l (
Loc
)Location of the full expression
case 1; in 2; end ~~~~~~~~~~~~~~~~~
Represents a constant assignment (i.e. `A = 1`)
Fields:
-
scope (
MaybeNode
)Scope where the constant is defined:
Some(Const("A"))
forA::B = 1
None
if it's defined in the current scope (i.e.A = 1
)Some(Cbase)
if it's defined in the global scope (i.e.::A = 1
)
-
name (
Str
)Name of the constant,
String("A")
forA = 1
-
value (
MaybeNode
)Value that is assigned to a constant,
Int("1")
forA = 1
.Note:
None
if constant assignment is a part of the multi-assignment. In such casevalue
belongs toMasgn
node of the multi-assignment. -
double_colon_l (
MaybeLoc
)Location of the
::
operatorA::B = 1 ~~ ::A = 1 ~~
None
if the constant is defined in the current scope -
name_l (
Loc
)Location of the constant name
A::CONST = 1 ~~~~~
-
operator_l (
MaybeLoc
)Location of the
=
operatorA = 1 ~
None
if constant assignment is a part of the multi-assignment. In such case=
belongs to aMasgn
node -
expression_l (
Loc
)Location of the full expression
A = 1 ~~~~~
Represents leading `::` part of the constant access/assignment that is used to get/set on a global namespace.
Fields:
-
expression_l (
Loc
)Location of the full expression
::A ~~
Represents a class definition (using a `class` keyword, `Class.new` is just a method call)
Fields:
-
name (
Node
)Name of the class,
String("Foo")
forclass Foo; end
-
superclass (
MaybeNode
)Superclass. Can be an expression in cases like
class A < (obj.foo + 1); end
None
if no explicit superclass given (i.e.class Foo; end
) -
body (
MaybeNode
)Body of the method,
None
if there's no body. -
keyword_l (
Loc
)Location of the
class
keyword.class Foo; end ~~~~~
-
operator_l (
MaybeLoc
)Location of the
<
operatorclass A < B; end ~
None
if there's no explicit superclass given. -
end_l (
Loc
)Location of the
end
keyword.class Foo; end ~~~
-
expression_l (
Loc
)Location of the full expression
class Foo; end ~~~~~~~~~~~~~~
Represents a `Complex` literal (that returns an `Complex` number)
Fields:
-
value (
Str
)Value of the complex literal, returned as a
String
,String("1i")
for1i
-
operator_l (
MaybeLoc
)Location of the
-
(but not+
) operator.+
is a part of the literal:+1i
isString("+1i")
withoperator = None
-1i
isString("1i")
withoperator = String("-")
-1i ~
-
expression_l (
Loc
)Location of the full expression
-1i ~~~
Represents constant access (i.e. `Foo::Bar`)
Fields:
-
scope (
MaybeNode
)Scope where the constant is taken from:
Some(Const("A"))
forA::B
None
if it's taken from the current scope (i.e.A
)Some(Cbase)
if it's taken from the global scope (i.e.::A
)
-
name (
Str
)Name of the constant,
String("Foo")
forFoo
-
double_colon_l (
MaybeLoc
)Location of the
::
operator.None
if constant is taken from the current scope.A::B ~~
-
name_l (
Loc
)Location of the constant name
Foo::Bar ~~~
-
expression_l (
Loc
)Location of the full expression
Foo::Bar ~~~~~~~~
Const pattern used in pattern matching (e.g. `in A(1, 2)`)
Fields:
-
const (
Node
)Constant that is used,
Const("Foo")
forin For(42)
-
pattern (
Node
)Inner part of the constant pattern
ArrayPattern(vec![ Int("1") ])
forFoo(1)
-
begin_l (
Loc
)Location of the open parenthesis
case 1; in Foo(42); end ~
-
end_l (
Loc
)Location of the closing parenthesis
case 1; in Foo(42); end ~
-
expression_l (
Loc
)Location of the full expression
case 1; in Foo(42); end ~~~~~~~
Represents conditional method call using `&.` operator
Fields:
-
recv (
Node
)Receiver of the method call,
Int("1")
for1&.foo
-
method_name (
Str
)Name of the method,
String("foo")
for1&.foo
-
args (
Nodes
)List of arguments
foo&.bar(42) # and also setters like foo&.bar = 42
-
dot_l (
Loc
)Location of the
&.
operatorfoo&.bar ~~
-
selector_l (
MaybeLoc
)Location of the method name
foo&.bar(42) ~~~
None
in a very special case when method call is implicit (i.e.foo&.()
) -
begin_l (
MaybeLoc
)Location of the open parenthesis
foo&.bar(42) ~
None
if there are no parentheses -
end_l (
MaybeLoc
)Location of the closing parenthesis
foo&.bar(42) ~
None
if there are no parentheses -
operator_l (
MaybeLoc
)Location of the operator if
CSend
is a part of assignment likefoo&.bar = 1 ~
None
for a regular call. -
expression_l (
Loc
)Location of the full expression
foo&.bar(42) ~~~~~~~~~~~~
Represents access to class variable (i.e. `@@var`)
Fields:
-
name (
Str
)Name of the class variable,
String("@@foo")
for@@foo
-
expression_l (
Loc
)Location of the full expression
@@foo ~~~~~
Represents class variable assignment (i.e. `@@var = 42`)
Fields:
-
name (
Str
)Name of the class variable,
String("@@foo")
for@@foo = 1
-
value (
MaybeNode
)Value that is assigned to class variable,
Int("1")
for@@foo = 1
-
name_l (
Loc
)Location of the class variable name
@@foo = 1 ~~~~~
-
operator_l (
MaybeLoc
)Location of the
=
operator@@foo = 1 ~
-
expression_l (
Loc
)Location of the full expression
@@foo = 1 ~~~~~~~~~
Represents method definition using `def` keyword (not on a singleton, see `Defs` node).
Fields:
-
name (
Str
)Name of the method,
String("foo")
fordef foo; end
-
args (
MaybeNode
)Arguments of a method,
None
if there's no arguments.All information about parentheses around arguments is stored in this node.
-
body (
MaybeNode
)Body of a method,
None
if there's no body. -
keyword_l (
Loc
)Location of the
def
keyword.def foo; end ~~~
-
name_l (
Loc
)Location of the method name.
def foo; end ~~~
-
end_l (
MaybeLoc
)Location of the
end
keyword.def foo; end ~~~
None
for endless method definition -
assignment_l (
MaybeLoc
)Location of the
=
operator for endless method definitiondef m() = 1 ~
None
for regular method definition -
expression_l (
Loc
)Location of the full expression
def m(a); foo; end ~~~~~~~~~~~~~~~~~~
Represents a `defined?(foo)` expression
Fields:
-
value (
Node
)Value given to
defined?
-
keyword_l (
Loc
)Location of the
defined?
keyworddefined?(foo) ~~~~~~~~
-
begin_l (
MaybeLoc
)Location of the open parenthesis
defined?(foo) ~
None
if there are no parentheses -
end_l (
MaybeLoc
)Location of the closing parenthesis
defined?(foo) ~
None
if there are no parentheses -
expression_l (
Loc
)Location of the full expression
defined?(foo) ~~~~~~~~~~~~~
Represents a singleton method definition (i.e. `def self.foo; end`)
Fields:
-
definee (
Node
)Definee of a method definition,
Lvar("x")
fordef x.foo; end
-
name (
Str
)Name of the method,
String("foo")
fordef x.foo; end
-
args (
MaybeNode
)Arguments of a method,
None
if there's no arguments.All information about parentheses around arguments is stored in this node.
-
body (
MaybeNode
)Body of the method,
None
if there's no body. -
keyword_l (
Loc
)Location of the
def
keyworddef self.foo; end ~~~
-
operator_l (
Loc
)Location of the
.
def self.foo; end ~
-
name_l (
Loc
)Location of the method name
def self.foo; end ~~~
-
assignment_l (
MaybeLoc
)Location of the
=
operator for endless method definitiondef self.foo() = 42 ~
None
for regular method definition -
end_l (
MaybeLoc
)Location of the
end
keyworddef self.foo; end ~~~
None
for endless method definition -
expression_l (
Loc
)Location of the full expression
def self.foo; end ~~~~~~~~~~~~~~~~~
Represents a string with interpolation (i.e. `"#{foo}"`)
Fields:
-
parts (
Nodes
)A list of string parts (static literals and interpolated expressions)
-
begin_l (
MaybeLoc
)Location of the string begin
"#{foo}" ~ %Q{#{foo}} ~~~
-
end_l (
MaybeLoc
)Location of the string end
"#{foo}" ~ %Q{#{foo}} ~
-
expression_l (
Loc
)Location of the full expression
"#{foo}" ~~~~~~~~ %Q{#{foo}} ~~~~~~~~~~
Represents a symbol with interpolation (i.e. `:"#{foo}"`)
Fields:
-
parts (
Nodes
)A list of symbol parts (static literals and interpolated expressions)
-
begin_l (
MaybeLoc
)Location of the symbol begin
:"#{foo}" ~~
None
ifDsym
is a part of the interpolated symbol array:%I[#{bar}]
-
end_l (
MaybeLoc
)Location of the symbol begin
:"#{foo}" ~
None
ifDsym
is a part of the interpolated symbol array:%I[#{bar}]
-
expression_l (
Loc
)Location of the full expression
:"#{foo}" ~~~~~~~~~
Represents exclusive flip-flop (i.e. in `if foo...bar; end`)
Fields:
-
left (
MaybeNode
)Left part of the flip-flop.
None
if based on a range without begin (...bar
) -
right (
MaybeNode
)Right part of the flip-flop.
None
if based on a range without end (foo...
) -
operator_l (
Loc
)Location of the
...
operatorif foo...bar; end ~~~
-
expression_l (
Loc
)Location of the full expression
if foo...bar; end ~~~~~~~~~
Represents a special empty else that is a part of the pattern matching.
Usually empty else (e.g. part of the `if` statement) doesn't mean anything,
however in pattern matching it prevents raising a `NoPatternError`.
Throwing away this `else` may affect your code.
Fields:
-
expression_l (
Loc
)Location of the
else
keywordcase foo; in 1; else; end ~~~~
Represents a special `__ENCODING__` keyword
Fields:
-
expression_l (
Loc
)Location of the
__ENCODING__
keyword__ENCODING__ ~~~~~~~~~~~~
Represents a block of code with `ensure` (i.e. `begin; ensure; end`)
Fields:
-
body (
MaybeNode
)Block of code that is wrapped into
ensure
Note: that's the body of theensure
blockInt("1")
forbegin; 1; ensure; 2; end
-
ensure (
MaybeNode
)Body of the
ensure
blockInt("2")
forbegin; 1; ensure; 2; end
-
keyword_l (
Loc
)Location of the
ensure
keywordbegin; ensure; end ~~~~~~
-
expression_l (
Loc
)Location of the full expression
begin; 1; rescue; 2; else; 3; ensure; 4; end ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note: begin/end belong to
KwBegin
node.
Represents range literal with excluded `end` (i.e. `1...3`)
Fields:
-
left (
MaybeNode
)Begin of the range,
None
if range has no begin (i.e...42
) -
right (
MaybeNode
)End of the range,
None
if range has no end (i.e42...
) -
operator_l (
Loc
)Location of the
...
operator1...3 ~~~
-
expression_l (
Loc
)Location of the full expression
1...3 ~~~~~
Represents a `false` literal
Fields:
-
expression_l (
Loc
)Location of the
false
literalfalse ~~~~~
Represents a special `__FILE__` literal
Fields:
-
expression_l (
Loc
)Location of the
__FILE__
literal__FILE__ ~~~~~~~~
Represents a find pattern using in pattern matching (i.e. `in [*x, 1 => a, *y]`)
It's different from `ArrayPattern`/`ConstPattern` because it supports multiple wildcard pattern
Fields:
-
elements (
Nodes
)Inner part of the find pattern
-
begin_l (
MaybeLoc
)Location of the begin
case foo; in [*x, 1 => a, *y]; end ~
None
if there are no brackets/parentheses -
end_l (
MaybeLoc
)Location of the end
case foo; in [*x, 1 => a, *y]; end ~
None
if there are no brackets/parentheses -
expression_l (
Loc
)Location of the full expression
case foo; in [*x, 1 => a, *y]; end ~~~~~~~~~~~~~~~~
Represents a float literal (i.e. `42.5`)
Fields:
-
value (
Str
)String value of the literal,
String("42.5")
for42.5
-
operator_l (
MaybeLoc
)Location of unary
-
(but not+
)-42.5 ~
-
expression_l (
Loc
)Location of the full expression
-42.5 ~~~~~
Represents a `for` loop
Fields:
-
iterator (
Node
)Variable that is used in loop,
Lvasgn("a")
infor a in b; end
-
iteratee (
Node
)Collection that is for iteration.
Lvar("b")
infor a in b; end
-
body (
MaybeNode
)Body of the loop.
None
if there's no body -
keyword_l (
Loc
)Location of the
for
keywordfor a in b; end ~~~
-
operator_l (
Loc
)Location of the
in
keywordfor a in b; end ~~
-
begin_l (
Loc
)Location of the
do
keywordfor a in b do; end ~~
Note: this
do
is optional, and sobegin_l
can beNone
. -
end_l (
Loc
)Location of the
end
keywordfor a in b; end ~~~
-
expression_l (
Loc
)Location of the full expression
for a in b; end ~~~~~~~~~~~~~~~
Represents a special `...` argument that forwards positional/keyword/block arguments.
Fields:
-
expression_l (
Loc
)Location of the
...
def m(...); end ~~~
Represents a `...` operator that contains forwarded argument (see `ForwardArg`)
Fields:
-
expression_l (
Loc
)Location of the
...
def m(...); foo(...); end ~~~
Represents access to global variable (i.e. `$foo`)
Fields:
-
name (
Str
)Name of the global variable,
String("$foo")
for$foo
-
expression_l (
Loc
)Location of the full expression
$foo ~~~~
Represents global variable assignment (i.e. `$foo = 42`)
Fields:
-
name (
Str
)Name of the global variable,
String("$foo")
for$foo
-
value (
MaybeNode
)Value that is assigned to global variable,
Int("42")
for$foo = 42
None
if global variable assignment is a part of the multi-assignment. In such casevalue
is a part of theMasgn
node. -
name_l (
Loc
)Location of the global variable name
$foo = 42 ~~~~
-
operator_l (
MaybeLoc
)Location of the
=
operator$foo = 42 ~
None
if global variable assignment is a part of the multi-assignment. In such case=
operator belongs to theMasgn
node. -
expression_l (
Loc
)Location of the full expression
$foo = 42 ~~~~~~~~~
Represents a hash literal (i.e. `{ foo: 42 }`)
Fields:
-
pairs (
Nodes
)A list of key-value pairs
-
begin_l (
MaybeLoc
)Location of the open parenthesis
{ a: 1 } ~
None
if hash literal is implicit, e.g.foo(key: "value")
-
end_l (
MaybeLoc
)Location of the closing parenthesis
{ a: 1 } ~
None
if hash literal is implicit, e.g.foo(key: "value")
-
expression_l (
Loc
)Location of the full expression
{ a: 1 } ~~~~~~~~
Represents a hash pattern used in pattern matching (i.e. `in { a: 1 }`)
Fields:
-
elements (
Nodes
)A list of inner patterns
-
begin_l (
MaybeLoc
)Location of the open parenthesis
case foo; in { a: 1 }; end ~
None
if there are no parentheses -
end_l (
MaybeLoc
)Location of the open parenthesis
case foo; in { a: 1 }; end ~
None
if there are no parentheses -
expression_l (
Loc
)Location of the full expression
case foo; in { a: 1 }; end ~~~~~~~~
Represents a here-document literal (both with and without interpolation)
It's similar to `Dstr` in terms of abstract syntax tree, but has different source maps.
Fields:
-
parts (
Nodes
)A list of string parts (static literals and interpolated expressions)
-
heredoc_body_l (
Loc
)Location of the here-document body
<<-HERE\n a\n #{42}\nHERE ~~~~~~~~~~~~~~~
-
heredoc_end_l (
Loc
)Location of the here-document end
<<-HERE\n a\n #{42}\nHERE ~~~~
-
expression_l (
Loc
)Location of the here-document identifier
<<-HERE\n a\n #{42}\nHERE ~~~~~~~
Note: This is the only node (with
XHeredoc
) that hasexpression_l
smaller that all other sub-locations merged. The reason for that is that it's possible to add more code after here-document ID:<<-HERE + "rest" content HERE
Represents an `if` statement (i.e. `if foo; bar; else; baz; end`)
Fields:
-
cond (
Node
)Condition given to the
if
statement,Lvar("a")
forif a; b; else; c; end
-
if_true (
MaybeNode
)True-branch of the
if
statement,Lvar("b")
forif a; b; else; c; end
-
if_false (
MaybeNode
)False-branch of the
if
statement,Lvar("c")
forif a; b; else; c; end
-
keyword_l (
Loc
)Location of the
if
keywordif foo; end ~~
-
begin_l (
Loc
)Location of the
then
keywordif foo then; end ~~~~
None
ifthen
keyword is omitted -
else_l (
MaybeLoc
)Location of the
else
keywordif foo; else; end ~~~~
None
if there's noelse
branch -
end_l (
MaybeLoc
)Location of the
end
keywordif foo; end ~~~
-
expression_l (
Loc
)Location of the full expression
if a then; b; else; c end ~~~~~~~~~~~~~~~~~~~~~~~~~
Represents an `if` guard used in pattern matching (i.e. `case foo; in pattern if guard; end`)
Fields:
-
cond (
Node
)Condition of the guard,
Lvar("foo")
inin pattern if guard
-
keyword_l (
Loc
)Location of the
if
keywordcase foo; in pattern if cond; end ~~
-
expression_l (
Loc
)Location of the full expression
case foo; in pattern if cond; end ~~~~~~~
Represents inclusive flip-flop (i.e. in `if foo..bar; end`)
Fields:
-
left (
MaybeNode
)Left part of the flip-flop.
None
if based on a range without begin (..bar
) -
right (
MaybeNode
)Right part of the flip-flop.
None
if based on a range without end (foo..
) -
operator_l (
Loc
)Location of the
..
operatorif foo..bar; end ~~
-
expression_l (
Loc
)Location of the full expression
if foo..bar; end ~~~~~~~~
Represents an `if`/`unless` modifier (i.e. `stmt if cond`)
Fields:
-
cond (
Node
)Condition of the modifier
-
if_true (
MaybeNode
)True-branch of the modifier.
Always set for
if
modifier. AlwaysNone
forunless
modifier. -
if_false (
MaybeNode
)False-branch of the modifier.
Always set for
unless
modifier. AlwaysNone
forif
modifier. -
keyword_l (
Loc
)Location of the
if
/unless
keywordstmt if cond ~~ stmt unless cond ~~~~~~
-
expression_l (
Loc
)Location of the full expression
stmt if cond ~~~~~~~~~~~~ stmt unless cond ~~~~~~~~~~~~~~~~
Represents ternary `if` statement (i.e. `cond ? if_true : if_false`)
Fields:
-
cond (
Node
)Condition of the
if
statement -
if_true (
Node
)True-branch
-
if_false (
Node
)True-branch
-
question_l (
Loc
)Location of the
?
operatorcond ? if_true : if_false ~
-
colon_l (
Loc
)Location of the
:
operatorcond ? if_true : if_false ~
-
expression_l (
Loc
)Location of the full expression
cond ? if_true : if_false ~~~~~~~~~~~~~~~~~~~~~~~~~
Represents indexing operation (i.e. `foo[1,2,3]`)
Fields:
-
recv (
Node
)Receiver of indexing
-
indexes (
Nodes
)A list of indexes
-
begin_l (
Loc
)Location of open bracket
foo[1, 2, 3] ~
-
end_l (
Loc
)Location of closing bracket
foo[1, 2, 3] ~
-
expression_l (
Loc
)Location of the full expression
foo[1, 2, 3] ~~~~~~~~~~~~
Represents assignment using indexing operation (i.e. `foo[1, 2, 3] = bar`)
Fields:
-
recv (
Node
)Receiver of the indexing
-
indexes (
Nodes
)A list of indexes
-
value (
MaybeNode
)Value that is assigned
None
if assignment is a part of the multi-assignment. In such casevalue
belongs toMasgn
node. -
begin_l (
Loc
)Location of open bracket
foo[1, 2, 3] = bar ~
-
end_l (
Loc
)Location of closing bracket
foo[1, 2, 3] = bar ~
-
operator_l (
MaybeLoc
)Location of the
=
operatorfoo[1, 2, 3] = bar ~
None
if assignment is a part of the multi-assignment. In such case operator=
belongs toMasgn
node. -
expression_l (
Loc
)Location of the full expression
foo[1, 2, 3] = bar ~~~~~~~~~~~~~~~~~~
Represents an `in pattern` branch of the pattern matching
Fields:
-
pattern (
Node
)Value that is used for matching
-
guard (
MaybeNode
)Guard that is used for matching
Optional, so can be
None
-
body (
MaybeNode
)Body of the branch that is invoked if value matches pattern
-
keyword_l (
Loc
)Location of the
in
keywordcase value; in pattern; end ~~
-
begin_l (
Loc
)Location of the
then
keywordcase value; in pattern then; end ~~~~
-
expression_l (
Loc
)Location of the full expression
case value; in pattern then; 42; end ~~~~~~~~~~~~~~~~~~~
Represents an integer literal (i.e. `42`)
Fields:
-
value (
Str
)String value of the literal,
String("42")
for42
-
operator_l (
MaybeLoc
)Location of unary
-
(but not+
)-42 ~
-
expression_l (
Loc
)Location of the full expression
-42 ~~~
Represents inclusive range (i.e. `2..4`)
Fields:
-
left (
MaybeNode
)Begin of the range,
None
if range has nobegin
(i.e...4
) -
right (
MaybeNode
)End of the range,
None
if range has noend
(i.e.2..
) -
operator_l (
Loc
)Location of the
..
operator2..4 ~~
-
expression_l (
Loc
)Location of the full expression
2..4 ~~~~
Represents access to instance variable (i.e. `@foo`)
Fields:
-
name (
Str
)Name of the instance variable,
String("@foo")
in@foo
-
expression_l (
Loc
)Location of the full expression
@foo ~~~~
Represents instance variable assignment (i.e `@foo = 42`)
Fields:
-
name (
Str
)Name of the instance variable,
String("@foo")
in@foo = 42
-
value (
MaybeNode
)Value that is assigned to instance variable.
None
if instance variable assignment is a part of the multi-assignment. In such casevalue
is a part of theMasgn
node. -
name_l (
Loc
)Location of the instance variable name.
@foo = 1 ~~~~
-
operator_l (
MaybeLoc
)Location of the
=
operator.@foo = 1 ~
None
if instance variable assignment is a part of the multi-assignment. In such casevalue
is a part of theMasgn
node. -
expression_l (
Loc
)Location of the full expression
@foo = 42 ~~~~~~~~~
Represents required keyword argument (i.e. `foo` in `def m(foo:); end`)
Fields:
-
name (
Str
)Name of the keyword argument
-
name_l (
Loc
)Location of the name
def foo(bar:); end ~~~
-
expression_l (
Loc
)Location of the full expression
def foo(bar:); end ~~~~
Represents kwargs that are given to a method call, super or yield (i.e. `foo(bar: 1)`)
Fields:
-
pairs (
Nodes
)A list of key-value pairs
-
begin_l (
MaybeLoc
)Always None
-
end_l (
MaybeLoc
)Always None
-
expression_l (
Loc
)Location of the full expression
foo(bar: 1) ~~~~~~
Represents an explicit `begin; end` block.
The reason why it's different is that
```text
begin; foo; end while cond
```
is a post-while loop (same with post-until loop)
Fields:
-
statements (
Nodes
)A list of statements
-
begin_l (
MaybeLoc
)Location of the
begin
keywordbegin; foo; end ~~~~~
-
end_l (
MaybeLoc
)Location of the
end
keywordbegin; foo; end ~~~
-
expression_l (
Loc
)Location of the full expression
begin; foo; bar ~~~~~~~~~~~~~~~
Represents an special argument that rejects all keyword arguments (i.e. `def m(**nil); end`)
Fields:
-
name_l (
Loc
)Location of the
nil
def m(**nil); end ~~~
-
expression_l (
Loc
)Location of the
nil
def m(**nil); end ~~~~~
Represents an optional keyword argument (i.e. `foo` in `def m(foo: 42); end`)
Fields:
-
name (
Str
)Name of the optional keyword argument
-
default (
Node
)Default value of the optional keyword argument
-
name_l (
Loc
)Location of the argument name
def m(foo: 1); end ~~~
-
expression_l (
Loc
)Location of the argument name
def m(foo: 1); end ~~~~~~
Represents a keyword rest argument (i.e. `foo` in `def m(**foo); end`)
Fields:
-
name (
MaybeStr
)Name of the keyword rest argument,
String("foo")
indef m(**foo); end
.None
if argument has no name (def m(**); end
) -
operator_l (
Loc
)Location of the
**
operatordef m(**foo); end ~~
-
name_l (
MaybeLoc
)Location of the argument name
def m(**foo); end ~~~
None
if argument has no name (def m(**); end
) -
expression_l (
Loc
)Location of the full expression
def m(**foo); end ~~~~~
Represents a keyword arguments splat (i.e. `**bar` in a call like `foo(**bar)`)
Fields:
-
value (
Node
)Value that is converted into a
Hash
using**
-
operator_l (
Loc
)Location of the
**
operatorfoo(**bar) ~~
-
expression_l (
Loc
)Location of the full expression
foo(**bar) ~~~~~
Represents a lambda call using `->` (i.e. `-> {}`)
Note that `Lambda` is a part of the `Block`, not other way around.
Fields:
-
expression_l (
Loc
)Location of the
->
-> {} ~~
Represents a special `__LINE__` literal
Fields:
-
expression_l (
Loc
)Location of the
__LINE__
literal__LINE__ ~~~~~~~~
Represents access to a local variable (i.e. `foo`)
Parser knows that it's a local variable because:
1. there was an assignment to this variable **before** accessing it
2. it's an argument of the current method / block
3. it's been implicitly declared by `MatchWithLvasgn` node
Otherwise it's a method call (see `Send`)
Fields:
-
name (
Str
)Name of the local variable
-
expression_l (
Loc
)Location of the local variable
foo ~~~
Represents local variable assignment (i.e. `foo = 42`)
Fields:
-
name (
Str
)Name of the local variable
-
value (
MaybeNode
)Value that is assigned to a local variable
-
name_l (
Loc
)Location of the local variable name
foo = 42 ~~~
-
operator_l (
MaybeLoc
)Location of the
=
operatorfoo = 42 ~
None
if local variable assignment is a part of the multi-assignment. In such casevalue
is a part of theMasgn
node. -
expression_l (
Loc
)Location of the full expression
foo = 42 ~~~~~~~~
Represents mass-assignment (i.e. `foo, bar = 1, 2`)
Fields:
-
lhs (
Node
)Left hand statement of the assignment
-
rhs (
Node
)Left hand statement of the assignment
-
operator_l (
Loc
)Location of the
=
operatorfoo, bar = 1, 2 ~
-
expression_l (
Loc
)Location of the full expression
foo, bar = 1, 2 ~~~~~~~~~~~~~~~
Represents pattern matching using one of the given patterns (i.e. `foo in 1 | 2`)
Fields:
-
lhs (
Node
)Left pattern
-
rhs (
Node
)Right pattern
-
operator_l (
Loc
)Location of the
|
operatorfoo in 1 | 2 ~
-
expression_l (
Loc
)Location of the full expression
foo in 1 | 2 ~~~~~
Represents matching with renaming into specified local variable (i.e. `case 1; in Integer => a; end`)
Fields:
-
value (
Node
)Pattern that is used for matching
-
as (
Node
)Variable that is assigned if matched (see
MatchVar
node) -
operator_l (
Loc
)Location of the
=>
operatorcase 1; in Integer => a; end ~~
-
expression_l (
Loc
)Location of the full expression
case 1; in Integer => a; end ~~~~~~~~~~~~
Represents implicit matching using `if /regex/`
```text
if /.*/
puts 'true'
else
puts 'false'
end
```
Prints "false".
Under the hood this construction matches regex against `$_`, so the following works:
```text
$_ = 'match_me'
if /match_me/
puts 'true'
else
puts 'false'
end
```
this code prints "true".
Fields:
-
re (
Node
)Given regex
-
expression_l (
Loc
)Location of the regex
if /re/; end ~~~~
Technically this location is redundant, but keeping it is the only way to have the same interface for all nodes.
Represents empty hash pattern that is used in pattern matching (i.e. `in **nil`)
Fields:
-
operator_l (
Loc
)Location of the
**
operatorin **nil ~~
-
name_l (
Loc
)Location of the name
in **nil ~~~
-
expression_l (
Loc
)Location of the full expression
in **nil ~~~~~
Represents a one-line pattern matching that can throw an error (i.e. `foo => pattern`)
Fields:
-
value (
Node
)Value that is used for matching
-
pattern (
Node
)Pattern that is used for matching
-
operator_l (
Loc
)Location of the
=>
operatorfoo => pattern ~~
-
expression_l (
Loc
)Location of the full expression
foo => pattern ~~~~~~~~~~~~~~
Represents a one-line pattern matching that never throws but returns true/false (i.e. `foo in pattern`)
Fields:
-
value (
Node
)Value that is used for matching
-
pattern (
Node
)Pattern that is used for matching
-
operator_l (
Loc
)Location of the
in
operatorfoo in pattern ~~
-
expression_l (
Loc
)Location of the full expression
foo in pattern ~~~~~~~~~~~~~~
Represents a wildcard pattern used in pattern matching (i.e. `in *foo`)
Fields:
-
name (
MaybeNode
)Name of the variable name
None
if there's no name (i.e.in *
) -
operator_l (
Loc
)Location of the
*
operatorcase foo; in *bar; end ~
-
expression_l (
Loc
)Location of the
*
operatorcase foo; in *bar; end ~~~~
Represents matching with assignment into a local variable (i.e. `pattern => var`)
Fields:
-
name (
Str
)Name of the variable that is assigned if matching succeeds
-
name_l (
Loc
)Location of the name
case foo; in pattern => bar; end ~~~
Note it can also be produced by a hash pattern
case foo; in { a: }; end ~
-
expression_l (
Loc
)Location of the full expression
case foo; in pattern => bar; end ~~~
Note it can also be produced by a hash pattern
case foo; in { a: }; end ~~
Represents matching a regex that produces local variables (i.e. `/(?<match>bar)/ =~ 'bar'`)
Each named group in regex declares a local variable.
Fields:
-
re (
Node
)Regex that is used for matching
-
value (
Node
)Value that is used for matching
-
operator_l (
Loc
)Location of the
=~
operatir/(?<match>bar)/ =~ 'bar' ~~
-
expression_l (
Loc
)Location of the full expression
/(?<match>bar)/ =~ 'bar' ~~~~~~~~~~~~~~~~~~~~~~~~
Represents left hand statement of the mass-assignment (i.e. `foo, bar` in `foo, bar = 1, 2`)
Fields:
-
items (
Nodes
)A list of items that are assigned
-
begin_l (
MaybeLoc
)Location of the open parenthesis
(a, b) = 1, 2 ~
None
if there are no parentheses -
end_l (
MaybeLoc
)Location of the closing parenthesis
(a, b) = 1, 2 ~
None
if there are no parentheses -
expression_l (
Loc
)Location of the full expression
(a, b) = 1, 2 ~~~~~~
Represents module declaration using `module` keyword
Fields:
-
name (
Node
)Name of the module
-
body (
MaybeNode
)Body of the module
None
if module has no body -
keyword_l (
Loc
)Location of the
module
keywordmodule M; end ~~~~~~
-
end_l (
Loc
)Location of the
end
keywordmodule M; end ~~~
-
expression_l (
Loc
)Location of the full expression
module M; end ~~~~~~~~~~~~~
Represents `next` keyword
Fields:
-
args (
Nodes
)Arguments given to
next
-
keyword_l (
Loc
)Location of the
next
keywordnext 42 ~~~~
-
expression_l (
Loc
)Location of the full expression
next(42) ~~~~~~~~
Represents `nil` literal
Fields:
-
expression_l (
Loc
)Location of the
nil
keywordnil ~~~
Represents numeric global variable (e.g. `$1`)
Fields:
-
name (
RawStr
)Name of the variable,
String("1")
for$1
-
expression_l (
Loc
)Location of the full expression
$1 ~~
Represents a block that takes numbered parameters (i.e. `proc { _1 }`)
Fields:
-
call (
Node
)Method call that takes a block
-
numargs (
U8
)Number of parameters that block takes
-
body (
Node
)Block body
-
begin_l (
Loc
)Location of the open brace
proc { _1 } ~
-
end_l (
Loc
)Location of the closing brace
proc { _1 } ~
-
expression_l (
Loc
)Location of the open brace
proc { _1 } ~~~~~~~~~~~
Represents an operation with assignment (e.g. `a += 1`)
Fields:
-
recv (
Node
)Left hand statement of the assignment
-
operator (
Str
)Operator, can be one of:
+=
-=
*=
/=
|=
&=
>>=
<<=
%=
^=
**=
-
value (
Node
)Right hand statement of the assignment
-
operator_l (
Loc
)Location of the operator
a.b <<= c ~~~
-
expression_l (
Loc
)Location of the operator
a.b <<= c ~~~~~~~~~
Represents optional positional argument (i.e. `foo` in `m(foo = 1)`)
Fields:
-
name (
Str
)Name of the argument
-
default (
Node
)Default value of the argument
-
name_l (
Loc
)Location of the argument name
def m(foo = 1); end ~~~
-
operator_l (
Loc
)Location of the
=
operatordef m(foo = 1); end ~
-
expression_l (
Loc
)Location of the full expression
def m(foo = 1); end ~~~~~~~
Represents `foo || bar` (or `foo or bar`) statement.
Fields:
-
lhs (
Node
)Left hand statement
-
rhs (
Node
)Right hand statement
-
operator_l (
Loc
)Location of the
||
/or
operatorfoo || bar ~~
-
expression_l (
Loc
)Location of the full expression
foo || bar ~~~~~~~~~~
Represents `lhs ||= rhs` assignment
Fields:
-
recv (
Node
)Left hand statement
-
value (
Node
)Right hand statement
-
operator_l (
Loc
)Location of the
||=
operatorfoo ||= bar ~~~
-
expression_l (
Loc
)Location of the full expression
foo ||= bar ~~~~~~~~~~~
Represents a key/value pair (e.g. a part of the `Hash` node)
Fields:
-
key (
Node
)Key of the pair
-
value (
Node
)Value of the pair
-
operator_l (
Loc
)Location of the
:
or=>
operator{ foo: bar } ~ { :foo => bar } ~~
-
expression_l (
Loc
)Location of the full expression
{ foo: bar } ~~~~~~~~ { :foo => bar } ~~~~~~~~~~~
Represents a pattern based on a "pinned" variable (e.g. `^foo`)
Fields:
-
var (
Node
)Variable that is pinned
-
selector_l (
Loc
)Location of the
^
operatorcase foo; in ^bar; end ~
-
expression_l (
Loc
)Location of the full expression
case foo; in ^bar; end ~~~~
Represents `END { .. }` statement
Fields:
-
body (
MaybeNode
)Body of the block
-
keyword_l (
Loc
)Location of the
END
keywordEND { 42 } ~~~
-
begin_l (
Loc
)Location of the open parenthesis
END { 42 } ~
-
end_l (
Loc
)Location of the closing parenthesis
END { 42 } ~
-
expression_l (
Loc
)Location of the full expression
END { 42 } ~~~~~~~~~~
Represents `BEGIN { ... }` statement
Fields:
-
body (
MaybeNode
)Body of the block
-
keyword_l (
Loc
)Location of the
BEGIN
keywordBEGIN { 42 } ~~~~~
-
begin_l (
Loc
)Location of the open parenthesis
BEGIN { 42 } ~
-
end_l (
Loc
)Location of the closing parenthesis
BEGIN { 42 } ~
-
expression_l (
Loc
)Location of the full expression
BEGIN { 42 } ~~~~~~~~~~~~
Represents a sole block argument (e.g. `|foo|`)
Block that takes a single array argument automatically expands it.
Adding trailing comma after block argument disables this behavior (and then the only argument is emitted as `Arg`).
Fields:
-
args (
Nodes
)Parts of the sole block argument.
proc { |(a, b)| }
also counts as a sole argument, so this list may contain:- A single
Arg
node (forproc { |a| }
case) - Multiple
Arg
nodes (forproc { |(a, b, c)| }
case)
- A single
-
begin_l (
MaybeLoc
)Location of the open parenthesis
proc { |(foo, bar)| } ~
None
if there's only one argument -
end_l (
MaybeLoc
)Location of the open parenthesis
proc { |(foo, bar)| } ~
None
if there's only one argument -
expression_l (
Loc
)Location of the full expression
proc { |(foo, bar)| } ~~~~~~~~~~
Represents rational literal (e.g. `1r`)
Fields:
-
value (
Str
)String value of the literal,
String("1r")
for1r
-
operator_l (
MaybeLoc
)Location of the unary
-
(but not+
)-1r ~
-
expression_l (
Loc
)Location of the full expression
-1r ~~~
Represents `redo` keyword
Fields:
-
expression_l (
Loc
)Location of the full expression
redo ~~~~
Represents regex literal (e.g. `/foo/`)
Fields:
-
parts (
Nodes
)A list of static and dynamic regex parts
-
options (
RegexpOptions
)Regex options.
None
if regex has no explicit flags -
begin_l (
Loc
)Location of the regex begin
/foo/ ~ %r{foo} ~~
-
end_l (
Loc
)Location of the regex end
/foo/ ~ %r{foo} ~
-
expression_l (
Loc
)Location of the full expression
/foo/mix ~~~~~~~~
Represents flags of the regex literal (i.e. `mix` for `/foo/mix`)
Fields:
-
options (
Chars
)A list of flags
-
expression_l (
Loc
)Location of the full expression
/foo/mix ~~~
Represents a `rescue` block
Fields:
-
body (
MaybeNode
)Body of the block that is wrapped into
rescue
(i.e. the part that may throw an error) -
rescue_bodies (
Nodes
)A list of
rescue
handlers (seeRescueBody
node) -
else (
MaybeNode
)Else branch.
None
if there's noelse
branch -
else_l (
MaybeLoc
)Location of the
else
keywordbegin; 1; rescue StandardError => e; 2; else; 3; end ~~~~
None
if there's noelse
branch -
expression_l (
Loc
)Location of the full expression
begin; 1; rescue StandardError => e; 2; else; 3; end ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note:
begin/end
keywords belong toKwBegin
node
Represents a single `rescue` handler (i.e. `rescue E => e ...`)
Fields:
-
exc_list (
MaybeNode
)A list of exception classes
None
if no classes specified (i.e.rescue => e; ...
or justrescue; ...
) -
exc_var (
MaybeNode
)Variable that captures exception
None
if no variable specified (i.e.rescue E; ...
or justrescue; ...
) -
body (
MaybeNode
)Body of the handler
-
keyword_l (
Loc
)Location of the
rescue
keywordbegin; 1; rescue E => e; 2; end ~~~~~~
-
assoc_l (
MaybeLoc
)Location of the
=>
operatorbegin; 1; rescue E => e; 2; end ~~
None
if exception is not captured. -
begin_l (
MaybeLoc
)Location of the
then
keywordbegin; 1; rescue E => e then; 2; end ~~~~
then
is optional, sobegin_l
can beNone
-
expression_l (
Loc
)Location of the full expression
begin; 1; rescue E => e then; 2; end ~~~~~~~~~~~~~~~~~~~~~
Represents positional rest argument (i.e. `*foo` in `def m(*foo); end`)
Fields:
-
name (
MaybeStr
)Name of the argument.
None
if argument has no name (i.e.def m(*); end
) -
operator_l (
Loc
)Location of the
*
operatordef m(*foo); end ~
-
name_l (
MaybeLoc
)Location of the argument name
def m(*foo); end ~~~
-
expression_l (
Loc
)Location of the full expression
def m(*foo); end ~~~~
Represents `retry` keyword
Fields:
-
expression_l (
Loc
)Location of the
retry
keywordretry ~~~~~
Represents `return` keyword
Fields:
-
args (
Nodes
)A list of values that is returned
-
keyword_l (
Loc
)Location of the
return
keywordreturn 1, 2 ~~~~~~
-
expression_l (
Loc
)Location of the full expression
return 1, 2 ~~~~~~~~~~~
Represents opening a singleton class (i.e. `class << foo; ... end;`)
Fields:
-
expr (
Node
)Expression that is used to get a singleton class
Lvar("foo")
forclass << foo; end
-
body (
MaybeNode
)Body of the block
-
keyword_l (
Loc
)Location of the
class
keywordclass << foo; end ~~~~~
-
operator_l (
Loc
)Location of the
<<
operatorclass << foo; end ~~
-
end_l (
Loc
)Location of the
end
keywordclass << foo; end ~~~
-
expression_l (
Loc
)Location of the full expression
class << foo; end ~~~~~~~~~~~~~~~~~
Represents `self` keyword
Fields:
-
expression_l (
Loc
)Location of the
self
keywordself ~~~~
Represents a method call (e.g. `foo.bar(42)`)
Fields:
-
recv (
MaybeNode
)Receiver of the method call
None
for implicit method call (e.g.foo(42)
) -
method_name (
Str
)Name of the method that is called
-
args (
Nodes
)A list of arguments
-
dot_l (
MaybeLoc
)Location of the
.
operatorfoo.bar(42) ~
None
for implicit method call (e.g.foo(42)
) -
selector_l (
MaybeLoc
)Location of the method name
foo.bar(42) ~~~
None
in a very special case when method call is implicit (i.e.foo.(42)
) -
begin_l (
MaybeLoc
)Location of open parenthesis
foo(42) ~
None
if there are no parentheses -
end_l (
MaybeLoc
)Location of closing parenthesis
foo(42) ~
None
if there are no parentheses -
operator_l (
MaybeLoc
)Location of the operator if method is a setter
foo.bar = 42 ~
None
otherwise -
expression_l (
Loc
)Location of the full expression
foo.bar(42) ~~~~~~~~~~~
Represents a special block argument that "shadows" outer variable (i.e. `|;foo|`)
Fields:
-
name (
Str
)Name of the argument
-
expression_l (
Loc
)Location of the argument
proc { |;foo|} ~~~
Represents an arguments splat (i.e. `*bar` in a call like `foo(*bar)`)
Fields:
-
value (
MaybeNode
)Value that is converted to array
-
operator_l (
Loc
)Location of the
*
operatorfoo(*bar) ~
-
expression_l (
Loc
)Location of the full expression
foo(*bar) ~~~~
Represents a plain non-interpolated string literal (e.g. `"foo"`)
Fields:
-
value (
StringValue
)Value of the string literal
Note that it's a
StringValue
, not aString
. The reason is that you can get UTF-8 incompatible strings from a valid UTF-8 source using escape sequences like"\xFF"
These "", "x", "F", "F" chars are valid separately, but together they construct a char with code = 255 that is invalid for UTF-8.
You can use
to_string_lossy
orto_string
methods to get a raw string value. -
begin_l (
MaybeLoc
)Location of the string begin
"foo" ~
None
if string literal is a part of the words array (like%w[foo bar baz]
) -
end_l (
MaybeLoc
)Location of the string begin
"foo" ~
None
if string literal is a part of the words array (like%w[foo bar baz]
) -
expression_l (
Loc
)Location of the full expression
"foo" ~~~~~
Represents a `super` keyword
Fields:
-
args (
Nodes
)A list of arguments given to
super
-
keyword_l (
Loc
)Location of the
super
keywordsuper(1, 2) ~~~~~
-
begin_l (
MaybeLoc
)Location of the open parenthesis
super(1, 2) ~
None
if there are no parentheses -
end_l (
MaybeLoc
)Location of the closing parenthesis
super(1, 2) ~
None
if there are no parentheses -
expression_l (
Loc
)Location of the full expression
super(1, 2) ~~~~~~~~~~~
Represents a plain symbol literal (i.e. `:foo`)
Note that `:` in `{ foo: bar }` belongs to a `pair` node.
Fields:
-
name (
StringValue
)Value of the symbol literal
Note that it's a
StringValue
, not aString
. The reason is that you can get UTF-8 incompatible strings from a valid UTF-8 source using escape sequences like"\xFF"
These "", "x", "F", "F" chars are valid separately, but together they construct a char with code = 255 that is invalid for UTF-8.
You can use
to_string_lossy
orto_string
methods to get a raw symbol value. -
begin_l (
MaybeLoc
)Location of the symbol begin
:foo ~
None
if symbol is a label ({ foo: 1 }
) or a part of the symbols array (%i[foo bar baz]
) -
end_l (
MaybeLoc
)Location of the symbol end
{ 'foo': 1 } ~
None
if symbol is not a string label (:foo
) or a part of the symbols array (%i[foo bar baz]
) -
expression_l (
Loc
)Location of the full expression
:foo ~~~~ { foo: 1 } ~~~~ %i[foo] ~~~
Represents a `true` literal
Fields:
-
expression_l (
Loc
)Location of the
true
keywordtrue ~~~~
Represents an `undef` keyword (e.g. `undef foo, :bar`)
Fields:
-
names (
Nodes
)A list of names to
undef
-
keyword_l (
Loc
)Location the
undef
keywordundef foo, :bar ~~~~~
-
expression_l (
Loc
)Location of the full expression
undef :foo, bar ~~~~~~~~~~~~~~~
Represents an `unless` guard used in pattern matching (i.e. `in pattern unless guard`)
Fields:
-
cond (
Node
)Condition of the guard,
Lvar("foo")
inin pattern unless guard
-
keyword_l (
Loc
)Location of the
unless
keywordcase foo; in pattern unless cond; end ~~~~~~
-
expression_l (
Loc
)Location of the full expression
case foo; in pattern unless cond; end ~~~~~~~~~~~
Represents `until` loop
Fields:
-
cond (
Node
)Condition of the loop
-
body (
MaybeNode
)Body of the loop.
None
if body is empty -
keyword_l (
Loc
)Location of the
until
keyworduntil cond do; foo; end ~~~~~
-
begin_l (
MaybeLoc
)Location of the
do
keyworduntil cond do; foo; end ~~
do
is optional, and sobegin_l
can beNone
-
end_l (
MaybeLoc
)Location of the
end
keyworduntil cond do; foo; end ~~~
None
if loop is a modifier (i.e.foo until bar
) -
expression_l (
Loc
)Location of the full expression
until cond do; foo; end ~~~~~~~~~~~~~~~~~~~~~~~ foo until bar ~~~~~~~~~~~~~
Represents a post-until loop
```text
begin
foo
end until bar
```
Fields:
-
cond (
Node
)Condition of the loop
-
body (
Node
)Body of the loop
-
keyword_l (
Loc
)Location of the
until
keywordbegin; foo; end until bar ~~~~~
-
expression_l (
Loc
)Location of the
until
keywordbegin; foo; end until bar ~~~~~~~~~~~~~~~~~~~~~~~~~
Represents a branch of the `case` statement (i.e. `when foo`)
Fields:
-
patterns (
Nodes
)A list of values to compare/match against
-
body (
MaybeNode
)Body of the
when
branch -
keyword_l (
Loc
)Location of the
when
keywordcase foo; when bar; end ~~~~
-
begin_l (
Loc
)Location of the
then
keywordcase foo; when bar then baz; end ~~~~
then
is optional, and sobegin_l
can beNone
-
expression_l (
Loc
)Location of the full expression
case foo; when bar then baz; end ~~~~~~~~~~~~~~~~~
Represents `while` loop
Fields:
-
cond (
Node
)Condition of the loop
-
body (
MaybeNode
)Body of the loop.
None
if body is empty -
keyword_l (
Loc
)Location of the
while
keywordwhile cond do; foo; end ~~~~~
-
begin_l (
MaybeLoc
)Location of the
do
keywordwhile cond do; foo; end ~~
do
is optional, and sobegin_l
can beNone
-
end_l (
MaybeLoc
)Location of the
end
keywordwhile cond do; foo; end ~~~
None
if loop is a modifier (i.e.foo while bar
) -
expression_l (
Loc
)Location of the full expression
while cond do; foo; end ~~~~~~~~~~~~~~~~~~~~~~~ foo while bar ~~~~~~~~~~~~~
Represents a post-while loop
```text
begin
foo
end while bar
```
Fields:
-
cond (
Node
)Condition of the loop
-
body (
Node
)Body of the loop
-
keyword_l (
Loc
)Location of the
while
keywordbegin; foo; end while bar ~~~~~
-
expression_l (
Loc
)Location of the
while
keywordbegin; foo; end while bar ~~~~~~~~~~~~~~~~~~~~~~~~~
Represents a executable here-document literal (both with and without interpolation)
It's similar to `Xstr` in terms of abstract syntax tree, but has different source maps.
Fields:
-
parts (
Nodes
)A list of string parts (static literals and interpolated expressions)
-
heredoc_body_l (
Loc
)Location of the executable here-document body
<<-`HERE`\n a\n #{42}\nHERE ~~~~~~~~~~~~~~~
-
heredoc_end_l (
Loc
)Location of the executable here-document end
<<-`HERE`\n a\n #{42}\nHERE ~~~~
-
expression_l (
Loc
)Location of the executable here-document identifier
<<-`HERE`\n a\n #{42}\nHERE ~~~~~~~
Note: This is the only node (with
Heredoc
) that hasexpression_l
smaller that all other sub-locations merged. The reason for that is that it's possible to add more code after here-document ID:<<-`HERE` + "rest" content HERE
Represents an executable string (i.e. `` `sh #{script_name}` ``)
Fields:
-
parts (
Nodes
)A list of string parts (static literals and interpolated expressions)
-
begin_l (
Loc
)Location of the string begin
`#{foo}` ~ %X{#{foo}} ~~~
-
end_l (
Loc
)Location of the string end
`#{foo}` ~ %X{#{foo}} ~
-
expression_l (
Loc
)Location of the full expression
`#{foo}` ~~~~~~~~ %X{#{foo}} ~~~~~~~~~~
Represents an `yield` keyword
Fields:
-
args (
Nodes
)A list of arguments given to
yield
-
keyword_l (
Loc
)Location of the
yield
keywordyield 1, 2 ~~~~~
-
begin_l (
MaybeLoc
)Location of the open parenthesis
yield(1, 2) ~
None
if there are no parentheses -
end_l (
MaybeLoc
)Location of the closing parenthesis
yield(1, 2) ~
None
if there are no parentheses -
expression_l (
Loc
)Location of the full expression
yield(1, 2) ~~~~~~~~~~~
Represents a `super` call without arguments and parentheses
It's different from `super()` as it implicitly forwards current arguments
Fields:
-
expression_l (
Loc
)Location of the
super
keywordsuper ~~~~~