From 64dbdd97baaefbc02d1558320bdcc00345ea7376 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 29 Dec 2023 21:27:54 +0100 Subject: [PATCH] little update --- packages/haskell/.gitignore | 3 ++- packages/haskell/README.md | 6 ++++++ packages/haskell/main.js | 8 ++++++-- packages/haskell/public/README.md | 3 +++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 packages/haskell/public/README.md diff --git a/packages/haskell/.gitignore b/packages/haskell/.gitignore index 30378b91..213c8054 100644 --- a/packages/haskell/.gitignore +++ b/packages/haskell/.gitignore @@ -23,4 +23,5 @@ dist-ssr *.sln *.sw? -public/tree-sitter.wasm \ No newline at end of file +public/tree-sitter.wasm +public/tree-sitter-haskell.wasm \ No newline at end of file diff --git a/packages/haskell/README.md b/packages/haskell/README.md index 2769a416..0143b93e 100644 --- a/packages/haskell/README.md +++ b/packages/haskell/README.md @@ -23,3 +23,9 @@ I've tried to generate it using , without a new npm package version being released, which is why I've written this comment: . So either someone authorized releases a new version of the package or we might need to pull the changes and try to build it from the tree-sitter master branch. + +## Update 1 + +I've managed to make it work by using [this tree-sitter-haskell.wasm](https://github.com/tree-sitter/tree-sitter-haskell/blob/master/tree-sitter-haskell.wasm), instead of using the version on npm! Make sure both `tree-sitter.wasm` and `tree-sitter-haskell.wasm` are in the public dir, then run `pnpm dev`. The console should log a tree sitter AST string. + +Next step: understand how the ast works to then transform it into JS function calls! diff --git a/packages/haskell/main.js b/packages/haskell/main.js index e7d2c78b..dd96e32f 100644 --- a/packages/haskell/main.js +++ b/packages/haskell/main.js @@ -2,6 +2,10 @@ import Parser from 'web-tree-sitter'; console.log('Parser', Parser); -Parser.init().then(() => { - console.log('init done..'); +Parser.init().then(async () => { + const parser = new Parser(); + const Lang = await Parser.Language.load('tree-sitter-haskell.wasm'); + parser.setLanguage(Lang); + const tree = parser.parse('d1 $ s "hh*3"'); + console.log(tree.rootNode.toString()); }); diff --git a/packages/haskell/public/README.md b/packages/haskell/public/README.md new file mode 100644 index 00000000..6f8ff001 --- /dev/null +++ b/packages/haskell/public/README.md @@ -0,0 +1,3 @@ +# public + +this file is just here to make sure the public folder exists