Gulp plugin for PEG parsers compilation.
Install plugin
npm install gulp-peg --save-dev
Add peg-compilation task into your gulp-file:
var $ = require('gulp-load-plugins')();
gulp.task('pegjs', function () {
return gulp
.src(paths.src + '/{app,components}/**/*.pegjs')
.pipe($.peg({
angular: {
module: "angularModuleName",
factory: "factoryName"
}
}).on('error', function handleError(err) {
console.error(err.toString());
this.emit('end');
}))
.pipe(gulp.dest(paths.src))
});
Finish
Plugin redirects passed options directly to PEG, so read its documentation for details.
The generated source can be wrapped in different ways:
This option is inspired by grunt-peg plugin, and defines variable to which the generated parser will be assigned in the output file. Default value is module.exports
.
This option is inspired by grunt-peg plugin. It creates an Angular module with a factory containing the generated source.