Faster rewrite
This commit is contained in:
parent
09e9e45338
commit
6e60bebf3d
10
src/modal.c
10
src/modal.c
|
@ -11,7 +11,7 @@ static char bank_a[0x4000], *prog_ = bank_a;
|
|||
static char bank_b[0x4000], *outp_ = bank_b;
|
||||
static char *regs[0x100];
|
||||
|
||||
#define spacer(c) (c < 0x21 || c == '(' || c == ')')
|
||||
#define spacer(c) (c < 0x21 || c == '(' || c == ')' || !c)
|
||||
|
||||
static char *
|
||||
walk(char *s)
|
||||
|
@ -149,13 +149,13 @@ add_rule(char *p)
|
|||
static int
|
||||
rewrite(void)
|
||||
{
|
||||
char c, c_ = 0, last = 0, *p = direction ? bank_b : bank_a, *o = p;
|
||||
char c, last = 0, *p = direction ? bank_b : bank_a;
|
||||
while((c = *p) && c <= ' ') p++;
|
||||
while((c = *p)) {
|
||||
int i;
|
||||
if(p[0] == '<' && p[1] == '>') return add_rule(p);
|
||||
if(p != o) c_ = *(p - 1);
|
||||
if(p == o || spacer(c_)) {
|
||||
if(p[0] == '<' && p[1] == '>')
|
||||
return add_rule(p);
|
||||
if(spacer(last)) {
|
||||
for(i = 0; i < rules_len; i++) {
|
||||
Rule *r = &rules[i];
|
||||
char *res = match_rule(p, r);
|
||||
|
|
Loading…
Reference in New Issue