Sweet.js Macro taking anything passed to macro taking structure failing -
Sweet.js Macro taking anything passed to macro taking structure failing -
i have macro take in code in between parenthesis. pass macro has rules on code. other things in test
, named differently, figured minimal testcase useful here.
macro testimpl { rule { { $lhs:expr $rhs:expr } } => { } } macro test { rule { $code ... } => { testimpl { $code ... } } } testimpl { true true } // works test(true true) // throws next error
here's error message get:
{ name: 'macro', message: 'macro `testimpl` not matched `{} ...`', stx: { token: { type: 3, value: 'testimpl', linenumber: 13, linestart: 98, range: [object], sm_linenumber: 9, sm_linestart: 98, sm_range: [object], leadingcomments: [object] }, context: { mark: 649, context: [object], instnum: 131515 }, deferredcontext: null } } /home/havvy/sweetjs/playground/node_modules/sweet.js/lib/sweet.js:100 throw new syntaxerror(syn.printsyntaxerror(source$2, err)) ^ syntaxerror: [macro] macro `testimpl` not matched `{} ...` 9: rule { $code ... } => { testimpl { $code ... } } ^ @ expand$2 (/home/havvy/sweetjs/playground/node_modules/sweet.js/lib/sweet.js:100:27) @ parse (/home/havvy/sweetjs/playground/node_modules/sweet.js/lib/sweet.js:136:29) @ object.compile (/home/havvy/sweetjs/playground/node_modules/sweet.js/lib/sweet.js:144:19) @ object.exports.run (/home/havvy/sweetjs/playground/node_modules/sweet.js/lib/sjs.js:85:27) @ object.<anonymous> (/home/havvy/sweetjs/playground/node_modules/sweet.js/bin/sjs:7:23) @ module._compile (module.js:456:26) @ object.module._extensions..js (module.js:474:10) @ module.load (module.js:356:32) @ function.module._load (module.js:312:12) @ function.module.runmain (module.js:497:10)
i think missing outer parens in rule test
.
test(true true)
expands to
testimpl { (true true) }
which doesn't match rule in testimpl
.
changing test
rule rule { ($code ...) }
should work.
macros sweet.js
Comments
Post a Comment