Skip to content
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

add fmt command to format .wast file #83

Merged
merged 16 commits into from
Nov 27, 2023
Merged

add fmt command to format .wast file #83

merged 16 commits into from
Nov 27, 2023

Conversation

Swrup
Copy link
Contributor

@Swrup Swrup commented Nov 26, 2023

No description provided.

src/cmd_fmt.ml Outdated Show resolved Hide resolved
src/bin/owi.ml Outdated Show resolved Hide resolved
src/types.ml Outdated Show resolved Hide resolved
src/types.ml Outdated Show resolved Hide resolved
src/types.ml Outdated Show resolved Hide resolved
src/types.ml Outdated Show resolved Hide resolved
@zapashcanon
Copy link
Member

zapashcanon commented Nov 26, 2023

Thanks !

Could you remove test/print/print_text.ml and update test/print/print.t to replace the line: dune exec -- ./print_text.exe m.wast by dune exec owi -- fmt m.wast ?

One other nice thing would be to change test/main.ml. For now it runs the reference test suite (located in test/reference in two mode: a normal mode and a mode where it optimizes code (to make sure it breaks nothing). Could you add a third mode where we parse, then we format and check that everything goes well ? It shouldn't be too hard by simply looking at the test_directory and test_file functions.

@zapashcanon
Copy link
Member

Also fix #83.

@zapashcanon
Copy link
Member

zapashcanon commented Nov 27, 2023

One more little thing: could you try to check the file extension and if it's .wast then do what you already did (i.e. Parse.Script.from_file and Text.pp_script.

But if it's .wat then, call Parse.Module.from_file and Text.pp_modul instead ?

And if it's none of them, we could either error out or try in script mode anyway. My guess is that we should probably error out but I don't really mind.

@Swrup
Copy link
Contributor Author

Swrup commented Nov 27, 2023

Could you add a third mode where we parse, then we format and check that everything goes well ? It shouldn't be too hard by simply looking at the test_directory and test_file functions.

It's not going well 😩

src/cmd_fmt.ml Outdated Show resolved Hide resolved
src/cmd_fmt.ml Outdated Show resolved Hide resolved
test/main.ml Outdated Show resolved Hide resolved
test/main.ml Outdated Show resolved Hide resolved
test/main.ml Outdated Show resolved Hide resolved
test/main.ml Outdated Show resolved Hide resolved
@zapashcanon zapashcanon marked this pull request as ready for review November 27, 2023 09:16
@zapashcanon
Copy link
Member

Thanks!

@zapashcanon zapashcanon merged commit bfbf51f into OCamlPro:main Nov 27, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants