Error parsing JS that contains an identifier `macro`
Created by: BinaryMuse
I have been working on integrating Sweet.js into part of our build workflow and ran into an issue where the parser throws due to encountering an identifier macro
that doesn't define a macro. (A macro is a first-class business entity in our system.) Is there a good way to work around this issue?
Here's a small reproducible test case:
macro id {
rule {
($x)
} => {
$x
}
}
function printMacro(macro) {
if (!macro) console.log('not defined');
else console.log(macro);
}
$ sjs file.js
/Users/btilley/.nvm/v0.10.26/lib/node_modules/sweet.js/lib/sweet.js:99
throw new SyntaxError(syn.printSyntaxError(source, err));
^
SyntaxError: [enforest] Macro declaration must include body
at expand$2 (/Users/btilley/.nvm/v0.10.26/lib/node_modules/sweet.js/lib/sweet.js:99:27)
at parse (/Users/btilley/.nvm/v0.10.26/lib/node_modules/sweet.js/lib/sweet.js:113:29)
at Object.compile (/Users/btilley/.nvm/v0.10.26/lib/node_modules/sweet.js/lib/sweet.js:121:19)
at Object.exports.run (/Users/btilley/.nvm/v0.10.26/lib/node_modules/sweet.js/lib/sjs.js:70:27)
at Object.<anonymous> (/Users/btilley/.nvm/v0.10.26/lib/node_modules/sweet.js/bin/sjs:7:23)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
Using Sweet.js version 0.5.0.
Thanks!