Code Formatter - dickensas/smartlexer GitHub Wiki
To format the AST tree, the database can fed with keywords and gutter keys with keywords, wrapBy and wrapAt
Example Database
{
"max": 200,
"spaces": 3,
"wrapBy":[
{"name":"}","skipAt":[";"]},
{"name":"{"},
{"name":";"},
{"name":":"}
],
"wrapAt":[
{"name":"using"},
{"name":"{", "gutter":"+"},
{"name":"}", "gutter":"-"}
],
"keywords":[
{"name":"class"},
{"name":"include"},
{"name":"break"},
{"name":"case"},
{"name":"catch"},
{"name":"char"},
{"name":"const"},
{"name":"do"},
{"name":"void"},
{"name":"while"},
{"name":"int"},
{"name":"return"}
]
}
Output
int main()
{
return 0;
}
the curling brace wrapped both sides reason being both wrapBy and wrapAt is specified for both "{" and "}"
"gutter":"+"
make the code 3 spaces fixed gutter from left for the next line to the first "{"
similarly the intend can be formatted and customized