bytecodealliance / bytecodealliance/wasm-tools

Implement Display trait for AST types

Open
#1 1 comment 0 reactions 0 assignees View on GitHub
wast
Dominant language
Rust
Stars
1.8k
Forks
351
Avg merge
16h 57m
Merged PRs (30d)
38

Description

I want to propose implementing the `Display` trait for all of the AST types to easily convert from AST to human readable wat/wast. I volunteer to implement this.

I am in the design phase of writing a language which is a strict extension of wat and wast (https://github.com/vitiral/wak-lang) and so would like to use this crate. However, one of the debug implementations of my compiler will be to export commented wat code so it is clear how code was generated. For instance:

```
32
```

Might "compile" into
```
(;(;@1:0;) 32;)
(i32.const 32)
```

(where `(;@1:0;)` is a nested comment representing the line number where the source code starts)

In order to implement this, I need all wat types to be printed to human-readable wat source. Obviously I could create my own traits and implement all the types into that, but I think this would be generally useful for other users of this crate.

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.