Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Latest commit

 

History

History
4827 lines (2879 loc) · 71.8 KB

NODES.md

File metadata and controls

4827 lines (2879 loc) · 71.8 KB

Alias

Represents `alias to from` statement.

Fields:

  1. to (Node)

    Target of the alias.

    Sym("foo") node for alias :foo :bar

  2. from (Node)

    Source of the alias.

    Sym("bar") node for alias :foo :bar

  3. keyword_l (Loc)

    Location of the alias keyword

    alias foo bar
    ~~~~~
    
  4. expression_l (Loc)

    Location of the full expression

    alias foo bar
    ~~~~~~~~~~~~~
    

And

Represents `foo && bar` (or `foo and bar`) statement.

Fields:

  1. lhs (Node)

    Left hand statament of the && operation.

    Lvar("foo") node for foo && bar

  2. rhs (Node)

    Right hand statement of the && operation.

    Lvar("bar") node for foo && bar

  3. operator_l (Loc)

    Location of the && (or and) operator

    a && b
      ~~
    
  4. expression_l (Loc)

    Location of the full expression

    a && b
    ~~~~~~
    

AndAsgn

Represents `a &&= 1` statement.

Fields:

  1. recv (Node)

    Receiver of the &&= operation.

    Lvasgn("a") node for a &&= 1

  2. value (Node)

    Right hand statement of assignment

    Int("1") node for a &&= 1

  3. operator_l (Loc)

    Location of the &&= operator

    a &&= 1
      ~~~
    
  4. expression_l (Loc)

    Location of the full expression

    a &&= 1
    ~~~~~~~
    

Arg

Represents a positional required block/method argument.

`a` in `def m(a); end` or `proc { |a| }`

Fields:

  1. name (Str)

    Name of the argument

  2. expression_l (Loc)

    Location of the full expression

    def m(argument); end
          ~~~~~~~~
    

Args

Represents an arguments list

`Args(vec![Arg("a"), Optarg("b", Int("1"))])` in `def m(a, b = 1); end`

Fields:

  1. args (Nodes)

    List of arguments

  2. expression_l (Loc)

    Location of the full expression

    def m(a, b = 1, c:, &blk); end
         ~~~~~~~~~~~~~~~~~~~~
    
  3. begin_l (MaybeLoc)

    Location of the open parenthesis

    def m(a, b = 1, c:, &blk); end
         ~
    

    None for code like def m; end or def m arg; end

  4. end_l (MaybeLoc)

    Location of the closing parenthesis

    def m(a, b = 1, c:, &blk); end
                            ~
    

    None for code like def m; end or def m arg; end

Array

Represents an array literal

Fields:

  1. elements (Nodes)

    A list of elements

  2. begin_l (MaybeLoc)

    Location of the open bracket

    [1, 2, 3]
    ~
    
  3. end_l (MaybeLoc)

    Location of the closing bracket

    [1, 2, 3]
            ~
    
  4. expression_l (Loc)

    Location of the full expression

    [1, 2, 3]
    ~~~~~~~~~
    

ArrayPattern

Represents an array pattern used in pattern matching

Fields:

  1. elements (Nodes)

    A list of elements

  2. begin_l (MaybeLoc)

    Location of the open bracket

    [1, ^a, 3 => foo]
    ~
    

    None for pattern like 1, 2 without brackets

  3. end_l (MaybeLoc)

    Location of the closing bracket

    [1, ^a, 3 => foo]
                    ~
    

    None for pattern like 1, 2 without brackets

  4. expression_l (Loc)

    Location of the full expression

    [1, ^a, 3 => foo]
    ~~~~~~~~~~~~~~~~~
    

ArrayPatternWithTail

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:

  1. elements (Nodes)

    A list of elements

  2. begin_l (MaybeLoc)

    Location of the open bracket

    [1, ^a, 3 => foo,]
    ~
    

    None for pattern like 1, 2, without brackets

  3. end_l (MaybeLoc)

    Location of the closing bracket

    [1, ^a, 3 => foo,]
                     ~
    

    None for pattern like 1, 2, without brackets

  4. expression_l (Loc)

    Location of the full expression

    [1, ^a, 3 => foo,]
    ~~~~~~~~~~~~~~~~~~
    

BackRef

Represents special global variables:
1. `` $` ``
2. `$&`
3. `$'`
4. `$+`

Fields:

  1. name (Str)

    Name of the variable ("$+" for $+)

  2. expression_l (Loc)

    Location of the full expression

    $+
    ~~
    

Begin

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:

  1. statements (Nodes)

    A list of statements

  2. begin_l (MaybeLoc)

    Begin of the block

    (1; 2)
    ~
    

    None if the block of code is "implicit", like

    if true; 1; 2; end
    
  3. end_l (MaybeLoc)

    End of the block

    (1; 2)
         ~
    

    None if the block of code is "implicit", like

    if true; 1; 2; end
    
  4. expression_l (Loc)

    Location of the full expression

    (1; 2)
    ~~~~~~
    

Block

Represents a Ruby block that is passed to a method (`proc { |foo| bar }`)

Fields:

  1. call (Node)

    Method call that takes a block

    Send("foo") in foo {}

  2. args (MaybeNode)

    A list of argument that block takes

    vec![ Arg("a"), Optarg("b", Int("1")) ] for proc { |a, b = 1| }

    None if the block takes no arguments

  3. body (MaybeNode)

    Block body, None if block has no body.

  4. begin_l (Loc)

    Location of the open brace

    proc { }
         ~
    
  5. end_l (Loc)

    Location of the closing brace

    proc { }
           ~
    
  6. expression_l (Loc)

    Location of the full expression

    proc { }
    ~~~~~~~~
    

Blockarg

Represents a `&blk` argument in the method definition (but not in the method call, see `BlockPass`)

Fields:

  1. name (MaybeStr)

    Name of the argument, String("foo") for def m(&foo)

  2. operator_l (Loc)

    Location of the & operator

    def m(&foo); end
          ~
    
  3. name_l (MaybeLoc)

    Location of the name

    def m(&foo); end
           ~~~
    
  4. expression_l (Loc)

    Location of the full expression

    def m(&foo); end
          ~~~~
    

BlockPass

Represents a `&blk` argument of the method call (but not of the method definition, see `BlockArg`)

