0xPolygonMiden / miden-vm

STARK-based virtual machine
MIT License
620 stars 157 forks source link

Miden Assembly Linter? #1469

Open partylikeits1983 opened 3 months ago

partylikeits1983 commented 3 months ago

Feature description

I was wondering if there is a linter/code formatter for miden assembly files. There is probably some standard code formatter for assembly that could be adapted to miden assembly.

Why is this feature needed?

Improves readability and standardization of Miden Assembly files.

bobbinth commented 3 months ago

This would be super cool - but we don't have it yet. I think @polydez has created a simple syntax highlighter for Miden assembler - but I don't know if it does any formatting.

polydez commented 3 months ago

@bobbinth, no, it does just simple syntax highlighting for reserved words. It also has several code snippets, like begin ... end: https://github.com/polydez/masm-syntax-hl

partylikeits1983 commented 3 months ago

@bobbinth @polydez I built a basic MASM formatter, it is pretty basic, and probably still has issues that need to be ironed out. Here it is: https://github.com/partylikeits1983/masm-formatter

https://crates.io/crates/masm-formatter

bitwalker commented 1 month ago

There is a rustfmt like API available in the miden-formatting crate (and re-exported via miden-core::prettier), via the PrettyPrint trait. This is implemented for both MASM and MAST textual formats. A formatter tool simply needs to parse a module, then write it back to disk like write!(&mut file, "{module}")?;

We don't have a linter though, that would be nice!