Print rules after evaluation
This commit is contained in:
parent
cff87b8f06
commit
f2a5feddd4
|
@ -71,8 +71,7 @@ bind(char r)
|
||||||
{
|
{
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
char c, *s = regs[(int)r];
|
char c, *s = regs[(int)r];
|
||||||
if(!s)
|
if(!s) return !printf("?%c Empty\n", r);
|
||||||
return !printf("!! Reading from invalid register: ?%c\n", r);
|
|
||||||
if(s[0] == '(') {
|
if(s[0] == '(') {
|
||||||
while((c = *s++)) {
|
while((c = *s++)) {
|
||||||
if(c == '(') depth++;
|
if(c == '(') depth++;
|
||||||
|
@ -172,6 +171,7 @@ static void
|
||||||
print_rules(void)
|
print_rules(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
printf("\n");
|
||||||
for(i = 0; i < rules_len; i++)
|
for(i = 0; i < rules_len; i++)
|
||||||
printf("<> (%s) (%s)\n", rules[i].a, rules[i].b);
|
printf("<> (%s) (%s)\n", rules[i].a, rules[i].b);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -182,8 +182,7 @@ parse_line(char *line)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
if(line[0] == 0) return 1;
|
if(line[0] == 0) return 1;
|
||||||
if(line[0] == '<' && line[1] == '>')
|
if(line[0] == '<' && line[1] == '>') return !!addrule(line);
|
||||||
return !!addrule(line);
|
|
||||||
while((c = *line++))
|
while((c = *line++))
|
||||||
*prog_++ = c;
|
*prog_++ = c;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -216,9 +215,9 @@ main(int argc, char **argv)
|
||||||
return !printf("Modal - Modal Interpreter, 4 Apr 2024.\n");
|
return !printf("Modal - Modal Interpreter, 4 Apr 2024.\n");
|
||||||
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();
|
|
||||||
printf(".. %s\n", bank_a);
|
printf(".. %s\n", bank_a);
|
||||||
while(rewrite())
|
while(rewrite())
|
||||||
;
|
;
|
||||||
|
print_rules();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue