rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

Possibility of emitting binary AST and accepting binary AST

Open jfrolich opened this issue 3 years ago • 3 comments

Currently, it's not possible to emit a binary AST or accept a binary AST using the rescript format command line tool. I am working on a more tightly integrated version of graphql-ppx and it is now dependent on refmt for this (and thus is in ReasonML instead of ReScript). This is necessary for snapshot testing. To properly test the ppx I need to go from source code -> binary AST -> ppx -> binary AST -> source code. An example on how this can be achieved with refmt is the following command:

refmt --parse re --print binary operations/customDecoder.re | ppx.exe /dev/stdin /dev/stdout | refmt --parse binary --print re

Other solutions are also welcome, but without snapshot testing, it's really hard to know if a ppx is behaving correctly.

Are you open for a PR to achieve this? (even if it's undocumented that would be fine)

jfrolich avatar Jan 25 '22 06:01 jfrolich

you probably can use syntax repo. it emits an executable that prints/parses binary ast.

amiralies avatar Feb 07 '22 22:02 amiralies

Nice. I'll probably do that, but I would need to vendor it because I want to have 0 (OCaml) dependencies. So I still would rather have this functionality as part of the rescript compiler.

jfrolich avatar Feb 08 '22 03:02 jfrolich

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 13 '24 08:03 stale[bot]