Debian Codegraph @

terps/alan2/rules.c

raw symbols SCIP
1 /*----------------------------------------------------------------------*\
2
3 rules.c
4
5 Rule handling unit of Alan interpreter module, ARUN.
6
7 \*----------------------------------------------------------------------*/
8
9 #include <stdio.h>
10
11 #include "types.h"
12 #include "main.h"
13 #include "inter.h"
14 #include "debug.h"
15 #include "exe.h"
16 #include "stack.h"
17
18 #include "rules.h"
19
20 #ifdef GLK
21 #include "glkio.h"
22 #endif
23
24 #ifdef _PROTOTYPES_
25 void rules(void)
26 #else
27 void rules()
28 #endif
29 {
30 Boolean change = TRUE;
31 int i;
32
33 for (i = 1; !endOfTable(&ruls[i-1]); i++)
34 ruls[i-1].run = FALSE;
35
36 while (change) {
37 change = FALSE;
38 for (i = 1; !endOfTable(&ruls[i-1]); i++)
39 if (!ruls[i-1].run) {
40 if (trcflg) {
41 printf("\n<RULE %d (at ", i);
42 debugsay(cur.loc);
43 if (!stpflg)
44 printf("), Evaluating");
45 else
46 printf("), Evaluating:>\n");
47 }
48 interpret(ruls[i-1].exp);
49 if (pop()) {
50 change = TRUE;
51 ruls[i-1].run = TRUE;
52 if (trcflg)
53 if (!stpflg)
54 printf(", Executing:>\n");
55 else {
56 printf("\nRULE %d (at ", i);
57 debugsay(cur.loc);
58 printf("), Executing:>\n");
59 }
60 interpret(ruls[i-1].stms);
61 } else if (trcflg && !stpflg)
62 printf(":>\n");
63 }
64 }
65 }