mozilla/sweet.js — pull request #404 by r3m0t (2014-10-16 21:10:13+00:00)
Title: Allow # in readtable

The command line script reads stxcase.js with a user-provided readtable which makes it impossible to define a # behaviour and use it from the `sjs` command.

Example:
```readtable.js
var sweetjs = require('sweet.js');
var recursed = false;
module.exports = sweetjs.currentReadtable().extend({
'#': function (ch, reader, toks, source, index) {
if (recursed) return null;
var start = reader.index;
var tok;
recursed = true;
reader.readToken(); // read the #
tok = reader.suppressReadError(reader.readDelimiter);
recursed = false;
if (tok !== null && tok.value == '{}') {
// looks like #{ } form
return null;
}
return [reader.makePunctuator('+', { start: start })];
}
});
```

```a.js
macro m {
case {_ $x } => {
var y = makeValue(42, #{$x});
return [y]
}
}
m foo # 5
```

Invocation:
`bin/sjs -l ./readtable.js -s < ./a.js`