Skip to content

Implement Display trait for AST types #1

Open
@vitiral

Description

@vitiral

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    wastRelated to the text format of WebAssembly (wat/wast)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions