-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WASM? #222
Comments
If you want to create a WASM module for your parser definitions, probably it is better to write parser on Rust using rust-peg (this project obviously was inspired by pegjs, if you look at the project internals and it's grammar language is still very close to the language used by pegjs/peggy). Rust can be compiled to wasm module directly. |
Mingun's answer is good for today, but there's no reason why can't generate WASM directly from peggy one day. It could be done as a plugin to keep the runtime dependencies low for the core project (like https://github.com/metadevpro/ts-pegjs) |
Like, are you suggesting making a plugin that generates a Rust parser then compiles to WASM? |
Also what if we figured out a way to use the ANSI C plugin? Would there be a performance benefit? |
I was thinking the plugin could generate WASM directly, then either call back into JS for the actions, or use something like AssemblyScript to compile the actions themselves. |
For generation, something like binaryen.js probably gets us there with only a lot of work involved. |
I'm trying to run the Textmate scope selector parser in microsoft/vscode-textmate#52 (comment) but the performance is very bad on lower-end CPUs because of the parser's recursion. 😔 Looks like I will have to start cramming Rust and researching |
Can you check to see if this makes things any better? segment
= _ segment:([a-zA-Z0-9+_][a-zA-Z0-9-+_]*) _ {
return new matchers.SegmentMatcher(segment);
} (just removes the |
Wait, trying it again now.. |
Broke the parser when I tried to feed it a wildcard |
I cached the generated matcher functions AND their output and the performance improved :) |
Leaving this open as the feature request for WASM support. |
Parsers and WebAssembly go hand in hand. Kinda surprised this hasn't been suggested already!
The text was updated successfully, but these errors were encountered: