A loader for webpack which transforms .jison files into JS code.
Install the package using npm
:
$ npm install jison-gho-loader --save-dev
// 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);
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);
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.