3 ms·
Why do you need a grammar if this is supposed to learn it itself from the code?
by thealistra 10y ago
Why do you need a grammar if this is supposed to learn it itself from the code?
- jurgenv 10y agoThe grammar is used to compute the code layout features that CodeBuff learns from: it parses each file and associates spacing and indentation features to trees' contextual features. Then, when we parse a new file to pretty-print, we parse again with the _same parser_ and the features that were learned are matched to the tree at hand to recover the "right" spacing and indentation features for the given example code.
- parrt 10y agoThe hard part of building a code formatter by hand is coding all the formatting rules, not the parsing. All formatters are based upon parsers so that is a constant across them. Creating a grammar from exemplars is still an unsolved problem.