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

JSON backend #732

Open
wxrdnx opened this issue Oct 6, 2024 · 3 comments
Open

JSON backend #732

wxrdnx opened this issue Oct 6, 2024 · 3 comments

Comments

@wxrdnx
Copy link

wxrdnx commented Oct 6, 2024

I've implemented a simple JSON backend that can dump internal ASTs into JSON files.
The goal is to convert the AST into a cross-language representation that it can be used by languages other than Ocaml.
Would you guys be interested in adding this feature into your repo?

https://github.com/wxrdnx/sail/tree/json/src/sail_json_backend

@Trolldemorted
Copy link
Contributor

Does it export the AST with all inferred types?

Related issue: #144

@Alasdair
Copy link
Collaborator

Alasdair commented Oct 6, 2024

Yes, I think we would be interested.

We currently have a dependency on the Yojson library for all our JSON handling. It might be better to write a 'a ast -> Yojson.Safe.t function, then using Yojson's printing function to produce the final string. That function could also be parameterised by a 'a -> Yojson.Safe.t parameter for the annotations (or using a module to parameterise everything without passing an extra argument explicitly).

@wxrdnx
Copy link
Author

wxrdnx commented Oct 6, 2024

No, it does not.
For example, E_block would output something like

{
  ...
  "E_block": {
    ...
  }
}

So while most types are "preserved" in the keys, the Ocaml types are not preserved.

Does it export the AST with all inferred types?

Related issue: #144

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

No branches or pull requests

3 participants