aboutsummaryrefslogtreecommitdiff
path: root/sloth.c
diff options
context:
space:
mode:
Diffstat (limited to 'sloth.c')
-rw-r--r--sloth.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/sloth.c b/sloth.c
index 8314b79..5db7df0 100644
--- a/sloth.c
+++ b/sloth.c
@@ -1,6 +1,7 @@
#include "sloth.h"
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
void sloth_deinit(Sloth *ctx)
{
@@ -10,6 +11,23 @@ void sloth_deinit(Sloth *ctx)
}
}
+SlothError sloth_exec(Sloth *ctx, const char *s)
+{
+ printf("exec %s\n", s);
+ return NULL;
+}
+
+SlothError sloth_exec_line(Sloth *ctx, char *s)
+{
+ static const char *sep = "\t\n\v\f\r ";
+ for (char *tok = strtok(s, sep); tok != NULL; tok = strtok(NULL, sep)) {
+ const SlothError err = sloth_exec(ctx, tok);
+ if (err != NULL)
+ return err;
+ }
+ return NULL;
+}
+
SlothError sloth_pop(Sloth *ctx, SlothByte *v)
{
if (ctx->stack_size == 0)