Skip to content

Instantly share code, notes, and snippets.

@zaydek-owl
Last active Aug 21, 2017
Embed
What would you like to do?
import std.file, std.regex, std.stdio;
void main(string[] args)
{
if (args.length != 2)
return;
auto text = readText(args[1]);
enum common = `((?:func|for|if|else)[^{\n]*)\n`;
text = replaceAll(text, ctRegex!(common ~ `\t*\{` ), "$1 {\n" );
text = replaceAll(text, ctRegex!(common ~ `([^\n]+)\n` ), "$1 {\n$2 }\n");
text = replaceAll(text, ctRegex!( `\}(\s+)else`), "$1} else" );
write(text);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment