Removed argument queue
This commit is contained in:
parent
c61e775241
commit
865f040da3
|
@ -4,5 +4,6 @@
|
||||||
<> (reverse/l (?h ?t) ?l) (reverse/l ?t (?h ?l))
|
<> (reverse/l (?h ?t) ?l) (reverse/l ?t (?h ?l))
|
||||||
<> (reverse/l (?h) ?l) (str (?h ?l))
|
<> (reverse/l (?h) ?l) (str (?h ?l))
|
||||||
<> (implode str ?*) (?*)
|
<> (implode str ?*) (?*)
|
||||||
|
<> ((read)) (?:)
|
||||||
|
|
||||||
(implode reverse (explode hello))
|
(implode reverse (explode hello)) (read)
|
2
makefile
2
makefile
|
@ -8,7 +8,7 @@ all: dest bin/modal
|
||||||
dest:
|
dest:
|
||||||
@ mkdir -p bin
|
@ mkdir -p bin
|
||||||
run: all
|
run: all
|
||||||
@ bin/modal examples/test.modal "(arg1)" "(arg2)" "(arg3)"
|
@ bin/modal examples/test.modal "(arg1) (arg2 (arg3))"
|
||||||
test: all
|
test: all
|
||||||
@ bin/modal -v
|
@ bin/modal -v
|
||||||
@ bin/modal examples/test.modal 2> /dev/null
|
@ bin/modal examples/test.modal 2> /dev/null
|
||||||
|
|
14
src/modal.c
14
src/modal.c
|
@ -4,7 +4,7 @@ typedef struct {
|
||||||
char *a, *b;
|
char *a, *b;
|
||||||
} Rule;
|
} Rule;
|
||||||
|
|
||||||
static int rules_len, direction, queue;
|
static int rules_len, direction;
|
||||||
static Rule rules[0x100];
|
static Rule rules[0x100];
|
||||||
static char dict[0x8000], *dict_ = dict;
|
static char dict[0x8000], *dict_ = dict;
|
||||||
static char bank_a[0x4000], *prog_ = bank_a;
|
static char bank_a[0x4000], *prog_ = bank_a;
|
||||||
|
@ -54,6 +54,7 @@ match(char *p, Rule *r)
|
||||||
int i;
|
int i;
|
||||||
char c, *a = r->a, *b = p;
|
char c, *a = r->a, *b = p;
|
||||||
for(i = 0x21; i < 0x7f; i++)
|
for(i = 0x21; i < 0x7f; i++)
|
||||||
|
if((char)i != ':')
|
||||||
regs[i] = 0;
|
regs[i] = 0;
|
||||||
while((c = *a)) {
|
while((c = *a)) {
|
||||||
if(c == '?') {
|
if(c == '?') {
|
||||||
|
@ -100,11 +101,10 @@ plode(char *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
commit(char r, char *incoming)
|
commit(char r)
|
||||||
{
|
{
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
char c, *s = regs[(int)r];
|
char c, *s = regs[(int)r];
|
||||||
if(r == ':' && incoming != NULL) s = incoming, queue++;
|
|
||||||
if(!s) return !fprintf(stderr, "?%c Empty\n", r);
|
if(!s) return !fprintf(stderr, "?%c Empty\n", r);
|
||||||
if(r == '*')
|
if(r == '*')
|
||||||
s = plode(s);
|
s = plode(s);
|
||||||
|
@ -164,7 +164,7 @@ parse_rulefrag(char *line)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rewrite(char *incoming)
|
rewrite(void)
|
||||||
{
|
{
|
||||||
char c, *p = direction ? bank_b : bank_a;
|
char c, *p = direction ? bank_b : bank_a;
|
||||||
while((c = *p) && c <= ' ') p++;
|
while((c = *p) && c <= ' ') p++;
|
||||||
|
@ -185,7 +185,7 @@ rewrite(char *incoming)
|
||||||
char cc, *b = r->b;
|
char cc, *b = r->b;
|
||||||
while((cc = *b++)) {
|
while((cc = *b++)) {
|
||||||
if(cc == '?')
|
if(cc == '?')
|
||||||
commit(*b++, incoming);
|
commit(*b++);
|
||||||
else
|
else
|
||||||
*outp_++ = cc;
|
*outp_++ = cc;
|
||||||
}
|
}
|
||||||
|
@ -231,8 +231,8 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
*w++ = 0;
|
*w++ = 0;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
queue = 2;
|
regs[':'] = argv[2];
|
||||||
while(rewrite(argv[queue]))
|
while(rewrite())
|
||||||
;
|
;
|
||||||
print_rules();
|
print_rules();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue