From 296caf6cce8120bf3537f8ab05ddc4bc7273e859 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Thu, 13 Sep 2018 16:51:34 -0400 Subject: initial commit --- bf.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 bf.c (limited to 'bf.c') diff --git a/bf.c b/bf.c new file mode 100644 index 0000000..ddec8f5 --- /dev/null +++ b/bf.c @@ -0,0 +1,19 @@ +#include +#define S (1<<16) +#define I a[1] +#define D a[0] +#define C case +#define B break +static char d[S], p[S]; +int main(int i, char *a[]) { + fread(p, 1, S, fopen(I, "r")); + for (D = d, I = p; I < p + S; I++) { + switch (i = *I) { + C '[': C ']': for (i = '\\' - *I; i < 0 ? *D : !*D; i += *(I += i > 0 ? 1 : -1) == '[' ? 1 : *I == ']' ? -1 : 0); B; + C '+': C '-': *D -= i - ','; B; + C '<': C '>': D += i - '='; B; + C ',': *D = getchar(); B; + C '.': putchar(*D); B; + } + } +} -- cgit v1.2.1