-
-
Save uael/b1af7daa2e6f3a55020aa4f253ea65df 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
#include <unistd.h> | |
int main(int ac, char **av) { | |
char brank, *ptr, *input, optab[4096] = {0}; | |
if (ac <= 1) { | |
write(1, "\n", 1); | |
return 0; | |
} | |
ptr = optab; | |
input = av[1]; | |
while (*input) switch (*input) { | |
case '>': ++ptr; | |
goto next; | |
case '<': --ptr; | |
goto next; | |
case '+': ++*ptr; | |
goto next; | |
case '-': --*ptr; | |
goto next; | |
case '.': write(1, ptr, 1); | |
goto next; | |
case '[': | |
goto next; | |
case ']': brank = 1; | |
if (*ptr) do switch (*--input) { | |
case '[': | |
--brank; | |
break; | |
case ']': | |
++brank; | |
default: | |
break; | |
} while (brank > 0); | |
goto next; | |
next: | |
default: | |
++input; | |
break; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment