The AST is pretty normalized out of the box. The trick is to use `nnkCallKinds`.
    
    
    import macros
    
    macro swapArgs(n: untyped): untyped =
      if n.kind in nnkCallKinds:
        let tmp = n[2]
        n[2] = n[1]
        n[1] = tmp
      result = n
    
    echo swapArgs(5 - 6)
    echo swapArgs(`-`(5, 6))
    

Dot calls are special because they are ambiguous; `a.f(x)` can really mean 
"call field 'f' in 'a' with argument 'x' " instead of "call f with a, x" and so 
we cannot normalize it before your macro gets to see it. 

Reply via email to