I'm trying to write a rule for capturing the expression and arguments of a function call with sweet.js.
Here's my current macro (that fails to match):
macro foo {
rule {
( $fn:expr ($args ...) )
} => {
$fn("stuff", $args ...) // pushes "stuff" to the beginning of the arguments
}
}
And some inputs and expected outputs:
foo(somefn("bar"))
should output:
somefn("stuff", "bar")
and
foo(console.log("bar"))
should output:
console.log("stuff", "bar")
Any assistance would be greatly appreciated.