2024-02-24 21:30:30 +00:00
|
|
|
//import * as babelparser from "../babel/packages/babel-parser";
|
|
|
|
import * as babelparser from "@babel/parser";
|
|
|
|
//import core from "../babel/packages/babel-core";
|
|
|
|
import { parse_with_plugins } from "./parser/parse";
|
2024-05-11 14:09:03 +00:00
|
|
|
import {
|
|
|
|
SelfHostedRecipe,
|
|
|
|
TransformRecipe,
|
|
|
|
transform,
|
|
|
|
} from "./transform/transform";
|
2024-05-23 11:46:40 +00:00
|
|
|
import { readdir } from "node:fs/promises";
|
2024-05-11 14:09:03 +00:00
|
|
|
import { parseJSTQL } from "./langium/langiumRunner";
|
2024-05-19 17:53:14 +00:00
|
|
|
|
|
|
|
const dir = "../prettier/src";
|
|
|
|
|
2024-05-23 11:46:40 +00:00
|
|
|
const path = "test_files/pipeline_test.js";
|
2024-02-24 21:30:30 +00:00
|
|
|
const file = Bun.file(path);
|
|
|
|
const codeFromFile = await file.text();
|
|
|
|
const main = async () => {
|
2024-05-11 14:09:03 +00:00
|
|
|
//transform(selfHostedTransformExampleMultiStmt, codeFromFile);
|
2024-05-23 11:46:40 +00:00
|
|
|
/*
|
2024-05-19 17:53:14 +00:00
|
|
|
console.log(codeFromFile);
|
2024-05-11 14:09:03 +00:00
|
|
|
const jstql_file =
|
2024-05-23 11:46:40 +00:00
|
|
|
"/home/rolfmg/Coding/Master/didactic-chainsaw/dsl_files/pipeline.jstql";
|
2024-05-11 14:09:03 +00:00
|
|
|
const test_file = Bun.file(jstql_file);
|
|
|
|
const test_JSTQL = await test_file.text();
|
2024-05-12 18:06:37 +00:00
|
|
|
let proposals = await parseJSTQL(test_JSTQL);
|
|
|
|
|
2024-05-23 11:46:40 +00:00
|
|
|
let [code, count] = transform(proposals[0].cases, codeFromFile);
|
|
|
|
await Bun.write("output_files/pipeline_out.js", code);
|
|
|
|
return;
|
|
|
|
*/
|
|
|
|
const jstql_file =
|
|
|
|
"/home/rolfmg/Coding/Master/didactic-chainsaw/dsl_files/pipeline.jstql";
|
|
|
|
const test_file = Bun.file(jstql_file);
|
|
|
|
const test_JSTQL = await test_file.text();
|
|
|
|
let proposals = await parseJSTQL(test_JSTQL);
|
|
|
|
|
|
|
|
let basepathExamplesJSFiles = "../next.js";
|
|
|
|
let examples = (await readdir(basepathExamplesJSFiles, { recursive: true }))
|
|
|
|
.filter((x) => x.endsWith(".js"))
|
|
|
|
.map((x) => basepathExamplesJSFiles + "/" + x);
|
|
|
|
console.log(examples);
|
|
|
|
|
|
|
|
let sum = 0;
|
|
|
|
console.log("Scripts found ", sum, "matches!");
|
|
|
|
let count = 0;
|
|
|
|
for (let examplesFile of examples) {
|
|
|
|
try {
|
|
|
|
if (examplesFile.split("/").includes("compiled")) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
console.log(examplesFile);
|
|
|
|
let script = await Bun.file(examplesFile).text();
|
|
|
|
let [resultString, matches] = transform(proposals[0].cases, script);
|
|
|
|
sum += matches;
|
|
|
|
if (matches > 0) {
|
|
|
|
await Bun.write(
|
|
|
|
"output_testing/" + count + examplesFile.split("/").at(-1),
|
|
|
|
resultString
|
|
|
|
);
|
|
|
|
count += 1;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.log("Failed");
|
|
|
|
}
|
|
|
|
console.log("current sum", sum);
|
|
|
|
}
|
|
|
|
console.log(sum);
|
2023-12-11 18:38:30 +00:00
|
|
|
};
|
2023-12-06 12:44:49 +00:00
|
|
|
|
|
|
|
main();
|