mirror of
				https://github.com/mermaid-js/mermaid.git
				synced 2025-11-04 04:44:08 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			17 lines
		
	
	
		
			421 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
		
			421 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import jison from 'jison';
 | 
						|
 | 
						|
export const transformJison = (src: string): string => {
 | 
						|
  // @ts-ignore - Jison is not typed properly
 | 
						|
  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}`;
 | 
						|
};
 |