-
Notifications
You must be signed in to change notification settings - Fork 6
Support Wasm Text Format (%.wat) #1
Comments
Thanks for the shout-out to GoAWK. :-) Regarding line and column info: most GoAWK errors are errors during parsing, where I have line and column info in the tokens being parsed, so I can include that in the error. However, I don't store this in the syntax tree (AST nodes), so the few runtime errors that do exist don't include col/line info. If doing it again I'd probably add that info to AST nodes, though. |
went with a loop instead of an iterator api, and only implemented the basic lexer so far. the column and line positions will indeed make it upwards. next step is a proof of concept parser, later finish the lexing which floating points will be the most tedious! tetratelabs/wazero#63 |
in studying next steps one thing I recognize is at some point we need to do full wat2wasm to satisfy FunctionInstance.Body which is a field that contains the binary encoding of the function. Meanwhile, I'm focused on how to surface the stream of parsing. It appears that routinely peek 2 known tokens is needed. Ex lparen and a field name (keyword). It may be efficient to give a windowing function of up to N tokens to allow the parser function to do more. At the moment, I think only seeing one token isn't useful at all, and you can see wabt for example routinely needs 2 https://github.com/WebAssembly/wabt/blob/main/src/wast-parser.h#L79-L96 |
TL;DR: I think we should delete the text compiler to focus energy on the ever expanding responsibilities catering to other core specs. 👍 or if you 👎 please add a comment why and how we can solve the labor issue.
Even though I spent personally months on this, I think the best choice is to delete this code, for better attention to the core responsibilities of a runtime, and also before we release 1.0 |
PS I'm totally game at least internally to divert attention to a |
If folks are wondering why I piped up now, it is more than just the things on wazero 1.0 or webassembly 2.0. What I noticed was that the next WASI is built on the component model which extends grammar even further. I think the best focus of this project is the runtime, and particularly laboring towards the best JIT we can do, and best dev/debug story we can do. The text format has very little to do with this, yet an ever expanding definition. Choosing battles wisely is ditching it. EOF |
What I'll do is create a new repo called watzero and migrate code in such a way that it is standalone. I'll temporarily add a dependency back here to watzero then replace those parts with a wasm builder api before we cut 1.0 That's the most decoupled plan I can think of which also gives hope if someone wants to help move forward a dependency free wat2wasm go lib. If watzero doesn't end up doing that, we'll archive it. |
I started to do the migration in a separate repo, but that didn't work out well. I started over doing it in internal/watzero, which we can then |
This drops the text format (%.wat) and renames InstantiateModuleFromCode to InstantiateModuleFromBinary as it is no longer ambiguous. We decided to stop supporting the text format as it isn't typically used in production, yet costs a lot of work to develop. Given the resources available and the increased work added with WebAssembly 2.0 and soon WASI 2, we can't afford to spend the time on it. The old parser is used only internally and will eventually be moved to its own repository named watzero, possibly towards archival. See #59 Signed-off-by: Adrian Cole <adrian@tetrate.io>
This drops the text format (%.wat) and renames InstantiateModuleFromCode to InstantiateModuleFromBinary as it is no longer ambiguous. We decided to stop supporting the text format as it isn't typically used in production, yet costs a lot of work to develop. Given the resources available and the increased work added with WebAssembly 2.0 and soon WASI 2, we can't afford to spend the time on it. The old parser is used only internally and will eventually be moved to its own repository named watzero, possibly towards archival. See #59 Signed-off-by: Adrian Cole <adrian@tetrate.io>
This drops the text format (%.wat) and renames InstantiateModuleFromCode to InstantiateModuleFromBinary as it is no longer ambiguous. We decided to stop supporting the text format as it isn't typically used in production, yet costs a lot of work to develop. Given the resources available and the increased work added with WebAssembly 2.0 and soon WASI 2, we can't afford to spend the time on it. The old parser is used only internally and will eventually be moved to its own repository named watzero, possibly towards archival. See #59 Signed-off-by: Adrian Cole <adrian@tetrate.io>
planning to cancel the text parser altogether in #2 Doing so can help us keep the rest of the code alive, which has more utility and easier to maintain. If we start having enough help, the prior commit has the last working version. |
closing as won't fix so that we can focus on the other parts. It seems a lot more people are interested in compiling go into wasm, not wat2wasm |
We currently decode Wasm Binary Format. This means that usage depends on an external tool that targets it (ex tinygo -> wasm).
Wasm also defines a Text Format, which if supported gives a number of pros:
Non-goals:
Optional and should be in follow-up pull requests, not a Big Bang:
There will be some challenges and choices along the way.
Development can and should be done incrementally. For example, by making all code
internal
, we can convert simplest to most complicated wasm already used in this project into inlined or testdatawat
for test cases or benchmarks.Those working around this meanwhile, can install wat2wasm on their system then reference it from go, similar to this, then using
wasm.DecodeModule()
on the result:To implement this well will include parsing and lexing well, including retention of line and column information on errors. For example, goawk and mugo may be helpful background reading.
The text was updated successfully, but these errors were encountered: