changeset 12274:3c04e9ef7a3a draft

<kspalaiologos> `` cp -rf /hackenv/tmp/asmbf-1.2.7/bin/* /hackenv/lib/kps/
author HackEso <hackeso@esolangs.org>
date Tue, 31 Dec 2019 17:47:30 +0000
parents de2990eb5cdf
children 295ffadc0bb2
files lib/kps/bconv lib/kps/bfasm lib/kps/bfi lib/kps/bfi-rle lib/kps/bfintd lib/kps/bfmake lib/kps/bfpp lib/kps/derle.pl lib/kps/labels.pl lib/kps/strip.pl
diffstat 10 files changed, 44 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
Binary file lib/kps/bconv has changed
Binary file lib/kps/bfasm has changed
Binary file lib/kps/bfi has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/kps/bfi-rle	Tue Dec 31 17:47:30 2019 +0000
@@ -0,0 +1,5 @@
+#!/bin/bash -e
+name="/tmp/bfprog$RANDOM"
+derle.pl $1 > $name
+bfi $name
+rm -f $name
Binary file lib/kps/bfintd has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/kps/bfmake	Tue Dec 31 17:47:30 2019 +0000
@@ -0,0 +1,7 @@
+#!/bin/bash -e
+
+name=$(echo "$1" | cut -f 1 -d '.')
+
+/bin/bfpp "$1"
+/bin/bfasm < "$1.p" | /bin/strip.pl > "${1%.*}.b"
+rm -f "$1.p"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/kps/bfpp	Tue Dec 31 17:47:30 2019 +0000
@@ -0,0 +1,7 @@
+#!/bin/bash -e
+
+set -o pipefail
+
+{ cat <<<"#define __NEWLINE__ "$'\n'"#define __ICOUNTER__ "$'\n'"" ; cat "$1" | sed -e "1!b" -e '/#/d' ; } | gcc -E -I. -Ilib - -o "$1.i"
+perl -pe "s/\xFF/\x0A/g;" < "$1.i" | perl -pe 's/\xFE/$x++/ge;' | /bin/labels.pl | sed '/^#/ d' > "$1.p"
+rm -f "$1.i"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/kps/derle.pl	Tue Dec 31 17:47:30 2019 +0000
@@ -0,0 +1,6 @@
+#!/usr/bin/perl -p
+
+my ($style) = @ARGV;
+
+s/\d+(.)/$1x$&/ge if $style eq "postfix" or $style == undef;
+s/(.)\d+/$1x$&/ge if $style eq "prefix";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/kps/labels.pl	Tue Dec 31 17:47:30 2019 +0000
@@ -0,0 +1,7 @@
+#!/usr/bin/perl
+
+# asm2bf label preprocessor.
+# C'mon, who doesn't love regexes?
+
+$n=0;%o=();$_=do{local$/;<>};s/^[ \t]*@([A-Za-z_]+[A-Za-z0-9_]*).*$/$o{$1}=++$n;'lbl '.$n."\n";/gem;
+s/(%([A-Za-z_]+[A-Za-z0-9_]*)|"[^"\n]*%([A-Za-z_]+[A-Za-z0-9_]*))/substr($1,0,1)eq'"'?$1:%o{substr$1,1}/ge;print;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/kps/strip.pl	Tue Dec 31 17:47:30 2019 +0000
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+
+$_ = do { local $/; <> };
+do {
+	$l = length;
+	s/[\n\r\t ]+//g;
+	s/<>//g;
+	s/><//g;
+	s/\+-//g;
+	s/-\+//g;
+} while($l != length);
+print;