mermaid/.vite/jisonTransformer.js

16 lines
359 B
JavaScript
Raw Normal View History

2022-09-22 15:35:22 +05:30
import jison from 'jison';
export const transformJison = (src) => {
const parser = new jison.Generator(src, {
moduleType: 'js',
'token-stack': true,
});
const source = parser.generate({ moduleMain: '() => {}' });
const exporter = `
parser.parser = parser;
export { parser };
export default parser;
`;
return `${source} ${exporter}`;
};