From 1713409a40b792e544028faedbad19b799104045 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sat, 6 Apr 2024 12:38:51 -0700 Subject: [PATCH] Added first syscall example --- examples/test.modal | 9 ++------- src/modal.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/examples/test.modal b/examples/test.modal index b9a0457..4035038 100644 --- a/examples/test.modal +++ b/examples/test.modal @@ -1,8 +1,3 @@ -<> (eq ?x ?x) (#t) -<> (eq ?x ?y) (#f) -<> (q ?x) (q ?x) -<> (if ?c ?t ?f) (if/q ?c q ?t q ?f) -<> (if/q (#t) q ?t q ?f) (?t) -<> (if/q (#f) q ?t q ?f) (?f) +<> ((send ?:)) () -if (eq foo bar) (if (eq foo baz) a b) (if (eq foo foo) b c) \ No newline at end of file +(send (hello world)) \ No newline at end of file diff --git a/src/modal.c b/src/modal.c index 470d5a5..4bb9b7e 100644 --- a/src/modal.c +++ b/src/modal.c @@ -42,6 +42,15 @@ compare(char *a, char *b) return 0; } +static void +call(char *s) +{ + char *ss = walk(s); + if(*s == '(') s++, --ss; + while(s < ss) + putc(*(s++), stdout); +} + static char * match(char *p, Rule *r) { @@ -55,7 +64,9 @@ match(char *p, Rule *r) if(regs[id]) { if(!compare(regs[id], b)) return NULL; - } else + } else if(id == ':') + call(b); + else regs[id] = b; a++, b = walk(b), c = *b; }