npm install grunt-jison> grunt plugin for jison parser
~0.4.4If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
``shell`
npm install grunt-jison --save-dev
One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
`js`
grunt.loadNpmTasks('grunt-jison');
to the data object passed into grunt.initConfig().`js
grunt.initConfig({
jison: {
target : {
options: {
// Task-specific options go here.
},
files: {
// Target-specific file lists and/or options go here.
}
}
}
})
`$3
#### options.moduleType
Type:
String
Default value: commonjsThe type of module you want to generate with Jison.
Possible values are
commonjs, js and amd.#### options.moduleParser
Type:
String
Default value: lalrThe type of algorithm to use for the parser.
Possible values are
lr0, slr, lalr, lr.#### options.moduleName
Type: String
Default value: parser
When using js for options.moduleType, specifies the
variable name of the parser.
#### Default Options
``js`
grunt.initConfig({
jison: {
my_parser : {
files: { 'generated-parser.js': 'grammar-file.jison' }
}
}
})
#### Custom Options
In this example, we generate a AMD module instead of a standard JS file.
`js`
grunt.initConfig({
jison: {
target : {
options: { moduleType: 'amd' },
files: { 'generated-parser.amd.js': 'grammar-file.jison' }
}
}
})
#### Optional lex file
In this example, we generate a module with a file containing a grammar and a
file containing a lexical grammar.
`js``
grunt.initConfig({
jison: {
target : {
options: { moduleType: 'amd' },
files: { 'generated-parser.amd.js': 'grammar-file.jison', 'lex-file.jisonlex'}
}
}
})