Mercurial > repo
view bin/labels.pl @ 12145:30b6dd2f3e7d draft
<b_jonas> learn kspalaiologos is addicted to brainfuck. His current work is disassembling brainfuck code for a casino that lost the source code.
author | HackEso <hackeso@esolangs.org> |
---|---|
date | Mon, 18 Nov 2019 02:19:26 +0000 |
parents | b413473a9ec3 |
children |
line wrap: on
line source
#!/usr/bin/perl # asm2bf label preprocessor. # C'mon, who doesn't love regexes? # Released to the public domain by Krzysztof Szewczyk. $n=0;%o=();$_=do{local$/;<>};s/^[ \t]*@([A-Za-z_]+).*$/$o{$1}=++$n;'lbl '.$n."\n";/gem; s/(%[A-Za-z_]+|"[^"\n]*%[A-Za-z_]+)/substr($1,0,1)eq'"'?$1:%o{substr$1,1}/ge;print;