Organized things a bit

This commit is contained in:
Devine Lu Linvega 2024-04-04 15:33:22 -07:00
parent 41f7807cd6
commit 23e3fc2176
11 changed files with 13 additions and 13 deletions

View File

@ -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.

View File

@ -1,3 +0,0 @@
#!/usr/bin/env sh
python3 ./modal.py $1

View File

@ -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:

View File

@ -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;