Renamed memory banks

This commit is contained in:
Devine Lu Linvega 2024-04-06 08:21:14 -07:00
parent 0d9cd63829
commit f2e1b60f99
1 changed files with 9 additions and 9 deletions

View File

@ -7,8 +7,8 @@ typedef struct {
static int rules_len; static int rules_len;
static Rule rules[0x100]; static Rule rules[0x100];
static char dict[0x8000], *dict_ = dict; static char dict[0x8000], *dict_ = dict;
static char prog[0x1000], *prog_ = prog; static char bank_a[0x1000], *prog_ = bank_a;
static char outp[0x1000], *outp_ = outp; static char bank_b[0x1000], *outp_ = bank_b;
static char *regs[0x100]; static char *regs[0x100];
#define spacer(c) (c == ' ' || c == '(' || c == ')') #define spacer(c) (c == ' ' || c == '(' || c == ')')
@ -78,7 +78,7 @@ bind(char r)
if(c == '(') depth++; if(c == '(') depth++;
*outp_++ = c; *outp_++ = c;
if(c == ')') --depth; if(c == ')') --depth;
if(!depth) return; if(!depth) return 1;
} }
} }
while(!spacer(s[0]) && (*outp_++ = *s++)) while(!spacer(s[0]) && (*outp_++ = *s++))
@ -89,11 +89,11 @@ bind(char r)
static void static void
save(int rule) save(int rule)
{ {
int i, end = outp_ - outp; int i, end = outp_ - bank_b;
/* todo: change pointer instead of copying memory */ /* todo: change pointer instead of copying memory */
for(i = 0; i <= end; i++) prog[i] = outp[i]; for(i = 0; i <= end; i++) bank_a[i] = bank_b[i];
prog_ = prog, outp_ = outp; prog_ = bank_a, outp_ = bank_b;
printf("%02d %s\n", rule, prog); printf("%02d %s\n", rule, bank_a);
} }
static char * static char *
@ -138,7 +138,7 @@ addrule(char *s)
static int static int
rewrite(void) rewrite(void)
{ {
char c, *p = prog; char c, *p = bank_a;
while((c = *p)) { while((c = *p)) {
int i; int i;
if(p[0] == '<' && p[1] == '>') if(p[0] == '<' && p[1] == '>')
@ -217,7 +217,7 @@ main(int argc, char **argv)
if(!parse(argv[1])) if(!parse(argv[1]))
return !printf("Invalid Modal file: %s.\n", argv[1]); return !printf("Invalid Modal file: %s.\n", argv[1]);
print_rules(); print_rules();
printf(".. %s\n", prog); printf(".. %s\n", bank_a);
while(rewrite()) while(rewrite())
; ;
return 0; return 0;