// Generated by CoffeeScript 2.0.0-beta9-dev var CoffeeScript, compile, eachCode; CoffeeScript = require('./module'); eachCode = require('pegjs-each-code'); compile = function (csCode, options) { var csAST, jsAST; if (null == options) options = {}; csAST = CoffeeScript.parse('-> ' + csCode.trimRight()); if (csAST.body.statements.length > 1) throw new Error('inconsistent base indentation'); jsAST = CoffeeScript.compile(csAST, { bare: true, inScope: options.inScope }); jsAST.leadingComments = []; jsAST.body = jsAST.body[0].expression.body.body.concat(jsAST.body.slice(1)); return CoffeeScript.js(jsAST); }; exports.use = function (config) { return config.passes.transform.unshift(function (ast) { ast.initializer.code = CoffeeScript.cs2js(ast.initializer.code, { bare: true }); return eachCode(ast, function (node, labels, ruleName) { var error; try { return node.code = compile(node.code, { inScope: labels }); } catch (e$) { error = e$; throw new Error("In the '" + ruleName + "' rule:\n" + error.message + ''); } }); }); };