2020-01-31 05:26:46 +03:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const fs = require("fs");
|
2020-09-23 06:18:45 +03:00
|
|
|
const { resolve } = require("path");
|
2020-01-31 05:26:46 +03:00
|
|
|
|
|
|
|
const jison = require("jison")
|
|
|
|
|
2020-09-23 06:18:45 +03:00
|
|
|
const grammar = fs.readFileSync(resolve(__dirname, "grammar.jison")).toString();
|
2020-01-31 05:26:46 +03:00
|
|
|
|
|
|
|
const parser = new jison.Parser(grammar);
|
|
|
|
|
|
|
|
const parserSource = parser.generate({ moduleName: "parser" });
|
|
|
|
|
2020-11-15 01:42:36 +03:00
|
|
|
const esmSuffix = `
|
|
|
|
|
|
|
|
// Added By ../generate.js
|
|
|
|
const parse = exports.parse;
|
|
|
|
export { parse, parser }
|
|
|
|
`;
|
|
|
|
|
2020-09-23 06:18:45 +03:00
|
|
|
fs.writeFileSync(resolve(__dirname, "./lib/_parser.js"), parserSource);
|
2020-11-15 01:42:36 +03:00
|
|
|
fs.writeFileSync(resolve(__dirname, "./lib._esm/_parser.js"), parserSource + esmSuffix);
|