summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorTyler Murphy <tylerm@tylerm.dev>2023-04-13 17:04:05 -0400
committerTyler Murphy <tylerm@tylerm.dev>2023-04-13 17:04:05 -0400
commitfafd290ed990aa2bef34b44fe373175eb6133093 (patch)
tree5d4848b3006bc4eec5d5f49d6372516e1a2a0ba3 /src/main.c
downloadbrainfucked-fafd290ed990aa2bef34b44fe373175eb6133093.tar.gz
brainfucked-fafd290ed990aa2bef34b44fe373175eb6133093.tar.bz2
brainfucked-fafd290ed990aa2bef34b44fe373175eb6133093.zip
brainfucked
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..ac5e0f7
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,39 @@
+#include "program.h"
+#include "interpreter.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+
+/// < Move pointer left
+/// > Move pointer right
+/// + Increment cell by one
+/// - Decrement cell by one
+/// [ Jump past the matching ] if the cell at the pointer is 0
+/// ] Jump back to the matching [ if the cell at the pointer is nonzero
+/// . Output ascii at current cell
+/// , Input ascii into current cell
+/// * Allocate new tape size of current cell and replace with pointer
+/// ! Free allocated pointer in current cell
+/// ( Go to tape at pointer in current cell
+/// ) Leave tape last entered
+/// ` Output null terminated string at current cell
+/// ~ Input string into current cells with max length in current cell
+/// % Clear screen
+
+int main(int argc, char** argv) {
+ if (argc != 2) {
+ printf("usage: brainfucked infile\n");
+ return EXIT_FAILURE;
+ }
+
+ Program program;
+ program_init(argv[1], &program);
+ run_program(&program);
+ program_free(&program);
+
+ return EXIT_SUCCESS;
+}