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

Grammar rules as documentation on the AST module #975

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

W95Psp
Copy link
Collaborator

@W95Psp W95Psp commented Oct 8, 2024

Following a discussion with @karthikbhargavan, @cmester0 and I have been experimenting with putting OCaml comments directly onto the AST module, documenting the grammar rules covered by the internal AST of hax.

However, we believe that's not the best way to do things.

@cmester0 had a great idea: use the rust printer of hax to generate the grammar.

The idea is the following:

  • we define two top-level values for each type: enumerate and default
  • enumerate for type t is of type t set, default for type t is of type t
  • enumerate for each t scalar will be a default value (say 0 for ints, "" for strings, etc.)
  • enumerate of t list would be all possible combinations of the values enumerate<t> in list of length from zero to say 3
  • enumerate of t option would be the set None and Some of all the values in enumerate for type t
  • for every type of the AST, we derive via PPX default and enumerate. We need to make sure those enumerate are finite somehow (we can have a seen list of values, or do something statically, let's see)
  • use the rust printer to generate rules

Status: let's not merge this

@W95Psp W95Psp marked this pull request as draft October 8, 2024 12:49
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