Do no allocate empty cells in dict

This commit is contained in:
Devine Lu Linvega 2024-04-24 15:17:57 -07:00
parent ca76fdd9c3
commit 399ac8dd17
1 changed files with 6 additions and 12 deletions

View File

@ -7,7 +7,7 @@ typedef struct {
static int flip, quiet, cycles = 0x10000;
static Rule rules[0x1000], *rules_ = rules, lambda;
static char dict[0x8000], *dict_ = dict;
static char dict[0x8000], *dict_ = dict, empty;
static char bank_a[0x4000], *src_ = bank_a;
static char bank_b[0x4000], *dst_ = bank_b;
@ -163,14 +163,11 @@ compile_rule(Rule *r, int id, char *src)
{
int wrapped, reg;
char c, *cap;
r->id = id, r->ptr = 0;
r->id = id, r->ptr = 0, r->a = &empty, r->b = ∅
/* phase: left */
r->a = r->b = dict_;
while((c = *src) && c == ' ') src++;
if(c == ')' || (c == '<' && src[1] == '>')) {
*dict_++ = 0;
return src;
}
if(c == ')' || (c == '<' && src[1] == '>')) return src;
r->a = dict_;
cap = walk(src);
wrapped = c == '(';
if(wrapped) src++, cap--;
@ -187,12 +184,9 @@ compile_rule(Rule *r, int id, char *src)
src += wrapped;
*dict_++ = 0;
/* phase: right */
r->b = dict_;
while((c = *src) && c == ' ') src++;
if(c == ')' || (c == '<' && src[1] == '>')) {
*dict_++ = 0;
return src;
}
if(c == ')' || (c == '<' && src[1] == '>')) return src;
r->b = dict_;
cap = walk(src);
wrapped = c == '(';
if(wrapped) src++, cap--;