mermaid/.esbuild/jisonTransformer.cjs

15 lines
360 B
JavaScript
Raw Normal View History

2022-09-20 21:14:56 +05:30
const { Generator } = require('jison');
exports.transformJison = (src) => {
2022-09-20 21:14:56 +05:30
const parser = new Generator(src, {
moduleType: 'js',
'token-stack': true,
});
const source = parser.generate({ moduleMain: '() => {}' });
const exporter = `
2022-09-20 21:14:56 +05:30
parser.parser = parser;
export { parser };
export default parser;
`;
2022-09-20 21:14:56 +05:30
return `${source} ${exporter}`;
};