2024-07-09 08:10:33 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2024 Puter Technologies Inc.
|
2024-07-10 20:12:09 +00:00
|
|
|
*
|
2024-07-09 08:10:33 +00:00
|
|
|
* This file is part of Puter.
|
2024-07-10 20:12:09 +00:00
|
|
|
*
|
2024-07-09 08:10:33 +00:00
|
|
|
* Puter is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published
|
|
|
|
* by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2024-07-10 20:12:09 +00:00
|
|
|
*
|
2024-07-09 08:10:33 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
2024-07-10 20:12:09 +00:00
|
|
|
*
|
2024-07-09 08:10:33 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2024-07-10 20:12:09 +00:00
|
|
|
|
|
|
|
|
2024-07-09 07:40:34 +00:00
|
|
|
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);
|