tolkfmt-test-dev
Version:
Code formatter for the Tolk programming language
29 lines (25 loc) • 841 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const parser_1 = require("./parser");
const comments_1 = require("./comments");
const render_1 = require("./render");
const node_1 = require("./print/node");
const main = async () => {
await (0, parser_1.initParser)("../wasm/tree-sitter.wasm", "../wasm/tree-sitter-tolk.wasm");
const parser = (0, parser_1.createTolkParser)();
const cst = parser.parse(`
// aaa
// bbbb
// aaaa
fun foo() {}
`);
if (!cst?.rootNode)
throw new Error(`Unable to parse file`);
const ctx = { comments: (0, comments_1.bindComments)(cst.rootNode), sortImports: true };
const doc = (0, node_1.printNode)(cst.rootNode, ctx);
if (doc) {
console.log((0, render_1.render)(doc, 100) + "---");
}
};
void main();
//# sourceMappingURL=main.js.map