Walk over wildcards
This commit is contained in:
parent
1a0dcb2a5e
commit
742cbf1298
src
25
src/modal.c
25
src/modal.c
|
@ -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++;
|
||||
|
|
Loading…
Reference in New Issue