Fields:

  1. value (MaybeNode)

    Value that is converted to a block

    Int("1") in foo(&1) (yes, it's possible)

  2. operator_l (Loc)

    Location of the & operator

    foo(&blk)
        ~
    
  3. expression_l (Loc)

    Location of the full expression

    foo(&bar)
        ~~~~
    

Break

Represents a `break` keyword (with optional argument)

Fields:

  1. args (Nodes)

    A list of arguments

  2. keyword_l (Loc)

    Location of the break keyword

    break :foo
    ~~~~~
    
  3. expression_l (Loc)

    Location of the full expression

    break(:foo)
    ~~~~~~~~~~~
    

Case

Represents a `case` statement (for pattern matching see `CaseMatch` node)

Fields:

  1. expr (MaybeNode)

    Expression given to case, Int("1") for case 1; end None for code like

    case
    when pattern
    end
    
  2. when_bodies (Nodes)

    A list of When nodes (each has patterns and body)

  3. else_body (MaybeNode)

    Body of the else branch, None if there's no else branch

  4. keyword_l (Loc)

    Location of the case keyword

    case 1; end
    ~~~~
    
  5. else_l (MaybeLoc)

    Location of the else keyword

    case 1; else; end
            ~~~~
    

    None if there's no else branch

  6. end_l (Loc)

    Location of the end keyword

    case 1; end
            ~~~
    
  7. expression_l (Loc)

    Location of the full expression

    case 1; end
    ~~~~~~~~~~~
    

CaseMatch

Represents a `case` statement used for pattern matching (for regular `case` see `Case` node)

Fields:

  1. expr (Node)

    Expression given to case, Int("1") for case 1; in 1; end None for code like

    case
    in pattern
    end
    
  2. in_bodies (Nodes)

    A list of InPattern nodes (each has pattern, guard and body)

  3. else_body (MaybeNode)

    Body of the else branch, None if there's no else branch

  4. keyword_l (Loc)

    Location of the case keyword

    case 1; in 2; end
    ~~~~
    
  5. else_l (MaybeLoc)

    Location of the else keyword

    case 1; in 2; else; end
                  ~~~~
    

    None if there's no else branch

  6. end_l (Loc)

    Location of the end keyword

    case 1; in 2; end
                  ~~~
    
  7. expression_l (Loc)

    Location of the full expression

    case 1; in 2; end
    ~~~~~~~~~~~~~~~~~
    

Casgn

Represents a constant assignment (i.e. `A = 1`)

Fields:

  1. scope (MaybeNode)

    Scope where the constant is defined:

    1. Some(Const("A")) for A::B = 1
    2. None if it's defined in the current scope (i.e. A = 1)
    3. Some(Cbase) if it's defined in the global scope (i.e. ::A = 1)
  2. name (Str)

    Name of the constant, String("A") for A = 1

  3. value (MaybeNode)

    Value that is assigned to a constant, Int("1") for A = 1.

    Note: None if constant assignment is a part of the multi-assignment. In such case value belongs to Masgn node of the multi-assignment.

  4. double_colon_l (MaybeLoc)

    Location of the :: operator

    A::B = 1
     ~~
    
    ::A = 1
    ~~
    

    None if the constant is defined in the current scope

  5. name_l (Loc)

    Location of the constant name

    A::CONST = 1
       ~~~~~
    
  6. operator_l (MaybeLoc)

    Location of the = operator

    A = 1
      ~
    

    None if constant assignment is a part of the multi-assignment. In such case = belongs to a Masgn node

  7. expression_l (Loc)

    Location of the full expression

    A = 1
    ~~~~~
    

Cbase

Represents leading `::` part of the constant access/assignment that is used to get/set on a global namespace.

Fields:

  1. expression_l (Loc)

    Location of the full expression

    ::A
    ~~
    

Class

Represents a class definition (using a `class` keyword, `Class.new` is just a method call)

Fields:

  1. name (Node)

    Name of the class, String("Foo") for class Foo; end

  2. 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)

  3. body (MaybeNode)

    Body of the method, None if there's no body.

  4. keyword_l (Loc)

    Location of the class keyword.

    class Foo; end
    ~~~~~
    
  5. operator_l (MaybeLoc)

    Location of the < operator

    class A < B; end
            ~
    

    None if there's no explicit superclass given.

  6. end_l (Loc)

    Location of the end keyword.

    class Foo; end
               ~~~
    
  7. expression_l (Loc)

    Location of the full expression

    class Foo; end
    ~~~~~~~~~~~~~~
    

Complex

Represents a `Complex` literal (that returns an `Complex` number)

Fields:

  1. value (Str)

    Value of the complex literal, returned as a String, String("1i") for 1i

  2. operator_l (MaybeLoc)

    Location of the - (but not +) operator. + is a part of the literal:

    1. +1i is String("+1i") with operator = None
    2. -1i is String("1i") with operator = String("-")
    -1i
    ~
    
  3. expression_l (Loc)

    Location of the full expression

    -1i
    ~~~
    

Const

Represents constant access (i.e. `Foo::Bar`)

Fields:

  1. scope (MaybeNode)

    Scope where the constant is taken from:

    1. Some(Const("A")) for A::B
    2. None if it's taken from the current scope (i.e. A)
    3. Some(Cbase) if it's taken from the global scope (i.e. ::A)
  2. name (Str)

    Name of the constant, String("Foo") for Foo

  3. double_colon_l (MaybeLoc)

    Location of the :: operator. None if constant is taken from the current scope.

    A::B
     ~~
    
  4. name_l (Loc)

    Location of the constant name

    Foo::Bar
         ~~~
    
  5. expression_l (Loc)

    Location of the full expression

    Foo::Bar
    ~~~~~~~~
    

ConstPattern

Const pattern used in pattern matching (e.g. `in A(1, 2)`)

Fields:

  1. const (Node)

    Constant that is used, Const("Foo") for in For(42)

  2. pattern (Node)

    Inner part of the constant pattern

    ArrayPattern(vec![ Int("1") ]) for Foo(1)

  3. begin_l (Loc)

    Location of the open parenthesis

    case 1; in Foo(42); end
                  ~
    
  4. end_l (Loc)

    Location of the closing parenthesis

    case 1; in Foo(42); end
                     ~
    
  5. expression_l (Loc)

    Location of the full expression

    case 1; in Foo(42); end
               ~~~~~~~
    

CSend

Represents conditional method call using `&.` operator

Fields:

  1. recv (Node)

    Receiver of the method call, Int("1") for 1&.foo

  2. method_name (Str)

    Name of the method, String("foo") for 1&.foo

  3. args (Nodes)

    List of arguments

    foo&.bar(42)
    # and also setters like
    foo&.bar = 42
    
  4. dot_l (Loc)

    Location of the &. operator

    foo&.bar
       ~~
    
  5. 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&.())

  6. begin_l (MaybeLoc)

    Location of the open parenthesis

    foo&.bar(42)
            ~
    

    None if there are no parentheses

  7. end_l (MaybeLoc)

    Location of the closing parenthesis

    foo&.bar(42)
               ~
    

    None if there are no parentheses

  8. operator_l (MaybeLoc)

    Location of the operator if CSend is a part of assignment like

    foo&.bar = 1
             ~
    

    None for a regular call.

  9. expression_l (Loc)

    Location of the full expression

    foo&.bar(42)
    ~~~~~~~~~~~~
    

Cvar

Represents access to class variable (i.e. `@@var`)

Fields:

  1. name (Str)

    Name of the class variable, String("@@foo") for @@foo

  2. expression_l (Loc)

    Location of the full expression

    @@foo
    ~~~~~
    

Cvasgn

Represents class variable assignment (i.e. `@@var = 42`)

Fields:

  1. name (Str)

    Name of the class variable, String("@@foo") for @@foo = 1

  2. value (MaybeNode)

    Value that is assigned to class variable, Int("1") for @@foo = 1

  3. name_l (Loc)

    Location of the class variable name

    @@foo = 1
    ~~~~~
    
  4. operator_l (MaybeLoc)

    Location of the = operator

    @@foo = 1
          ~
    
  5. expression_l (Loc)

    Location of the full expression

    @@foo = 1
    ~~~~~~~~~
    

Def

Represents method definition using `def` keyword (not on a singleton, see `Defs` node).

Fields:

  1. name (Str)

    Name of the method, String("foo") for def foo; end

  2. args (MaybeNode)

    Arguments of a method, None if there's no arguments.

    All information about parentheses around arguments is stored in this node.

  3. body (MaybeNode)

    Body of a method, None if there's no body.

  4. keyword_l (Loc)

    Location of the def keyword.

    def foo; end
    ~~~
    
  5. name_l (Loc)

    Location of the method name.

    def foo; end
        ~~~
    
  6. end_l (MaybeLoc)

    Location of the end keyword.

    def foo; end
             ~~~
    

    None for endless method definition

  7. assignment_l (MaybeLoc)

    Location of the = operator for endless method definition

    def m() = 1
            ~
    

    None for regular method definition

  8. expression_l (Loc)

    Location of the full expression

    def m(a); foo; end
    ~~~~~~~~~~~~~~~~~~
    

