Class | Rewriter |
In: |
lib/rewriter.rb
|
Parent: | SexpProcessor |
Rewriter (probably should be renamed) is a first-pass filter that normalizes some of ruby‘s ASTs to make them more processable later in the pipeline. It only has processors for what it is interested in, so real the individual methods for a better understanding of what it does.
Rewrites :attrasgn nodes to the unified :call format:
[:attrasgn, lhs, :name=, args],
becomes:
[:call, lhs, :name=, args]
Rewrites :defn nodes to pull the functions arguments to the top:
Input:
[:defn, name, [:scope, [:block, [:args, ...]]]] [:defn, name, [:fbody, [:scope, [:block, [:args, ...]]]]] [:defn, name, [:ivar, name]] [:defn, name, [:attrset, name]]
Output:
[:defn, name, args, body]
I‘m not really sure what this is for, other than to guarantee that there are 4 elements in the sexp.