mozilla/sweet.js — pull request #246 by disnet (2014-02-07 06:37:09+00:00)
Title: revised withSyntax to update the patternEnv directly

Rather than have `withSyntax` be an expansion of `syntaxCase` use the approach of #216 but localized rather than trying to simulate the full lexical scope of a `let` binding.

To get a sense of how it works:

```js
function foo() {
return withSyntax ($y = [makeValue(42, null)]) {
return withSyntax ($z = [makeValue(100, null)]) {
return #{$x + $y + $z}
}
}
}
```
expands:
```js
function foo() {
return function () {
var res = function () {
match.patternEnv = patternModule.extendEnv(match.patternEnv);
match.patternEnv['$y'] = {
level: 0,
match: [makeValue(42, null)]
};
return function () {
var res$2 = function () {
match.patternEnv = patternModule.extendEnv(match.patternEnv);
match.patternEnv['$z'] = {
level: 0,
match: [makeValue(100, null)]
};
return patternModule.transcribe(getTemplate(339), name_stx, match.patternEnv);
}();
match.patternEnv = match.patternEnv.parent;
return res$2;
}();
}();
match.patternEnv = match.patternEnv.parent;
return res;
}();
}
```

@natefaubion does this look good to you?