Comments (6)
Compiling web-tree-sitter
using ASSERTIONS=1
, via script/build-wasm --debug
, refines the error message to:
Aborted(Assertion failed: undefined symbol `_ZTVN10__cxxabiv117__class_type_infoE`.
perhaps a side module was not linked in?
if this global was expected to arrive from a system library,
try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment)
Compiling with EMCC_FORCE_STDLIBS=1
does not make a difference.
from tree-sitter-haskell.
The issue is that web-tree-sitter
performs dead code elimination, and eliminates all but a select few functions listed in exports.json. The following patch to tree-sitter
ensures that the functions used by tree-sitter-haskell
are kept:
diff --git a/lib/binding_web/exports.json b/lib/binding_web/exports.json
index e0b3f718..36342e52 100644
--- a/lib/binding_web/exports.json
+++ b/lib/binding_web/exports.json
@@ -3,6 +3,15 @@
"_free",
"_malloc",
+ "__ZNSt3__24cerrE",
+ "__ZNSt3__25ctypeIcE2idE",
+ "__ZTVN10__cxxabiv117__class_type_infoE",
+ "__ZTVN10__cxxabiv120__si_class_type_infoE",
+ "__ZTVN10__cxxabiv120__function_type_infoE",
+ "__ZTVN10__cxxabiv119__pointer_type_infoE",
+ "__ZTVN10__cxxabiv121__vmi_class_type_infoE",
+ "___cxa_pure_virtual",
+
"__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm",
"__ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv",
"__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm",
However, I suppose such a patch is unlikely to be accepted. Is the use of these functions really worth the hassle?
from tree-sitter-haskell.
With the above patch applied to tree-sitter
running a simple parser test results in the following error:
TypeError: Cannot read properties of undefined (reading 'apply')
at e.<computed> (tree-sitter-haskell/node_modules/web-tree-sitter/tree-sitter.js:1:10543)
at wasm://wasm/00ea81ae:wasm-function[2590]:0xc09ac
at e.<computed> (tree-sitter-haskell/node_modules/web-tree-sitter/tree-sitter.js:1:10543)
at wasm://wasm/00ea81ae:wasm-function[2962]:0xc55b5
at e.<computed> (tree-sitter-haskell/node_modules/web-tree-sitter/tree-sitter.js:1:10543)
at wasm://wasm/00ea81ae:wasm-function[2961]:0xc55a8
at e.<computed> (tree-sitter-haskell/node_modules/web-tree-sitter/tree-sitter.js:1:10543)
at wasm://wasm/00ea81ae:wasm-function[2939]:0xc5468
at e.<computed> (tree-sitter-haskell/node_modules/web-tree-sitter/tree-sitter.js:1:10543)
at wasm://wasm/00ea81ae:wasm-function[2583]:0xc089a
from tree-sitter-haskell.
To help reproducing these errors, here is a simple script which uses the generated wasm, to be called as script/parse-example.js
:
#!/usr/bin/env node
const fs = require('fs')
const Parser = require('web-tree-sitter');
if (process.argv.length < 3) {
console.log('Usage: script/parse-example.js <haskell-file>')
process.exit(1)
}
const fileName = process.argv[2]
const sourceCode = fs.readFileSync(fileName, 'utf8')
Parser.init().then(() => {
Parser.Language.load('tree-sitter-haskell.wasm').then((Haskell) => {
const parser = new Parser;
parser.setLanguage(Haskell);
const tree = parser.parse(sourceCode);
console.log(tree.rootNode.toString());
});
});
from tree-sitter-haskell.
The following patch to web-tree-sitter
makes tree-sitter-haskell
work:
diff --git a/lib/binding_web/exports.json b/lib/binding_web/exports.json
index e0b3f718..3a43ae33 100644
--- a/lib/binding_web/exports.json
+++ b/lib/binding_web/exports.json
@@ -3,6 +3,17 @@
"_free",
"_malloc",
+ "__ZNSt3__24cerrE",
+ "__ZNSt3__25ctypeIcE2idE",
+ "__ZTVN10__cxxabiv117__class_type_infoE",
+ "__ZTVN10__cxxabiv120__si_class_type_infoE",
+ "__ZTVN10__cxxabiv120__function_type_infoE",
+ "__ZTVN10__cxxabiv119__pointer_type_infoE",
+ "__ZTVN10__cxxabiv121__vmi_class_type_infoE",
+ "__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE25__init_copy_ctor_externalEPKcm",
+ "__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE25__init_copy_ctor_externalEPKcm",
+ "___cxa_pure_virtual",
+
"__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm",
"__ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv",
"__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm",
from tree-sitter-haskell.
Created two issues which may help debug such problems in the future (tree-sitter/tree-sitter#1565 and tree-sitter/tree-sitter#1566).
from tree-sitter-haskell.
Related Issues (20)
- Combining characters in identifiers are not parsed correctly HOT 1
- Include . from qualified modules and variables HOT 6
- Segfault on large files (in Neovim) HOT 1
- Upgrade node-gyp dependency HOT 2
- Components parser as type when they are not HOT 1
- Include ! from strictness annotations
- exp_section_right not parsed when containing a hash HOT 3
- Incorrect parse for function with where-clause and comments HOT 4
- Can't npm install tree-sitter-haskell on Mac M3 Node.js v20.10? HOT 1
- Incorrect parse due to top-level splices HOT 11
- Failed builds due to very big file(s). HOT 3
- Qualified/unqualified module paths colored differently HOT 3
- Typed Template Haskell quotations / splices not handled correctly HOT 3
- "finally" is highlighted like a language keyword HOT 1
- Hangs when highlighting/parsing `data Aa = Bb | Cc | ` HOT 3
- Misparse of explicit-braced code
- UnicodeSyntax support HOT 10
- "undefined symbol: tree_sitter_haskell_external_scanner_create" when running "tree-sitter test" HOT 7
- Support `OverloadedRecordDot` HOT 8
- I added three more symbols for built-in syntax.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tree-sitter-haskell.