From 6ad9490f45444131a78ff0183422e0c9405d3b79 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Thu, 4 Apr 2024 16:31:10 -0700 Subject: [PATCH] Do not skip first token --- examples/hello.modal | 4 ++++ examples/test.modal | 5 ++--- src/modal.c | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 examples/hello.modal diff --git a/examples/hello.modal b/examples/hello.modal new file mode 100644 index 0000000..dd63d61 --- /dev/null +++ b/examples/hello.modal @@ -0,0 +1,4 @@ +<> (?x dup) (?x ?x) +<> (?x ?y swap) (?y ?x) + +foo ((A B swap) dup) \ No newline at end of file diff --git a/examples/test.modal b/examples/test.modal index dd63d61..a520c1c 100644 --- a/examples/test.modal +++ b/examples/test.modal @@ -1,4 +1,3 @@ -<> (?x dup) (?x ?x) -<> (?x ?y swap) (?y ?x) +<> (duppre ?x) (?x ?x) -foo ((A B swap) dup) \ No newline at end of file +what (duppre twice) \ No newline at end of file diff --git a/src/modal.c b/src/modal.c index fd7fa6f..8ab0a04 100644 --- a/src/modal.c +++ b/src/modal.c @@ -128,8 +128,11 @@ tokenize(char *t, FILE *f) r->a = parse_rulefrag(f), r->b = parse_rulefrag(f); return; } + while((c = *t++)) + *prog_++ = c; + *prog_++ = ' '; while(f && fread(&c, 1, 1, f) && c) - *prog_++ = c == 0xa ? 0x20 : c; + *prog_++ = c == 0xa ? ' ' : c; } static int