runtimeverification / k

K Framework Tools 7.0
BSD 3-Clause "New" or "Revised" License
443 stars 145 forks source link

Create a K source to AST to source tool #4282

Open Scott-Guest opened 4 months ago

Scott-Guest commented 4 months ago

Related:

We should consider creating a tool for round-tripping K source code to AST and back.

This serves two purposes:

ehildenb commented 4 months ago

pyk can definitely do this pretty easily. We can very much use kompile to read in and produce the AST, and then use pyk to read in the definition and then write it out again with a new pretty-printer. Pyk's pretty-printer would need some updating.

ehildenb commented 4 months ago

With some of @gtrepta work, we could probably also do it mostly in pyk, and just do inner parsing using kompile tooling.

Scott-Guest commented 4 months ago

@ehildenb Agreed, @Baltoli and I had similar thoughts.

There is a small gap between parsed outer syntax and the user source that we'll need to address (e.g. desugaring of inline priority declarations into a separate syntax priority statement), but it should be manageable.