mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
37 lines
789 B
JavaScript
37 lines
789 B
JavaScript
const babelParser = require('@babel/parser');
|
|
const generate = (require('@babel/generator')).default;
|
|
const fs = require('fs');
|
|
|
|
const recast = require('recast');
|
|
|
|
const example = fs.readFileSync('./src/backend/src/filesystem/ll_operations/ll_read.js');
|
|
|
|
{
|
|
const ast = recast.parse(example, {
|
|
parser: {
|
|
parse (source) {
|
|
return babelParser.parse(source, {
|
|
ranges: true,
|
|
tokens: true,
|
|
});
|
|
},
|
|
},
|
|
});
|
|
const { code } = recast.print(ast);
|
|
}
|
|
|
|
{
|
|
const ast = babelParser.parse('' + example, {
|
|
tokens: true,
|
|
});
|
|
|
|
console.log(JSON.stringify(ast, undefined, ' '));
|
|
}
|
|
|
|
/*
|
|
const { code } = generate(ast, {
|
|
retainLines: true,
|
|
});
|
|
*/
|
|
|
|
// console.log(code);
|