1
2 /**************************************************************************
3
4 ace.c
5 Colin Ramsay (cram@itee.uq.edu.au)
6 25 Feb 00
7
8 ADVANCED COSET ENUMERATOR, Version 3.001
9
10 Copyright 2000
11 Centre for Discrete Mathematics and Computing,
12 Department of Mathematics and
13 Department of Computer Science & Electrical Engineering,
14 The University of Queensland, QLD 4072.
15 (http://staff.itee.uq.edu.au/havas)
16
17 This is the top level stuff for Level 2 of ACE; that is, the standalone,
18 interactive `demonstration application'.
19
20 Historical fact: the first run of ACE's Level 2 interactive interface which
21 included an actual enumeration (as opposed to just sitting in the main loop
22 twiddling its thumbs) lasted from 10:56:57am to 10:59:03am on Tues 29th Dec
23 1998, and took place in the Dept of CS & EE at The Univ of Qld. The group
24 was A_5, over the trivial subgroup, and the correct answer (ie, 60) was
25 obtained!
26
27 **************************************************************************/
28
29 #include "al2.h"
30
31 /******************************************************************
32 Stuff declared in al2.h
33 ******************************************************************/
34
35 jmp_buf env;
36 Logic okstart, okcont, okredo;
37 Logic tabinfo, tabindex;
38 int lresult;
39 Logic echo, skipnl;
40 int currip;
41 char currkey[64], currname[128];
42 int *currword, currsiz, currexp;
43 int intcnt, intarr[32];
44
45 /******************************************************************
46 int main(void)
47
48 ACE takes no arguments, and normally returns 0; something -ve will
49 be returned on an `error'. By default, all input is from stdin &
50 all output is to stdout, via the fip/fop Level 0 parameters.
51 ******************************************************************/
52
main(void)53 int main(void)
54 {
55 al2_init(); /* Initialise Levels 2, 1 & 0 (incl. fop/fop) */
56
57 fprintf(fop, "%s %s", ACE_VER, al0_date());
58 fprintf(fop, "=========================================\n");
59
60 /* If we're working on a `normal' Unix box, "uname -n" returns the name
61 of the host, which we print out neatly at the start of a run. (Of
62 course, we could also access this using the "sys:...;" ACE command.) If
63 required, define AL2_HINFO in the make file. We assume that the system()
64 call's output will go to fop! This code could be expanded to print out
65 any other information regarding the current host that is required. */
66
67 #ifdef AL2_HINFO
68 fprintf(fop, "Host information:\n");
69 fflush(fop);
70 system("echo \" name = `uname -n`\"");
71 #endif
72
73 switch(setjmp(env))
74 {
75 case 0: /* First time through */
76
77 /* Level 0 stuff, set to "Default" mode */
78
79 pdefn = 3; /* Default is to use the pdl ... */
80 ffactor1 = 0; /* ... with fill factor of ~5(ncol+2)/4 */
81 pdsiz1 = 256; /* ... and a 256 byte list */
82
83 lahead = 0; /* We do a CL, not a lookahead */
84
85 dedmode = 4; /* Process all deductions ... */
86 dedsiz1 = 1000;
87
88 /* Level 1 stuff */
89
90 grpname = al2_strdup("G"); /* Default group name */
91 subgrpname = al2_strdup("H"); /* Default subgroup name */
92
93 /* Level 2 stuff */
94
95 break;
96
97 case 1: /* Non-fatal error (continuable) */
98
99 break;
100
101 case 2: /* Non-fatal error (restartable) */
102
103 okstart = ((costable != NULL) && (ndgen > 0));
104 okcont = okredo = FALSE;
105
106 tabinfo = tabindex = FALSE;
107
108 break;
109
110 case 3: /* Fatal error (aborts) */
111
112 fprintf(fop, "=========================================\n");
113 fprintf(fop, "%s %s", ACE_VER, al0_date());
114
115 exit(-1);
116 break;
117
118 default: /* Reality failure */
119
120 fprintf(fop, "** INTERNAL ERROR\n");
121 fprintf(fop, " unknown jump to error handler\n");
122 fprintf(fop, "=========================================\n");
123 fprintf(fop, "%s %s", ACE_VER, al0_date());
124
125 exit(-2);
126 break;
127 }
128
129 /* If costable is NULL at this point, then either this is the first time
130 through, or an attempt to allocate the requested workspace has failed.
131 In either case, we attempt to allocate the default amount of workspace.
132 If this fails, then we terminate extremely prejudicially. */
133
134 if (costable == NULL)
135 {
136 if ((costable = (int *)malloc(DEFWORK*sizeof(int))) == NULL)
137 {
138 fprintf(fop, "** MEMORY PROBLEM\n");
139 fprintf(fop, " unable to allocate default workspace\n");
140 fprintf(fop, "=========================================\n");
141 fprintf(fop, "%s %s", ACE_VER, al0_date());
142
143 exit(-3);
144 }
145
146 workspace = DEFWORK;
147 workmult = 1;
148
149 /* We have a newly allocated table, so start is (maybe) possible.
150 Continuing & redoing are not. The table has no information. */
151
152 okstart = (ndgen > 0);
153 okcont = okredo = FALSE;
154
155 tabinfo = tabindex = FALSE;
156 }
157
158 al2_cmdloop(); /* Where it all happens! */
159
160 fprintf(fop, "=========================================\n");
161 fprintf(fop, "%s %s", ACE_VER, al0_date());
162
163 return(0);
164 }
165
166