Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
disnet committed Oct 11, 2013
1 parent 48900d5 commit 015697b
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 44 deletions.
23 changes: 13 additions & 10 deletions browser/scripts/expander.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,14 @@
} else if (head$363.hasPrototype(Delimiter$205) && delim$373.token.value === '[]') {
return step$362(ArrayLiteral$197.create(head$363), rest$364);
} else if (head$363.hasPrototype(Delimiter$205) && head$363.delim.token.value === '{}') {
return step$362(Block$196.create(head$363), rest$364);
} else if (head$363.hasPrototype(Keyword$203) && (keyword$371.token.value === 'let' && (rest$364[0] && rest$364[0].token.type === parser$101.Token.Identifier || rest$364[0] && rest$364[0].token.type === parser$101.Token.Keyword) && rest$364[1] && rest$364[1].token.value === '=' && rest$364[2] && rest$364[2].token.value === 'macro')) {
var mac$419 = enforest$226(rest$364.slice(2), env$361);
if (!mac$419.result.hasPrototype(AnonMacro$211)) {
throw new Error('expecting an anonymous macro definition in syntax let binding, not: ' + mac$419.result);
}
return step$362(LetMacro$209.create(rest$364[0], mac$419.result.body), mac$419.rest);
} else if (head$363.hasPrototype(Keyword$203) && (keyword$371.token.value === 'var' && rest$364[0])) {
// Call
// record the comma for later
// but dump it for the next loop turn
Expand All @@ -784,14 +792,7 @@
// ObjectGet
// ArrayLiteral
// Block
return step$362(Block$196.create(head$363), rest$364);
} else if (head$363.hasPrototype(Keyword$203) && (keyword$371.token.value === 'let' && (rest$364[0] && rest$364[0].token.type === parser$101.Token.Identifier || rest$364[0] && rest$364[0].token.type === parser$101.Token.Keyword) && rest$364[1] && rest$364[1].token.value === '=' && rest$364[2] && rest$364[2].token.value === 'macro')) {
var mac$419 = enforest$226(rest$364.slice(2), env$361);
if (!mac$419.result.hasPrototype(AnonMacro$211)) {
throw new Error('expecting an anonymous macro definition in syntax let binding, not: ' + mac$419.result);
}
return step$362(LetMacro$209.create(rest$364[0], mac$419.result.body), mac$419.rest);
} else if (head$363.hasPrototype(Keyword$203) && (keyword$371.token.value === 'var' && rest$364[0])) {
// VariableStatement
var vsRes$420 = enforestVarStatement$224(rest$364, env$361);
if (vsRes$420) {
return step$362(VariableStatement$217.create(head$363, vsRes$420.result), vsRes$420.rest);
Expand Down Expand Up @@ -1127,7 +1128,9 @@
var expandedArgs$486 = expand$233([flatArgs$485], env$474, newDef$479, templateMap$476);
parser$101.assert(expandedArgs$486.length === 1, 'should only get back one result');
// stitch up the function with all the renamings
term$473.params = expandedArgs$486[0];
if (term$473.params) {
term$473.params = expandedArgs$486[0];
}
if (term$473.hasPrototype(Module$219)) {
bodyTerms$483[0].body.delim.token.inner = _$100.filter(bodyTerms$483[0].body.delim.token.inner, function (innerTerm$494) {
if (innerTerm$494.hasPrototype(Export$221)) {
Expand Down Expand Up @@ -1188,7 +1191,7 @@
syn$102.makeIdent('module', null),
modBody$508
], env$506);
return flatten$235(res$509[0].body.token.inner);
return flatten$235(res$509[0].body.expose().token.inner);
}
// break delimiter tree structure down to flat array of syntax objects
function flatten$235(stx$516) {
Expand Down
27 changes: 16 additions & 11 deletions browser/scripts/sjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,37 @@ exports.run = function () {
var mod$107 = argv$100.module;
var cwd$108 = process.cwd();
var Module$109 = module.constructor;
var modulepath$110, modulefile$111, modulemock$112;
var modulemock$110;
if (mod$107) {
modulemock$112 = {
modulemock$110 = {
id: cwd$108 + '/$sweet-loader.js',
filename: '$sweet-loader.js',
paths: /^\.\/|\.\./.test(cwd$108) ? [cwd$108] : Module$109._nodeModulePaths(cwd$108)
};
modulepath$110 = Module$109._resolveFilename(mod$107, modulemock$112);
modulefile$111 = fs$97.readFileSync(modulepath$110, 'utf8');
file$106 = modulefile$111 + '\n' + file$106;
if (typeof mod$107 === 'string') {
mod$107 = [mod$107];
}
file$106 = mod$107.reduceRight(function (f$111, m$112) {
var modulepath$113 = Module$109._resolveFilename(m$112, modulemock$110);
var modulefile$114 = fs$97.readFileSync(modulepath$113, 'utf8');
return modulefile$114 + '\n' + f$111;
}, file$106);
}
if (watch$103 && outfile$102) {
fs$97.watch(infile$101, function () {
file$106 = fs$97.readFileSync(infile$101, 'utf8');
try {
fs$97.writeFileSync(outfile$102, sweet$99.compile(file$106), 'utf8');
} catch (e$113) {
console.log(e$113);
} catch (e$115) {
console.log(e$115);
}
});
} else if (outfile$102) {
if (sourcemap$105) {
var result$114 = sweet$99.compileWithSourcemap(file$106, infile$101);
var mapfile$115 = path$98.basename(outfile$102) + '.map';
fs$97.writeFileSync(outfile$102, result$114[0] + '\n//# sourceMappingURL=' + mapfile$115, 'utf8');
fs$97.writeFileSync(outfile$102 + '.map', result$114[1], 'utf8');
var result$116 = sweet$99.compileWithSourcemap(file$106, infile$101);
var mapfile$117 = path$98.basename(outfile$102) + '.map';
fs$97.writeFileSync(outfile$102, result$116[0] + '\n//# sourceMappingURL=' + mapfile$117, 'utf8');
fs$97.writeFileSync(outfile$102 + '.map', result$116[1], 'utf8');
} else {
fs$97.writeFileSync(outfile$102, sweet$99.compile(file$106), 'utf8');
}
Expand Down
16 changes: 15 additions & 1 deletion browser/scripts/syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,21 @@
if (typeof val$165 === 'boolean') {
return mkSyntax$111(stx$166, val$165 ? 'true' : 'false', parser$102.Token.BooleanLiteral);
} else if (typeof val$165 === 'number') {
return mkSyntax$111(stx$166, val$165, parser$102.Token.NumericLiteral);
if (val$165 !== val$165) {
return makeDelim$117('()', [
makeValue$112(0, stx$166),
makePunc$116('/', stx$166),
makeValue$112(0, stx$166)
], stx$166);
}
if (val$165 < 0) {
return makeDelim$117('()', [
makePunc$116('-', stx$166),
makeValue$112(Math.abs(val$165), stx$166)
], stx$166);
} else {
return mkSyntax$111(stx$166, val$165, parser$102.Token.NumericLiteral);
}
} else if (typeof val$165 === 'string') {
return mkSyntax$111(stx$166, val$165, parser$102.Token.StringLiteral);
} else if (val$165 === null) {
Expand Down
23 changes: 13 additions & 10 deletions lib/expander.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,14 @@
} else if (head$363.hasPrototype(Delimiter$205) && delim$373.token.value === '[]') {
return step$362(ArrayLiteral$197.create(head$363), rest$364);
} else if (head$363.hasPrototype(Delimiter$205) && head$363.delim.token.value === '{}') {
return step$362(Block$196.create(head$363), rest$364);
} else if (head$363.hasPrototype(Keyword$203) && (keyword$371.token.value === 'let' && (rest$364[0] && rest$364[0].token.type === parser$101.Token.Identifier || rest$364[0] && rest$364[0].token.type === parser$101.Token.Keyword) && rest$364[1] && rest$364[1].token.value === '=' && rest$364[2] && rest$364[2].token.value === 'macro')) {
var mac$419 = enforest$226(rest$364.slice(2), env$361);
if (!mac$419.result.hasPrototype(AnonMacro$211)) {
throw new Error('expecting an anonymous macro definition in syntax let binding, not: ' + mac$419.result);
}
return step$362(LetMacro$209.create(rest$364[0], mac$419.result.body), mac$419.rest);
} else if (head$363.hasPrototype(Keyword$203) && (keyword$371.token.value === 'var' && rest$364[0])) {
// Call
// record the comma for later
// but dump it for the next loop turn
Expand All @@ -784,14 +792,7 @@
// ObjectGet
// ArrayLiteral
// Block
return step$362(Block$196.create(head$363), rest$364);
} else if (head$363.hasPrototype(Keyword$203) && (keyword$371.token.value === 'let' && (rest$364[0] && rest$364[0].token.type === parser$101.Token.Identifier || rest$364[0] && rest$364[0].token.type === parser$101.Token.Keyword) && rest$364[1] && rest$364[1].token.value === '=' && rest$364[2] && rest$364[2].token.value === 'macro')) {
var mac$419 = enforest$226(rest$364.slice(2), env$361);
if (!mac$419.result.hasPrototype(AnonMacro$211)) {
throw new Error('expecting an anonymous macro definition in syntax let binding, not: ' + mac$419.result);
}
return step$362(LetMacro$209.create(rest$364[0], mac$419.result.body), mac$419.rest);
} else if (head$363.hasPrototype(Keyword$203) && (keyword$371.token.value === 'var' && rest$364[0])) {
// VariableStatement
var vsRes$420 = enforestVarStatement$224(rest$364, env$361);
if (vsRes$420) {
return step$362(VariableStatement$217.create(head$363, vsRes$420.result), vsRes$420.rest);
Expand Down Expand Up @@ -1127,7 +1128,9 @@
var expandedArgs$486 = expand$233([flatArgs$485], env$474, newDef$479, templateMap$476);
parser$101.assert(expandedArgs$486.length === 1, 'should only get back one result');
// stitch up the function with all the renamings
term$473.params = expandedArgs$486[0];
if (term$473.params) {
term$473.params = expandedArgs$486[0];
}
if (term$473.hasPrototype(Module$219)) {
bodyTerms$483[0].body.delim.token.inner = _$100.filter(bodyTerms$483[0].body.delim.token.inner, function (innerTerm$494) {
if (innerTerm$494.hasPrototype(Export$221)) {
Expand Down Expand Up @@ -1188,7 +1191,7 @@
syn$102.makeIdent('module', null),
modBody$508
], env$506);
return flatten$235(res$509[0].body.token.inner);
return flatten$235(res$509[0].body.expose().token.inner);
}
// break delimiter tree structure down to flat array of syntax objects
function flatten$235(stx$516) {
Expand Down
27 changes: 16 additions & 11 deletions lib/sjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,37 @@ exports.run = function () {
var mod$107 = argv$100.module;
var cwd$108 = process.cwd();
var Module$109 = module.constructor;
var modulepath$110, modulefile$111, modulemock$112;
var modulemock$110;
if (mod$107) {
modulemock$112 = {
modulemock$110 = {
id: cwd$108 + '/$sweet-loader.js',
filename: '$sweet-loader.js',
paths: /^\.\/|\.\./.test(cwd$108) ? [cwd$108] : Module$109._nodeModulePaths(cwd$108)
};
modulepath$110 = Module$109._resolveFilename(mod$107, modulemock$112);
modulefile$111 = fs$97.readFileSync(modulepath$110, 'utf8');
file$106 = modulefile$111 + '\n' + file$106;
if (typeof mod$107 === 'string') {
mod$107 = [mod$107];
}
file$106 = mod$107.reduceRight(function (f$111, m$112) {
var modulepath$113 = Module$109._resolveFilename(m$112, modulemock$110);
var modulefile$114 = fs$97.readFileSync(modulepath$113, 'utf8');
return modulefile$114 + '\n' + f$111;
}, file$106);
}
if (watch$103 && outfile$102) {
fs$97.watch(infile$101, function () {
file$106 = fs$97.readFileSync(infile$101, 'utf8');
try {
fs$97.writeFileSync(outfile$102, sweet$99.compile(file$106), 'utf8');
} catch (e$113) {
console.log(e$113);
} catch (e$115) {
console.log(e$115);
}
});
} else if (outfile$102) {
if (sourcemap$105) {
var result$114 = sweet$99.compileWithSourcemap(file$106, infile$101);
var mapfile$115 = path$98.basename(outfile$102) + '.map';
fs$97.writeFileSync(outfile$102, result$114[0] + '\n//# sourceMappingURL=' + mapfile$115, 'utf8');
fs$97.writeFileSync(outfile$102 + '.map', result$114[1], 'utf8');
var result$116 = sweet$99.compileWithSourcemap(file$106, infile$101);
var mapfile$117 = path$98.basename(outfile$102) + '.map';
fs$97.writeFileSync(outfile$102, result$116[0] + '\n//# sourceMappingURL=' + mapfile$117, 'utf8');
fs$97.writeFileSync(outfile$102 + '.map', result$116[1], 'utf8');
} else {
fs$97.writeFileSync(outfile$102, sweet$99.compile(file$106), 'utf8');
}
Expand Down
16 changes: 15 additions & 1 deletion lib/syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,21 @@
if (typeof val$165 === 'boolean') {
return mkSyntax$111(stx$166, val$165 ? 'true' : 'false', parser$102.Token.BooleanLiteral);
} else if (typeof val$165 === 'number') {
return mkSyntax$111(stx$166, val$165, parser$102.Token.NumericLiteral);
if (val$165 !== val$165) {
return makeDelim$117('()', [
makeValue$112(0, stx$166),
makePunc$116('/', stx$166),
makeValue$112(0, stx$166)
], stx$166);
}
if (val$165 < 0) {
return makeDelim$117('()', [
makePunc$116('-', stx$166),
makeValue$112(Math.abs(val$165), stx$166)
], stx$166);
} else {
return mkSyntax$111(stx$166, val$165, parser$102.Token.NumericLiteral);
}
} else if (typeof val$165 === 'string') {
return mkSyntax$111(stx$166, val$165, parser$102.Token.StringLiteral);
} else if (val$165 === null) {
Expand Down

0 comments on commit 015697b

Please sign in to comment.