Defined

Represents a `defined?(foo)` expression

Fields:

  1. value (Node)

    Value given to defined?

  2. keyword_l (Loc)

    Location of the defined? keyword

    defined?(foo)
    ~~~~~~~~
    
  3. begin_l (MaybeLoc)

    Location of the open parenthesis

    defined?(foo)
            ~
    

    None if there are no parentheses

  4. end_l (MaybeLoc)

    Location of the closing parenthesis

    defined?(foo)
                ~
    

    None if there are no parentheses

  5. expression_l (Loc)

    Location of the full expression

    defined?(foo)
    ~~~~~~~~~~~~~
    

Defs

Represents a singleton method definition (i.e. `def self.foo; end`)

Fields:

  1. definee (Node)

    Definee of a method definition, Lvar("x") for def x.foo; end

  2. name (Str)

    Name of the method, String("foo") for def x.foo; end

  3. args (MaybeNode)

    Arguments of a method, None if there's no arguments.

    All information about parentheses around arguments is stored in this node.

  4. body (MaybeNode)

    Body of the method, None if there's no body.

  5. keyword_l (Loc)

    Location of the def keyword

    def self.foo; end
    ~~~
    
  6. operator_l (Loc)

    Location of the .

    def self.foo; end
            ~
    
  7. name_l (Loc)

    Location of the method name

    def self.foo; end
             ~~~
    
  8. assignment_l (MaybeLoc)

    Location of the = operator for endless method definition

    def self.foo() = 42
                   ~
    

    None for regular method definition

  9. end_l (MaybeLoc)

    Location of the end keyword

    def self.foo; end
                  ~~~
    

    None for endless method definition

  10. expression_l (Loc)

    Location of the full expression

    def self.foo; end
    ~~~~~~~~~~~~~~~~~
    

Dstr

Represents a string with interpolation (i.e. `"#{foo}"`)

