transforms rules before recursion sort, attaches cursors to root of AST