Closed WilliamDue closed 1 month ago
If you want submodules, then put them under Futhark.Fmt
. There is one rule for the Futhark.CLI
hierarchy, and that is that the modules there corrspond exactly to CLI executables.
I have pushed a change to Futhark.CLI.Fmt
that makes it read input from stdin if no file is given.
The
Futhark.CLI.Fmt.AST
module does not, in fact, define an AST.Although you should consider the formatting of the following file.
def x = 0x123
You will notice that the output is wrong. The solution is to keep around the original source bytestring and use the offsets in the AST location information to retrieve the original syntax for number literals.
We should have solved this problem here. Also we will think of a better name for AST.
Since this is now pretty much functionally correct, I have marked it for review. Fix all the style issues please.
We are decently happy with this version. Currently trailing comments works but it does not work perfectly see tests/fmt/trailingComments0.fut
. We think we could do a hacky solution but it seems like we would have to maybe rethink some design choices a bit to make it work in a none hacky way.
What are all those Zone.Identifier files?
In technical terms, we have made a whoopsie daisy.
Please don't reformat files that are not relevant to your work.
I think the problem is gone now.
tests_fmt/expected
would be more interesting if all the input files were not already formatted.
Can I merge this now?
Test script in tests_fmt is not done yet, but should be in next hour or so. The test themselves remain "uninteresting", most of them cover issues, where the AST used to represent two different code snippets with the same term (like the pattern thing in loops).
So it is done now?
We have added it to CI now it should hopefully be "done" now. I think we have some edge case problems with correctly place comments dealing with sep
but they should probably be squashed as they come. One of these are sumtypes, they are not located if they do not take an argument.
We think ideally the Fmt type should also be Located
such that comments can be placed correctly and the location should be based on the expression that is formatted. And when concatenated with another Fmt the smallest location that is not NoLoc should be used for the new Fmt.
chmod +x tools/testformatter.sh
Actually a side note, there is probably quite alot of cases where sep
places comments wrongly. This is because we had to change how sep worked because we wanted trailing comments. The thing with Fmt
having a locaiton is probably not that good actually.
This pull request contains the work in progress code formatter for Futhark.