2021-09-30 00:07:57 +02:00
|
|
|
const { Generator } = require('jison');
|
2021-11-25 13:09:38 -08:00
|
|
|
const validate = require('schema-utils');
|
2021-12-11 12:02:39 +01:00
|
|
|
|
|
|
|
const schema = {
|
|
|
|
title: 'Jison Parser options',
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
'token-stack': {
|
|
|
|
type: 'boolean',
|
|
|
|
},
|
|
|
|
debug: {
|
|
|
|
type: 'boolean',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
additionalProperties: false,
|
|
|
|
};
|
2021-09-30 00:07:57 +02:00
|
|
|
|
|
|
|
module.exports = function jisonLoader(source) {
|
|
|
|
const options = this.getOptions();
|
2021-11-25 13:09:38 -08:00
|
|
|
(validate.validate || validate)(schema, options, {
|
2021-09-30 00:07:57 +02:00
|
|
|
name: 'Jison Loader',
|
|
|
|
baseDataPath: 'options',
|
|
|
|
});
|
|
|
|
return new Generator(source, options).generate();
|
|
|
|
};
|