Fields:

  1. parts (Nodes)

    A list of string parts (static literals and interpolated expressions)

  2. begin_l (MaybeLoc)

    Location of the string begin

    "#{foo}"
    ~
    
    %Q{#{foo}}
    ~~~
    
  3. end_l (MaybeLoc)

    Location of the string end

    "#{foo}"
           ~
    
    %Q{#{foo}}
             ~
    
  4. expression_l (Loc)

    Location of the full expression

    "#{foo}"
    ~~~~~~~~
    
    %Q{#{foo}}
    ~~~~~~~~~~
    

Dsym

Represents a symbol with interpolation (i.e. `:"#{foo}"`)

Fields:

  1. parts (Nodes)

    A list of symbol parts (static literals and interpolated expressions)

  2. begin_l (MaybeLoc)

    Location of the symbol begin

    :"#{foo}"
    ~~
    

    None if Dsym is a part of the interpolated symbol array:

    %I[#{bar}]
    
  3. end_l (MaybeLoc)

    Location of the symbol begin

    :"#{foo}"
            ~
    

    None if Dsym is a part of the interpolated symbol array:

    %I[#{bar}]
    
  4. expression_l (Loc)

    Location of the full expression

    :"#{foo}"
    ~~~~~~~~~
    

EFlipFlop

Represents exclusive flip-flop (i.e. in `if foo...bar; end`)

Fields:

  1. left (MaybeNode)

    Left part of the flip-flop. None if based on a range without begin (...bar)

  2. right (MaybeNode)

    Right part of the flip-flop. None if based on a range without end (foo...)

  3. operator_l (Loc)

    Location of the ... operator

    if foo...bar; end
          ~~~
    
  4. expression_l (Loc)

    Location of the full expression

    if foo...bar; end
       ~~~~~~~~~
    

EmptyElse

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:

  1. expression_l (Loc)

    Location of the else keyword

    case foo; in 1; else; end
                    ~~~~
    

Encoding

Represents a special `__ENCODING__` keyword

Fields:

  1. expression_l (Loc)

    Location of the __ENCODING__ keyword

    __ENCODING__
    ~~~~~~~~~~~~
    

Ensure

Represents a block of code with `ensure` (i.e. `begin; ensure; end`)

Fields:

  1. body (MaybeNode)

    Block of code that is wrapped into ensure Note: that's the body of the ensure block

    Int("1") for begin; 1; ensure; 2; end

  2. ensure (MaybeNode)

    Body of the ensure block

    Int("2") for begin; 1; ensure; 2; end

  3. keyword_l (Loc)

    Location of the ensure keyword

    begin; ensure; end
           ~~~~~~
    
  4. expression_l (Loc)

    Location of the full expression

    begin; 1; rescue; 2; else; 3; ensure; 4; end
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

    Note: begin/end belong to KwBegin node.

Erange

Represents range literal with excluded `end` (i.e. `1...3`)

Fields:

  1. left (MaybeNode)

    Begin of the range, None if range has no begin (i.e ...42)

  2. right (MaybeNode)

    End of the range, None if range has no end (i.e 42...)

  3. operator_l (Loc)

    Location of the ... operator

    1...3
     ~~~
    
  4. expression_l (Loc)

    Location of the full expression

    1...3
    ~~~~~
    

False

Represents a `false` literal

Fields:

  1. expression_l (Loc)

    Location of the false literal

    false
    ~~~~~
    

File

Represents a special `__FILE__` literal

Fields:

  1. expression_l (Loc)

    Location of the __FILE__ literal

    __FILE__
    ~~~~~~~~
    

FindPattern

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:

  1. elements (Nodes)

    Inner part of the find pattern

  2. begin_l (MaybeLoc)

    Location of the begin

    case foo; in [*x, 1 => a, *y]; end
                 ~
    

    None if there are no brackets/parentheses

  3. end_l (MaybeLoc)

    Location of the end

    case foo; in [*x, 1 => a, *y]; end
                                ~
    

    None if there are no brackets/parentheses

  4. expression_l (Loc)

    Location of the full expression

    case foo; in [*x, 1 => a, *y]; end
                 ~~~~~~~~~~~~~~~~
    

Float

Represents a float literal (i.e. `42.5`)

Fields:

  1. value (Str)

    String value of the literal, String("42.5") for 42.5

  2. operator_l (MaybeLoc)

    Location of unary - (but not +)

    -42.5
    ~
    
  3. expression_l (Loc)

    Location of the full expression

    -42.5
    ~~~~~
    

For

Represents a `for` loop

Fields:

  1. iterator (Node)

    Variable that is used in loop, Lvasgn("a") in for a in b; end

  2. iteratee (Node)

    Collection that is for iteration. Lvar("b") in for a in b; end

  3. body (MaybeNode)

    Body of the loop. None if there's no body

  4. keyword_l (Loc)

    Location of the for keyword

    for a in b; end
    ~~~
    
  5. operator_l (Loc)

    Location of the in keyword

    for a in b; end
          ~~
    
  6. begin_l (Loc)

    Location of the do keyword

    for a in b do; end
               ~~
    

    Note: this do is optional, and so begin_l can be None.

  7. end_l (Loc)

    Location of the end keyword

    for a in b; end
                ~~~
    
  8. expression_l (Loc)

    Location of the full expression

    for a in b; end
    ~~~~~~~~~~~~~~~
    

ForwardArg

Represents a special `...` argument that forwards positional/keyword/block arguments.

Fields:

  1. expression_l (Loc)

    Location of the ...

    def m(...); end
          ~~~
    

ForwardedArgs

Represents a `...` operator that contains forwarded argument (see `ForwardArg`)

Fields:

  1. expression_l (Loc)

    Location of the ...

    def m(...); foo(...); end
                    ~~~
    

Gvar

Represents access to global variable (i.e. `$foo`)

Fields:

  1. name (Str)

    Name of the global variable, String("$foo") for $foo

  2. expression_l (Loc)

    Location of the full expression

    $foo
    ~~~~
    

Gvasgn

Represents global variable assignment (i.e. `$foo = 42`)

Fields:

  1. name (Str)

    Name of the global variable, String("$foo") for $foo

  2. 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 case value is a part of the Masgn node.

  3. name_l (Loc)

    Location of the global variable name

    $foo = 42
    ~~~~
    
  4. 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 the Masgn node.

  5. expression_l (Loc)

    Location of the full expression

    $foo = 42
    ~~~~~~~~~
    

Hash

Represents a hash literal (i.e. `{ foo: 42 }`)

Fields:

  1. pairs (Nodes)

    A list of key-value pairs

  2. begin_l (MaybeLoc)

    Location of the open parenthesis

    { a: 1 }
    ~
    

    None if hash literal is implicit, e.g. foo(key: "value")

  3. end_l (MaybeLoc)

    Location of the closing parenthesis

    { a: 1 }
           ~
    

    None if hash literal is implicit, e.g. foo(key: "value")

  4. expression_l (Loc)

    Location of the full expression

    { a: 1 }
    ~~~~~~~~
    

HashPattern

Represents a hash pattern used in pattern matching (i.e. `in { a: 1 }`)

Fields:

  1. elements (Nodes)

    A list of inner patterns

  2. begin_l (MaybeLoc)

    Location of the open parenthesis

    case foo; in { a: 1 }; end
                 ~
    

    None if there are no parentheses

  3. end_l (MaybeLoc)

    Location of the open parenthesis

    case foo; in { a: 1 }; end
                        ~
    

    None if there are no parentheses

  4. expression_l (Loc)

    Location of the full expression

    case foo; in { a: 1 }; end
                 ~~~~~~~~
    

Heredoc

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:

  1. parts (Nodes)

    A list of string parts (static literals and interpolated expressions)

  2. heredoc_body_l (Loc)

    Location of the here-document body

    <<-HERE\n  a\n   #{42}\nHERE
    ~~~~~~~~~~~~~~~
    
  3. heredoc_end_l (Loc)

    Location of the here-document end

    <<-HERE\n  a\n   #{42}\nHERE
                            ~~~~
    
  4. expression_l (Loc)

    Location of the here-document identifier

    <<-HERE\n  a\n   #{42}\nHERE
    ~~~~~~~
    

    Note: This is the only node (with XHeredoc) that has expression_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
    

If

Represents an `if` statement (i.e. `if foo; bar; else; baz; end`)

Fields:

  1. cond (Node)

    Condition given to the if statement, Lvar("a") for if a; b; else; c; end

  2. if_true (MaybeNode)

    True-branch of the if statement, Lvar("b") for if a; b; else; c; end

  3. if_false (MaybeNode)

    False-branch of the if statement, Lvar("c") for if a; b; else; c; end

  4. keyword_l (Loc)

    Location of the if keyword

    if foo; end
    ~~
    
  5. begin_l (Loc)

    Location of the then keyword

    if foo then; end
           ~~~~
    

    None if then keyword is omitted

  6. else_l (MaybeLoc)

    Location of the else keyword

    if foo; else; end
            ~~~~
    

    None if there's no else branch

  7. end_l (MaybeLoc)

    Location of the end keyword

    if foo; end
            ~~~
    
  8. expression_l (Loc)

    Location of the full expression

    if a then; b; else; c end
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    

IfGuard

Represents an `if` guard used in pattern matching (i.e. `case foo; in pattern if guard; end`)

Fields:

  1. cond (Node)

    Condition of the guard, Lvar("foo") in in pattern if guard

  2. keyword_l (Loc)

    Location of the if keyword

    case foo; in pattern if cond; end
                         ~~
    
  3. expression_l (Loc)

    Location of the full expression

    case foo; in pattern if cond; end
                         ~~~~~~~
    

IFlipFlop

Represents inclusive flip-flop (i.e. in `if foo..bar; end`)

Fields:

  1. left (MaybeNode)

    Left part of the flip-flop. None if based on a range without begin (..bar)

  2. right (MaybeNode)

    Right part of the flip-flop. None if based on a range without end (foo..)

  3. operator_l (Loc)

    Location of the .. operator

    if foo..bar; end
          ~~
    
  4. expression_l (Loc)

    Location of the full expression

    if foo..bar; end
       ~~~~~~~~
    

IfMod

Represents an `if`/`unless` modifier (i.e. `stmt if cond`)

Fields:

  1. cond (Node)

    Condition of the modifier

  2. if_true (MaybeNode)

    True-branch of the modifier.

    Always set for if modifier. Always None for unless modifier.

  3. if_false (MaybeNode)

    False-branch of the modifier.

    Always set for unless modifier. Always None for if modifier.

  4. keyword_l (Loc)

    Location of the if/unless keyword

    stmt if cond
         ~~
    
    stmt unless cond
         ~~~~~~
    
  5. expression_l (Loc)

    Location of the full expression

    stmt if cond
    ~~~~~~~~~~~~
    
    stmt unless cond
    ~~~~~~~~~~~~~~~~
    

IfTernary

Represents ternary `if` statement (i.e. `cond ? if_true : if_false`)

Fields:

  1. cond (Node)

    Condition of the if statement

  2. if_true (Node)

    True-branch

  3. if_false (Node)

    True-branch

  4. question_l (Loc)

    Location of the ? operator

    cond ? if_true : if_false
         ~
    
  5. colon_l (Loc)

    Location of the : operator

    cond ? if_true : if_false
                   ~
    
  6. expression_l (Loc)

    Location of the full expression

    cond ? if_true : if_false
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    

Index

Represents indexing operation (i.e. `foo[1,2,3]`)

Fields:

  1. recv (Node)

    Receiver of indexing

  2. indexes (Nodes)

    A list of indexes

  3. begin_l (Loc)

    Location of open bracket

    foo[1, 2, 3]
       ~
    
  4. end_l (Loc)

    Location of closing bracket

    foo[1, 2, 3]
               ~
    
  5. expression_l (Loc)

    Location of the full expression

    foo[1, 2, 3]
    ~~~~~~~~~~~~
    

IndexAsgn

Represents assignment using indexing operation (i.e. `foo[1, 2, 3] = bar`)

Fields:

  1. recv (Node)

    Receiver of the indexing

  2. indexes (Nodes)

    A list of indexes

  3. value (MaybeNode)

    Value that is assigned

    None if assignment is a part of the multi-assignment. In such case value belongs to Masgn node.

  4. begin_l (Loc)

    Location of open bracket

    foo[1, 2, 3] = bar
       ~
    
  5. end_l (Loc)

    Location of closing bracket

    foo[1, 2, 3] = bar
               ~
    
  6. operator_l (MaybeLoc)

    Location of the = operator

    foo[1, 2, 3] = bar
                 ~
    

    None if assignment is a part of the multi-assignment. In such case operator = belongs to Masgn node.

  7. expression_l (Loc)

    Location of the full expression

    foo[1, 2, 3] = bar
    ~~~~~~~~~~~~~~~~~~
    

InPattern

Represents an `in pattern` branch of the pattern matching

Fields:

  1. pattern (Node)

    Value that is used for matching

  2. guard (MaybeNode)

    Guard that is used for matching

    Optional, so can be None

  3. body (MaybeNode)

    Body of the branch that is invoked if value matches pattern

  4. keyword_l (Loc)

    Location of the in keyword

    case value; in pattern; end
                ~~
    
  5. begin_l (Loc)

    Location of the then keyword

    case value; in pattern then; end
                           ~~~~
    
  6. expression_l (Loc)

    Location of the full expression

    case value; in pattern then; 42; end
                ~~~~~~~~~~~~~~~~~~~
    

Int

Represents an integer literal (i.e. `42`)

Fields:

  1. value (Str)

    String value of the literal, String("42") for 42

  2. operator_l (MaybeLoc)

    Location of unary - (but not +)

    -42
    ~
    
  3. expression_l (Loc)

    Location of the full expression

    -42
    ~~~
    

Irange

Represents inclusive range (i.e. `2..4`)

Fields:

  1. left (MaybeNode)

    Begin of the range, None if range has no begin (i.e. ..4)

  2. right (MaybeNode)

    End of the range, None if range has no end (i.e. 2..)

  3. operator_l (Loc)

    Location of the .. operator

    2..4
     ~~
    
  4. expression_l (Loc)

    Location of the full expression

    2..4
    ~~~~
    

Ivar

Represents access to instance variable (i.e. `@foo`)

Fields:

  1. name (Str)

    Name of the instance variable, String("@foo") in @foo

  2. expression_l (Loc)

    Location of the full expression

    @foo
    ~~~~
    

Ivasgn

Represents instance variable assignment (i.e `@foo = 42`)

Fields:

  1. name (Str)

    Name of the instance variable, String("@foo") in @foo = 42

  2. value (MaybeNode)

    Value that is assigned to instance variable.

    None if instance variable assignment is a part of the multi-assignment. In such case value is a part of the Masgn node.

  3. name_l (Loc)

    Location of the instance variable name.

    @foo = 1
    ~~~~
    
  4. operator_l (MaybeLoc)

    Location of the = operator.

    @foo = 1
         ~
    

    None if instance variable assignment is a part of the multi-assignment. In such case value is a part of the Masgn node.

  5. expression_l (Loc)

    Location of the full expression

    @foo = 42
    ~~~~~~~~~
    

Kwarg

Represents required keyword argument (i.e. `foo` in `def m(foo:); end`)

Fields:

  1. name (Str)

    Name of the keyword argument

  2. name_l (Loc)

    Location of the name

    def foo(bar:); end
            ~~~
    
  3. expression_l (Loc)

    Location of the full expression

    def foo(bar:); end
            ~~~~
    

Kwargs

Represents kwargs that are given to a method call, super or yield (i.e. `foo(bar: 1)`)

Fields:

  1. pairs (Nodes)

    A list of key-value pairs

  2. begin_l (MaybeLoc)

    Always None

  3. end_l (MaybeLoc)

    Always None

  4. expression_l (Loc)

    Location of the full expression

    foo(bar: 1)
        ~~~~~~
    

KwBegin

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:

  1. statements (Nodes)

    A list of statements

  2. begin_l (MaybeLoc)

    Location of the begin keyword

    begin; foo; end
    ~~~~~
    
  3. end_l (MaybeLoc)

    Location of the end keyword

    begin; foo; end
                ~~~
    
  4. expression_l (Loc)

    Location of the full expression

    begin; foo; bar
    ~~~~~~~~~~~~~~~
    

Kwnilarg

Represents an special argument that rejects all keyword arguments (i.e. `def m(**nil); end`)

Fields:

  1. name_l (Loc)

    Location of the nil

    def m(**nil); end
            ~~~
    
  2. expression_l (Loc)

    Location of the nil

    def m(**nil); end
          ~~~~~
    

Kwoptarg

Represents an optional keyword argument (i.e. `foo` in `def m(foo: 42); end`)

Fields:

  1. name (Str)

    Name of the optional keyword argument

  2. default (Node)

    Default value of the optional keyword argument

  3. name_l (Loc)

    Location of the argument name

    def m(foo: 1); end
          ~~~
    
  4. expression_l (Loc)

    Location of the argument name

    def m(foo: 1); end
          ~~~~~~
    

Kwrestarg

Represents a keyword rest argument (i.e. `foo` in `def m(**foo); end`)

Fields:

  1. name (MaybeStr)

    Name of the keyword rest argument, String("foo") in def m(**foo); end.

    None if argument has no name (def m(**); end)

  2. operator_l (Loc)

    Location of the ** operator

    def m(**foo); end
          ~~
    
  3. name_l (MaybeLoc)

    Location of the argument name

    def m(**foo); end
            ~~~
    

    None if argument has no name (def m(**); end)

  4. expression_l (Loc)

    Location of the full expression

    def m(**foo); end
          ~~~~~
    

Kwsplat

Represents a keyword arguments splat (i.e. `**bar` in a call like `foo(**bar)`)

Fields:

  1. value (Node)

    Value that is converted into a Hash using **

  2. operator_l (Loc)

    Location of the ** operator

    foo(**bar)
        ~~
    
  3. expression_l (Loc)

    Location of the full expression

    foo(**bar)
        ~~~~~
    

Lambda

Represents a lambda call using `->` (i.e. `-> {}`)

Note that `Lambda` is a part of the `Block`, not other way around.

Fields:

  1. expression_l (Loc)

    Location of the ->

    -> {}
    ~~
    

Line

Represents a special `__LINE__` literal

Fields:

  1. expression_l (Loc)

    Location of the __LINE__ literal

    __LINE__
    ~~~~~~~~
    

Lvar

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:

  1. name (Str)

    Name of the local variable

  2. expression_l (Loc)

    Location of the local variable

    foo
    ~~~
    

Lvasgn

Represents local variable assignment (i.e. `foo = 42`)

Fields:

  1. name (Str)

    Name of the local variable

  2. value (MaybeNode)

    Value that is assigned to a local variable

  3. name_l (Loc)

    Location of the local variable name

    foo = 42
    ~~~
    
  4. operator_l (MaybeLoc)

    Location of the = operator

    foo = 42
        ~
    

    None if local variable assignment is a part of the multi-assignment. In such case value is a part of the Masgn node.

  5. expression_l (Loc)

    Location of the full expression

    foo = 42
    ~~~~~~~~
    

Masgn

Represents mass-assignment (i.e. `foo, bar = 1, 2`)

Fields:

  1. lhs (Node)

    Left hand statement of the assignment

  2. rhs (Node)

    Left hand statement of the assignment

  3. operator_l (Loc)

    Location of the = operator

    foo, bar = 1, 2
             ~
    
  4. expression_l (Loc)

    Location of the full expression

    foo, bar = 1, 2
    ~~~~~~~~~~~~~~~
    

MatchAlt

Represents pattern matching using one of the given patterns (i.e. `foo in 1 | 2`)

Fields:

  1. lhs (Node)

    Left pattern

  2. rhs (Node)

    Right pattern

  3. operator_l (Loc)

    Location of the | operator

    foo in 1 | 2
             ~
    
  4. expression_l (Loc)

    Location of the full expression

    foo in 1 | 2
           ~~~~~
    

MatchAs

Represents matching with renaming into specified local variable (i.e. `case 1; in Integer => a; end`)

Fields:

  1. value (Node)

    Pattern that is used for matching

  2. as (Node)

    Variable that is assigned if matched (see MatchVar node)

  3. operator_l (Loc)

    Location of the => operator

    case 1; in Integer => a; end
                       ~~
    
  4. expression_l (Loc)

    Location of the full expression

    case 1; in Integer => a; end
               ~~~~~~~~~~~~
    

MatchCurrentLine

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:

  1. re (Node)

    Given regex

  2. 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.

MatchNilPattern

Represents empty hash pattern that is used in pattern matching (i.e. `in **nil`)

Fields:

  1. operator_l (Loc)

    Location of the ** operator

    in **nil
       ~~
    
  2. name_l (Loc)

    Location of the name

    in **nil
         ~~~
    
  3. expression_l (Loc)

    Location of the full expression

    in **nil
       ~~~~~
    

MatchPattern

Represents a one-line pattern matching that can throw an error (i.e. `foo => pattern`)

Fields:

  1. value (Node)

    Value that is used for matching

  2. pattern (Node)

    Pattern that is used for matching

  3. operator_l (Loc)

    Location of the => operator

    foo => pattern
        ~~
    
  4. expression_l (Loc)

    Location of the full expression

    foo => pattern
    ~~~~~~~~~~~~~~
    

MatchPatternP

Represents a one-line pattern matching that never throws but returns true/false (i.e. `foo in pattern`)

Fields:

  1. value (Node)

    Value that is used for matching

  2. pattern (Node)

    Pattern that is used for matching

  3. operator_l (Loc)

    Location of the in operator

    foo in pattern
        ~~
    
  4. expression_l (Loc)

    Location of the full expression

    foo in pattern
    ~~~~~~~~~~~~~~
    

MatchRest

Represents a wildcard pattern used in pattern matching (i.e. `in *foo`)

Fields:

  1. name (MaybeNode)

    Name of the variable name

    None if there's no name (i.e. in *)

  2. operator_l (Loc)

    Location of the * operator

    case foo; in *bar; end
                 ~
    
  3. expression_l (Loc)

    Location of the * operator

    case foo; in *bar; end
                 ~~~~
    

MatchVar

Represents matching with assignment into a local variable (i.e. `pattern => var`)

Fields:

  1. name (Str)

    Name of the variable that is assigned if matching succeeds

  2. 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
                   ~
    
  3. 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
                   ~~
    

MatchWithLvasgn

Represents matching a regex that produces local variables (i.e. `/(?<match>bar)/ =~ 'bar'`)

Each named group in regex declares a local variable.

Fields:

  1. re (Node)

    Regex that is used for matching

  2. value (Node)

    Value that is used for matching

  3. operator_l (Loc)

    Location of the =~ operatir

    /(?<match>bar)/ =~ 'bar'
                    ~~
    
  4. expression_l (Loc)

    Location of the full expression

    /(?<match>bar)/ =~ 'bar'
    ~~~~~~~~~~~~~~~~~~~~~~~~
    

Mlhs

Represents left hand statement of the mass-assignment (i.e. `foo, bar` in `foo, bar = 1, 2`)

Fields:

  1. items (Nodes)

    A list of items that are assigned

  2. begin_l (MaybeLoc)

    Location of the open parenthesis

    (a, b) = 1, 2
    ~
    

    None if there are no parentheses

  3. end_l (MaybeLoc)

    Location of the closing parenthesis

    (a, b) = 1, 2
         ~
    

    None if there are no parentheses

  4. expression_l (Loc)

    Location of the full expression

    (a, b) = 1, 2
    ~~~~~~
    

Module

Represents module declaration using `module` keyword

Fields:

  1. name (Node)

    Name of the module

  2. body (MaybeNode)

    Body of the module

    None if module has no body

  3. keyword_l (Loc)

    Location of the module keyword

    module M; end
    ~~~~~~
    
  4. end_l (Loc)

    Location of the end keyword

    module M; end
              ~~~
    
  5. expression_l (Loc)

    Location of the full expression

    module M; end
    ~~~~~~~~~~~~~
    

Next

Represents `next` keyword

Fields:

  1. args (Nodes)

    Arguments given to next

  2. keyword_l (Loc)

    Location of the next keyword

    next 42
    ~~~~
    
  3. expression_l (Loc)

    Location of the full expression

    next(42)
    ~~~~~~~~
    

Nil

Represents `nil` literal

Fields:

  1. expression_l (Loc)

    Location of the nil keyword

    nil
    ~~~
    

NthRef

Represents numeric global variable (e.g. `$1`)

Fields:

  1. name (RawStr)

    Name of the variable, String("1") for $1

  2. expression_l (Loc)

    Location of the full expression

    $1
    ~~
    

Numblock

Represents a block that takes numbered parameters (i.e. `proc { _1 }`)

Fields:

  1. call (Node)

    Method call that takes a block

  2. numargs (U8)

    Number of parameters that block takes

  3. body (Node)

    Block body

  4. begin_l (Loc)

    Location of the open brace

    proc { _1 }
         ~
    
  5. end_l (Loc)

    Location of the closing brace

    proc { _1 }
              ~
    
  6. expression_l (Loc)

    Location of the open brace

    proc { _1 }
    ~~~~~~~~~~~
    

OpAsgn

Represents an operation with assignment (e.g. `a += 1`)

Fields:

  1. recv (Node)

    Left hand statement of the assignment

  2. operator (Str)

    Operator, can be one of:

    1. +=
    2. -=
    3. *=
    4. /=
    5. |=
    6. &=
    7. >>=
    8. <<=
    9. %=
    10. ^=
    11. **=
  3. value (Node)

    Right hand statement of the assignment

  4. operator_l (Loc)

    Location of the operator

    a.b <<= c
        ~~~
    
  5. expression_l (Loc)

    Location of the operator

    a.b <<= c
    ~~~~~~~~~
    

Optarg

Represents optional positional argument (i.e. `foo` in `m(foo = 1)`)

Fields:

  1. name (Str)

    Name of the argument

  2. default (Node)

    Default value of the argument

  3. name_l (Loc)

    Location of the argument name

    def m(foo = 1); end
          ~~~
    
  4. operator_l (Loc)

    Location of the = operator

    def m(foo = 1); end
              ~
    
  5. expression_l (Loc)

    Location of the full expression

    def m(foo = 1); end
          ~~~~~~~
    

Or

Represents `foo || bar` (or `foo or bar`) statement.

Fields:

  1. lhs (Node)

    Left hand statement

  2. rhs (Node)

    Right hand statement

  3. operator_l (Loc)

    Location of the ||/or operator

    foo || bar
        ~~
    
  4. expression_l (Loc)

    Location of the full expression

    foo || bar
    ~~~~~~~~~~
    

OrAsgn

Represents `lhs ||= rhs` assignment

Fields:

  1. recv (Node)

    Left hand statement

  2. value (Node)

    Right hand statement

  3. operator_l (Loc)

    Location of the ||= operator

    foo ||= bar
        ~~~
    
  4. expression_l (Loc)

    Location of the full expression

    foo ||= bar
    ~~~~~~~~~~~
    

Pair

Represents a key/value pair (e.g. a part of the `Hash` node)

Fields:

  1. key (Node)

    Key of the pair

  2. value (Node)

    Value of the pair

  3. operator_l (Loc)

    Location of the : or => operator

    { foo: bar }
         ~
    
    { :foo => bar }
           ~~
    
  4. expression_l (Loc)

    Location of the full expression

    { foo: bar }
      ~~~~~~~~
    
    { :foo => bar }
      ~~~~~~~~~~~
    

Pin

Represents a pattern based on a "pinned" variable (e.g. `^foo`)

Fields:

  1. var (Node)

    Variable that is pinned

  2. selector_l (Loc)

    Location of the ^ operator

    case foo; in ^bar; end
                 ~
    
  3. expression_l (Loc)

    Location of the full expression

    case foo; in ^bar; end
                 ~~~~
    

Postexe

Represents `END { .. }` statement

Fields:

  1. body (MaybeNode)

    Body of the block

  2. keyword_l (Loc)

    Location of the END keyword

    END { 42 }
    ~~~
    
  3. begin_l (Loc)

    Location of the open parenthesis

    END { 42 }
        ~
    
  4. end_l (Loc)

    Location of the closing parenthesis

    END { 42 }
             ~
    
  5. expression_l (Loc)

    Location of the full expression

    END { 42 }
    ~~~~~~~~~~
    

Preexe

Represents `BEGIN { ... }` statement

Fields:

  1. body (MaybeNode)

    Body of the block

  2. keyword_l (Loc)

    Location of the BEGIN keyword

    BEGIN { 42 }
    ~~~~~
    
  3. begin_l (Loc)

    Location of the open parenthesis

    BEGIN { 42 }
          ~
    
  4. end_l (Loc)

    Location of the closing parenthesis

    BEGIN { 42 }
               ~
    
  5. expression_l (Loc)

    Location of the full expression

    BEGIN { 42 }
    ~~~~~~~~~~~~
    

Procarg0

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:

  1. args (Nodes)

    Parts of the sole block argument.

    proc { |(a, b)| } also counts as a sole argument, so this list may contain:

    1. A single Arg node (for proc { |a| } case)
    2. Multiple Arg nodes (for proc { |(a, b, c)| } case)
  2. begin_l (MaybeLoc)

    Location of the open parenthesis

    proc { |(foo, bar)| }
            ~
    

    None if there's only one argument

  3. end_l (MaybeLoc)

    Location of the open parenthesis

    proc { |(foo, bar)| }
                     ~
    

    None if there's only one argument

  4. expression_l (Loc)

    Location of the full expression

    proc { |(foo, bar)| }
            ~~~~~~~~~~
    

Rational

Represents rational literal (e.g. `1r`)

Fields:

  1. value (Str)

    String value of the literal, String("1r") for 1r

  2. operator_l (MaybeLoc)

    Location of the unary - (but not +)

    -1r
    ~
    
  3. expression_l (Loc)

    Location of the full expression

    -1r
    ~~~
    

Redo

Represents `redo` keyword

Fields:

  1. expression_l (Loc)

    Location of the full expression

    redo
    ~~~~
    

Regexp

Represents regex literal (e.g. `/foo/`)

Fields:

  1. parts (Nodes)

    A list of static and dynamic regex parts

  2. options (RegexpOptions)

    Regex options.

    None if regex has no explicit flags

  3. begin_l (Loc)

    Location of the regex begin

    /foo/
    ~
    
    %r{foo}
    ~~
    
  4. end_l (Loc)

    Location of the regex end

    /foo/
        ~
    
    %r{foo}
          ~
    
  5. expression_l (Loc)

    Location of the full expression

    /foo/mix
    ~~~~~~~~
    

RegOpt

Represents flags of the regex literal (i.e. `mix` for `/foo/mix`)

Fields:

  1. options (Chars)

    A list of flags

  2. expression_l (Loc)

    Location of the full expression

    /foo/mix
         ~~~
    

Rescue

Represents a `rescue` block

Fields:

  1. body (MaybeNode)

    Body of the block that is wrapped into rescue (i.e. the part that may throw an error)

  2. rescue_bodies (Nodes)

    A list of rescue handlers (see RescueBody node)

  3. else (MaybeNode)

    Else branch.

    None if there's no else branch

  4. else_l (MaybeLoc)

    Location of the else keyword

    begin; 1; rescue StandardError => e; 2; else; 3; end
                                            ~~~~
    

    None if there's no else branch

  5. expression_l (Loc)

    Location of the full expression

    begin; 1; rescue StandardError => e; 2; else; 3; end
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

    Note: begin/end keywords belong to KwBegin node

RescueBody

Represents a single `rescue` handler (i.e. `rescue E => e ...`)

Fields:

  1. exc_list (MaybeNode)

    A list of exception classes

    None if no classes specified (i.e. rescue => e; ... or just rescue; ...)

  2. exc_var (MaybeNode)

    Variable that captures exception

    None if no variable specified (i.e. rescue E; ... or just rescue; ... )

  3. body (MaybeNode)

    Body of the handler

  4. keyword_l (Loc)

    Location of the rescue keyword

    begin; 1; rescue E => e; 2; end
              ~~~~~~
    
  5. assoc_l (MaybeLoc)

    Location of the => operator

    begin; 1; rescue E => e; 2; end
                       ~~
    

    None if exception is not captured.

  6. begin_l (MaybeLoc)

    Location of the then keyword

    begin; 1; rescue E => e then; 2; end
                            ~~~~
    

    then is optional, so begin_l can be None

  7. expression_l (Loc)

    Location of the full expression

    begin; 1; rescue E => e then; 2; end
              ~~~~~~~~~~~~~~~~~~~~~
    

Restarg

Represents positional rest argument (i.e. `*foo` in `def m(*foo); end`)

Fields:

  1. name (MaybeStr)

    Name of the argument.

    None if argument has no name (i.e. def m(*); end)

  2. operator_l (Loc)

    Location of the * operator

    def m(*foo); end
          ~
    
  3. name_l (MaybeLoc)

    Location of the argument name

    def m(*foo); end
           ~~~
    
  4. expression_l (Loc)

    Location of the full expression

    def m(*foo); end
          ~~~~
    

Retry

Represents `retry` keyword

Fields:

  1. expression_l (Loc)

    Location of the retry keyword

    retry
    ~~~~~
    

Return

Represents `return` keyword

Fields:

  1. args (Nodes)

    A list of values that is returned

  2. keyword_l (Loc)

    Location of the return keyword

    return 1, 2
    ~~~~~~
    
  3. expression_l (Loc)

    Location of the full expression

    return 1, 2
    ~~~~~~~~~~~
    

SClass

Represents opening a singleton class (i.e. `class << foo; ... end;`)

Fields:

  1. expr (Node)

    Expression that is used to get a singleton class

    Lvar("foo") for class << foo; end

  2. body (MaybeNode)

    Body of the block

  3. keyword_l (Loc)

    Location of the class keyword

    class << foo; end
    ~~~~~
    
  4. operator_l (Loc)

    Location of the << operator

    class << foo; end
          ~~
    
  5. end_l (Loc)

    Location of the end keyword

    class << foo; end
                  ~~~
    
  6. expression_l (Loc)

    Location of the full expression

    class << foo; end
    ~~~~~~~~~~~~~~~~~
    

Self_

Represents `self` keyword

Fields:

  1. expression_l (Loc)

    Location of the self keyword

    self
    ~~~~
    

Send

Represents a method call (e.g. `foo.bar(42)`)

Fields:

  1. recv (MaybeNode)

    Receiver of the method call

    None for implicit method call (e.g. foo(42))

  2. method_name (Str)

    Name of the method that is called

  3. args (Nodes)

    A list of arguments

  4. dot_l (MaybeLoc)

    Location of the . operator

    foo.bar(42)
       ~
    

    None for implicit method call (e.g. foo(42))

  5. 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))

  6. begin_l (MaybeLoc)

    Location of open parenthesis

    foo(42)
       ~
    

    None if there are no parentheses

  7. end_l (MaybeLoc)

    Location of closing parenthesis

    foo(42)
          ~
    

    None if there are no parentheses

  8. operator_l (MaybeLoc)

    Location of the operator if method is a setter

    foo.bar = 42
            ~
    

    None otherwise

  9. expression_l (Loc)

    Location of the full expression

    foo.bar(42)
    ~~~~~~~~~~~
    

Shadowarg

Represents a special block argument that "shadows" outer variable (i.e. `|;foo|`)

Fields:

  1. name (Str)

    Name of the argument

  2. expression_l (Loc)

    Location of the argument

    proc { |;foo|}
             ~~~
    

Splat

Represents an arguments splat (i.e. `*bar` in a call like `foo(*bar)`)

Fields:

  1. value (MaybeNode)

    Value that is converted to array

  2. operator_l (Loc)

    Location of the * operator

    foo(*bar)
        ~
    
  3. expression_l (Loc)

    Location of the full expression

    foo(*bar)
        ~~~~
    

Str

Represents a plain non-interpolated string literal (e.g. `"foo"`)

Fields:

  1. value (StringValue)

    Value of the string literal

    Note that it's a StringValue, not a String. 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 or to_string methods to get a raw string value.

  2. 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])

  3. 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])

  4. expression_l (Loc)

    Location of the full expression

    "foo"
    ~~~~~
    

