Closed wenkokke closed 2 years ago
very nice.
FWIW, I spent a little time looking into why this patch is needed.
typeid
symbol is needed because of the use of iostream
for logging. I guess iostream relies on runtime type information at some level.string::__init_copy_ctor_external
symbol is needed because of an automatic conversion between a string literal (const char *)
and a std::string
that happens when passing "#endif"
to the consume_until
function.I'd really like to make the process of compiling parsers to WASM more foolproof. It's unfortunate that web-tree-sitter
currently needs to decide how much of the C/C++ standard libraries to bundle; it seems to be a limitation of Emscripten's dynamic linking system that the "main module" needs to be the one to include the standard library. Maybe there's some alternative strategy though.
In the meantime, it seems like neither of these symbols in the patch is critical to the functionality of the scanner; it would probably be pretty straightforward to get it working with the existing web-tree-sitter
.
Version of #55 with minimal changes, updated after merge of #54:
tree-sitter-haskell.wasm
and patchingweb-tree-sitter
npm run examples-wasm
script/tree-sitter-parse.js
for parsing files usingtree-sitter-haskell.wasm
$mode
throughscript/parse-example[s]
which can be either 'native' or 'wasm' (default is 'native')