I am trying to write a sweet macro but have some troubles.
macro to_str {
case { _ ($tok) } => {
return [makeValue(unwrapSyntax(#{$tok}) + '=', #{ here })];
}
}
macro foo {
rule {($vars (,) ...) } => {
$(to_str($vars) + $vars) (,) ...
}
}
foo(a, b) should expand to
'a=' + a , 'b=' + b
And it works as expected.
But if one of the arguments is another macro, there will be some faults.
E.g. there is a macro named 'bar', then foo(a, bar) will cause below error:
SyntaxError: [macro] Macro `bar` could not be matched with `...`
80: foo(a, bar)
How can I fix this problem? Thanks