comparison bin/labels.pl @ 12012:b413473a9ec3 draft

<kspalaiologos> ` cp tmp/asmbf-1.1.1/labels.pl /hackenv/bin
author HackEso <hackeso@esolangs.org>
date Thu, 14 Nov 2019 16:13:19 +0000
parents
children
comparison
equal deleted inserted replaced
12011:76de149fb2be 12012:b413473a9ec3
1 #!/usr/bin/perl
2
3 # asm2bf label preprocessor.
4 # C'mon, who doesn't love regexes?
5
6 # Released to the public domain by Krzysztof Szewczyk.
7
8 $n=0;%o=();$_=do{local$/;<>};s/^[ \t]*@([A-Za-z_]+).*$/$o{$1}=++$n;'lbl '.$n."\n";/gem;
9 s/(%[A-Za-z_]+|"[^"\n]*%[A-Za-z_]+)/substr($1,0,1)eq'"'?$1:%o{substr$1,1}/ge;print;