RubyParser.new.parse "1+1"
s(:call, s(:lit, 1), :+, s(:array, s(:lit, 1)))
Above code is from this link
Why there is array after + in the Sexp. I am just trying to learn ruby parser and the whole AST thing. I have been programming for a while but have no formal education in computer science. So do point to good article which explains AST etc. Please no dragon book. I tried couple of times but couldn’t understand much of that book
In Ruby (or at least in MRI), all message sends have exactly one argument: an array. If you send a message with no arguments, the array will simply be empty, if you send a message with one argument (as is the case in this example), the array will have one element.