~ubuntu-branches/ubuntu/wily/gargoyle-free/wily-proposed

« back to all changes in this revision

Viewing changes to terps/alan2/rules.c

  • Committer: Package Import Robot
  • Author(s): Sylvain Beucler
  • Date: 2013-07-28 13:38:56 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130728133856-4k6uc864wzsnrx04
Tags: 2011.1a-1
* New upstream release
* Alan 2 interpreter is now Free Software, include it
* Update fonts package names in dependencies (Closes: #715160)
* Bump Standards-Version to 3.9.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}