-
Notifications
You must be signed in to change notification settings - Fork 148
Description
Originally from a Discord thread. @avh4’s response there:
Yeah, I'm open to PRs for that! See lenient parser for some of the other ideas that have been documented.
The main concern is to make sure that it doesn't make the parser start doing a lot of backtracking, and to make sure that the grammar remains unambiguous and that it doesn't change the parsing of any valid Elm files
I’m creating an issue for tracking.
Here’s the idea:
What if elm-format could parse and format incomplete Elm code?
case thing ofwith 0 branchesletinwith 0 declarations- case branches with nothing after the
-> - let bindings or top-level declarations with nothing after
= ifwith nothing betweenthenandelse, or nothing afterelse- and whatever else we can think of where the grammar says “there should be a
<thing>after the<symbol>” but the<thing>is missing so far, or “there should be one or more<thing>in<construct>” but there are zero so far.
The idea here is that while writing out new pieces of code (where parts are left to fill in yet), you don’t lose formatting.
I have learned to put placeholders like x, ä or TODO all over the place while writing code so that “I don’t lose elm-format”. But sometimes I forget and then it feels like elm-format (on save) stopped working until I realize “oh, I must have left a syntax error behind somewhere”.