Last active
August 21, 2017 21:36
-
-
Save zaydek-owl/28823563ac2ec50ab4f794c34a0911d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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