News for hackers. Stuff that matters.
Re:Show HN: CodeBuff – smart code formatter by thealistra on Monday September 19, 2016 @04:10AM (#12529745)
Why do you need a grammar if this is supposed to learn it itself from the code?
Re:Show HN: CodeBuff – smart code formatter by jurgenv on Monday September 19, 2016 @05:27AM (#12530031)
The 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.

Re:Show HN: CodeBuff – smart code formatter by parrt on Monday September 19, 2016 @11:38AM (#12532230)
The 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.