Housekeeping

This commit is contained in:
Devine Lu Linvega 2024-04-28 20:37:53 -07:00
parent c9e932765a
commit e84ef37c5d
1 changed files with 7 additions and 13 deletions

View File

@ -34,10 +34,10 @@ walk(char *s)
static int static int
sint(char *s) sint(char *s)
{ {
int acc = 0; int r = 0;
char c; char c;
while((c = *s++) && c > 0x20) acc *= 10, acc += c - '0'; while((c = *s++) && c > 0x20) r = r * 10 + c - '0';
return acc; return r;
} }
static void static void
@ -97,13 +97,9 @@ write_reg(char r, char *reg)
char c, *cap = walk(reg); char c, *cap = walk(reg);
switch(r) { switch(r) {
case '>': /* op: output */ case '>': /* op: output */
case ':': case ':': device_write(reg); return;
device_write(reg);
return;
case '<': /* op: input */ case '<': /* op: input */
case '~': case '~': device_read(); return;
device_read();
return;
case '^': /* op: join */ case '^': /* op: join */
if(*reg == '(') reg++, --cap; if(*reg == '(') reg++, --cap;
while(reg < cap && (c = *reg++)) while(reg < cap && (c = *reg++))
@ -244,8 +240,7 @@ rewrite(void)
while(*s == ' ') s++; while(*s == ' ') s++;
cap = walk(s), r = find_rule(s, cap); cap = walk(s), r = find_rule(s, cap);
if(r != NULL) { if(r != NULL) {
if(!quiet) if(!quiet) fprintf(stderr, ">< (%s) (%s)\n", r->a, r->b);
fprintf(stderr, ">< (%s) (%s)\n", r->a, r->b);
r->a = 0; r->a = 0;
} }
while(*cap == ' ') cap++; while(*cap == ' ') cap++;
@ -256,8 +251,7 @@ rewrite(void)
r = rules_, r->id = rules_ - rules - 1; r = rules_, r->id = rules_ - rules - 1;
s = parse_frag(&r->b, parse_frag(&r->a, s + 2)); s = parse_frag(&r->b, parse_frag(&r->a, s + 2));
if(*r->a) { if(*r->a) {
if(!quiet) if(!quiet) fprintf(stderr, "<> (%s) (%s)\n", r->a, r->b);
fprintf(stderr, "<> (%s) (%s)\n", r->a, r->b);
rules_++; rules_++;
} }
while(*s == ' ') s++; while(*s == ' ') s++;