blob: 977077a339de8876762bc90b8eb13dfa6efc0ffb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import peggy from 'peggy';
const tspegjs: any = require('ts-pegjs');
export const GRAMMAR_FILE = 'grammar.pegjs';
export const GENERATED_PARSER = 'parser.ts';
export const generateParser = async (file: string, output: string) => {
const grammar = await Bun.file(file).text();
const parserSrc = peggy.generate(grammar, {
format: 'commonjs',
plugins: [tspegjs],
output: 'source',
});
await Bun.write(output, parserSrc);
};
|