mermaid/.build/jisonTransformer.ts

17 lines
421 B
TypeScript
Raw Permalink Normal View History

2022-09-22 15:35:22 +05:30
import jison from 'jison';
2022-09-23 10:56:39 +05:30
export const transformJison = (src: string): string => {
2024-05-21 22:24:04 +05:30
// @ts-ignore - Jison is not typed properly
2022-09-22 15:35:22 +05:30
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}`;
};