Integrating canopy (with a demo parser from the canopy docs)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user