Added first syscall example

This commit is contained in:
Devine Lu Linvega 2024-04-06 12:38:51 -07:00
parent a0bb670722
commit 1713409a40
2 changed files with 14 additions and 8 deletions

View File

@ -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)
(send (hello world))

View File

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