Super

Represents a `super` keyword

Fields:

  1. args (Nodes)

    A list of arguments given to super

  2. keyword_l (Loc)

    Location of the super keyword

    super(1, 2)
    ~~~~~
    
  3. begin_l (MaybeLoc)

    Location of the open parenthesis

    super(1, 2)
         ~
    

    None if there are no parentheses

  4. end_l (MaybeLoc)

    Location of the closing parenthesis

    super(1, 2)
              ~
    

    None if there are no parentheses

  5. expression_l (Loc)

    Location of the full expression

    super(1, 2)
    ~~~~~~~~~~~
    

Sym

Represents a plain symbol literal (i.e. `:foo`)

Note that `:` in `{ foo: bar }` belongs to a `pair` node.

Fields:

  1. name (StringValue)

    Value of the symbol literal

    Note that it's a StringValue, not a String. 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 or to_string methods to get a raw symbol value.

  2. 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])

  3. 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])

  4. expression_l (Loc)

    Location of the full expression

    :foo
    ~~~~
    
    { foo: 1 }
      ~~~~
    
    %i[foo]
       ~~~
    

True

Represents a `true` literal

Fields:

  1. expression_l (Loc)

    Location of the true keyword

    true
    ~~~~
    

Undef

Represents an `undef` keyword (e.g. `undef foo, :bar`)

