What is the meaning of the 'send' keyword in Ruby's AST?

Viewed 350

I am trying to learn the Ruby lexer and parser (whitequark parser) to know more about the procedure to further generate machine code from a Ruby script.

On parsing the following Ruby code string.

def add(a, b)
    return a + b
end

puts add 1, 2

It results in the following S-expression notation.

s(:begin,
    s(:def, :add,
        s(:args,
            s(:arg, :a),
            s(:arg, :b)),
        s(:return,
            s(:send,
                s(:lvar, :a), :+,
                s(:lvar, :b)))),
    s(:send, nil, :puts,
        s(:send, nil, :add,
            s(:int, 1),
            s(:int, 3))))

Can anyone please explain me the definition of the :send keyword in the resultant S-expression notation?

2 Answers
Related