Artifact 7e23af883e94d99022443b551157e24afa3375ba
- File
sample/ast.pmy
- 2010-11-24 13:22:04 - part of checkin [f9c31f3cd8] on branch trunk - Fixed the null dereference bug when directly wrote "case 1 when 2: 3" in REPL. It was due to null LexPosition in the AST. Now AST.pos !is null is an invariant of AST. (user: kinaba) [annotate]
def reverse(lst, acc) { case(lst) when {car:a, cdr: d}: reverse(d, {car:a, cdr:acc}) when {}: acc }; @macro reverseArgs(e) {@value( var ev = @macro(e); case(ev) when {is:"App", fun:f, args:a}: ( ev {args: reverse(a, {})} # {is:"App", fun:f, args:reverse(a, {})} ) when _ : ( ev ) )}; def main() { print( reverseArgs(1 + 2) ); print( reverseArgs(1 - 2) ); }; main()