Fields:

  1. names (Nodes)

    A list of names to undef

  2. keyword_l (Loc)

    Location the undef keyword

    undef foo, :bar
    ~~~~~
    
  3. expression_l (Loc)

    Location of the full expression

    undef :foo, bar
    ~~~~~~~~~~~~~~~
    

UnlessGuard

Represents an `unless` guard used in pattern matching (i.e. `in pattern unless guard`)

Fields:

  1. cond (Node)

    Condition of the guard, Lvar("foo") in in pattern unless guard

  2. keyword_l (Loc)

    Location of the unless keyword

    case foo; in pattern unless cond; end
                         ~~~~~~
    
  3. expression_l (Loc)

    Location of the full expression

    case foo; in pattern unless cond; end
                         ~~~~~~~~~~~
    

Until

Represents `until` loop

Fields:

  1. cond (Node)

    Condition of the loop

  2. body (MaybeNode)

    Body of the loop.

    None if body is empty

  3. keyword_l (Loc)

    Location of the until keyword

    until cond do; foo; end
    ~~~~~
    
  4. begin_l (MaybeLoc)

    Location of the do keyword

    until cond do; foo; end
               ~~
    

    do is optional, and so begin_l can be None

  5. end_l (MaybeLoc)

    Location of the end keyword

    until cond do; foo; end
                        ~~~
    

    None if loop is a modifier (i.e. foo until bar)

  6. expression_l (Loc)

    Location of the full expression

    until cond do; foo; end
    ~~~~~~~~~~~~~~~~~~~~~~~
    
    foo until bar
    ~~~~~~~~~~~~~
    

