From 23e3fc217679ec31ece6ed2a4f0315afb0ce9d89 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Thu, 4 Apr 2024 15:33:22 -0700 Subject: [PATCH] Organized things a bit --- README.md | 9 +++++++-- build.sh | 3 --- combinators.modal => examples/combinators.modal | 0 concat.modal => examples/concat.modal | 0 lisp.modal => examples/lisp.modal | 0 prelude.modal => examples/prelude.modal | 0 prelude2.modal => examples/prelude2.modal | 0 test.modal => examples/test.modal | 0 makefile | 4 ++-- modal.py => old/modal.py | 0 src/modal.c | 10 ++++------ 11 files changed, 13 insertions(+), 13 deletions(-) delete mode 100755 build.sh rename combinators.modal => examples/combinators.modal (100%) rename concat.modal => examples/concat.modal (100%) rename lisp.modal => examples/lisp.modal (100%) rename prelude.modal => examples/prelude.modal (100%) rename prelude2.modal => examples/prelude2.modal (100%) rename test.modal => examples/test.modal (100%) rename modal.py => old/modal.py (100%) diff --git a/README.md b/README.md index fa6683a..06c0311 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,18 @@ A pattern/replacement can be: A variable: ?foo, ?bar, ?baz A sequence of the above: (foo bar baz), (foo ?bar baz), foo (bar (baz)) +## Build + +``` +cc src/modal.c -o bin/modal +``` + ## Run ``` -python3 ./modal.py +bin/modal examples/hello.modal ``` ## Credits Created by [wryl](https://wryl.tech/), Immediate Mode Technologies. - diff --git a/build.sh b/build.sh deleted file mode 100755 index 5cd834b..0000000 --- a/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env sh - -python3 ./modal.py $1 diff --git a/combinators.modal b/examples/combinators.modal similarity index 100% rename from combinators.modal rename to examples/combinators.modal diff --git a/concat.modal b/examples/concat.modal similarity index 100% rename from concat.modal rename to examples/concat.modal diff --git a/lisp.modal b/examples/lisp.modal similarity index 100% rename from lisp.modal rename to examples/lisp.modal diff --git a/prelude.modal b/examples/prelude.modal similarity index 100% rename from prelude.modal rename to examples/prelude.modal diff --git a/prelude2.modal b/examples/prelude2.modal similarity index 100% rename from prelude2.modal rename to examples/prelude2.modal diff --git a/test.modal b/examples/test.modal similarity index 100% rename from test.modal rename to examples/test.modal diff --git a/makefile b/makefile index c11ef42..02ffa3b 100644 --- a/makefile +++ b/makefile @@ -8,10 +8,10 @@ all: dest bin/modal dest: @ mkdir -p bin run: all - @ bin/modal test.modal + @ bin/modal examples/test.modal test: all @ bin/modal -v - @ bin/modal test.modal + @ bin/modal examples/test.modal install: all @ cp bin/modal ~/bin/ uninstall: diff --git a/modal.py b/old/modal.py similarity index 100% rename from modal.py rename to old/modal.py diff --git a/src/modal.c b/src/modal.c index 128fa88..fd7fa6f 100644 --- a/src/modal.c +++ b/src/modal.c @@ -19,8 +19,7 @@ walk(char *s) while((c = *s++)) { if(c == '(') depth++; if(c == ')') --depth; - if(c == ' ' && !depth) - break; + if(c == ' ' && !depth) break; } return s - 1; } @@ -55,6 +54,7 @@ static void save(void) { int i, end = outp_ - outp; + /* todo: change pointer instead of copying memory */ for(i = 0; i <= end; i++) prog[i] = outp[i]; prog_ = prog, outp_ = outp; printf(".. %s\n", prog); @@ -111,10 +111,8 @@ parse_rulefrag(FILE *f) while(f && fread(&c, 1, 1, f) && c && c != 0xa) { if(c == '(') depth++; if(c == ')') --depth; - if(c == ' ' && !depth) - break; - else - *dict_++ = c; + if(c == ' ' && !depth) break; + *dict_++ = c; } *dict_++ = 0; return origin;