Integrating canopy (with a demo parser from the canopy docs)

This commit is contained in:
Jeff Avallone
2014-11-24 22:31:20 -05:00
parent fe06a99178
commit ba9b779ba7
8 changed files with 43 additions and 13 deletions
+24
View File
@@ -0,0 +1,24 @@
var through = require('through'),
canopy = require('canopy');
module.exports = function(file) {
if (!/\.peg$/.test(file)) {
return through();
}
var data = '';
return through(
function(buf) {
data += buf;
},
function() {
try {
this.queue(String(canopy.compile(data)));
} catch(err) {
this.emit('error', err);
}
this.queue(null);
}
);
};