UntilPost

Represents a post-until loop

```text
begin
foo
end until bar
```

Fields:

  1. cond (Node)

    Condition of the loop

  2. body (Node)

    Body of the loop

  3. keyword_l (Loc)

    Location of the until keyword

    begin; foo; end until bar
                    ~~~~~
    
  4. expression_l (Loc)

    Location of the until keyword

    begin; foo; end until bar
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    

When

Represents a branch of the `case` statement (i.e. `when foo`)

Fields:

  1. patterns (Nodes)

    A list of values to compare/match against

  2. body (MaybeNode)

    Body of the when branch

  3. keyword_l (Loc)

    Location of the when keyword

    case foo; when bar; end
              ~~~~
    
  4. begin_l (Loc)

    Location of the then keyword

    case foo; when bar then baz; end
                       ~~~~
    

    then is optional, and so begin_l can be None

  5. expression_l (Loc)

    Location of the full expression

    case foo; when bar then baz; end
              ~~~~~~~~~~~~~~~~~
    

While

Represents `while` loop

Fields:

  1. cond (Node)

    Condition of the loop

  2. body (MaybeNode)

    Body of the loop.

    None if body is empty

  3. keyword_l (Loc)

    Location of the while keyword

    while cond do; foo; end
    ~~~~~
    
  4. begin_l (MaybeLoc)

    Location of the do keyword

    while cond do; foo; end
               ~~
    

    do is optional, and so begin_l can be None

  5. end_l (MaybeLoc)

    Location of the end keyword

    while cond do; foo; end
                        ~~~
    

    None if loop is a modifier (i.e. foo while bar)

  6. expression_l (Loc)

    Location of the full expression

    while cond do; foo; end
    ~~~~~~~~~~~~~~~~~~~~~~~
    
    foo while bar
    ~~~~~~~~~~~~~
    

