jison-gho-loader
v1.0.2
Published
A loader for webpack which transforms .jison files into JS code.
Downloads
3
Maintainers
Readme
jison-gho-loader
A loader for webpack which transforms .jison files into JS code.
Usage
Install the package using npm
:
$ npm install jison-gho-loader --save-dev
Ad-hoc use
// RequireJS
const parser = require('jison-gho-loader!./grammar.jison').parser;
// import/export
import {parser} from 'jison-gho-loader!./grammar.jison';
const result = parser.parse(input_to_parse);
Webpack config
Your webpack.config.js
should contain:
module.exports = {
module: {
rules: [
{
test: /\.jison$/,
use: 'jison-gho-loader'
}
]
}
}
And then just import the grammar.jison
without loader prefix:
// RequireJS
const parser = require('./grammar.jison').parser;
// import/export
import {parser} from './grammar.jison';
const result = parser.parse(input_to_parse);
Options
You can specify options that can be sent to the jison-gho
like which parser type to use
(lalr, ll, lr, etc). Example:
module.exports = {
module: {
rules: [
{
test: /\.jison$/,
use: {
loader: 'jison-gho-loader',
options: { parserType: 'lr0' }
}
}
]
}
}
All options can be found in the index.js
file.
License
MIT (http://www.opensource.org/licenses/mit-license.php)