VerCors as a round-trip source transformer #1099
pieter-bos
started this conversation in
General
Replies: 1 comment
-
I noticed that |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The normal functionality of VerCors is to take a source file and compile it down until it fits into viper. We've been gaining modes that take a source file, parse and resolve it, apply some transformations to it, and then render it back out to a source file. We've gone through some effort to make it so the pretty-printer is more correct than it was and better at making the output look pretty, but in the end this is not quite what we want: really we should be able to take a source file, parse and resolve it, and then output it back character-for-character identical.
Applying transformations should then interact with this in some sensible way (e.g.: applying simplifications would destroy the whitespace information we carry around those nodes and revert to pretty-printing).
The current VerCors functionalities that depend on round-trip source transforming are:
xml
file in some format and then pretty-printspvl
for itpvl
program, resolves and transforms it, then pretty-printsjava
for itpvl
program, resolves and transforms it, then pretty-printspvl
for itjava
program, resolves and transforms it, then pretty-printsjava
for itThe initial concern between parsing and col is mostly whitespace, and a little bit of node support (think like
+=
doesn't exist). In transformations (especiallyLangSpecificToCol
) we can consider adding further metadata to the tree. I think most of these can just be stored inOrigin
. Example:Assign("x", Plus("2", "3")(beforeBinOp=" ", afterBinOp=" "))(beforeBinOp=" ", afterBinOp=" ")
. If2+3
is simplified the correct output isx = 5
, achieved by the space around=
being stored in theAssign
.JavaClass
becomes aClass(...)(javaAttributes=Seq("public"))
or so. This means the fact it's public is no longer relevant forpublic
and this origin metadata is not used in further transformations (!!!), but remembered for output anyway.Beta Was this translation helpful? Give feedback.
All reactions