WhilePost

Represents a post-while loop

```text
begin
foo
end while bar
```

Fields:

  1. cond (Node)

    Condition of the loop

  2. body (Node)

    Body of the loop

  3. keyword_l (Loc)

    Location of the while keyword

    begin; foo; end while bar
                    ~~~~~
    
  4. expression_l (Loc)

    Location of the while keyword

    begin; foo; end while bar
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    

XHeredoc

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:

  1. parts (Nodes)

    A list of string parts (static literals and interpolated expressions)

  2. heredoc_body_l (Loc)

    Location of the executable here-document body

    <<-`HERE`\n  a\n   #{42}\nHERE
             ~~~~~~~~~~~~~~~
    
  3. heredoc_end_l (Loc)

    Location of the executable here-document end

    <<-`HERE`\n  a\n   #{42}\nHERE
                              ~~~~
    
  4. 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 has expression_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
    

Xstr

Represents an executable string (i.e. `` `sh #{script_name}` ``)

Fields:

  1. parts (Nodes)

    A list of string parts (static literals and interpolated expressions)

  2. begin_l (Loc)

    Location of the string begin

    `#{foo}`
    ~
    
    %X{#{foo}}
    ~~~
    
  3. end_l (Loc)

    Location of the string end

    `#{foo}`
           ~
    
    %X{#{foo}}
             ~
    
  4. expression_l (Loc)

    Location of the full expression

    `#{foo}`
    ~~~~~~~~
    
    %X{#{foo}}
    ~~~~~~~~~~
    

Yield

Represents an `yield` keyword

Fields:

  1. args (Nodes)

    A list of arguments given to yield

  2. keyword_l (Loc)

    Location of the yield keyword

    yield 1, 2
    ~~~~~
    
  3. begin_l (MaybeLoc)

    Location of the open parenthesis

    yield(1, 2)
         ~
    

    None if there are no parentheses

  4. end_l (MaybeLoc)

    Location of the closing parenthesis

    yield(1, 2)
              ~
    

    None if there are no parentheses

  5. expression_l (Loc)

    Location of the full expression

    yield(1, 2)
    ~~~~~~~~~~~
    

ZSuper

Represents a `super` call without arguments and parentheses

It's different from `super()` as it implicitly forwards current arguments

Fields:

  1. expression_l (Loc)

    Location of the super keyword

    super
    ~~~~~