LESSGOOOO Finally i added some stupid custom syntax :)
This commit is contained in:
parent
19b4b86e20
commit
f0b7b1ba98
3 changed files with 85 additions and 27 deletions
53
.vscode/launch.json
vendored
Normal file
53
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"type": "bun",
|
||||
"request": "launch",
|
||||
"name": "Debug Bun",
|
||||
|
||||
// The path to a JavaScript or TypeScript file to run.
|
||||
"program": "src/index.js",
|
||||
|
||||
// The arguments to pass to the program, if any.
|
||||
"args": [],
|
||||
|
||||
// The working directory of the program.
|
||||
"cwd": "${workspaceFolder}",
|
||||
|
||||
// The environment variables to pass to the program.
|
||||
"env": {},
|
||||
|
||||
// If the environment variables should not be inherited from the parent process.
|
||||
"strictEnv": false,
|
||||
|
||||
// If the program should be run in watch mode.
|
||||
// This is equivalent to passing `--watch` to the `bun` executable.
|
||||
// You can also set this to "hot" to enable hot reloading using `--hot`.
|
||||
"watchMode": false,
|
||||
|
||||
// If the debugger should stop on the first line of the program.
|
||||
"stopOnEntry": false,
|
||||
|
||||
// If the debugger should be disabled. (for example, breakpoints will not be hit)
|
||||
"noDebug": false,
|
||||
|
||||
// The path to the `bun` executable, defaults to your `PATH` environment variable.
|
||||
"runtime": "bun",
|
||||
|
||||
// The arguments to pass to the `bun` executable, if any.
|
||||
// Unlike `args`, these are passed to the executable itself, not the program.
|
||||
"runtimeArgs": [],
|
||||
},
|
||||
{
|
||||
"type": "bun",
|
||||
"request": "attach",
|
||||
"name": "Attach to Bun",
|
||||
|
||||
// The URL of the WebSocket inspector to attach to.
|
||||
// This value can be retrieved by using `bun --inspect`.
|
||||
"url": "ws://localhost:6499/",
|
||||
}
|
||||
]
|
||||
}
|
10
.vscode/settings.json
vendored
Normal file
10
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
// The path to the `bun` executable.
|
||||
"bun.runtime": "/home/rolfmg/.bun/bin/bun",
|
||||
|
||||
// If support for Bun should be added to the default "JavaScript Debug Terminal".
|
||||
"bun.debugTerminal.enabled": true,
|
||||
|
||||
// If the debugger should stop on the first line of the program.
|
||||
"bun.debugTerminal.stopOnEntry": true,
|
||||
}
|
49
src/index.js
49
src/index.js
|
@ -1,35 +1,30 @@
|
|||
import * as babelparser from "../babel/packages/babel-parser/lib";
|
||||
import traverse from "@babel/traverse";
|
||||
import generate from "@babel/generator";
|
||||
import traverse from "../babel/packages/babel-traverse/lib";
|
||||
import generate from "../babel/packages/babel-generator/lib";
|
||||
|
||||
const main = () => {
|
||||
|
||||
let code_To_Insert = "697 + 457";
|
||||
let code_To_Insert = "697 + 457";
|
||||
|
||||
let code = "1 + 1;";
|
||||
let ast = babelparser.parse(code);
|
||||
console.log(ast);
|
||||
let insert_ast = babelparser.parse(code);
|
||||
let code = "1 + 1;";
|
||||
let ast = babelparser.parse(code);
|
||||
console.log(ast);
|
||||
let insert_ast = babelparser.parse(code);
|
||||
|
||||
traverse(ast, {
|
||||
enter(path) {
|
||||
if (path.isBinaryExpression({ operator: "+" })) {
|
||||
path.node.operator = "@@@";
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
traverse(ast, {
|
||||
enter(path){
|
||||
if (path.isBinaryExpression({operator: "+"})){
|
||||
path.node.operator="@@@";
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
console.log(JSON.stringify(ast, null, 4));
|
||||
const out = generate(ast, {}, code);
|
||||
console.log("input: " + code);
|
||||
console.log("output: " + out.code);
|
||||
let inout = babelparser.parse(out.code);
|
||||
console.log(inout);
|
||||
console.log(generate(inout, {}, code));
|
||||
|
||||
|
||||
}
|
||||
|
||||
console.log(JSON.stringify(ast, null, 4));
|
||||
const out = generate(ast, {}, code);
|
||||
console.log("input: " + code);
|
||||
console.log("output: " + out.code);
|
||||
let inout = babelparser.parse(out.code);
|
||||
console.log(inout);
|
||||
console.log(generate(inout, {}, code));
|
||||
};
|
||||
|
||||
main();
|
||||
|
|
Loading…
Reference in a new issue