{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/technical-report-towards-a-universal-code","title":"Technical Report: Towards a Universal Code Formatter through Machine Learning","arxiv_id":"1606.08866","date":"2016-06-28","proceeding":null,"authors":["Terence Parr","Jurgin Vinju"],"abstract":"There are many declarative frameworks that allow us to implement code\nformatters relatively easily for any specific language, but constructing them\nis cumbersome. The first problem is that \"everybody\" wants to format their code\ndifferently, leading to either many formatter variants or a ridiculous number\nof configuration options. Second, the size of each implementation scales with a\nlanguage's grammar size, leading to hundreds of rules.\n  In this paper, we solve the formatter construction problem using a novel\napproach, one that automatically derives formatters for any given language\nwithout intervention from a language expert. We introduce a code formatter\ncalled CodeBuff that uses machine learning to abstract formatting rules from a\nrepresentative corpus, using a carefully designed feature set. Our experiments\non Java, SQL, and ANTLR grammars show that CodeBuff is efficient, has excellent\naccuracy, and is grammar invariant for a given language. It also generalizes to\na 4th language tested during manuscript preparation.","url_abs":"http://arxiv.org/abs/1606.08866v1","url_pdf":"http://arxiv.org/pdf/1606.08866v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"technical-report-towards-a-universal-code","repo_url":"https://github.com/antlr/codebuff","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"none","reach":null},{"paper_slug":"technical-report-towards-a-universal-code","repo_url":"https://github.com/kaby76/cs-codebuff","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":null}],"tasks":[{"task_slug":"machine-learning","task_name":"BIG-bench Machine Learning"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":null,"mcp":null,"developers":"https://syntology.ai/developers"},"arxiv_metadata":null,"syntology_extracted_results":null}