3 ms·
Couldn't you start from Dart's BNF grammar, create a BNF grammar of "formatted" Dart and then format the code accordingly?
by _xgw 8y ago
Couldn't you start from Dart's BNF grammar, create a BNF grammar of "formatted" Dart and then format the code accordingly?
- ORioN63 8y agoYou could, but in reality it won't work very well due to recursive rules.
- munificent 8y agoMaybe. If you think of the formatted output as a grammar that includes whitespace, you'll probably discover it is very context-sensitive. Then determining what context to synthesize when making the translation is probably more or less equivalent to how you'd otherwise write the formatter.