Walk over wildcards

This commit is contained in:
Devine Lu Linvega 2024-04-04 10:59:00 -07:00
parent 1a0dcb2a5e
commit 742cbf1298
1 changed files with 24 additions and 1 deletions

View File

@ -9,13 +9,36 @@ static Rule rules[0x100];
static char dict[0x8000], *next = dict;
static char prog[0x1000], *prog_ = prog;
static char *regs[0x100];
static void
bind(int id, char *addr)
{
printf("bind register %02x -> %s\n", id, addr);
regs[id] = addr;
}
static char *
walk(char *s)
{
char c;
while((c = *s++))
if(*s == ')') break;
return s;
}
static int
match(char *p, Rule *r)
{
char c, *a = r->a, *b = p;
while((c = *a)) {
/* registers */
if(c == '?') {
printf("WILDCARD: %s | %s\n", p, r->a);
char cc;
int id = *(++a);
bind(id, b);
a++, b = walk(b);
printf("[%s][%s]\n", a, b);
}
if(c != *b) return 0;
a++, b++;