Print rules after evaluation

This commit is contained in:
Devine Lu Linvega 2024-04-06 10:28:00 -07:00
parent cff87b8f06
commit f2a5feddd4
1 changed files with 4 additions and 5 deletions

View File

@ -71,8 +71,7 @@ bind(char r)
{
int depth = 0;
char c, *s = regs[(int)r];
if(!s)
return !printf("!! Reading from invalid register: ?%c\n", r);
if(!s) return !printf("?%c Empty\n", r);
if(s[0] == '(') {
while((c = *s++)) {
if(c == '(') depth++;
@ -172,6 +171,7 @@ static void
print_rules(void)
{
int i;
printf("\n");
for(i = 0; i < rules_len; i++)
printf("<> (%s) (%s)\n", rules[i].a, rules[i].b);
printf("\n");
@ -182,8 +182,7 @@ parse_line(char *line)
{
char c;
if(line[0] == 0) return 1;
if(line[0] == '<' && line[1] == '>')
return !!addrule(line);
if(line[0] == '<' && line[1] == '>') return !!addrule(line);
while((c = *line++))
*prog_++ = c;
return 1;
@ -216,9 +215,9 @@ main(int argc, char **argv)
return !printf("Modal - Modal Interpreter, 4 Apr 2024.\n");
if(!parse(argv[1]))
return !printf("Invalid Modal file: %s.\n", argv[1]);
print_rules();
printf(".. %s\n", bank_a);
while(rewrite())
;
print_rules();
return 0;
}