Houeskeeping
This commit is contained in:
parent
b866c69776
commit
c63021cf03
2
makefile
2
makefile
|
@ -8,7 +8,7 @@ all: dest
|
||||||
dest:
|
dest:
|
||||||
@ mkdir -p bin
|
@ mkdir -p bin
|
||||||
run: all bin/modal
|
run: all bin/modal
|
||||||
@ bin/modal -q examples/hello.modal
|
@ bin/modal examples/hello.modal
|
||||||
debug: all bin/modal-debug
|
debug: all bin/modal-debug
|
||||||
@ bin/modal-debug examples/hello.modal
|
@ bin/modal-debug examples/hello.modal
|
||||||
test: all bin/modal-debug bin/modal
|
test: all bin/modal-debug bin/modal
|
||||||
|
|
21
src/modal.c
21
src/modal.c
|
@ -109,18 +109,14 @@ apply_rule(Rule *r, char *s)
|
||||||
while((c = *a)) { /* phase: match rule */
|
while((c = *a)) { /* phase: match rule */
|
||||||
if(c == '?') {
|
if(c == '?') {
|
||||||
char *pcap = walk(s), *reg = NULL;
|
char *pcap = walk(s), *reg = NULL;
|
||||||
int id = *(++a);
|
unsigned int id = *(++a) - '0';
|
||||||
unsigned int id2 = id - '0';
|
if(id < r->ptr) reg = regs[id];
|
||||||
if(id2 < r->ptr) {
|
|
||||||
reg = regs[id2];
|
|
||||||
}
|
|
||||||
if(reg) { /* reg cmp */
|
if(reg) { /* reg cmp */
|
||||||
char *rcap = walk(reg), *pp = s;
|
char *rcap = walk(reg), *pp = s;
|
||||||
while(reg < rcap || pp < pcap)
|
while(reg < rcap || pp < pcap)
|
||||||
if(*reg++ != *pp++) return 0;
|
if(*reg++ != *pp++) return 0;
|
||||||
} else { /* reg set */
|
} else /* reg set */
|
||||||
regs[id2] = s;
|
regs[id] = s;
|
||||||
}
|
|
||||||
a++, s = pcap;
|
a++, s = pcap;
|
||||||
if(!spacer(*a))
|
if(!spacer(*a))
|
||||||
while((c = *a) && !spacer(c)) a++;
|
while((c = *a) && !spacer(c)) a++;
|
||||||
|
@ -134,14 +130,11 @@ apply_rule(Rule *r, char *s)
|
||||||
while((c = *b++)) {
|
while((c = *b++)) {
|
||||||
if(c == '?') {
|
if(c == '?') {
|
||||||
char *reg = NULL;
|
char *reg = NULL;
|
||||||
int id = *b;
|
unsigned int id = *b - '0';
|
||||||
unsigned int id2 = id - '0';
|
if(id < r->ptr) reg = regs[id];
|
||||||
if(id2 < r->ptr) {
|
|
||||||
reg = regs[id2];
|
|
||||||
}
|
|
||||||
if(reg) {
|
if(reg) {
|
||||||
b++;
|
b++;
|
||||||
if(!write_reg(r->key[id2], reg) && dst_ != origin) dst_--;
|
if(!write_reg(r->key[id], reg) && dst_ != origin) dst_--;
|
||||||
} else
|
} else
|
||||||
*dst_++ = c;
|
*dst_++ = c;
|
||||||
} else
|
} else
|
||||||
|
|
Loading…
Reference in New Issue