News for hackers. Stuff that matters.
Re:The Hardest Program I've Ever Written by sklogic on Thursday September 10, 2015 @04:20AM (#10196758)
And yet, the best place to add your pretty-printing and indentation hints is parser. Hints are attached to the grammar, so it makes sense to merge the two things, and then generate two different tools out of the single source. Three, actually - an AST pretty-printer, a textual code formatter and, finally, a parser itself.
Re:The Hardest Program I've Ever Written by eltaco on Thursday September 10, 2015 @03:35PM (#10200082)
There's an issue for a CST (AST with whitespace, comments, etc) in the estree repo [1]. JSCS is planning on using https://github.com/mdevils/cst for future autofixing rules.

[1] https://github.com/estree/estree/issues/41

Re:The Hardest Program I've Ever Written by sklogic on Thursday September 10, 2015 @05:26PM (#10200663)
The beauty of this pretty-printing solution (merging it with the parser) is that you don't even need any parsing tree to be constructed. The parser will simply walk the stream and annotate it with the pretty-printing instructions (pushing an popping the indentation context, adding the weighted break candidates, etc.).