Skip to content

codegraft/grunt-jison

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grunt-jison Build Status

grunt plugin for jison parser

Getting Started

This plugin requires Grunt ~0.4.4

If 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:

npm install grunt-jison --save-dev

One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-jison');

The "jison" task

Overview

In your project's Gruntfile, add a section named jison to the data object passed into grunt.initConfig().

grunt.initConfig({
  jison: {
    target : {
    	options: {
      	// Task-specific options go here.
    	},
    	files: {
      	// Target-specific file lists and/or options go here.
    	}
     }
  }
})

Options

options.moduleType

Type: String Default value: commonjs

The type of module you want to generate with Jison. Possible values are commonjs, js and amd.

options.moduleParser

Type: String Default value: lalr

The 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.

Usage Examples

Default Options

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.

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.

grunt.initConfig({
  jison: {
    target : {
      options: { moduleType: 'amd' },
      files: { 'generated-parser.amd.js': ['grammar-file.jison',  'lex-file.jisonlex'}
    }
  }
})

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

(Nothing yet)

About

grunt plugin for jison parser

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%