Do no allocate empty cells in dict
This commit is contained in:
parent
ca76fdd9c3
commit
399ac8dd17
18
src/modal.c
18
src/modal.c
|
@ -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--;
|
||||
|
|
Loading…
Reference in New Issue