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;