47static KEYWORD formatoptions[] = {
48 {
"allfloat", (TFUN)0, ALLINTEGERDOUBLE, 0}
49 ,{
"c", (TFUN)0, CMODE, 0}
50 ,{
"doublefortran", (TFUN)0, DOUBLEFORTRANMODE, 0}
51 ,{
"float", (TFUN)0, 0, 2}
53 ,{
"floatprecision", (TFUN)0, 0, 5}
55 ,{
"fortran", (TFUN)0, FORTRANMODE, 0}
56 ,{
"fortran90", (TFUN)0, FORTRANMODE, 4}
57 ,{
"maple", (TFUN)0, MAPLEMODE, 0}
58 ,{
"mathematica", (TFUN)0, MATHEMATICAMODE, 0}
59 ,{
"normal", (TFUN)0, NORMALFORMAT, 1}
60 ,{
"nospaces", (TFUN)0, NOSPACEFORMAT, 3}
61 ,{
"pfortran", (TFUN)0, PFORTRANMODE, 0}
62 ,{
"quadfortran", (TFUN)0, QUADRUPLEFORTRANMODE, 0}
63 ,{
"quadruplefortran", (TFUN)0, QUADRUPLEFORTRANMODE, 0}
64 ,{
"rational", (TFUN)0, RATIONALMODE, 1}
65 ,{
"reduce", (TFUN)0, REDUCEMODE, 0}
66 ,{
"spaces", (TFUN)0, NORMALFORMAT, 3}
67 ,{
"vortran", (TFUN)0, VORTRANMODE, 0}
70static KEYWORD trace4options[] = {
71 {
"contract", (TFUN)0, CHISHOLM, 0 }
72 ,{
"nocontract", (TFUN)0, 0, CHISHOLM }
73 ,{
"nosymmetrize",(TFUN)0, 0, ALSOREVERSE}
74 ,{
"notrick", (TFUN)0, NOTRICK, 0 }
75 ,{
"symmetrize", (TFUN)0, ALSOREVERSE, 0 }
76 ,{
"trick", (TFUN)0, 0, NOTRICK }
80 {
"nosymmetrize",(TFUN)0, 0, ALSOREVERSE}
81 ,{
"symmetrize", (TFUN)0, ALSOREVERSE, 0 }
85 {
"stats", &(AC.StatsFlag), 1, 0}
86 ,{
"statistics", &(AC.StatsFlag), 1, 0}
87 ,{
"shortstats", &(AC.ShortStats), 1, 0}
88 ,{
"shortstatistics",&(AC.ShortStats), 1, 0}
89 ,{
"warnings", &(AC.WarnFlag), 1, 0}
90 ,{
"allwarnings", &(AC.WarnFlag), 2, 0}
91 ,{
"setup", &(AC.SetupFlag), 1, 0}
92 ,{
"names", &(AC.NamesFlag), 1, 0}
93 ,{
"allnames", &(AC.NamesFlag), 2, 0}
94 ,{
"codes", &(AC.CodesFlag), 1, 0}
95 ,{
"highfirst", &(AC.SortType), SORTHIGHFIRST, SORTLOWFIRST}
96 ,{
"lowfirst", &(AC.SortType), SORTLOWFIRST, SORTHIGHFIRST}
97 ,{
"powerfirst", &(AC.SortType), SORTPOWERFIRST, SORTHIGHFIRST}
98 ,{
"tokens", &(AC.TokensWriteFlag),1, 0}
102 {
"compress", &(AC.NoCompress), 0, 1}
103 ,{
"checkpoint", &(AC.CheckpointFlag), 1, 0}
104 ,{
"insidefirst", &(AC.insidefirst), 1, 0}
105 ,{
"propercount", &(AC.BottomLevel), 1, 0}
106 ,{
"stats", &(AC.StatsFlag), 1, 0}
107 ,{
"statistics", &(AC.StatsFlag), 1, 0}
108 ,{
"shortstats", &(AC.ShortStats), 1, 0}
109 ,{
"shortstatistics",&(AC.ShortStats), 1, 0}
110 ,{
"names", &(AC.NamesFlag), 1, 0}
111 ,{
"allnames", &(AC.NamesFlag), 2, 0}
112 ,{
"warnings", &(AC.WarnFlag), 1, 0}
113 ,{
"allwarnings", &(AC.WarnFlag), 2, 0}
114 ,{
"highfirst", &(AC.SortType), SORTHIGHFIRST, SORTLOWFIRST}
115 ,{
"lowfirst", &(AC.SortType), SORTLOWFIRST, SORTHIGHFIRST}
116 ,{
"powerfirst", &(AC.SortType), SORTPOWERFIRST, SORTHIGHFIRST}
117 ,{
"setup", &(AC.SetupFlag), 1, 0}
118 ,{
"codes", &(AC.CodesFlag), 1, 0}
119 ,{
"tokens", &(AC.TokensWriteFlag),1,0}
120 ,{
"properorder", &(AC.properorderflag),1,0}
121 ,{
"threadloadbalancing",&(AC.ThreadBalancing),1, 0}
122 ,{
"threads", &(AC.ThreadsFlag),1, 0}
123 ,{
"threadsortfilesynch",&(AC.ThreadSortFileSynch),1, 0}
124 ,{
"threadstats", &(AC.ThreadStats),1, 0}
125 ,{
"finalstats", &(AC.FinalStats),1, 0}
126 ,{
"fewerstats", &(AC.ShortStatsMax), 10, 0}
127 ,{
"fewerstatistics",&(AC.ShortStatsMax), 10, 0}
128 ,{
"processstats", &(AC.ProcessStats),1, 0}
129 ,{
"oldparallelstats",&(AC.OldParallelStats),1,0}
130 ,{
"parallel", &(AC.parallelflag),PARALLELFLAG,NOPARALLEL_USER}
131 ,{
"nospacesinnumbers",&(AO.NoSpacesInNumbers),1,0}
132 ,{
"indentspace", &(AO.IndentSpace),INDENTSPACE,0}
133 ,{
"totalsize", &(AM.PrintTotalSize), 1, 0}
134 ,{
"flag", (
int *)&(AC.debugFlags), 1, 0}
135 ,{
"oldfactarg", &(AC.OldFactArgFlag), 1, 0}
136 ,{
"memdebugflag", &(AC.MemDebugFlag), 1, 0}
137 ,{
"oldgcd", &(AC.OldGCDflag), 1, 0}
138 ,{
"oldprfsign", &(AC.OldPRFSignFlag), 1, 0}
139 ,{
"innertest", &(AC.InnerTest), 1, 0}
140 ,{
"wtimestats", &(AC.WTimeStatsFlag), 1, 0}
141 ,{
"sortreallocate", &(AC.SortReallocateFlag), 1, 0}
142 ,{
"backtrace", &(AC.PrintBacktraceFlag), 1, 0}
143 ,{
"flint", &(AC.FlintPolyFlag), 1, 0}
144 ,{
"humanstats", &(AC.HumanStatsFlag), 1, 0}
145 ,{
"humanstatistics", &(AC.HumanStatsFlag), 1, 0}
146 ,{
"grccverbose", &(AC.GrccVerbose), 1, 0}
147 ,{
"sortverbose", &(AC.SortVerbose), 1, 0}
157int CoFormat(UBYTE *s)
162 while ( *s ==
' ' || *s ==
',' ) s++;
165 AC.OutputSpaces = NORMALFORMAT;
171 if ( *s ==
'O' || *s ==
'o' ) {
172 if ( ( FG.cTable[s[1]] == 1 ) ||
173 ( s[1] ==
'=' && FG.cTable[s[2]] == 1 ) ) {
174 s++;
if ( *s ==
'=' ) s++;
176 while ( *s >=
'0' && *s <=
'9' ) x = 10*x + *s++ -
'0';
177 while ( *s ==
',' ) s++;
178 AO.OptimizationLevel = x;
179 AO.Optimize.greedytimelimit = 0;
180 AO.Optimize.mctstimelimit = 0;
181 AO.Optimize.printstats = 0;
182 AO.Optimize.debugflags = 0;
183 AO.Optimize.schemeflags = 0;
184 AO.Optimize.mctsdecaymode = 1;
186 M_free(AO.inscheme,
"Horner input scheme");
187 AO.inscheme = 0; AO.schemenum = 0;
193 AO.Optimize.mctsconstant.fval = -1.0;
194 AO.Optimize.horner = O_OCCURRENCE;
195 AO.Optimize.hornerdirection = O_FORWARDORBACKWARD;
196 AO.Optimize.method = O_CSE;
199 AO.Optimize.horner = O_OCCURRENCE;
200 AO.Optimize.hornerdirection = O_FORWARDORBACKWARD;
201 AO.Optimize.method = O_GREEDY;
202 AO.Optimize.greedyminnum = 10;
203 AO.Optimize.greedymaxperc = 5;
206 AO.Optimize.mctsconstant.fval = 1.0;
207 AO.Optimize.horner = O_MCTS;
208 AO.Optimize.hornerdirection = O_FORWARDORBACKWARD;
209 AO.Optimize.method = O_GREEDY;
210 AO.Optimize.mctsnumexpand = 1000;
211 AO.Optimize.mctsnumkeep = 10;
212 AO.Optimize.mctsnumrepeat = 1;
213 AO.Optimize.greedyminnum = 10;
214 AO.Optimize.greedymaxperc = 5;
217 AO.Optimize.horner = O_SIMULATED_ANNEALING;
218 AO.Optimize.saIter = 1000;
219 AO.Optimize.saMaxT.fval = 2000;
220 AO.Optimize.saMinT.fval = 1;
224 MesPrint(
"&Illegal optimization specification in format statement");
227 if ( error == 0 && *s != 0 && x > 0 )
return(CoOptimizeOption(s));
233 while ( FG.cTable[*s] == 0 ) s++;
235 if ( StrICont(ss,(UBYTE *)
"optimize") == 0 ) {
237 while ( *s ==
',' ) s++;
238 if ( *s ==
'=' ) s++;
239 AO.OptimizationLevel = 3;
240 AO.Optimize.mctsconstant.fval = 1.0;
241 AO.Optimize.horner = O_MCTS;
242 AO.Optimize.hornerdirection = O_FORWARDORBACKWARD;
243 AO.Optimize.method = O_GREEDY;
244 AO.Optimize.mctstimelimit = 0;
245 AO.Optimize.mctsnumexpand = 1000;
246 AO.Optimize.mctsnumkeep = 10;
247 AO.Optimize.mctsnumrepeat = 1;
248 AO.Optimize.greedytimelimit = 0;
249 AO.Optimize.greedyminnum = 10;
250 AO.Optimize.greedymaxperc = 5;
251 AO.Optimize.printstats = 0;
252 AO.Optimize.debugflags = 0;
253 AO.Optimize.schemeflags = 0;
254 AO.Optimize.mctsdecaymode = 1;
256 M_free(AO.inscheme,
"Horner input scheme");
257 AO.inscheme = 0; AO.schemenum = 0;
259 return(CoOptimizeOption(s));
263 MesPrint(
"&Illegal optimization specification in format statement");
269 else if ( FG.cTable[*s] == 1 ) {
271 while ( FG.cTable[*s] == 1 ) x = 10*x + *s++ -
'0';
272 if ( x <= 0 || x >= MAXLINELENGTH ) {
274 MesPrint(
"&Illegal value for linesize: %d",x);
278 MesPrint(
" ... Too small value for linesize corrected to 39");
291 MesPrint(
"&Illegal linesize field in format statement");
295 key = FindKeyWord(s,formatoptions,
296 sizeof(formatoptions)/
sizeof(
KEYWORD));
298 if ( key->type == FORTRANMODE || key->type == PFORTRANMODE || key->type == DOUBLEFORTRANMODE
299 || key->type == QUADRUPLEFORTRANMODE || key->type == VORTRANMODE ) {
300 if (AC.LineLength > 72) AC.LineLength = 72;
302 if ( key->flags == 0 ) {
303 if ( key->type == FORTRANMODE || key->type == PFORTRANMODE
304 || key->type == DOUBLEFORTRANMODE || key->type == ALLINTEGERDOUBLE
305 || key->type == QUADRUPLEFORTRANMODE || key->type == VORTRANMODE ) {
306 AC.IsFortran90 = ISNOTFORTRAN90;
307 if ( AC.Fortran90Kind ) {
308 M_free(AC.Fortran90Kind,
"Fortran90 Kind");
309 AC.Fortran90Kind = 0;
312 if ( ( key->type == ALLINTEGERDOUBLE ) && AO.DoubleFlag != 0 ) {
317 AC.OutputMode = key->type & NODOUBLEMASK;
318 if ( ( key->type & DOUBLEPRECISIONFLAG ) != 0 ) {
321 else if ( ( key->type & QUADRUPLEPRECISIONFLAG ) != 0 ) {
326 else if ( key->flags == 1 ) {
327 AC.OutputMode = AC.OutNumberType = key->type;
329 else if ( key->flags == 2 ) {
330 while ( FG.cTable[*s] == 0 ) s++;
331 if ( *s == 0 ) AC.OutNumberType = 10;
332 else if ( *s ==
',' ) {
335 while ( FG.cTable[*s] == 1 ) x = 10*x + *s++ -
'0';
338 MesPrint(
"&Illegal float format specifier");
343 MesPrint(
"& ... float format value corrected to 3");
347 MesPrint(
"& ... float format value corrected to 100");
349 AC.OutNumberType = x;
353 else if ( key->flags == 3 ) {
354 AC.OutputSpaces = key->type;
356 else if ( key->flags == 4 ) {
357 AC.IsFortran90 = ISFORTRAN90;
358 if ( AC.Fortran90Kind ) {
359 M_free(AC.Fortran90Kind,
"Fortran90 Kind");
360 AC.Fortran90Kind = 0;
362 while ( FG.cTable[*s] <= 1 ) s++;
365 while ( *ss && *ss !=
',' ) ss++;
367 MesPrint(
"&No white space or comma's allowed in Fortran90 option: %s",s); error = 1;
370 AC.Fortran90Kind = strDup1(s,
"Fortran90 Kind");
374 AC.OutputMode = key->type & NODOUBLEMASK;
377 else if ( key->flags == 5 ) {
382 while ( FG.cTable[*s] == 0 ) s++;
383 while ( *s ==
' ' || *s ==
'\t' || *s ==
',' ) s++;
387 else if ( tolower(*s) ==
'o' && tolower(s[1]) ==
'f'
388 && tolower(s[2]) ==
'f' ) {
391 while ( *s ==
' ' || *s ==
'\t' || *s ==
',' ) s++;
392 if ( *s ) { s = ss;
goto WrongOption; }
395 else if ( FG.cTable[*s] == 1 ) {
397 ParseNumber(AO.FloatPrec,s)
402 if ( tolower(*s) ==
'd' ) { s++; }
403 else if ( tolower(*s) ==
'b' ) { AO.FloatPrec = AO.FloatPrec*log10(2.0); s++; }
404 else { s = ss;
goto WrongOption; }
405 while ( *s ==
' ' || *s ==
'\t' || *s ==
',' ) s++;
406 if ( *s ) { s = ss;
goto WrongOption; }
409WrongOption: MesPrint(
"&Illegal option in Format FloatPrecision: %s",s);
415 else if ( ( *s ==
'c' || *s ==
'C' ) && ( FG.cTable[s[1]] == 1 ) ) {
418 while ( *ss >=
'0' && *ss <=
'9' ) x = 10*x + *ss++ -
'0';
419 if ( *ss != 0 )
goto Unknown;
420 AC.OutputMode = CMODE;
424Unknown: MesPrint(
"&Unknown option: %s",s); error = 1;
437int CoCollect(UBYTE *s)
443 AC.AltCollectFun = 0;
444 if ( t == 0 )
goto syntaxerror;
445 t1 = t;
while ( *t1 ==
',' || *t1 ==
' ' || *t1 ==
'\t' ) t1++;
447 if ( *t1 && ( FG.cTable[*t1] == 0 || *t1 ==
'[' ) ) {
449 if ( t2 == 0 )
goto syntaxerror;
451 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
455 if ( *t && FG.cTable[*t] == 1 ) {
456 while ( *t >=
'0' && *t <=
'9' ) x = 10*x + *t++ -
'0';
457 if ( x > 100 ) x = 100;
458 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
459 if ( *t )
goto syntaxerror;
462 if ( *t )
goto syntaxerror;
465 if ( ( ( type = GetName(AC.varnames,s,&numfun,WITHAUTO) ) != CFUNCTION )
466 || ( functions[numfun].spec != 0 ) ) {
467 MesPrint(
"&%s should be a regular function",s);
469 if ( GetName(AC.exprnames,s,&numfun,NOAUTO) == NAMENOTFOUND )
470 AddFunction(s,0,0,0,0,0,-1,-1);
474 AC.CollectFun = numfun+FUNCTION;
475 AC.CollectPercentage = (WORD)x;
477 if ( ( ( type = GetName(AC.varnames,t1,&numfun,WITHAUTO) ) != CFUNCTION )
478 || ( functions[numfun].spec != 0 ) ) {
479 MesPrint(
"&%s should be a regular function",t1);
481 if ( GetName(AC.exprnames,t1,&numfun,NOAUTO) == NAMENOTFOUND )
482 AddFunction(t1,0,0,0,0,0,-1,-1);
486 AC.AltCollectFun = numfun+FUNCTION;
490 MesPrint(
"&Collect statement needs one or two functions (and a percentage) for its argument(s)");
499int setonoff(UBYTE *s,
int *flag,
int onvalue,
int offvalue)
501 if ( StrICmp(s,(UBYTE *)
"on") == 0 ) *flag = onvalue;
502 else if ( StrICmp(s,(UBYTE *)
"off") == 0 ) *flag = offvalue;
504 MesPrint(
"&Unknown option: %s, on or off expected",s);
515int CoCompress(UBYTE *s)
519 if ( StrICmp(s,(UBYTE *)
"on") == 0 ) {
523 else if ( StrICmp(s,(UBYTE *)
"off") == 0 ) {
528 t = s;
while ( FG.cTable[*t] <= 1 ) t++;
530 if ( StrICmp(s,(UBYTE *)
"gzip") == 0 ) {
532 Warning(
"gzip compression not supported on this platform");
536 AR.gzipCompress = GZIPDEFAULT;
539 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
541 if ( FG.cTable[*s] == 1 ) {
542 AR.gzipCompress = *s -
'0';
544 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
545 if ( *s == 0 )
return(0);
547 MesPrint(
"&Unknown gzip option: %s, a digit was expected",t);
552 MesPrint(
"&Unknown option: %s, on, off or gzip expected",s);
564int CoFlags(UBYTE *s,
int value)
568 MesPrint(
"&Proper syntax is: On/Off Flag,number[s];");
571 while ( *s ==
',' ) {
572 do { s++; }
while ( *s ==
',' );
574 if ( FG.cTable[*s] != 1 ) {
575 MesPrint(
"&Proper syntax is: On/Off Flag,number[s];");
579 while ( FG.cTable[*s] == 1 ) { i = 10*i + *s++ -
'0'; }
580 if ( i <= 0 || i > MAXFLAGS ) {
581 MesPrint(
"&The number of a flag in On/Off Flag should be in the range 0-%d",(
int)MAXFLAGS);
585 AC.debugFlags[i] = value;
588 MesPrint(
"&Proper syntax is: On/Off Flag,number[s];");
603 int i, num =
sizeof(onoffoptions)/
sizeof(
KEYWORD);
605 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
606 if ( *s == 0 )
return(0);
607 if ( chartype[*s] != 0 ) {
608 MesPrint(
"&Illegal character or option encountered in OFF statement");
611 t = s;
while ( chartype[*s] == 0 ) s++;
613 for ( i = 0; i < num; i++ ) {
614 if ( StrICont(t,(UBYTE *)(onoffoptions[i].name)) == 0 )
break;
617 MesPrint(
"&Unrecognized option in OFF statement: %s",t);
620 else if ( StrICont(t,(UBYTE *)
"compress") == 0 ) {
623 else if ( StrICont(t,(UBYTE *)
"checkpoint") == 0 ) {
625 AC.CheckpointInterval = 0;
626 if ( AC.CheckpointRunBefore ) { free(AC.CheckpointRunBefore); AC.CheckpointRunBefore = NULL; }
627 if ( AC.CheckpointRunAfter ) { free(AC.CheckpointRunAfter); AC.CheckpointRunAfter = NULL; }
628 if ( AC.NoShowInput == 0 ) MesPrint(
"Checkpoints deactivated.");
630 else if ( StrICont(t,(UBYTE *)
"threads") == 0 ) {
631 AS.MultiThreaded = 0;
633 else if ( StrICont(t,(UBYTE *)
"flag") == 0 ) {
635 return(CoFlags(s,0));
637 else if ( StrICont(t,(UBYTE *)
"innertest") == 0 ) {
640 if ( AC.TestValue ) {
641 M_free(AC.TestValue,
"InnerTest");
645 else if ( StrICont(t,(UBYTE *)
"sortreallocate") == 0 ) {
646 if ( AC.SortReallocateFlag == 2 ) {
654 *onoffoptions[i].var = onoffoptions[i].flags;
655 AR.SortType = AC.SortType;
656 AC.mparallelflag = AC.parallelflag | AM.hparallelflag;
669 int i, num =
sizeof(onoffoptions)/
sizeof(
KEYWORD);
672 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
673 if ( *s == 0 )
return(0);
674 if ( chartype[*s] != 0 ) {
675 MesPrint(
"&Illegal character or option encountered in ON statement");
678 t = s;
while ( chartype[*s] == 0 ) s++;
680 for ( i = 0; i < num; i++ ) {
681 if ( StrICont(t,(UBYTE *)(onoffoptions[i].name)) == 0 )
break;
684 MesPrint(
"&Unrecognized option in ON statement: %s",t);
687 if ( StrICont(t,(UBYTE *)
"backtrace") == 0 ) {
688#ifndef ENABLE_BACKTRACE
689 Warning(
"backtrace not supported on this platform");
692 else if ( StrICont(t,(UBYTE *)
"compress") == 0 ) {
695 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
698 while ( FG.cTable[*s] <= 1 ) s++;
700 if ( StrICmp(t,(UBYTE *)
"gzip") == 0 ) {
702 Warning(
"gzip compression not supported on this platform");
706 ZWRAP_useZSTDcompression(0);
709 else if ( StrICmp(t,(UBYTE *)
"zstd") == 0 ) {
711 ZWRAP_useZSTDcompression(1);
713 Warning(
"zstd compression not supported on this platform");
717 MesPrint(
"&Unrecognized option in ON compress statement: %s",t);
722 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
723 if ( FG.cTable[*s] == 1 ) {
724 AR.gzipCompress = *s++ -
'0';
725 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
727 MesPrint(
"&Unrecognized option in ON compress gzip/zstd statement: %s",t);
731 else if ( *s == 0 ) {
732 AR.gzipCompress = GZIPDEFAULT;
735 MesPrint(
"&Unrecognized option in ON compress gzip/zstd statement: %s, single digit expected",t);
740 else if ( StrICont(t,(UBYTE *)
"checkpoint") == 0 ) {
742 AC.CheckpointInterval = 0;
743 if ( AC.CheckpointRunBefore ) { free(AC.CheckpointRunBefore); AC.CheckpointRunBefore = NULL; }
744 if ( AC.CheckpointRunAfter ) { free(AC.CheckpointRunAfter); AC.CheckpointRunAfter = NULL; }
747 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
748 if ( FG.cTable[*s] == 1 ) {
751 do { interval = 10*interval + *s++ -
'0'; }
while ( FG.cTable[*s] == 1 );
752 if ( *s ==
's' || *s ==
'S' ) {
755 else if ( *s ==
'm' || *s ==
'M' ) {
758 else if ( *s ==
'h' || *s ==
'H' ) {
759 interval *= 3600; s++;
761 else if ( *s ==
'd' || *s ==
'D' ) {
762 interval *= 86400; s++;
764 if ( *s !=
',' && FG.cTable[*s] != 6 && FG.cTable[*s] != 10 ) {
765 MesPrint(
"&Unrecognized time interval in ON Checkpoint statement: %s", t);
768 AC.CheckpointInterval = interval * 100;
770 else if ( FG.cTable[*s] == 0 ) {
773 while ( FG.cTable[*s] == 0 ) s++;
775 if ( StrICmp(t,(UBYTE *)
"run") == 0 ) {
778 else if ( StrICmp(t,(UBYTE *)
"runafter") == 0 ) {
781 else if ( StrICmp(t,(UBYTE *)
"runbefore") == 0 ) {
785 MesPrint(
"&Unrecognized option in ON Checkpoint statement: %s", t);
789 if ( *s !=
'=' && FG.cTable[*(s+1)] != 9 ) {
790 MesPrint(
"&Unrecognized option in ON Checkpoint statement: %s", t);
796 if ( FG.cTable[*s] == 9 ) {
799 if ( AC.CheckpointRunBefore ) {
800 free(AC.CheckpointRunBefore); AC.CheckpointRunBefore = NULL;
803 AC.CheckpointRunBefore = Malloc1(s-t+1,
"AC.CheckpointRunBefore");
804 StrCopy(t, (UBYTE*)AC.CheckpointRunBefore);
808 if ( AC.CheckpointRunAfter ) {
809 free(AC.CheckpointRunAfter); AC.CheckpointRunAfter = NULL;
812 AC.CheckpointRunAfter = Malloc1(s-t+1,
"AC.CheckpointRunAfter");
813 StrCopy(t, (UBYTE*)AC.CheckpointRunAfter);
821 if ( FG.cTable[*s] != 9 ) {
822 MesPrint(
"&Unrecognized option in ON Checkpoint statement: %s", t);
846 else if ( StrICont(t,(UBYTE *)
"indentspace") == 0 ) {
848 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
851 while ( FG.cTable[*s] == 1 ) { i = 10*i + *s++ -
'0'; }
853 MesPrint(
"&Unrecognized option in ON IndentSpace statement: %s",t);
857 Warning(
"IndentSpace parameter adjusted to 40");
863 AO.IndentSpace = AM.ggIndentSpace;
867 else if ( ( StrICont(t,(UBYTE *)
"fewerstats") == 0 ) ||
868 ( StrICont(t,(UBYTE *)
"fewerstatistics") == 0 ) ) {
870 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
873 while ( FG.cTable[*s] == 1 ) { i = 10*i + *s++ -
'0'; }
875 MesPrint(
"&Unrecognized option in ON FewerStatistics statement: %s",t);
878 if ( i > AM.S0->MaxPatches ) {
880 MesPrint(
"&Warning: FewerStatistics parameter greater than MaxPatches(=%d). Adjusted to %d"
881 ,AM.S0->MaxPatches,(AM.S0->MaxPatches+1)/2);
882 i = (AM.S0->MaxPatches+1)/2;
884 AC.ShortStatsMax = i;
887 AC.ShortStatsMax = 10;
891 else if ( StrICont(t,(UBYTE *)
"threads") == 0 ) {
892 if ( AM.totalnumberofthreads > 1 ) AS.MultiThreaded = 1;
894 else if ( StrICont(t,(UBYTE *)
"flag") == 0 ) {
896 return(CoFlags(s,1));
898 else if ( StrICont(t,(UBYTE *)
"innertest") == 0 ) {
901 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
903 t = s;
while ( *t ) t++;
904 while ( t[-1] ==
' ' || t[-1] ==
'\t' ) t--;
906 if ( AC.TestValue ) M_free(AC.TestValue,
"InnerTest");
907 AC.TestValue = strDup1(s,
"InnerTest");
910 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
913 if ( AC.TestValue ) {
914 M_free(AC.TestValue,
"InnerTest");
919 else if ( StrICont(t,(UBYTE *)
"flint") == 0 ) {
921 MesPrint(
"&Warning: FORM was not built with FLINT support.");
922 MesPrint(
"Statement has no effect.");
926 *onoffoptions[i].var = onoffoptions[i].type;
927 AR.SortType = AC.SortType;
928 AC.mparallelflag = AC.parallelflag | AM.hparallelflag;
937int CoInsideFirst(UBYTE *s) {
return(setonoff(s,&AC.insidefirst,1,0)); }
944int CoProperCount(UBYTE *s) {
return(setonoff(s,&AC.BottomLevel,1,0)); }
951int CoDelete(UBYTE *s)
954 if ( StrICmp(s,(UBYTE *)
"storage") == 0 ) {
955 if ( DeleteStore(1) < 0 ) {
957 MesPrint(
"!>Cannot restart storage file");
964 while ( *t && *t !=
',' && *t !=
'>' ) t++;
966 if ( ( StrICmp(s,(UBYTE *)
"extrasymbols") == 0 )
967 || ( StrICmp(s,(UBYTE *)
"extrasymbol") == 0 ) ) {
975 if ( FG.cTable[*s] != 1 )
goto unknown;
976 while ( *s <=
'9' && *s >=
'0' ) x = 10*x + *s++ -
'0';
977 if ( *s )
goto unknown;
979 else if ( *s )
goto unknown;
980 if ( x < AM.gnumextrasym ) x = AM.gnumextrasym;
981 PruneExtraSymbols(x);
986 MesPrint(
"&Unknown option: %s",s);
1000 if ( StrICmp(s,(UBYTE *)
"brackets") == 0 ) AC.ComDefer = 1;
1001 else { MesPrint(
"&Unknown option: '%s'",s);
return(1); }
1010int CoFixIndex(UBYTE *s)
1012 int x, y, error = 0;
1014 if ( FG.cTable[*s] != 1 ) {
1015proper: MesPrint(
"&Proper syntax is: FixIndex,number:value[,number,value];");
1019 if ( *s !=
':' )
goto proper;
1021 if ( *s !=
'-' && *s !=
'+' && FG.cTable[*s] != 1 )
goto proper;
1022 ParseSignedNumber(y,s)
1023 if ( *s && *s !=
',' )
goto proper;
1024 while ( *s ==
',' ) s++;
1025 if ( x >= AM.OffsetIndex ) {
1026 MesPrint(
"&Fixed index out of allowed range. Change ConstIndex in setup file?");
1027 MesPrint(
"&Current value of ConstIndex = %d",AM.OffsetIndex-1);
1030 if ( y != (
int)((WORD)y) ) {
1031 MesPrint(
"&Value of d_(%d,%d) outside range for this computer",x,x);
1034 if ( error == 0 ) AC.FixIndices[x] = y;
1044int CoMetric(UBYTE *s)
1045{ DUMMYUSE(s); MesPrint(
"&The metric statement does not do anything yet");
return(1); }
1052int DoPrint(UBYTE *s,
int par)
1054 int i, error = 0, numdol = 0, type;
1058 WORD numexpr, tofile = 0, *w, par2 = 0;
1059 CBUF *C = cbuf + AC.cbufnum;
1060 while ( *s ==
',' ) s++;
1061 if ( ( *s ==
'+' || *s ==
'-' ) && ( s[1] ==
'f' || s[1] ==
'F' ) ) {
1062 t = s + 2;
while ( *t ==
' ' || *t ==
',' ) t++;
1064 if ( *s ==
'+' ) { tofile = 1; handle = AC.LogHandle; }
1068 else if ( *s ==
'<' ) {
1071 while ( *s && *s !=
'>' ) s++;
1073 MesPrint(
"&Improper filename in print statement");
1078 if ( ( handle = GetChannel((
char *)filename,1) ) < 0 )
return(1);
1079 SKIPBLANKS(s)
if ( *s ==
',' ) s++; SKIPBLANKS(s)
1080 if ( *s ==
'+' && ( s[1] ==
's' || s[1] ==
'S' ) ) {
1082 par2 |= PRINTONETERM;
1083 if ( *s ==
's' || *s ==
'S' ) {
1085 par2 |= PRINTONEFUNCTION;
1086 if ( *s ==
's' || *s ==
'S' ) {
1091 SKIPBLANKS(s)
if ( *s ==
',' ) s++; SKIPBLANKS(s)
1094 if ( par == PRINTON && *s ==
'"' ) {
1096 if ( tofile == 1 ) code[0] = TYPEFPRINT;
1097 else code[0] = TYPEPRINT;
1101 while ( *s && *s !=
'"' ) {
1102 if ( *s ==
'\\' ) s++;
1103 if ( *s ==
'%' && s[1] ==
'$' ) numdol++;
1107 MesPrint(
"&String in print statement should be enclosed in \"");
1111 AddComString(3,code,name,1);
1113 while ( *s ==
',' ) {
1116 s++; name = s;
while ( FG.cTable[*s] <= 1 ) s++;
1118 type = GetName(AC.dollarnames,name,&numexpr,NOAUTO);
1119 if ( type == NAMENOTFOUND ) {
1120 MesPrint(
"&$ variable %s not (yet) defined",name);
1124 C->
lhs[C->numlhs][1] += 2;
1125 *(C->
Pointer)++ = DOLLAREXPRESSION;
1131 MesPrint(
"&Illegal object in print statement");
1139 s = GetDoParam(s,&(C->
Pointer),-1);
1140 if ( s == 0 )
return(1);
1142 MesPrint(
"&unmatched [] in $ factor");
1150 MesPrint(
"&Illegal object in print statement");
1154 MesPrint(
"&More $ variables asked for than provided");
1162 for ( e = Expressions, i = NumExpressions; i > 0; i--, e++ ) {
1163 if ( e->status == LOCALEXPRESSION || e->status ==
1164 GLOBALEXPRESSION || e->status == UNHIDELEXPRESSION
1165 || e->status == UNHIDEGEXPRESSION ) e->printflag = par;
1172 if ( tolower(*s) ==
'f' ) par |= PRINTLFILE;
1173 else if ( tolower(*s) ==
's' ) {
1174 if ( tolower(s[1]) ==
's' ) {
1175 if ( tolower(s[2]) ==
's' ) {
1176 par |= PRINTONEFUNCTION | PRINTONETERM | PRINTALL;
1179 else if ( ( par & 3 ) < 2 ) par |= PRINTONEFUNCTION | PRINTONETERM;
1183 if ( ( par & 3 ) < 2 ) par |= PRINTONETERM;
1187illeg: MesPrint(
"&Illegal option in (n)print statement");
1191 if ( *s == 0 )
goto AllExpr;
1193 else if ( *s ==
'-' ) {
1195 if ( tolower(*s) ==
'f' ) par &= ~PRINTLFILE;
1196 else if ( tolower(*s) ==
's' ) {
1197 if ( tolower(s[1]) ==
's' ) {
1198 if ( tolower(s[2]) ==
's' ) {
1202 else if ( ( par & 3 ) < 2 ) {
1203 par &= ~PRINTONEFUNCTION;
1209 if ( ( par & 3 ) < 2 ) {
1210 par &= ~PRINTONETERM;
1211 par &= ~PRINTONEFUNCTION;
1218 if ( *s == 0 )
goto AllExpr;
1220 else if ( FG.cTable[*s] == 0 || *s ==
'[' ) {
1223 MesPrint(
"&Improper name in (n)print statement");
1227 if ( ( GetName(AC.exprnames,name,&numexpr,NOAUTO) == CEXPRESSION )
1228 && ( Expressions[numexpr].status == LOCALEXPRESSION
1229 || Expressions[numexpr].status == GLOBALEXPRESSION ) ) {
1231 if ( c ==
'[' && s[1] ==
']' ) {
1232 Expressions[numexpr].printflag = par | PRINTCONTENTS;
1236 Expressions[numexpr].printflag = par;
1238 else if ( GetLastExprName(name,&numexpr)
1239 && ( Expressions[numexpr].status == LOCALEXPRESSION
1240 || Expressions[numexpr].status == GLOBALEXPRESSION
1241 || Expressions[numexpr].status == UNHIDELEXPRESSION
1242 || Expressions[numexpr].status == UNHIDEGEXPRESSION
1247 MesPrint(
"&%s is not the name of an active expression",name);
1251 if ( c == 0 )
return(0);
1252 if ( c ==
'-' || c ==
'+' ) s--;
1254 else if ( *s ==
',' ) s++;
1256 MesPrint(
"&Illegal object in (n)print statement");
1268int CoPrint(UBYTE *s) {
return(DoPrint(s,PRINTON)); }
1275int CoPrintB(UBYTE *s) {
return(DoPrint(s,PRINTCONTENT)); }
1282int CoNPrint(UBYTE *s) {
return(DoPrint(s,PRINTOFF)); }
1289int CoPushHide(UBYTE *s)
1294 if ( AR.Fscr[2].PObuffer == 0 ) {
1295 ScratchBuf = (WORD *)Malloc1(AM.HideSize*
sizeof(WORD),
"hidesize");
1296 AR.Fscr[2].POsize = AM.HideSize *
sizeof(WORD);
1297 AR.Fscr[2].POfull = AR.Fscr[2].POfill = AR.Fscr[2].PObuffer = ScratchBuf;
1298 AR.Fscr[2].POstop = AR.Fscr[2].PObuffer + AM.HideSize;
1299 PUTZERO(AR.Fscr[2].POposition);
1301 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
1304 MesPrint(
"&PushHide statement should have no arguments");
1307 for ( i = 0; i < NumExpressions; i++ ) {
1308 switch ( Expressions[i].status ) {
1309 case DROPLEXPRESSION:
1310 case SKIPLEXPRESSION:
1311 case LOCALEXPRESSION:
1312 Expressions[i].status = HIDELEXPRESSION;
1313 Expressions[i].hidelevel = AC.HideLevel-1;
1315 case DROPGEXPRESSION:
1316 case SKIPGEXPRESSION:
1317 case GLOBALEXPRESSION:
1318 Expressions[i].status = HIDEGEXPRESSION;
1319 Expressions[i].hidelevel = AC.HideLevel-1;
1333int CoPopHide(UBYTE *s)
1336 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
1337 if ( AC.HideLevel <= 0 ) {
1338 MesPrint(
"&PopHide statement without corresponding PushHide statement");
1343 MesPrint(
"&PopHide statement should have no arguments");
1346 for ( i = 0; i < NumExpressions; i++ ) {
1347 switch ( Expressions[i].status ) {
1348 case HIDDENLEXPRESSION:
1349 if ( Expressions[i].hidelevel > AC.HideLevel )
1350 Expressions[i].status = UNHIDELEXPRESSION;
1352 case HIDDENGEXPRESSION:
1353 if ( Expressions[i].hidelevel > AC.HideLevel )
1354 Expressions[i].status = UNHIDEGEXPRESSION;
1368int SetExprCases(
int par,
int setunset,
int val)
1373 case SKIPLEXPRESSION:
1374 if ( !setunset ) val = LOCALEXPRESSION;
1376 case SKIPGEXPRESSION:
1377 if ( !setunset ) val = GLOBALEXPRESSION;
1379 case LOCALEXPRESSION:
1380 if ( setunset ) val = SKIPLEXPRESSION;
1382 case GLOBALEXPRESSION:
1383 if ( setunset ) val = SKIPGEXPRESSION;
1385 case INTOHIDEGEXPRESSION:
1386 case INTOHIDELEXPRESSION:
1393 case SKIPLEXPRESSION:
1394 case LOCALEXPRESSION:
1395 case HIDELEXPRESSION:
1396 if ( setunset ) val = DROPLEXPRESSION;
1398 case DROPLEXPRESSION:
1399 if ( !setunset ) val = LOCALEXPRESSION;
1401 case SKIPGEXPRESSION:
1402 case GLOBALEXPRESSION:
1403 case HIDEGEXPRESSION:
1404 if ( setunset ) val = DROPGEXPRESSION;
1406 case DROPGEXPRESSION:
1407 if ( !setunset ) val = GLOBALEXPRESSION;
1409 case HIDDENLEXPRESSION:
1410 case UNHIDELEXPRESSION:
1411 if ( setunset ) val = DROPHLEXPRESSION;
1413 case HIDDENGEXPRESSION:
1414 case UNHIDEGEXPRESSION:
1415 if ( setunset ) val = DROPHGEXPRESSION;
1417 case DROPHLEXPRESSION:
1418 if ( !setunset ) val = HIDDENLEXPRESSION;
1420 case DROPHGEXPRESSION:
1421 if ( !setunset ) val = HIDDENGEXPRESSION;
1423 case INTOHIDEGEXPRESSION:
1424 case INTOHIDELEXPRESSION:
1431 case DROPLEXPRESSION:
1432 case SKIPLEXPRESSION:
1433 case LOCALEXPRESSION:
1434 if ( setunset ) val = HIDELEXPRESSION;
1436 case HIDELEXPRESSION:
1437 if ( !setunset ) val = LOCALEXPRESSION;
1439 case DROPGEXPRESSION:
1440 case SKIPGEXPRESSION:
1441 case GLOBALEXPRESSION:
1442 if ( setunset ) val = HIDEGEXPRESSION;
1444 case HIDEGEXPRESSION:
1445 if ( !setunset ) val = GLOBALEXPRESSION;
1447 case INTOHIDEGEXPRESSION:
1448 case INTOHIDELEXPRESSION:
1455 case HIDDENLEXPRESSION:
1456 case DROPHLEXPRESSION:
1457 if ( setunset ) val = UNHIDELEXPRESSION;
1459 case UNHIDELEXPRESSION:
1460 if ( !setunset ) val = HIDDENLEXPRESSION;
1462 case HIDDENGEXPRESSION:
1463 case DROPHGEXPRESSION:
1464 if ( setunset ) val = UNHIDEGEXPRESSION;
1466 case UNHIDEGEXPRESSION:
1467 if ( !setunset ) val = HIDDENGEXPRESSION;
1469 case INTOHIDEGEXPRESSION:
1470 case INTOHIDELEXPRESSION:
1477 case HIDDENLEXPRESSION:
1478 case HIDDENGEXPRESSION:
1479 MesPrint(
"&Expression is already hidden");
1481 case DROPHLEXPRESSION:
1482 case DROPHGEXPRESSION:
1483 case UNHIDELEXPRESSION:
1484 case UNHIDEGEXPRESSION:
1486 MesPrint(
"&Cannot unhide/drop and put intohide expression in the same module");
1490 case LOCALEXPRESSION:
1491 case DROPLEXPRESSION:
1492 case SKIPLEXPRESSION:
1493 case HIDELEXPRESSION:
1494 if ( setunset ) val = INTOHIDELEXPRESSION;
1496 case GLOBALEXPRESSION:
1497 case DROPGEXPRESSION:
1498 case SKIPGEXPRESSION:
1499 case HIDEGEXPRESSION:
1500 if ( setunset ) val = INTOHIDEGEXPRESSION;
1502 case INTOHIDELEXPRESSION:
1503 if ( !setunset ) val = LOCALEXPRESSION;
1505 case INTOHIDEGEXPRESSION:
1506 if ( !setunset ) val = GLOBALEXPRESSION;
1523int SetExpr(UBYTE *s,
int setunset,
int par)
1529 for ( i = 0; i < NumExpressions; i++ ) {
1530 w = &(Expressions[i].status);
1531 *w = SetExprCases(par,setunset,*w);
1532 if ( *w < 0 ) error = 1;
1533 if ( ( par == HIDE || par == INTOHIDE ) && setunset == 1 )
1534 Expressions[i].hidelevel = AC.HideLevel;
1539 if ( *s ==
',' ) { s++;
continue; }
1540 if ( *s ==
'0' ) { s++;
continue; }
1543 MesPrint(
"&Improper name for an expression: '%s'",name);
1547 if ( GetName(AC.exprnames,name,&numexpr,NOAUTO) == CEXPRESSION ) {
1548 w = &(Expressions[numexpr].status);
1549 *w = SetExprCases(par,setunset,*w);
1550 if ( *w < 0 ) error = 1;
1551 if ( ( par == HIDE || par == INTOHIDE ) && setunset == 1 )
1552 Expressions[numexpr].hidelevel = AC.HideLevel;
1554 else if ( GetName(AC.varnames,name,&numexpr,NOAUTO) != NAMENOTFOUND ) {
1555 MesPrint(
"&%s is not an expression",name);
1568int CoDrop(UBYTE *s) {
return(SetExpr(s,1,DROP)); }
1575int CoNoDrop(UBYTE *s) {
return(SetExpr(s,0,DROP)); }
1582int CoSkip(UBYTE *s) {
return(SetExpr(s,1,SKIP)); }
1589int CoNoSkip(UBYTE *s) {
return(SetExpr(s,0,SKIP)); }
1596int CoHide(UBYTE *inp) {
1599 if ( AR.Fscr[2].PObuffer == 0 ) {
1600 ScratchBuf = (WORD *)Malloc1(AM.HideSize*
sizeof(WORD),
"hidesize");
1601 AR.Fscr[2].POsize = AM.HideSize *
sizeof(WORD);
1602 AR.Fscr[2].POfull = AR.Fscr[2].POfill = AR.Fscr[2].PObuffer = ScratchBuf;
1603 AR.Fscr[2].POstop = AR.Fscr[2].PObuffer + AM.HideSize;
1604 PUTZERO(AR.Fscr[2].POposition);
1606 return(SetExpr(inp,1,HIDE));
1614int CoIntoHide(UBYTE *inp) {
1617 if ( AR.Fscr[2].PObuffer == 0 ) {
1618 ScratchBuf = (WORD *)Malloc1(AM.HideSize*
sizeof(WORD),
"hidesize");
1619 AR.Fscr[2].POsize = AM.HideSize *
sizeof(WORD);
1620 AR.Fscr[2].POfull = AR.Fscr[2].POfill = AR.Fscr[2].PObuffer = ScratchBuf;
1621 AR.Fscr[2].POstop = AR.Fscr[2].PObuffer + AM.HideSize;
1622 PUTZERO(AR.Fscr[2].POposition);
1624 return(SetExpr(inp,1,INTOHIDE));
1632int CoNoIntoHide(UBYTE *inp) {
return(SetExpr(inp,0,INTOHIDE)); }
1639int CoNoHide(UBYTE *inp) {
return(SetExpr(inp,0,HIDE)); }
1646int CoUnHide(UBYTE *inp) {
return(SetExpr(inp,1,UNHIDE)); }
1653int CoNoUnHide(UBYTE *inp) {
return(SetExpr(inp,0,UNHIDE)); }
1660void AddToCom(
int n, WORD *array)
1662 CBUF *C = cbuf+AC.cbufnum;
1664 MesPrint(
" %a",n,array);
1667 while ( --n >= 0 ) *(C->
Pointer)++ = *array++;
1675int AddComString(
int n, WORD *array, UBYTE *thestring,
int par)
1677 CBUF *C = cbuf+AC.cbufnum;
1678 UBYTE *s = thestring, *w;
1683 int i, numchars = 0, size, zeroes;
1685 if ( *s ==
'\\' ) s++;
1686 else if ( par == 1 &&
1687 ( ( *s ==
'%' && s[1] !=
't' && s[1] !=
'T' && s[1] !=
'$' &&
1688 s[1] !=
'w' && s[1] !=
'W' && s[1] !=
'r' && s[1] != 0 ) || *s ==
'#'
1689 || *s ==
'@' || *s ==
'&' ) ) {
1695 size = numchars/
sizeof(WORD)+1;
1702 for ( i = 1; i < n; i++ ) *(C->
Pointer)++ = array[i];
1708 zeroes = size*
sizeof(WORD)-numchars;
1711 if ( *s ==
'\\' ) s++;
1712 else if ( par == 1 && ( ( *s ==
'%' &&
1713 s[1] !=
't' && s[1] !=
'T' && s[1] !=
'$' &&
1714 s[1] !=
'w' && s[1] !=
'W' && s[1] !=
'r' && s[1] != 0 ) || *s ==
'#'
1715 || *s ==
'@' || *s ==
'&' ) ) {
1720 while ( --zeroes >= 0 ) *w++ = 0;
1723 MesPrint(
"LH: %a",size+1+n,cc);
1724 MesPrint(
" %s",thestring);
1734int Add2ComStrings(
int n, WORD *array, UBYTE *string1, UBYTE *string2)
1736 CBUF *C = cbuf+AC.cbufnum;
1737 UBYTE *s1 = string1, *s2 = string2, *w;
1738 int i, num1chars = 0, num2chars = 0, size1, size2, zeroes1, zeroes2;
1740 while ( *s1 ) { s1++; num1chars++; }
1741 size1 = num1chars/
sizeof(WORD)+1;
1743 while ( *s2 ) { s2++; num2chars++; }
1744 size2 = num2chars/
sizeof(WORD)+1;
1749 *(C->
Pointer)++ = size1+size2+n+3;
1750 for ( i = 1; i < n; i++ ) *(C->
Pointer)++ = array[i];
1753 zeroes1 = size1*
sizeof(WORD)-num1chars;
1755 while ( *s1 ) { *w++ = *s1++; }
1756 while ( --zeroes1 >= 0 ) *w++ = 0;
1761 zeroes2 = size2*
sizeof(WORD)-num2chars;
1763 while ( *s2 ) { *w++ = *s2++; }
1764 while ( --zeroes2 >= 0 ) *w++ = 0;
1775int CoDiscard(UBYTE *s)
1778 Add2Com(TYPEDISCARD)
1781 MesPrint(
"&Illegal argument in discard statement: '%s'",s);
1796static WORD ccarray[5] = { TYPEOPERATION,5,CONTRACT,0,0 };
1798int CoContract(UBYTE *s)
1804 if ( *s !=
',' && *s ) {
1805proper: MesPrint(
"&Illegal number in contract statement");
1811 else ccarray[4] = 0;
1812 if ( FG.cTable[*s] == 1 ) {
1814 if ( *s )
goto proper;
1817 else if ( *s )
goto proper;
1818 else ccarray[3] = -1;
1827int CoGoTo(UBYTE *inp)
1831 while ( FG.cTable[*s] <= 1 ) s++;
1833 MesPrint(
"&Label should be an alpha-numeric string");
1837 Add3Com(TYPEGOTO,x);
1846int CoLabel(UBYTE *inp)
1850 while ( FG.cTable[*s] <= 1 ) s++;
1852 MesPrint(
"&Label should be an alpha-numeric string");
1856 if ( AC.Labels[x] >= 0 ) {
1857 MesPrint(
"&Label %s defined more than once",AC.LabelNames[x]);
1860 AC.Labels[x] = cbuf[AC.cbufnum].numlhs;
1873int DoArgument(UBYTE *s,
int par)
1876 UBYTE *name, *t, *v, c;
1877 WORD *oldworkpointer = AT.WorkPointer, *w, *ww, number, *scale;
1878 int error = 0, zeroflag, type, x;
1879 AC.lhdollarflag = 0;
1880 while ( *s ==
',' ) s++;
1886 if ( AC.arglevel >= MAXNEST ) {
1887 MesPrint(
"@Nesting of argument statements more than %d levels"
1891 AC.argsumcheck[AC.arglevel] = NestingChecksum();
1892 AC.argstack[AC.arglevel] = cbuf[AC.cbufnum].Pointer
1893 - cbuf[AC.cbufnum].Buffer + 2;
1895 *w++ = cbuf[AC.cbufnum].numlhs;
1900 case TYPESPLITFIRSTARG:
1901 case TYPESPLITLASTARG:
1903 case TYPEARGTOEXTRASYMBOL:
1904 *w++ = cbuf[AC.cbufnum].numlhs+1;
1912 s++; ParseSignedNumber(x,s)
1913 while ( *s ==
',' ) s++;
1917 t = s+1; SKIPBRA3(s)
1918 if ( par == TYPEARG ) {
1919 MesPrint(
"&Illegal () entry in argument statement");
1920 error = 1; s++;
goto skipbracks;
1922 else if ( par == TYPESPLITFIRSTARG ) {
1923 MesPrint(
"&Illegal () entry in splitfirstarg statement");
1924 error = 1; s++;
goto skipbracks;
1926 else if ( par == TYPESPLITLASTARG ) {
1927 MesPrint(
"&Illegal () entry in splitlastarg statement");
1928 error = 1; s++;
goto skipbracks;
1933 MesPrint(
"&Wildcarding not allowed in this type of statement");
1939 if ( *t ==
'(' && v[-1] ==
')' ) {
1941 if ( par == TYPESPLITARG ) oldworkpointer[0] = TYPESPLITARG2;
1942 else if ( par == TYPEFACTARG ) oldworkpointer[0] = TYPEFACTARG2;
1943 else if ( par == TYPENORM4 ) oldworkpointer[0] = TYPENORM4;
1944 else if ( par == TYPENORM ) {
1945 if ( *t ==
'-' ) { oldworkpointer[0] = TYPENORM3; t++; }
1946 else { oldworkpointer[0] = TYPENORM2; *scale = 0; }
1950 CBUF *C = cbuf+AC.cbufnum;
1951 WORD oldnumrhs = C->numrhs, oldnumlhs = C->numlhs;
1952 WORD prototype[SUBEXPSIZE+40];
1957 prototype[0] = SUBEXPRESSION;
1958 prototype[1] = SUBEXPSIZE;
1959 prototype[2] = C->numrhs+1;
1961 prototype[4] = AC.cbufnum;
1962 AT.WorkPointer += TYPEARGHEADSIZE+1;
1964 if ( ( retcode = CompileAlgebra(t,LHSIDE,prototype) ) < 0 )
1967 prototype[2] = retcode;
1968 ww = C->
lhs[retcode];
1969 AC.lhdollarflag = 0;
1971 *w++ = -2; *w++ = 0;
1973 else if ( ww[ww[0]] != 0 ) {
1974 MesPrint(
"&There should be only one term between ()");
1977 else if (
NewSort(BHEAD0) ) {
if ( !error ) error = 1; }
1980 if ( !error ) error = 1;
1983 AN.RepPoint = AT.RepCount + 1;
1986 while ( --i >= 0 ) *m++ = *mm++;
1987 mm = AT.WorkPointer; AT.WorkPointer = m;
1988 AR.Cnumlhs = C->numlhs;
1992 else if (
EndSort(BHEAD mm,0) < 0 ) {
1994 AT.WorkPointer = mm;
1996 else if ( *mm == 0 ) {
1997 *w++ = -2; *w++ = 0;
1998 AT.WorkPointer = mm;
2000 else if ( mm[mm[0]] != 0 ) {
2002 AT.WorkPointer = mm;
2005 AT.WorkPointer = mm;
2007 if ( par == TYPEFACTARG ) {
2008 if ( *mm != ABS(m[-1])+1 ) {
2011 mm[-1] = -*mm-1; w += *mm+1;
2019 { mm[-1] = -*mm-1; w += *mm+1; }
2021 oldworkpointer[1] = w - oldworkpointer;
2025 oldworkpointer[5] = AC.lhdollarflag;
2028 C->numrhs = oldnumrhs;
2029 C->numlhs = oldnumlhs;
2034 if ( *s == 0 ) { *w++ = 0; *w++ = 2; *w++ = 1; }
2037 if ( *s ==
',' ) { s++;
continue; }
2038 ww = w; *w++ = 0; w++;
2039 if ( FG.cTable[*s] > 1 && *s !=
'[' && *s !=
'{' ) {
2040 MesPrint(
"&Illegal parameters in statement");
2044 while ( FG.cTable[*s] == 0 || *s ==
'[' || *s ==
'{' ) {
2049 number = DoTempSet(name,s);
2050 name--; *s++ = c; c = *s; *s = 0;
2056 MesPrint(
"&Illegal name '%s'",name);
2060 if ( ( type = GetName(AC.varnames,name,&number,WITHAUTO) ) == CSET ) {
2061doset:
if ( Sets[number].type != CFUNCTION )
goto nofun;
2064 r1 = SetElements + Sets[number].first;
2065 r2 = SetElements + Sets[number].last;
2067 if ( *r1++ == FLOATFUN ) {
2068 MesPrint(
"&Illegal use of argument environment and float_.");
2073 *w++ = CSET; *w++ = number;
2075 else if ( type == CFUNCTION ) {
2077 if ( (number + FUNCTION) == FLOATFUN ) {
2078 MesPrint(
"&Illegal use of argument environment and float_.");
2082 *w++ = CFUNCTION; *w++ = number + FUNCTION;
2085nofun: MesPrint(
"&%s is not a function or a set of functions"
2091 while ( *s ==
',' ) s++;
2094 ww = w; w++; zeroflag = 0;
2095 while ( FG.cTable[*s] == 1 ) {
2097 if ( *s && *s !=
',' ) {
2098 MesPrint(
"&Illegal separator after number");
2100 while ( *s && *s !=
',' ) s++;
2102 while ( *s ==
',' ) s++;
2103 if ( x == 0 ) zeroflag = 1;
2104 if ( !zeroflag ) *w++ = (WORD)x;
2109 oldworkpointer[1] = w - oldworkpointer;
2110 if ( par == TYPEARG ) {
2111 AC.argstack[AC.arglevel-1] = cbuf[AC.cbufnum].Pointer
2112 - cbuf[AC.cbufnum].Buffer + 2;
2114 AddNtoL(oldworkpointer[1],oldworkpointer);
2115 AT.WorkPointer = oldworkpointer;
2124int CoArgument(UBYTE *s) {
return(DoArgument(s,TYPEARG)); }
2131int CoEndArgument(UBYTE *s)
2133 CBUF *C = cbuf+AC.cbufnum;
2134 while ( *s ==
',' ) s++;
2136 MesPrint(
"&Illegal syntax for EndArgument statement");
2139 if ( AC.arglevel <= 0 ) {
2140 MesPrint(
"&EndArgument without corresponding Argument statement");
2144 cbuf[AC.cbufnum].Buffer[AC.argstack[AC.arglevel]] = C->numlhs;
2145 if ( AC.argsumcheck[AC.arglevel] != NestingChecksum() ) {
2157int CoInside(UBYTE *s) {
return(ExecInside(s)); }
2164int CoEndInside(UBYTE *s)
2166 CBUF *C = cbuf+AC.cbufnum;
2167 while ( *s ==
',' ) s++;
2169 MesPrint(
"&Illegal syntax for EndInside statement");
2172 if ( AC.insidelevel <= 0 ) {
2173 MesPrint(
"&EndInside without corresponding Inside statement");
2177 cbuf[AC.cbufnum].Buffer[AC.insidestack[AC.insidelevel]] = C->numlhs;
2178 if ( AC.insidesumcheck[AC.insidelevel] != NestingChecksum() ) {
2190int CoNormalize(UBYTE *s) {
return(DoArgument(s,TYPENORM)); }
2197int CoMakeInteger(UBYTE *s) {
return(DoArgument(s,TYPENORM4)); }
2204int CoSplitArg(UBYTE *s) {
return(DoArgument(s,TYPESPLITARG)); }
2211int CoSplitFirstArg(UBYTE *s) {
return(DoArgument(s,TYPESPLITFIRSTARG)); }
2218int CoSplitLastArg(UBYTE *s) {
return(DoArgument(s,TYPESPLITLASTARG)); }
2225int CoFactArg(UBYTE *s) {
2226 if ( ( AC.topolynomialflag & TOPOLYNOMIALFLAG ) != 0 ) {
2227 MesPrint(
"&ToPolynomial statement and FactArg statement are not allowed in the same module");
2230 AC.topolynomialflag |= FACTARGFLAG;
2231 return(DoArgument(s,TYPEFACTARG));
2245int DoSymmetrize(UBYTE *s,
int par)
2248 int extra = 0, error = 0, err, fix, x, groupsize, num, i;
2250 WORD funnum, *w, *ww, type;
2254 MesPrint(
"&Improper function name");
2258 if ( c !=
',' || ( FG.cTable[s[1]] != 0 && s[1] !=
'[' ) )
break;
2259 if ( par <= 0 && StrICmp(name,(UBYTE *)
"cyclic") == 0 ) extra = 2;
2260 else if ( par <= 0 && StrICmp(name,(UBYTE *)
"rcyclic") == 0 ) extra = 6;
2262 MesPrint(
"&Illegal option: '%s'",name);
2267 if ( ( err = GetVar(name,&type,&funnum,CFUNCTION,WITHAUTO) ) == NAMENOTFOUND ) {
2268 MesPrint(
"&Undefined function: %s",name);
2269 AddFunction(name,0,0,0,0,0,-1,-1);
2274 if ( err == -1 ) error = 1;
2278 if ( *s ==
',' || *s ==
'(' || *s == 0 ) fix = -1;
2279 else if ( FG.cTable[*s] == 1 ) {
2282 Warning(
"Restriction to zero arguments removed");
2285 MesPrint(
"&Illegal character after :");
2291 *w++ = TYPEOPERATION;
2300 w += 2; ww = w; groupsize = -1;
2301 while ( *s ==
',' ) s++;
2305 while ( *s && *s !=
')' ) {
2306 if ( *s ==
',' ) { s++;
continue; }
2307 if ( FG.cTable[*s] != 1 )
goto illarg;
2309 if ( x <= 0 || ( fix > 0 && x > fix ) )
goto illnum;
2314 MesPrint(
"&Improper termination of statement");
2317 if ( groupsize < 0 ) groupsize = num;
2318 else if ( groupsize != num )
goto group;
2321 else if ( FG.cTable[*s] == 1 ) {
2322 if ( groupsize < 0 ) groupsize = 1;
2323 else if ( groupsize != 1 ) {
2324group: MesPrint(
"&All groups should have the same number of arguments");
2328 if ( x <= 0 || ( fix > 0 && x > fix ) ) {
2329illnum: MesPrint(
"&Illegal argument number: %d",x);
2335illarg: MesPrint(
"&Illegal argument");
2338 while ( *s ==
',' ) s++;
2347 for ( i = 0; i < fix; i++ ) *w++ = i;
2353 ww[-2] = (w-ww)/groupsize;
2355 AT.WorkPointer[1] = w - AT.WorkPointer;
2356 AddNtoL(AT.WorkPointer[1],AT.WorkPointer);
2365int CoSymmetrize(UBYTE *s) {
return(DoSymmetrize(s,SYMMETRIC)); }
2372int CoAntiSymmetrize(UBYTE *s) {
return(DoSymmetrize(s,ANTISYMMETRIC)); }
2379int CoCycleSymmetrize(UBYTE *s) {
return(DoSymmetrize(s,CYCLESYMMETRIC)); }
2386int CoRCycleSymmetrize(UBYTE *s) {
return(DoSymmetrize(s,RCYCLESYMMETRIC)); }
2393int CoWrite(UBYTE *s)
2399 if ( ( ( s =
SkipAName(s) ) == 0 ) || *s != 0 ) {
2400 MesPrint(
"&Proper use of write statement is: write option");
2405 MesPrint(
"&Unrecognized option in write statement");
2408 *key->var = key->type;
2409 AR.SortType = AC.SortType;
2418int CoNWrite(UBYTE *s)
2424 if ( ( ( s =
SkipAName(s) ) == 0 ) || *s != 0 ) {
2425 MesPrint(
"&Proper use of nwrite statement is: nwrite option");
2430 MesPrint(
"&Unrecognized option in nwrite statement");
2433 *key->var = key->flags;
2434 AR.SortType = AC.SortType;
2443static WORD ratstring[6] = { TYPEOPERATION, 6, RATIO, 0, 0, 0 };
2445int CoRatio(UBYTE *s)
2448 int i, type, error = 0;
2451 for ( i = 0; i < 3; i++ ) {
2456 if ( ( ( type = GetName(AC.varnames,t,&numsym,WITHAUTO) ) != CSYMBOL )
2457 && type != CDUBIOUS ) {
2458 MesPrint(
"&%s is not a symbol",t);
2460 if ( type < 0 ) numsym = AddSymbol(t,-MAXPOWER,MAXPOWER,0,0);
2463 if ( *s ==
',' ) s++;
2467 MesPrint(
"&The ratio statement needs three symbols for its arguments");
2485int CoRedefine(UBYTE *s)
2487 UBYTE *name, c, *args = 0;
2491 if ( FG.cTable[*s] || ( s =
SkipAName(s) ) == 0 || s[-1] ==
'_' ) {
2492 MesPrint(
"&Illegal name for preprocessor variable in redefine statement");
2496 for ( numprevar = NumPre-1; numprevar >= 0; numprevar-- ) {
2497 if ( StrCmp(name,PreVar[numprevar].name) == 0 )
break;
2499 if ( numprevar < 0 ) {
2500 MesPrint(
"&There is no preprocessor variable with the name `%s'",name);
2512 if ( chartype[*s] != 0 )
goto illarg;
2514 while ( chartype[*s] <= 1 ) s++;
2515 while ( *s ==
' ' || *s ==
'\t' ) s++;
2516 if ( *s ==
')' )
break;
2517 if ( *s !=
',' )
goto illargs;
2519 while ( *s ==
' ' || *s ==
'\t' ) s++;
2522 while ( *s ==
' ' || *s ==
'\t' ) s++;
2524 while ( *s ==
',' ) s++;
2526encl: MesPrint(
"&Value for %s should be enclosed in double quotes"
2527 ,PreVar[numprevar].name);
2531 while ( *s && *s !=
'"' ) {
if ( *s ==
'\\' ) s++; s++; }
2532 if ( *s !=
'"' )
goto encl;
2534 code[0] = TYPEREDEFPRE; code[1] = numprevar;
2538 Add2ComStrings(2,code,name,args);
2550 for ( j = 0; j < AC.numpfirstnum; j++ ) {
2551 if ( numprevar == AC.pfirstnum[j] )
break;
2553 if ( j >= AC.numpfirstnum ) {
2554 if ( j >= AC.sizepfirstnum ) {
2555 if ( AC.sizepfirstnum <= 0 ) { AC.sizepfirstnum = 10; }
2556 else { AC.sizepfirstnum = 2 * AC.sizepfirstnum; }
2557 newin = (LONG *)Malloc1(AC.sizepfirstnum*(
sizeof(WORD)+
sizeof(LONG)),
"AC.pfirstnum");
2558 newpf = (WORD *)(newin+AC.sizepfirstnum);
2559 for ( j = 0; j < AC.numpfirstnum; j++ ) {
2560 newpf[j] = AC.pfirstnum[j];
2561 newin[j] = AC.inputnumbers[j];
2563 if ( AC.inputnumbers ) M_free(AC.inputnumbers,
"AC.pfirstnum");
2564 AC.inputnumbers = newin;
2565 AC.pfirstnum = newpf;
2567 AC.pfirstnum[AC.numpfirstnum] = numprevar;
2568 AC.inputnumbers[AC.numpfirstnum] = -1;
2575 MesPrint(
"&Illegally formed name in argument of redefine statement");
2578 MesPrint(
"&Illegally formed arguments in redefine statement");
2590int CoRenumber(UBYTE *s)
2594 while ( *s ==
',' ) s++;
2596 if ( *s == 0 ) { x = 0; }
2597 else ParseNumber(x,s)
2598 if ( *s == 0 && x >= 0 && x <= 1 ) {
2599 Add3Com(TYPERENUMBER,x);
2602 MesPrint(
"&Illegal argument in Renumber statement: '%s'",inp);
2613 CBUF *C = cbuf+AC.cbufnum;
2614 UBYTE *ss = 0, c, *t;
2615 int error = 0, i = 0, type, x;
2616 WORD numindex,number;
2620 t++; s++;
while ( FG.cTable[*s] < 2 ) s++;
2622 if ( ( number = GetDollar(t) ) < 0 ) {
2623 MesPrint(
"&Undefined variable $%s",t);
2624 if ( !error ) error = 1;
2625 number = AddDollar(t,0,0,0);
2630 if ( ( s =
SkipAName(s) ) == 0 )
return(1);
2632 if ( ( ( type = GetOName(AC.exprnames,t,&numindex,NOAUTO) ) != NAMENOTFOUND )
2633 || ( ( type = GetOName(AC.varnames,t,&numindex,WITHAUTO) ) != CINDEX ) ) {
2634 if ( type != NAMENOTFOUND ) error = NameConflict(type,t);
2636 MesPrint(
"&%s should have been declared as an index",t);
2638 numindex = AddIndex(s,AC.lDefDim,AC.lDefDim4) + AM.OffsetIndex;
2642 Add3Com(TYPESUM,numindex);
2644 if ( *s == 0 )
break;
2646 MesPrint(
"&Illegal separator between objects in sum statement.");
2650 if ( FG.cTable[*s] == 0 || *s ==
'[' || *s ==
'$' ) {
2651 while ( FG.cTable[*s] == 0 || *s ==
'[' || *s ==
'$' ) {
2655 while ( FG.cTable[*s] < 2 ) s++;
2657 if ( ( number = GetDollar(t) ) < 0 ) {
2658 MesPrint(
"&Undefined variable $%s",t);
2659 if ( !error ) error = 1;
2660 number = AddDollar(t,0,0,0);
2666 if ( ( s =
SkipAName(s) ) == 0 )
return(1);
2668 if ( ( ( type = GetOName(AC.exprnames,t,&numindex,NOAUTO) ) != NAMENOTFOUND )
2669 || ( ( type = GetOName(AC.varnames,t,&numindex,WITHAUTO) ) != CINDEX ) ) {
2670 if ( type != NAMENOTFOUND ) error = NameConflict(type,t);
2672 MesPrint(
"&%s should have been declared as an index",t);
2674 numindex = AddIndex(s,AC.lDefDim,AC.lDefDim4) + AM.OffsetIndex;
2682 if ( *s == 0 )
return(error);
2684 MesPrint(
"&Illegal separator between objects in sum statement.");
2689 if ( FG.cTable[*s] == 1 ) {
2693 else if ( FG.cTable[*s] == 1 ) {
2694 while ( FG.cTable[*s] == 1 ) {
2697 while( FG.cTable[*s] == 1 ) x = 10*x + *s++ -
'0';
2698 if ( *s && *s !=
',' ) {
2699 MesPrint(
"&%s is not a legal fixed index",t);
2702 else if ( x >= AM.OffsetIndex ) {
2703 MesPrint(
"&%d is too large to be a fixed index",x);
2712 if ( *s == 0 )
break;
2717 MesPrint(
"&Illegal object in sum statement");
2729static WORD cttarray[7] = { TYPEOPERATION,7,TENVEC,0,0,1,0 };
2731int CoToTensor(UBYTE *s)
2734 int type, j, nargs, error = 0;
2735 WORD number, dol[2] = { 0, 0 };
2747 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
2748 if ( *s == 0 )
break;
2755 if ( ( s =
SkipAName(s) ) == 0 )
goto syntax_error;
2758 if ( ( s =
SkipAName(s) ) == 0 )
goto syntax_error;
2762 if ( nargs < 2 )
goto not_enough_arguments;
2767 for ( j = 2; j < nargs; j++ ) {
2768 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
2777 if ( FG.cTable[*s] == 0 || *s ==
'[' || *s ==
'_' ) {
2779 if ( ( s =
SkipAName(s) ) == 0 )
goto syntax_error;
2781 type = GetName(AC.varnames,t,&number,WITHAUTO);
2782 if ( type == CVECTOR ) {
2786 cttarray[6] = DoTempSet(t,s);
2790 else if ( type != CSET ) {
2791 MesPrint(
"&%s is not the name of a set or a vector",t);
2795 cttarray[6] = number;
2797 else if ( *s ==
'{' ) {
2798 t = ++s; SKIPBRA2(s) *s = 0;
2799 cttarray[6] = DoTempSet(t,s);
2802 if ( cttarray[6] < 0 ) {
2805 if ( AC.wildflag ) {
2806 MesPrint(
"&Improper use of wildcard(s) in set specification");
2815 if ( ( s =
SkipAName(s) ) == 0 )
goto syntax_error;
2817 if ( StrICmp(t,(UBYTE *)
"nosquare") == 0 ) cttarray[5] |= 2;
2818 else if ( StrICmp(t,(UBYTE *)
"functions") == 0 ) cttarray[5] |= 4;
2820 MesPrint(
"&Unrecognized option in ToTensor statement: '%s'",t);
2830 for ( j = 0; j < 2; j++ ) {
2831 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
2833 if ( ( s =
SkipAName(s) ) == 0 )
goto syntax_error;
2835 if ( t[0] ==
'$' ) {
2836 dol[j] = GetDollar(t+1);
2837 if ( dol[j] < 0 ) dol[j] = AddDollar(t+1,DOLUNDEFINED,0,0);
2839 type = GetName(AC.varnames,t,&number,WITHAUTO);
2840 if ( type == CVECTOR ) {
2841 cttarray[4] = number + AM.OffsetVector;
2843 else if ( type == CFUNCTION && ( functions[number].spec > 0 ) ) {
2844 cttarray[3] = number + FUNCTION;
2847 MesPrint(
"&%s is not a vector or a tensor",t);
2853 if ( cttarray[3] == 0 || cttarray[4] == 0 ) {
2854 if ( dol[0] == 0 && dol[1] == 0 ) {
2855 goto not_enough_arguments;
2857 else if ( cttarray[3] ) {
2858 if ( dol[1] ) cttarray[4] = dol[1];
2859 else if ( dol[0] ) { cttarray[4] = dol[0]; }
2861 goto not_enough_arguments;
2864 else if ( cttarray[4] ) {
2865 if ( dol[1] ) { cttarray[3] = -dol[1]; }
2866 else if ( dol[0] ) cttarray[3] = -dol[0];
2868 goto not_enough_arguments;
2872 if ( dol[0] == 0 || dol[1] == 0 ) {
2873 goto not_enough_arguments;
2876 cttarray[3] = -dol[0]; cttarray[4] = dol[1];
2880 AddNtoL(cttarray[1],cttarray);
2884 MesPrint(
"&Syntax error in ToTensor statement");
2887not_enough_arguments:
2888 MesPrint(
"&ToTensor statement needs a vector and a tensor");
2897static WORD ctvarray[6] = { TYPEOPERATION,6,TENVEC,0,0,0 };
2899int CoToVector(UBYTE *s)
2902 int j, type, error = 0;
2903 WORD number, dol[2];
2904 dol[0] = dol[1] = 0;
2905 ctvarray[3] = ctvarray[4] = ctvarray[5] = 0;
2906 for ( j = 0; j < 2; j++ ) {
2909proper: MesPrint(
"&Arguments of ToVector statement should be a vector and a tensor");
2914 dol[j] = GetDollar(t+1);
2915 if ( dol[j] < 0 ) dol[j] = AddDollar(t+1,DOLUNDEFINED,0,0);
2917 else if ( ( type = GetName(AC.varnames,t,&number,WITHAUTO) ) == CVECTOR )
2918 ctvarray[4] = number + AM.OffsetVector;
2919 else if ( type == CFUNCTION && ( functions[number].spec > 0 ) )
2920 ctvarray[3] = number+FUNCTION;
2922 MesPrint(
"&%s is not a vector or a tensor",t);
2925 *s = c;
if ( *s && *s !=
',' )
goto proper;
2928 if ( *s != 0 )
goto proper;
2929 if ( ctvarray[3] == 0 || ctvarray[4] == 0 ) {
2930 if ( dol[0] == 0 && dol[1] == 0 ) {
2931 MesPrint(
"&ToVector statement needs a vector and a tensor");
2934 else if ( ctvarray[3] ) {
2935 if ( dol[1] ) ctvarray[4] = dol[1];
2936 else if ( dol[0] ) ctvarray[4] = dol[0];
2938 MesPrint(
"&ToVector statement needs a vector and a tensor");
2942 else if ( ctvarray[4] ) {
2943 if ( dol[1] ) ctvarray[3] = -dol[1];
2944 else if ( dol[0] ) ctvarray[3] = -dol[0];
2946 MesPrint(
"&ToVector statement needs a vector and a tensor");
2951 if ( dol[0] == 0 || dol[1] == 0 ) {
2952 MesPrint(
"&ToVector statement needs a vector and a tensor");
2956 ctvarray[3] = -dol[0]; ctvarray[4] = dol[1];
2969int CoTrace4(UBYTE *s)
2971 int error = 0, type, option = CHISHOLM;
2973 WORD numindex, one = 1;
2977 if ( FG.cTable[*s] == 1 )
break;
2979proper: MesPrint(
"&Proper syntax for Trace4 is 'Trace4[,options],index;'");
2982 if ( *s == 0 )
break;
2984 if ( ( key = FindKeyWord(t,trace4options,
2985 sizeof(trace4options)/
sizeof(
KEYWORD)) ) == 0 )
break;
2987 option |= key->type;
2988 option &= ~key->flags;
2990 if ( ( *s++ = c ) !=
',' ) {
2991 MesPrint(
"&Illegal separator in Trace4 statement");
2994 if ( *s == 0 )
goto proper;
2997 if ( FG.cTable[*s] == 1 ) {
2999 ParseNumber(numindex,s)
3001 MesPrint(
"&Last argument of Trace4 should be an index");
3004 if ( numindex >= AM.OffsetIndex ) {
3005 MesPrint(
"&fixed index >= %d. Change value of OffsetIndex in setup file"
3010 else if ( *s ==
'$' ) {
3011 if ( ( type = GetName(AC.dollarnames,s+1,&numindex,NOAUTO) ) == CDOLLAR )
3012 numindex = -numindex;
3014 MesPrint(
"&%s is undefined",s);
3015 numindex = AddDollar(s+1,DOLINDEX,&one,1);
3020 MesPrint(
"&Trace4 should have a single index or $variable for its argument");
3024 else if ( ( type = GetName(AC.varnames,s,&numindex,WITHAUTO) ) == CINDEX ) {
3025 numindex += AM.OffsetIndex;
3028 else if ( type != -1 ) {
3029 if ( type != CDUBIOUS ) {
3030 if ( ( FG.cTable[*s] != 0 ) && ( *s !=
'[' ) ) {
3031 if ( *s ==
'+' && FG.cTable[s[1]] == 1 ) { s++;
goto retry; }
3034 NameConflict(type,s);
3035 type = MakeDubious(AC.varnames,s,&numindex);
3040 MesPrint(
"&%s is not an index",s);
3041 numindex = AddIndex(s,AC.lDefDim,AC.lDefDim4) + AM.OffsetIndex;
3044 if ( error )
return(error);
3045 if ( ( option & CHISHOLM ) != 0 )
3046 Add4Com(TYPECHISHOLM,numindex,(option & ALSOREVERSE));
3047 Add5Com(TYPEOPERATION,TAKETRACE,4 + (option & NOTRICK),numindex);
3056int CoTraceN(UBYTE *s)
3058 WORD numindex, one = 1;
3060 if ( FG.cTable[*s] == 1 ) {
3062 ParseNumber(numindex,s)
3064proper: MesPrint(
"&TraceN should have a single index for its argument");
3067 if ( numindex >= AM.OffsetIndex ) {
3068 MesPrint(
"&fixed index >= %d. Change value of OffsetIndex in setup file"
3073 else if ( *s ==
'$' ) {
3074 if ( ( type = GetName(AC.dollarnames,s+1,&numindex,NOAUTO) ) == CDOLLAR )
3075 numindex = -numindex;
3077 MesPrint(
"&%s is undefined",s);
3078 numindex = AddDollar(s+1,DOLINDEX,&one,1);
3083 MesPrint(
"&TraceN should have a single index or $variable for its argument");
3087 else if ( ( type = GetName(AC.varnames,s,&numindex,WITHAUTO) ) == CINDEX ) {
3088 numindex += AM.OffsetIndex;
3091 else if ( type != -1 ) {
3092 if ( type != CDUBIOUS ) {
3093 if ( ( FG.cTable[*s] != 0 ) && ( *s !=
'[' ) ) {
3094 if ( *s ==
'+' && FG.cTable[s[1]] == 1 ) { s++;
goto retry; }
3097 NameConflict(type,s);
3098 type = MakeDubious(AC.varnames,s,&numindex);
3103 MesPrint(
"&%s is not an index",s);
3104 numindex = AddIndex(s,AC.lDefDim,AC.lDefDim4) + AM.OffsetIndex;
3107 Add5Com(TYPEOPERATION,TAKETRACE,0,numindex);
3116int CoChisholm(UBYTE *s)
3118 int error = 0, type, option = CHISHOLM;
3120 WORD numindex, one = 1;
3124 if ( FG.cTable[*s] == 1 )
break;
3126proper: MesPrint(
"&Proper syntax for Chisholm is 'Chisholm[,options],index;'");
3129 if ( *s == 0 )
break;
3131 if ( ( key = FindKeyWord(t,chisoptions,
3132 sizeof(chisoptions)/
sizeof(
KEYWORD)) ) == 0 )
break;
3134 option |= key->type;
3135 option &= ~key->flags;
3137 if ( ( *s++ = c ) !=
',' ) {
3138 MesPrint(
"&Illegal separator in Chisholm statement");
3141 if ( *s == 0 )
goto proper;
3144 if ( FG.cTable[*s] == 1 ) {
3145 ParseNumber(numindex,s)
3147 MesPrint(
"&Last argument of Chisholm should be an index");
3150 if ( numindex >= AM.OffsetIndex ) {
3151 MesPrint(
"&fixed index >= %d. Change value of OffsetIndex in setup file"
3156 else if ( *s ==
'$' ) {
3157 if ( ( type = GetName(AC.dollarnames,s+1,&numindex,NOAUTO) ) == CDOLLAR )
3158 numindex = -numindex;
3160 MesPrint(
"&%s is undefined",s);
3161 numindex = AddDollar(s+1,DOLINDEX,&one,1);
3166 MesPrint(
"&Chisholm should have a single index or $variable for its argument");
3170 else if ( ( type = GetName(AC.varnames,s,&numindex,WITHAUTO) ) == CINDEX ) {
3171 numindex += AM.OffsetIndex;
3174 else if ( type != -1 ) {
3175 if ( type != CDUBIOUS ) {
3176 NameConflict(type,s);
3177 type = MakeDubious(AC.varnames,s,&numindex);
3182 MesPrint(
"&%s is not an index",s);
3183 numindex = AddIndex(s,AC.lDefDim,AC.lDefDim4) + AM.OffsetIndex;
3186 if ( error )
return(error);
3187 Add4Com(TYPECHISHOLM,numindex,(option & ALSOREVERSE));
3198int DoChain(UBYTE *s,
int option)
3202 if ( ( type = GetName(AC.dollarnames,s+1,&numfunc,NOAUTO) ) == CDOLLAR )
3205 MesPrint(
"&%s is undefined",s);
3206 numfunc = AddDollar(s+1,DOLINDEX,&one,1);
3211 MesPrint(
"&ChainIn/ChainOut should have a single function or $variable for its argument");
3215 else if ( ( type = GetName(AC.varnames,s,&numfunc,WITHAUTO) ) == CFUNCTION ) {
3216 numfunc += FUNCTION;
3219 else if ( type != -1 ) {
3220 if ( type != CDUBIOUS ) {
3221 NameConflict(type,s);
3222 type = MakeDubious(AC.varnames,s,&numfunc);
3227 MesPrint(
"&%s is not a function",s);
3228 numfunc = AddFunction(s,0,0,0,0,0,-1,-1) + FUNCTION;
3231 Add3Com(option,numfunc);
3242int CoChainin(UBYTE *s)
3244 return(DoChain(s,TYPECHAININ));
3254int CoChainout(UBYTE *s)
3256 return(DoChain(s,TYPECHAINOUT));
3267 WORD code = TYPEEXIT;
3268 while ( *s ==
',' ) s++;
3270 Add3Com(TYPEEXIT,0);
3275 while ( *s ) {
if ( *s ==
'\\' ) s++; s++; }
3276 if ( name[-1] !=
'"' || s[-1] !=
'"' ) {
3277 MesPrint(
"&Illegal syntax for exit statement");
3281 AddComString(1,&code,name,0);
3291int CoInParallel(UBYTE *s)
3293 return(DoInParallel(s,1));
3301int CoNotInParallel(UBYTE *s)
3303 return(DoInParallel(s,0));
3316int DoInParallel(UBYTE *s,
int par)
3329 AC.inparallelflag = par;
3331 for ( i = NumExpressions-1; i >= 0; i-- ) {
3333 if ( e->status == LOCALEXPRESSION || e->status == GLOBALEXPRESSION
3334 || e->status == UNHIDELEXPRESSION || e->status == UNHIDEGEXPRESSION
3343 while ( *s ==
',' ) s++;
3344 if ( *s == 0 )
break;
3345 if ( *s ==
'[' || FG.cTable[*s] == 0 ) {
3348 MesPrint(
"&Improper name for an expression: '%s'",t);
3352 if ( GetName(AC.exprnames,t,&number,NOAUTO) == CEXPRESSION ) {
3354 e = Expressions+number;
3355 if ( e->status == LOCALEXPRESSION || e->status == GLOBALEXPRESSION
3356 || e->status == UNHIDELEXPRESSION || e->status == UNHIDEGEXPRESSION
3362 else if ( GetName(AC.varnames,t,&number,NOAUTO) != NAMENOTFOUND ) {
3363 MesPrint(
"&%s is not an expression",t);
3369 MesPrint(
"&Illegal object in InParallel statement");
3371 while ( *s && *s !=
',' ) s++;
3372 if ( *s == 0 )
break;
3385int CoInExpression(UBYTE *s)
3392 if ( AC.inexprlevel >= MAXNEST ) {
3393 MesPrint(
"@Nesting of inexpression statements more than %d levels",(WORD)MAXNEST);
3396 AC.inexprsumcheck[AC.inexprlevel] = NestingChecksum();
3397 AC.inexprstack[AC.inexprlevel] = cbuf[AC.cbufnum].Pointer
3398 - cbuf[AC.cbufnum].Buffer + 2;
3400 *w++ = TYPEINEXPRESSION;
3403 while ( *s ==
',' ) s++;
3404 if ( *s == 0 )
break;
3405 if ( *s ==
'[' || FG.cTable[*s] == 0 ) {
3408 MesPrint(
"&Improper name for an expression: '%s'",t);
3412 if ( GetName(AC.exprnames,t,&number,NOAUTO) == CEXPRESSION ) {
3413 while ( Expressions[number].replace >= 0 ) {
3414 number = Expressions[number].replace;
3418 else if ( GetName(AC.varnames,t,&number,NOAUTO) != NAMENOTFOUND ) {
3419 MesPrint(
"&%s is not an expression",t);
3425 MesPrint(
"&Illegal object in InExpression statement");
3427 while ( *s && *s !=
',' ) s++;
3428 if ( *s == 0 )
break;
3431 AT.WorkPointer[1] = w - AT.WorkPointer;
3432 AddNtoL(AT.WorkPointer[1],AT.WorkPointer);
3441int CoEndInExpression(UBYTE *s)
3443 CBUF *C = cbuf+AC.cbufnum;
3444 while ( *s ==
',' ) s++;
3446 MesPrint(
"&Illegal syntax for EndInExpression statement");
3449 if ( AC.inexprlevel <= 0 ) {
3450 MesPrint(
"&EndInExpression without corresponding InExpression statement");
3454 cbuf[AC.cbufnum].Buffer[AC.inexprstack[AC.inexprlevel]] = C->numlhs;
3455 if ( AC.inexprsumcheck[AC.inexprlevel] != NestingChecksum() ) {
3467int CoSetExitFlag(UBYTE *s)
3470 MesPrint(
"&Illegal syntax for the SetExitFlag statement");
3473 Add2Com(TYPESETEXIT);
3481int CoTryReplace(UBYTE *p)
3485 WORD *w, error = 0, i, which = -1, c1, minvec = 0;
3502 if ( *p ==
'-' && minvec == 0 && which == (CVECTOR+1) ) {
3505 if ( *p ==
'[' || FG.cTable[*p] == 0 ) {
3507 if ( ( p =
SkipAName(p) ) == 0 )
return(1);
3509 i = GetName(AC.varnames,name,&c1,WITHAUTO);
3510 if ( which >= 0 && i >= 0 && i != CDUBIOUS && which != (i+1) ) {
3511 MesPrint(
"&Illegal combination of objects in TryReplace");
3514 else if ( minvec && i != CVECTOR && i != CDUBIOUS ) {
3515 MesPrint(
"&Currently a - sign can be used only with a vector in TryReplace");
3519 case CSYMBOL: *w++ = -SYMBOL; *w++ = c1;
break;
3521 if ( minvec ) *w++ = -MINVECTOR;
3522 else *w++ = -VECTOR;
3523 *w++ = c1 + AM.OffsetVector;
3526 case CINDEX: *w++ = -INDEX; *w++ = c1 + AM.OffsetIndex;
3527 if ( c1 >= AM.WilInd && c ==
'?' ) { *p++ = c; c = *p; }
3529 case CFUNCTION: *w++ = -c1-FUNCTION;
break;
3530 case CDUBIOUS: minvec = 0; error = 1;
break;
3532 MesPrint(
"&Illegal object type in TryReplace: %s",name);
3537 if ( which < 0 ) which = i+1;
3540 if ( *p ==
',' ) p++;
3544 MesPrint(
"&Illegal object in TryReplace");
3546 while ( *p && *p !=
',' ) {
3547 if ( *p ==
'(' ) SKIPBRA3(p)
3548 else if ( *p ==
'{' ) SKIPBRA2(p)
3549 else if ( *p ==
'[' ) SKIPBRA1(p)
3553 if ( *p ==
',' ) p++;
3554 if ( which < 0 ) which = 0;
3558 MesPrint(
"&Odd number of arguments in TryReplace");
3561 i = w - AT.WorkPointer;
3562 AT.WorkPointer[1] = i;
3563 AT.WorkPointer[2] = i - 3;
3564 AT.WorkPointer[4] = i - 3;
3565 AddNtoL((
int)i,AT.WorkPointer);
3584int CoModulus(UBYTE *inp)
3587 int Retval = 0, sign = 1;
3589 while ( *inp ==
',' || *inp ==
' ' || *inp ==
'\t' ) inp++;
3592 if ( AC.modpowers ) M_free(AC.modpowers,
"AC.modpowers");
3594 AN.ncmod = AC.ncmod = 0;
3595 if ( AC.halfmod ) M_free(AC.halfmod,
"halfmod");
3596 AC.halfmod = 0; AC.nhalfmod = 0;
3597 if ( AC.modinverses ) M_free(AC.modinverses,
"modinverses");
3603 if ( AT.aux_ != 0 ) {
3604 MesPrint(
"&Simultaneous use of floating point and modulus arithmetic makes no sense.");
3609 if ( *inp ==
'-' ) {
3614 while ( FG.cTable[*inp] == 0 ) {
3616 while ( FG.cTable[*inp] == 0 ) inp++;
3618 if ( StrICmp(p,(UBYTE *)
"nofunctions") == 0 ) {
3619 AC.modmode &= ~ALSOFUNARGS;
3621 else if ( StrICmp(p,(UBYTE *)
"alsofunctions") == 0 ) {
3622 AC.modmode |= ALSOFUNARGS;
3624 else if ( StrICmp(p,(UBYTE *)
"coefficientsonly") == 0 ) {
3625 AC.modmode &= ~ALSOFUNARGS;
3626 AC.modmode &= ~ALSOPOWERS;
3629 else if ( StrICmp(p,(UBYTE *)
"plusmin") == 0 ) {
3630 AC.modmode |= POSNEG;
3632 else if ( StrICmp(p,(UBYTE *)
"positive") == 0 ) {
3633 AC.modmode &= ~POSNEG;
3635 else if ( StrICmp(p,(UBYTE *)
"inversetable") == 0 ) {
3636 AC.modmode |= INVERSETABLE;
3638 else if ( StrICmp(p,(UBYTE *)
"noinversetable") == 0 ) {
3639 AC.modmode &= ~INVERSETABLE;
3641 else if ( StrICmp(p,(UBYTE *)
"nodollars") == 0 ) {
3642 AC.modmode &= ~ALSODOLLARS;
3644 else if ( StrICmp(p,(UBYTE *)
"alsodollars") == 0 ) {
3645 AC.modmode |= ALSODOLLARS;
3647 else if ( StrICmp(p,(UBYTE *)
"printpowersof") == 0 ) {
3649 if ( *inp !=
'(' ) {
3651 MesPrint(
"&Bad syntax in argument of PrintPowersOf(number) in Modulus statement");
3654 while ( *inp ==
',' || *inp ==
' ' || *inp ==
'\t' ) inp++;
3656 if ( FG.cTable[*inp] != 1 )
goto badsyntax;
3657 do { inp++; }
while ( FG.cTable[*inp] == 1 );
3659 if ( GetLong(p,(UWORD *)AC.powmod,&AC.npowmod) ) Retval = -1;
3660 if ( TakeModulus((UWORD *)AC.powmod,&AC.npowmod,AC.cmod,AC.ncmod,NOUNPACK) ) Retval = -1;
3661 if ( AC.npowmod == 0 ) {
3662 MesPrint(
"&Improper value for generator");
3665 if ( MakeModTable() ) Retval = -1;
3668 while ( *inp ==
',' || *inp ==
' ' || *inp ==
'\t' ) inp++;
3669 if ( *inp !=
')' )
goto badsyntax;
3673 else if ( StrICmp(p,(UBYTE *)
"alsopowers") == 0 ) {
3674 AC.modmode |= ALSOPOWERS;
3677 else if ( StrICmp(p,(UBYTE *)
"nopowers") == 0 ) {
3678 AC.modmode &= ~ALSOPOWERS;
3682 MesPrint(
"&Unrecognized option %s in Modulus statement",inp);
3686 while ( *inp ==
',' || *inp ==
' ' || *inp ==
'\t' ) inp++;
3688 MesPrint(
"&Modulus statement with no value!!!");
3694 if ( FG.cTable[*inp] != 1 ) {
3695 MesPrint(
"&Invalid value for modulus:%s",inp);
3696 if ( AC.modpowers ) M_free(AC.modpowers,
"AC.modpowers");
3698 AN.ncmod = AC.ncmod = 0;
3699 if ( AC.halfmod ) M_free(AC.halfmod,
"halfmod");
3700 AC.halfmod = 0; AC.nhalfmod = 0;
3701 if ( AC.modinverses ) M_free(AC.modinverses,
"modinverses");
3705 do { inp++; }
while ( FG.cTable[*inp] == 1 );
3707 Retval = GetLong(p,(UWORD *)AC.cmod,&AC.ncmod);
3708 if ( Retval == 0 && AC.ncmod == 0 )
goto SwitchOff;
3709 if ( sign < 0 ) AC.ncmod = -AC.ncmod;
3710 AN.ncmod = AC.ncmod;
3711 if ( ( AC.modmode & INVERSETABLE ) != 0 )
MakeInverses();
3712 if ( AC.halfmod ) M_free(AC.halfmod,
"halfmod");
3713 AC.halfmod = 0; AC.nhalfmod = 0;
3722int CoRepeat(UBYTE *inp)
3725 AC.RepSumCheck[AC.RepLevel] = NestingChecksum();
3727 if ( AC.RepLevel > AM.RepMax ) {
3728 MesPrint(
"&Too many repeat levels. Maximum is %d",AM.RepMax);
3731 Add3Com(TYPEREPEAT,-1)
3732 while ( *inp == ' ' || *inp == ',' || *inp == '\t' ) inp++;
3734 error = CompileStatement(inp);
3735 if ( CoEndRepeat(inp) ) error = 1;
3745int CoEndRepeat(UBYTE *inp)
3747 CBUF *C = cbuf+AC.cbufnum;
3748 int level, error = 0, repeatlevel = 0;
3751 if ( AC.RepLevel < 0 ) {
3752 MesPrint(
"&EndRepeat without Repeat");
3756 else if ( AC.RepSumCheck[AC.RepLevel] != NestingChecksum() ) {
3760 level = C->numlhs+1;
3761 while ( level > 0 ) {
3762 if ( C->
lhs[--level][0] == TYPEREPEAT ) {
3763 if ( repeatlevel == 0 ) {
3764 Add3Com(TYPEENDREPEAT,level)
3769 else if ( C->
lhs[level][0] == TYPEENDREPEAT ) repeatlevel++;
3783int DoBrackets(UBYTE *inp,
int par)
3787 WORD *to, i, type, *w, error = 0;
3788 WORD c1,c2, *WorkSave;
3791 WorkSave = to = AT.WorkPointer;
3793 if ( AT.BrackBuf == 0 ) {
3794 AR.MaxBracket = 100;
3795 AT.BrackBuf = (WORD *)Malloc1(
sizeof(WORD)*(AR.MaxBracket+1),
"bracket buffer");
3799 AC.bracketindexflag = 0;
3800 AT.bracketindexflag = 0;
3801 if ( *p ==
'+' || *p ==
'-' ) p++;
3802 if ( p[-1] ==
',' && *p ) p--;
3803 if ( p[-1] ==
'+' && *p ) { biflag = 1;
if ( *p !=
',' ) { *--p =
','; } }
3804 else if ( p[-1] ==
'-' && *p ) { biflag = -1;
if ( *p !=
',' ) { *--p =
','; } }
3806 while ( *p ==
',' ) {
3807redo: AR.BracketOn++;
3808 while ( *p ==
',' ) p++;
3809 if ( *p == 0 )
break;
3811 p++;
while ( *p ==
'0' ) p++;
3816 if ( p == 0 )
return(1);
3819 type = GetName(AC.varnames,inp,&c1,WITHAUTO);
3821 if ( type == CVECTOR || type == CDUBIOUS ) {
3825 if ( p == 0 )
return(1);
3828 type = GetName(AC.varnames,inp,&c2,WITHAUTO);
3829 if ( type != CVECTOR && type != CDUBIOUS ) {
3830 MesPrint(
"&Not a vector in dotproduct in bracket statement: %s",inp);
3833 else type = CDOTPRODUCT;
3836 MesPrint(
"&Illegal use of . after %s in bracket statement",inp);
3844 *to++ = SYMBOL; *to++ = 4; *to++ = c1; *to++ = 1;
break;
3846 *to++ = INDEX; *to++ = 3; *to++ = AM.OffsetVector + c1;
break;
3848 *to++ = c1+FUNCTION; *to++ = FUNHEAD; *to++ = 0;
3852 *to++ = DOTPRODUCT; *to++ = 5; *to++ = c1 + AM.OffsetVector;
3853 *to++ = c2 + AM.OffsetVector; *to++ = 1;
break;
3855 *to++ = DELTA; *to++ = 4; *to++ = EMPTYINDEX; *to++ = EMPTYINDEX;
break;
3857 *to++ = SETSET; *to++ = 4; *to++ = c1; *to++ = Sets[c1].type;
break;
3859 MesPrint(
"&Illegal bracket request for %s",pp);
3865 MesCerr(
"separator",p);
3866 AC.BracketNormalize = 0;
3867 AT.WorkPointer = WorkSave;
3871 *to++ = 1; *to++ = 1; *to++ = 3;
3872 *AT.WorkPointer = to - AT.WorkPointer;
3873 AT.WorkPointer = to;
3874 AC.BracketNormalize = 1;
3875 if ( BracketNormalize(BHEAD WorkSave) ) { error = 1; AR.BracketOn = 0; }
3878 if ( *w == 4 || !*w ) { AR.BracketOn = 0; }
3881 if ( i < 0 ) i = -i;
3884 if ( i > AR.MaxBracket ) {
3886 newbuf = (WORD *)Malloc1(
sizeof(WORD)*(i+1),
"bracket buffer");
3888 if ( AT.BrackBuf != 0 ) M_free(AT.BrackBuf,
"bracket buffer");
3889 AT.BrackBuf = newbuf;
3895 AC.BracketNormalize = 0;
3896 if ( par == 1 ) AR.BracketOn = -AR.BracketOn;
3898 AC.bracketindexflag = biflag;
3899 AT.bracketindexflag = biflag;
3901 AT.WorkPointer = WorkSave;
3910int CoBracket(UBYTE *inp)
3911{
return(DoBrackets(inp,0)); }
3918int CoAntiBracket(UBYTE *inp)
3919{
return(DoBrackets(inp,1)); }
3929int CoMultiBracket(UBYTE *inp)
3932 int i, error = 0, error1, type, num;
3936 if ( *inp !=
':' ) {
3937 MesPrint(
"&Illegal Multiple Bracket separator: %s",inp);
3941 if ( AC.MultiBracketBuf == 0 ) {
3942 AC.MultiBracketBuf = (WORD **)Malloc1(
sizeof(WORD *)*MAXMULTIBRACKETLEVELS,
"multi bracket buffer");
3943 for ( i = 0; i < MAXMULTIBRACKETLEVELS; i++ ) {
3944 AC.MultiBracketBuf[i] = 0;
3948 for ( i = 0; i < MAXMULTIBRACKETLEVELS; i++ ) {
3949 if ( AC.MultiBracketBuf[i] ) {
3950 M_free(AC.MultiBracketBuf[i],
"bracket buffer i");
3951 AC.MultiBracketBuf[i] = 0;
3954 AC.MultiBracketLevels = 0;
3956 AC.MultiBracketLevels = 0;
3960 if ( AT.BrackBuf == 0 ) {
3961 AR.MaxBracket = 100;
3962 AT.BrackBuf = (WORD *)Malloc1(
sizeof(WORD)*(AR.MaxBracket+1),
"bracket buffer");
3966 AC.bracketindexflag = 0;
3967 AT.bracketindexflag = 0;
3971 for ( i = 0; i < MAXMULTIBRACKETLEVELS; i++ ) {
3972 if ( *inp == 0 )
goto RegEnd;
3977 while ( *s && *s !=
':' ) {
3978 if ( *s ==
'[' ) { SKIPBRA1(s) s++; }
3979 else if ( *s ==
'{' ) { SKIPBRA2(s) s++; }
3983 if ( StrICont(inp,(UBYTE *)
"antibrackets") == 0 ) { type = 1; }
3984 else if ( StrICont(inp,(UBYTE *)
"brackets") == 0 ) { type = 0; }
3986 MesPrint(
"&Illegal (anti)bracket specification in MultiBracket statement");
3987 if ( error == 0 ) error = 1;
3990 while ( FG.cTable[*inp] == 0 ) inp++;
3991 if ( *inp !=
',' ) {
3992 MesPrint(
"&Illegal separator after (anti)bracket specification in MultiBracket statement");
3993 if ( error == 0 ) error = 1;
4000 error1 = DoBrackets(inp, type);
4001 if ( error < 0 )
return(error1);
4002 if ( error1 > error ) error = error1;
4006 if ( AR.BracketOn ) {
4007 num = AT.BrackBuf[0];
4008 to = AC.MultiBracketBuf[i] = (WORD *)Malloc1((num+2)*
sizeof(WORD),
"bracket buffer i");
4010 *to++ = AR.BracketOn;
4018 *s = c;
if ( c ==
':' ) s++;
4024 MesPrint(
"&More than %d levels in MultiBracket statement",(WORD)MAXMULTIBRACKETLEVELS);
4025 if ( error == 0 ) error = 1;
4028 AC.MultiBracketLevels = i;
4031 AC.bracketindexflag = 0;
4032 AT.bracketindexflag = 0;
4061WORD *CountComp(UBYTE *inp, WORD *to)
4065 WORD *w, mini = 0, type, c1, c2;
4073 while ( *p ==
',' ) {
4075 if ( *p ==
'[' || FG.cTable[*p] == 0 ) {
4076 if ( ( p =
SkipAName(inp) ) == 0 )
return(0);
4078 type = GetName(AC.varnames,inp,&c1,WITHAUTO);
4080 if ( type == CVECTOR || type == CDUBIOUS ) {
4084 if ( p == 0 )
return(0);
4087 type = GetName(AC.varnames,inp,&c2,WITHAUTO);
4088 if ( type != CVECTOR && type != CDUBIOUS ) {
4089 MesPrint(
"&Not a vector in dotproduct in if statement: %s",inp);
4092 else type = CDOTPRODUCT;
4095 MesPrint(
"&Illegal use of . after %s in if statement",inp);
4096 if ( type == NAMENOTFOUND )
4097 MesPrint(
"&%s is not a properly declared variable",inp);
4100 while ( *p && *p !=
')' && *p !=
',' ) p++;
4101 if ( *p ==
',' && FG.cTable[p[1]] == 1 ) {
4103 while ( *p && *p !=
')' && *p !=
',' ) p++;
4111 *w++ = SYMBOL; *w++ = 4; *w++ = c1;
4112Sgetnum:
if ( *p !=
',' ) {
4113 MesCerr(
"sequence",p);
4114 while ( *p && *p !=
')' && *p !=
',' ) p++;
4118 ParseSignedNumber(mini,p)
4119 if ( FG.cTable[p[-1]] != 1 || ( *p && *p !=
')' && *p !=
',' ) ) {
4120 while ( *p && *p !=
')' && *p !=
',' ) p++;
4123 MesPrint(
"&Improper value in count: %s",inp);
4125 while ( *p && *p !=
')' && *p !=
',' ) p++;
4130 *w++ = FUNCTION; *w++ = 4; *w++ = c1+FUNCTION;
goto Sgetnum;
4132 *w++ = DOTPRODUCT; *w++ = 5;
4133 *w++ = c2 + AM.OffsetVector;
4134 *w++ = c1 + AM.OffsetVector;
4137 *w++ = VECTOR; *w++ = 5;
4138 *w++ = c1 + AM.OffsetVector;
4140 *w++ = VECTBIT | DOTPBIT | FUNBIT;
4143 else if ( *p ==
'+' ) {
4146 while ( *p && *p !=
',' ) {
4147 if ( *p ==
'v' || *p ==
'V' ) {
4150 else if ( *p ==
'd' || *p ==
'D' ) {
4153 else if ( *p ==
'f' || *p ==
'F'
4154 || *p ==
't' || *p ==
'T' ) {
4157 else if ( *p ==
'?' ) {
4161 if ( p == 0 )
return(0);
4162 if ( ( c1 = DoTempSet(inp+1,p) ) < 0 )
return(0);
4163 if ( Sets[c1].type != CFUNCTION ) {
4164 MesPrint(
"&set type conflict: Function expected");
4172 if ( p == 0 )
return(0);
4174 type = GetName(AC.varnames,inp,&c1,WITHAUTO);
4176 if ( type != CSET && type != CDUBIOUS ) {
4177 MesPrint(
"&%s is not a set",inp);
4187 MesCerr(
"specifier for vector",p);
4195 MesCerr(
"specifier for vector",p);
4196 while ( *p && *p !=
')' && *p !=
',' ) p++;
4198 *w++ = VECTBIT | DOTPBIT | FUNBIT;
4205 MesPrint(
"&%s is not a symbol, function, vector or dotproduct",inp);
4207skipfield:
while ( *p && *p !=
')' && *p !=
',' ) p++;
4208 if ( *p && FG.cTable[p[1]] == 1 ) {
4210 while ( *p && *p !=
')' && *p !=
',' ) p++;
4217 while ( *p && *p !=
',' ) p++;
4222 if ( *p ==
')' ) p++;
4223 if ( *p ) { MesCerr(
"end of statement",p);
return(0); }
4224 if ( error )
return(0);
4249static UWORD *CIscratC = 0;
4254 int error = 0, level;
4255 WORD *w, *ww, *u, *s, *OldWork, *OldSpace = AT.WorkSpace;
4257 WORD lenpp, lenlev, ncoef, i, number;
4258 UBYTE *p, *pp, *ppp, c;
4259 CBUF *C = cbuf+AC.cbufnum;
4266 if ( *inp ==
'(' && inp[1] ==
',' ) inp += 2;
4267 else if ( *inp ==
'(' ) inp++;
4269 if ( CIscratC == 0 )
4270 CIscratC = (UWORD *)Malloc1((AM.MaxTal+2)*
sizeof(UWORD),
"CoIf");
4273 if ( AC.IfLevel >= AC.MaxIf ) DoubleIfBuffers();
4274 AC.IfCount[lenpp++] = 0;
4282 AC.IfSumCheck[AC.IfLevel] = NestingChecksum();
4284 w = OldWork = AT.WorkPointer;
4292 if ( FG.cTable[*p] == 1 ) {
4293 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4296 pp = CheckFloat(p,&spec);
4300 MesPrint(
"&The floating point system has not been started: %s",p);
4301 if ( !error ) error = 1;
4304 WORD *ow = AT.WorkPointer;
4307 ReadFloat((SBYTE *)p);
4310 AT.WorkPointer[0] = IFFLOATNUMBER;
4311 w = AT.WorkPointer + AT.WorkPointer[1];
4312 AT.WorkPointer = ow;
4313 if ( level ) w[FUNHEAD+3] = -w[FUNHEAD+3];
4315 goto DoneWithNumber;
4330 if ( GetLong(p,(UWORD *)w,&ncoef) ) { ncoef = 1; error = 1; }
4332 while ( FG.cTable[*++p] == 1 );
4335 if ( FG.cTable[*p] != 1 ) {
4336 MesCerr(
"sequence",p); error = 1;
goto OnlyNum;
4338 if ( GetLong(p,CIscratC,&ncoef) ) {
4339 ncoef = 1; error = 1;
4341 while ( FG.cTable[*++p] == 1 );
4343 MesPrint(
"&Division by zero!");
4348 if ( Simplify(BHEAD (UWORD *)w,(WORD *)(w-1),
4349 CIscratC,&ncoef) ) error = 1;
4356 s = (WORD *)CIscratC;
4358 while ( --i >= 0 ) *w++ = 0;
4363 while ( --i >= 0 ) *w++ = 0;
4364 s = (WORD *)CIscratC;
4376 while ( --ncoef >= 0 ) *w++ = 0;
4379 u[1] = WORDDIF(w,u);
4380 u[2] = (u[1] - 3)/2;
4381 if ( level ) u[2] = -u[2];
4389 else if ( *p ==
'+' ) { p++;
goto ReDo; }
4390 else if ( *p ==
'-' ) { level ^= 1; p++;
goto ReDo; }
4391 else if ( *p ==
'c' || *p ==
'C' ) {
4392 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4393 while ( FG.cTable[*++p] == 0 );
4395 if ( !StrICmp(inp,(UBYTE *)
"count") ) {
4398 MesPrint(
"&no ( after count");
4404 c = *++p; *p = 0; *inp =
',';
4405 w = CountComp(inp,w);
4407 if ( w == 0 ) { error = 1;
goto endofif; }
4410 else if ( ConWord(inp,(UBYTE *)
"coefficient") && ( p - inp ) > 3 ) {
4419 else if ( *p ==
'm' || *p ==
'M' ) {
4420 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4421 while ( !FG.cTable[*++p] );
4423 if ( !StrICmp(inp,(UBYTE *)
"match") ) {
4426 MesPrint(
"&no ( after match");
4437 AT.WorkSpace = AT.WorkPointer = w;
4439 while ( FG.cTable[*ppp] == 0 && ppp < p ) ppp++;
4440 if ( *ppp ==
',' ) AC.idoption = 0;
4441 else AC.idoption = SUBMULTI;
4442 level = CoIdExpression(inp,TYPEIF);
4443 AT.WorkSpace = OldSpace;
4444 AT.WorkPointer = OldWork;
4446 if ( level < 0 ) { error = -1;
goto endofif; }
4452 s = u = C->
lhs[C->numlhs];
4453 while ( u < C->Pointer ) *w++ = *u++;
4459 else if ( !StrICmp(inp,(UBYTE *)
"multipleof") ) {
4460 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4463 MesPrint(
"&no ( after multipleof");
4464 error = 1;
goto endofif;
4467 if ( FG.cTable[*p] != 1 ) {
4468Nomulof: MesPrint(
"&multipleof needs a short positive integer argument");
4469 error = 1;
goto endofif;
4472 if ( *p !=
')' || x <= 0 || x > MAXPOSITIVE )
goto Nomulof;
4474 *w++ = MULTIPLEOF; *w++ = 3; *w++ = (WORD)x;
4479NoGood: MesPrint(
"&Unrecognized word: %s",inp);
4483 if ( c ==
'(' ) SKIPBRA4(p)
4488 else if ( *p ==
'f' || *p ==
'F' ) {
4489 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4490 while ( FG.cTable[*++p] == 0 );
4492 if ( !StrICmp(inp,(UBYTE *)
"findloop") ) {
4495 MesPrint(
"&no ( after findloop");
4501 c = *++p; *p = 0; *inp =
',';
4502 if ( CoFindLoop(inp) ) { error = 1;
goto endofif; }
4503 s = u = C->
lhs[C->numlhs];
4504 while ( u < C->Pointer ) *w++ = *u++;
4507 if ( w == 0 ) { error = 1;
goto endofif; }
4510 else if ( !StrICmp(inp,(UBYTE *)
"flag") ) {
4511 UBYTE cc = c, *pppp;
4514 MesPrint(
"&no ( after flag");
4520 cc = *++p; *p = 0; *inp =
','; pppp = p;
4522 *w++ = IFUSERFLAG; *w++ = 0;
4525 while ( *inp ==
',' ) inp++;
4526 if ( *inp == 0 || *inp ==
')' )
break;
4527 while ( *inp >=
'0' && *inp <=
'9' ) x = 10*x+(*inp++-
'0');
4528 if ( x < 1 || x > BITSINWORD ) {
4529 MesPrint(
"&Flag number %d outside the permitted range 1-%d.",BITSINWORD);
4535 p = pppp; *p = cc; *inp =
'(';
4538 MesPrint(
"&The userflag condition in the if statement needs arguments.");
4546 else if ( *p ==
'e' || *p ==
'E' ) {
4547 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4548 while ( FG.cTable[*++p] == 0 );
4550 if ( !StrICmp(inp,(UBYTE *)
"expression") ) {
4553 MesPrint(
"&no ( after expression");
4557 p++; ww = w; *w++ = IFEXPRESSION; w++;
4558 while ( *p !=
')' ) {
4559 if ( *p ==
',' ) { p++;
continue; }
4560 if ( *p ==
'[' || FG.cTable[*p] == 0 ) {
4563 MesPrint(
"&Improper name for an expression: '%s'",pp);
4568 if ( GetName(AC.exprnames,pp,&number,NOAUTO) == CEXPRESSION ) {
4569 while ( Expressions[number].replace >= 0 ) {
4570 number = Expressions[number].replace;
4574 else if ( GetName(AC.varnames,pp,&number,NOAUTO) != NAMENOTFOUND ) {
4575 MesPrint(
"&%s is not an expression",pp);
4582 MesPrint(
"&Illegal object in Expression in if-statement");
4584 while ( *p && *p !=
',' && *p !=
')' ) p++;
4585 if ( *p == 0 || *p ==
')' )
break;
4595 else if ( *p ==
'i' || *p ==
'I' ) {
4596 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4597 while ( FG.cTable[*++p] == 0 );
4599 if ( !StrICmp(inp,(UBYTE *)
"isfactorized") ) {
4602 ww = w; *w++ = IFISFACTORIZED; w++;
4605 p++; ww = w; *w++ = IFISFACTORIZED; w++;
4606 while ( *p !=
')' ) {
4607 if ( *p ==
',' ) { p++;
continue; }
4608 if ( *p ==
'[' || FG.cTable[*p] == 0 ) {
4611 MesPrint(
"&Improper name for an expression: '%s'",pp);
4616 if ( GetName(AC.exprnames,pp,&number,NOAUTO) == CEXPRESSION ) {
4619 else if ( GetName(AC.varnames,pp,&number,NOAUTO) != NAMENOTFOUND ) {
4620 MesPrint(
"&%s is not an expression",pp);
4627 MesPrint(
"&Illegal object in IsFactorized in if-statement");
4629 while ( *p && *p !=
',' && *p !=
')' ) p++;
4630 if ( *p == 0 || *p ==
')' )
break;
4641 else if ( *p ==
'o' || *p ==
'O' ) {
4653 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4654 while ( FG.cTable[*++p] == 0 );
4655 c = cc = *p; *p = 0;
4656 if ( !StrICmp(inp,(UBYTE *)
"occurs") ) {
4660 MesPrint(
"&no ( after occurs");
4666 cc = *++p; *p = 0; *inp =
','; pp = p;
4668 *w++ = IFOCCURS; *w++ = 0;
4670 while ( *inp ==
',' ) inp++;
4671 if ( *inp == 0 || *inp ==
')' )
break;
4677 if ( *inp ==
'[' || FG.cTable[*inp] == 0 ) {
4678 if ( ( p =
SkipAName(inp) ) == 0 )
return(0);
4680 type = GetName(AC.varnames,inp,&c1,WITHAUTO);
4682 if ( type == CVECTOR || type == CDUBIOUS ) {
4686 if ( p == 0 )
return(0);
4689 type = GetName(AC.varnames,inp,&c2,WITHAUTO);
4690 if ( type != CVECTOR && type != CDUBIOUS ) {
4691 MesPrint(
"&Not a vector in dotproduct in if statement: %s",inp);
4694 else type = CDOTPRODUCT;
4697 MesPrint(
"&Illegal use of . after %s in if statement",inp);
4698 if ( type == NAMENOTFOUND )
4699 MesPrint(
"&%s is not a properly declared variable",inp);
4702 while ( *p && *p !=
')' && *p !=
',' ) p++;
4703 if ( *p ==
',' && FG.cTable[p[1]] == 1 ) {
4705 while ( *p && *p !=
')' && *p !=
',' ) p++;
4718 *w++ = c1 + AM.OffsetIndex;
4722 *w++ = c1 + AM.OffsetVector;
4726 *w++ = c1 + AM.OffsetVector;
4727 *w++ = c2 + AM.OffsetVector;
4734 MesPrint(
"&Illegal variable %s in occurs condition in if statement",inp);
4741 MesPrint(
"&Illegal object %s in occurs condition in if statement",inp);
4747 p = pp; *p = cc; *inp =
'(';
4750 MesPrint(
"&The occurs condition in the if statement needs arguments.");
4757 else if ( *p ==
'$' ) {
4758 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4760 while ( FG.cTable[*p] == 0 || FG.cTable[*p] == 1 ) p++;
4762 if ( ( i = GetDollar(inp) ) < 0 ) {
4763 MesPrint(
"&undefined dollar expression %s",inp);
4765 i = AddDollar(inp,DOLUNDEFINED,0,0);
4768 *w++ = IFDOLLAR; *w++ = 3; *w++ = i;
4774 if ( ( w = GetIfDollarFactor(&p,w) ) == 0 ) {
4778 else if ( *p !=
']' ) {
4789 else if ( *p ==
'.' ) {
4790 pp = CheckFloat(p,&spec);
4791 if ( pp > p )
goto HaveFloat;
4795 else if ( *p ==
'(' ) {
4797 MesCerr(
"parenthesis",p);
4802 if ( ++lenlev >= AC.MaxIf ) DoubleIfBuffers();
4803 AC.IfCount[lenpp++] = w-OldWork;
4808 else if ( *p ==
')' ) {
4809 if ( gotexp == 0 ) { MesCerr(
"position for )",p); error = 1; }
4811 u = AC.IfCount[--lenpp]+OldWork;
4814 if ( lenlev <= 0 ) {
4815 AT.WorkSpace = OldSpace;
4816 AT.WorkPointer = OldWork;
4820 MesPrint(
"&unmatched parenthesis in if/while ()");
4822 while ( *++p ==
')' );
4825 level = CompileStatement(p);
4826 if ( level ) error = level;
4828 if ( CoEndIf(p) && error == 0 ) error = 1;
4834 else if ( *p ==
'>' ) {
4835 if ( gotexp == 0 )
goto NoExp;
4836 if ( p[1] ==
'=' ) { *w++ = GREATEREQUAL; *w++ = 2; p += 2; }
4837 else { *w++ = GREATER; *w++ = 2; p++; }
4840 else if ( *p ==
'<' ) {
4841 if ( gotexp == 0 )
goto NoExp;
4842 if ( p[1] ==
'=' ) { *w++ = LESSEQUAL; *w++ = 2; p += 2; }
4843 else { *w++ = LESS; *w++ = 2; p++; }
4846 else if ( *p ==
'=' ) {
4847 if ( gotexp == 0 )
goto NoExp;
4848 if ( p[1] ==
'=' ) p++;
4849 *w++ = EQUAL; *w++ = 2; p++;
4852 else if ( *p ==
'!' && p[1] ==
'=' ) {
4853 if ( gotexp == 0 ) { p++;
goto NoExp; }
4854 *w++ = NOTEQUAL; *w++ = 2; p += 2;
4857 else if ( *p ==
'|' && p[1] ==
'|' ) {
4858 if ( gotexp == 0 ) { p++;
goto NoExp; }
4859 *w++ = ORCOND; *w++ = 2; p += 2;
4862 else if ( *p ==
'&' && p[1] ==
'&' ) {
4863 if ( gotexp == 0 ) {
4866 MesCerr(
"sequence",p);
4870 *w++ = ANDCOND; *w++ = 2; p += 2;
4874 else if ( *p == 0 ) {
4875 MesPrint(
"&Unmatched parentheses");
4880 if ( FG.cTable[*p] == 0 ) {
4883 while ( ( ij = FG.cTable[*++p] ) == 0 || ij == 1 );
4887 MesCerr(
"sequence",p);
4904 CBUF *C = cbuf+AC.cbufnum;
4906 while ( *p ==
',' ) p++;
4907 if ( tolower(*p) ==
'i' && tolower(p[1]) ==
'f' && p[2] ==
'(' )
4908 return(CoElseIf(p+2));
4909 MesPrint(
"&No extra text allowed as part of an else statement");
4912 if ( AC.IfLevel <= 0 ) { MesPrint(
"&else statement without if");
return(1); }
4913 if ( AC.IfSumCheck[AC.IfLevel-1] != NestingChecksum() - 1 ) {
4917 Add3Com(TYPEELSE,AC.IfLevel)
4918 C->Buffer[AC.IfStack[-1]] = C->numlhs;
4919 AC.IfStack[-1] = C->Pointer - C->Buffer - 1;
4928int CoElseIf(UBYTE *inp)
4930 CBUF *C = cbuf+AC.cbufnum;
4931 if ( AC.IfLevel <= 0 ) { MesPrint(
"&elseif statement without if");
return(1); }
4932 Add3Com(TYPEELSE,-AC.IfLevel)
4934 C->Buffer[*--AC.IfStack] = C->numlhs;
4955int CoEndIf(UBYTE *inp)
4957 CBUF *C = cbuf+AC.cbufnum;
4958 WORD i = C->numlhs, to, k = -AC.IfLevel;
4960 while ( *inp ==
',' ) inp++;
4963 MesPrint(
"&No extra text allowed as part of an endif/elseif statement");
4965 if ( AC.IfLevel <= 0 ) {
4966 MesPrint(
"&Endif statement without corresponding if");
return(1);
4969 C->
Buffer[*--AC.IfStack] = i+1;
4970 if ( AC.IfSumCheck[AC.IfLevel] != NestingChecksum() ) {
4974 Add3Com(TYPEENDIF,i+1)
4980 if ( C->
lhs[i][0] == TYPEELSE && C->
lhs[i][2] == to ) to = i;
4981 if ( C->
lhs[i][0] == TYPEIF ) {
4982 if ( C->
lhs[i][2] == to ) {
4984 if ( i <= 0 || C->lhs[i][0] != TYPEELSE
4985 || C->
lhs[i][2] != k )
break;
4986 C->
lhs[i][2] = C->numlhs;
5000int CoWhile(UBYTE *inp)
5002 CBUF *C = cbuf+AC.cbufnum;
5003 WORD startnum = C->numlhs + 1;
5007 if ( C->numlhs > startnum && C->
lhs[startnum][2] == C->numlhs
5008 && C->
lhs[C->numlhs][0] == TYPEENDIF ) {
5009 C->
lhs[C->numlhs][2] = startnum-1;
5012 else C->
lhs[startnum][2] = startnum;
5021int CoEndWhile(UBYTE *inp)
5025 CBUF *C = cbuf+AC.cbufnum;
5026 if ( AC.WhileLevel <= 0 ) {
5027 MesPrint(
"&EndWhile statement without corresponding While");
return(1);
5030 i = C->
Buffer[AC.IfStack[-1]];
5031 error = CoEndIf(inp);
5032 C->
lhs[C->numlhs][2] = i - 1;
5043static char *messfind[] = {
5044 "Findloop(function,arguments=#,loopsize(=#|<#)[,include=index])"
5045 ,
"Replaceloop,function,arguments=#,loopsize(=#|<#),outfun=function[,include=index]"
5047static WORD comfindloop[7] = { TYPEFINDLOOP,7,0,0,0,0,0 };
5049int DoFindLoop(UBYTE *inp,
int mode)
5052 WORD funnum, nargs = 0, nloop = 0, indexnum = 0, outfun = 0;
5053 int type, aflag, lflag, indflag, outflag, error = 0, sym;
5054 while ( *inp ==
',' ) inp++;
5057 MesPrint(
"&Proper syntax is:");
5058 MesPrint(
"%s",messfind[mode]);
5062 if ( ( ( type = GetName(AC.varnames,inp,&funnum,WITHAUTO) ) == NAMENOTFOUND )
5063 || type != CFUNCTION || ( ( sym = (functions[funnum].symmetric) & ~REVERSEORDER )
5064 != SYMMETRIC && sym != ANTISYMMETRIC ) ) {
5065 MesPrint(
"&%s should be a (anti)symmetric function or tensor",inp);
5070 aflag = lflag = indflag = outflag = 0;
5071 while ( *inp ==
',' ) {
5072 while ( *inp ==
',' ) inp++;
5074 if ( ( s =
SkipAName(inp) ) == 0 )
goto syntax;
5076 if ( StrICont(inp,(UBYTE *)
"arguments") == 0 ) {
5077 if ( c !=
'=' )
goto syntax;
5079 NeedNumber(nargs,s,syntax)
5083 else if ( StrICont(inp,(UBYTE *)
"loopsize") == 0 ) {
5084 if ( c !=
'=' && c !=
'<' )
goto syntax;
5086 if ( FG.cTable[*s] == 1 ) {
5087 NeedNumber(nloop,s,syntax)
5089 MesPrint(
"&loopsize should be at least 2");
5092 if ( c ==
'<' ) nloop = -nloop;
5094 else if ( tolower(*s) ==
'a' && tolower(s[1]) ==
'l'
5095 && tolower(s[2]) ==
'l' && FG.cTable[s[3]] > 1 ) {
5097 if ( c !=
'=' )
goto syntax;
5102 else if ( StrICont(inp,(UBYTE *)
"include") == 0 ) {
5103 if ( c !=
'=' )
goto syntax;
5105 if ( ( inp =
SkipAName(s) ) == 0 )
goto syntax;
5107 if ( ( type = GetName(AC.varnames,s,&indexnum,WITHAUTO) ) != CINDEX ) {
5108 MesPrint(
"&%s is not a proper index",s);
5111 else if ( indexnum < WILDOFFSET
5112 && indices[indexnum].dimension == 0 ) {
5113 MesPrint(
"&%s should be a summable index",s);
5116 indexnum += AM.OffsetIndex;
5120 else if ( StrICont(inp,(UBYTE *)
"outfun") == 0 ) {
5121 if ( c !=
'=' )
goto syntax;
5123 if ( ( inp =
SkipAName(s) ) == 0 )
goto syntax;
5125 if ( ( type = GetName(AC.varnames,s,&outfun,WITHAUTO) ) != CFUNCTION ) {
5126 MesPrint(
"&%s is not a proper function or tensor",s);
5134 MesPrint(
"&Unrecognized option in FindLoop or ReplaceLoop: %s",inp);
5137 while ( *inp && *inp !=
',' ) inp++;
5140 if ( *inp != 0 && mode == REPLACELOOP )
goto syntax;
5141 if ( mode == FINDLOOP && outflag > 0 ) {
5142 MesPrint(
"&outflag option is illegal in FindLoop");
5145 if ( mode == REPLACELOOP && outflag == 0 )
goto syntax;
5146 if ( aflag == 0 || lflag == 0 )
goto syntax;
5147 comfindloop[3] = funnum;
5148 comfindloop[4] = nloop;
5149 comfindloop[5] = nargs;
5150 comfindloop[6] = outfun;
5153 if ( mode == 0 ) comfindloop[2] = indexnum + 5;
5154 else comfindloop[2] = -indexnum - 5;
5156 else comfindloop[2] = mode;
5157 AddNtoL(comfindloop[1],comfindloop);
5166int CoFindLoop(UBYTE *inp)
5167{
return(DoFindLoop(inp,FINDLOOP)); }
5174int CoReplaceLoop(UBYTE *inp)
5176 int error = DoFindLoop(inp,REPLACELOOP);
5188static UBYTE *FunPowOptions[] = {
5189 (UBYTE *)
"nofunpowers"
5190 ,(UBYTE *)
"commutingonly"
5191 ,(UBYTE *)
"allfunpowers"
5194int CoFunPowers(UBYTE *inp)
5197 int i, maxoptions =
sizeof(FunPowOptions)/
sizeof(UBYTE *);
5198 while ( *inp ==
',' ) inp++;
5200 inp =
SkipAName(inp); c = *inp; *inp = 0;
5201 for ( i = 0; i < maxoptions; i++ ) {
5202 if ( StrICont(option,FunPowOptions[i]) == 0 ) {
5205 MesPrint(
"&Illegal FunPowers statement");
5212 MesPrint(
"&Illegal option in FunPowers statement: %s",option);
5221int CoUnitTrace(UBYTE *s)
5224 if ( FG.cTable[*s] == 1 ) {
5227nogood: MesPrint(
"&Value of UnitTrace should be a (positive) number or a symbol");
5230 AC.lUniTrace[0] = SNUMBER;
5231 AC.lUniTrace[2] = num;
5234 if ( GetName(AC.varnames,s,&num,WITHAUTO) == CSYMBOL ) {
5235 AC.lUniTrace[0] = SYMBOL;
5236 AC.lUniTrace[2] = num;
5241 if ( *s )
goto nogood;
5243 AC.lUnitTrace = num;
5259 WORD *w = AT.WorkPointer;
5261 while ( *s ==
',' ) s++;
5263 MesPrint(
"&Illegal syntax for Term statement");
5266 if ( AC.termlevel+1 >= AC.maxtermlevel ) {
5267 if ( AC.maxtermlevel <= 0 ) {
5268 AC.maxtermlevel = 20;
5269 AC.termstack = (LONG *)Malloc1(AC.maxtermlevel*
sizeof(LONG),
"termstack");
5270 AC.termsortstack = (LONG *)Malloc1(AC.maxtermlevel*
sizeof(LONG),
"termsortstack");
5271 AC.termsumcheck = (WORD *)Malloc1(AC.maxtermlevel*
sizeof(WORD),
"termsumcheck");
5274 DoubleBuffer((
void **)AC.termstack,(
void **)AC.termstack+AC.maxtermlevel,
5275 sizeof(LONG),
"doubling termstack");
5276 DoubleBuffer((
void **)AC.termsortstack,
5277 (
void **)AC.termsortstack+AC.maxtermlevel,
5278 sizeof(LONG),
"doubling termsortstack");
5279 DoubleBuffer((
void **)AC.termsumcheck,
5280 (
void **)AC.termsumcheck+AC.maxtermlevel,
5281 sizeof(LONG),
"doubling termsumcheck");
5282 AC.maxtermlevel *= 2;
5285 AC.termsumcheck[AC.termlevel] = NestingChecksum();
5286 AC.termstack[AC.termlevel] = cbuf[AC.cbufnum].Pointer
5287 - cbuf[AC.cbufnum].Buffer + 2;
5288 AC.termsortstack[AC.termlevel] = AC.termstack[AC.termlevel] + 1;
5292 *w++ = cbuf[AC.cbufnum].numlhs;
5293 *w++ = cbuf[AC.cbufnum].numlhs;
5294 AT.WorkPointer[1] = w - AT.WorkPointer;
5295 AddNtoL(AT.WorkPointer[1],AT.WorkPointer);
5304int CoEndTerm(UBYTE *s)
5306 CBUF *C = cbuf+AC.cbufnum;
5307 while ( *s ==
',' ) s++;
5309 MesPrint(
"&Illegal syntax for EndTerm statement");
5312 if ( AC.termlevel <= 0 ) {
5313 MesPrint(
"&EndTerm without corresponding Argument statement");
5317 cbuf[AC.cbufnum].Buffer[AC.termstack[AC.termlevel]] = C->numlhs;
5318 cbuf[AC.cbufnum].Buffer[AC.termsortstack[AC.termlevel]] = C->numlhs;
5319 if ( AC.termsumcheck[AC.termlevel] != NestingChecksum() ) {
5334 WORD *w = AT.WorkPointer;
5336 while ( *s ==
',' ) s++;
5338 MesPrint(
"&Illegal syntax for Sort statement");
5341 if ( AC.termlevel <= 0 ) {
5342 MesPrint(
"&The Sort statement can only be used inside a term environment");
5345 if ( error )
return(error);
5349 cbuf[AC.cbufnum].Buffer[AC.termsortstack[AC.termlevel-1]] =
5350 *w = cbuf[AC.cbufnum].numlhs+1;
5352 AC.termsortstack[AC.termlevel-1] = cbuf[AC.cbufnum].Pointer
5353 - cbuf[AC.cbufnum].Buffer + 3;
5354 if ( AC.termsumcheck[AC.termlevel-1] != NestingChecksum() - 1 ) {
5358 AT.WorkPointer[1] = w - AT.WorkPointer;
5359 AddNtoL(AT.WorkPointer[1],AT.WorkPointer);
5370int CoPolyFun(UBYTE *s)
5374 int type, error = 0;
5376 AR.PolyFun = AC.lPolyFun = 0;
5377 AR.PolyFunInv = AC.lPolyFunInv = 0;
5378 AR.PolyFunType = AC.lPolyFunType = 0;
5379 AR.PolyFunExp = AC.lPolyFunExp = 0;
5380 AR.PolyFunVar = AC.lPolyFunVar = 0;
5381 AR.PolyFunPow = AC.lPolyFunPow = 0;
5382 if ( *s == 0 ) {
return(0); }
5384 if ( t == 0 || *t != 0 ) {
5385 MesPrint(
"&PolyFun statement needs a single commuting function for its argument");
5388 if ( ( ( type = GetName(AC.varnames,s,&numfun,WITHAUTO) ) != CFUNCTION )
5389 || ( functions[numfun].spec != 0 ) || ( functions[numfun].commute != 0 ) ) {
5390 MesPrint(
"&%s should be a regular commuting function",s);
5392 if ( GetName(AC.exprnames,s,&numfun,NOAUTO) == NAMENOTFOUND )
5393 AddFunction(s,0,0,0,0,0,-1,-1);
5398 AR.PolyFun = AC.lPolyFun = numfun+FUNCTION;
5399 AR.PolyFunType = AC.lPolyFunType = 1;
5402 if ( mpfaux_ != 0 ) {
5403 MesPrint(
"&Simultaneous use of PolyFun and float_ is not allowed.");
5417int CoPolyRatFun(UBYTE *s)
5421 int type, error = 0;
5423 AR.PolyFun = AC.lPolyFun = 0;
5424 AR.PolyFunInv = AC.lPolyFunInv = 0;
5425 AR.PolyFunType = AC.lPolyFunType = 0;
5426 AR.PolyFunExp = AC.lPolyFunExp = 0;
5427 AR.PolyFunVar = AC.lPolyFunVar = 0;
5428 AR.PolyFunPow = AC.lPolyFunPow = 0;
5429 if ( *s == 0 )
return(error);
5431 if ( t == 0 )
goto NumErr;
5434 if ( mpfaux_ != 0 ) {
5435 MesPrint(
"&Simultaneous use of PolyFun and float_ is not allowed.");
5439 if ( ( ( type = GetName(AC.varnames,s,&numfun,WITHAUTO) ) != CFUNCTION )
5440 || ( functions[numfun].spec != 0 ) || ( functions[numfun].commute != 0 ) ) {
5441 MesPrint(
"&%s should be a regular commuting function",s);
5443 if ( GetName(AC.exprnames,s,&numfun,NOAUTO) == NAMENOTFOUND )
5444 AddFunction(s,0,0,0,0,0,-1,-1);
5448 AR.PolyFun = AC.lPolyFun = numfun+FUNCTION;
5449 AR.PolyFunInv = AC.lPolyFunInv = 0;
5450 AR.PolyFunType = AC.lPolyFunType = 2;
5451 AC.PolyRatFunChanged = 1;
5452 if ( c == 0 )
return(error);
5454 if ( *t ==
'-' ) { AC.PolyRatFunChanged = 0; t++; }
5455 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5456 if ( *t == 0 )
return(error);
5460 if ( t == 0 )
goto NumErr;
5462 if ( ( ( type = GetName(AC.varnames,s,&numfun,WITHAUTO) ) != CFUNCTION )
5463 || ( functions[numfun].spec != 0 ) || ( functions[numfun].commute != 0 ) ) {
5464 MesPrint(
"&%s should be a regular commuting function",s);
5466 if ( GetName(AC.exprnames,s,&numfun,NOAUTO) == NAMENOTFOUND )
5467 AddFunction(s,0,0,0,0,0,-1,-1);
5471 AR.PolyFunInv = AC.lPolyFunInv = numfun+FUNCTION;
5472 if ( c == 0 )
return(error);
5474 if ( *t ==
'-' ) { AC.PolyRatFunChanged = 0; t++; }
5475 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5476 if ( *t == 0 )
return(error);
5480 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5488 if ( t == 0 )
goto NumErr;
5490 if ( ( StrICmp(s,(UBYTE *)
"divergence") == 0 )
5491 || ( StrICmp(s,(UBYTE *)
"finddivergence") == 0 ) ) {
5493 MesPrint(
"&Illegal option field in PolyRatFun statement.");
5497 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5500 if ( t == 0 )
goto NumErr;
5502 if ( ( type = GetName(AC.varnames,s,&AC.lPolyFunVar,WITHAUTO) ) != CSYMBOL ) {
5503 MesPrint(
"&Illegal symbol %s in option field in PolyRatFun statement.",s);
5507 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5509 MesPrint(
"&Illegal termination of option in PolyRatFun statement.");
5512 AR.PolyFunExp = AC.lPolyFunExp = 1;
5513 AR.PolyFunVar = AC.lPolyFunVar;
5514 symbols[AC.lPolyFunVar].minpower = -MAXPOWER;
5515 symbols[AC.lPolyFunVar].maxpower = MAXPOWER;
5517 else if ( StrICmp(s,(UBYTE *)
"expand") == 0 ) {
5518 WORD x = 0, etype = 2;
5520 MesPrint(
"&Illegal option field in PolyRatFun statement.");
5524 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5527 if ( t == 0 )
goto NumErr;
5529 if ( ( type = GetName(AC.varnames,s,&AC.lPolyFunVar,WITHAUTO) ) != CSYMBOL ) {
5530 MesPrint(
"&Illegal symbol %s in option field in PolyRatFun statement.",s);
5534 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5535 if ( *t >
'9' || *t <
'0' ) {
5536 MesPrint(
"&Illegal option field in PolyRatFun statement.");
5539 while ( *t <=
'9' && *t >=
'0' ) x = 10*x + *t++ -
'0';
5540 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5544 if ( t == 0 )
goto ParErr;
5546 if ( StrICmp(s,(UBYTE *)
"fixed") == 0 ) {
5549 else if ( StrICmp(s,(UBYTE *)
"relative") == 0 ) {
5553 MesPrint(
"&Illegal termination of option in PolyRatFun statement.");
5557 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5559 MesPrint(
"&Illegal termination of option in PolyRatFun statement.");
5563 AR.PolyFunExp = AC.lPolyFunExp = etype;
5564 AR.PolyFunVar = AC.lPolyFunVar;
5565 AR.PolyFunPow = AC.lPolyFunPow = x;
5566 symbols[AC.lPolyFunVar].minpower = -MAXPOWER;
5567 symbols[AC.lPolyFunVar].maxpower = MAXPOWER;
5570ParErr: MesPrint(
"&Illegal option %s in PolyRatFun statement.",s);
5574 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5575 if ( *t == 0 )
return(error);
5578 MesPrint(
"&PolyRatFun statement needs one or two commuting function(s) for its argument(s)");
5587int CoMerge(UBYTE *inp)
5591 WORD numfunc, option = 0;
5592 if ( tolower(s[0]) ==
'o' && tolower(s[1]) ==
'n' && tolower(s[2]) ==
'c' &&
5593 tolower(s[3]) ==
'e' && tolower(s[4]) ==
',' ) {
5596 else if ( tolower(s[0]) ==
'a' && tolower(s[1]) ==
'l' && tolower(s[2]) ==
'l' &&
5597 tolower(s[3]) ==
',' ) {
5601 if ( ( type = GetName(AC.dollarnames,s+1,&numfunc,NOAUTO) ) == CDOLLAR )
5604 MesPrint(
"&%s is undefined",s);
5605 numfunc = AddDollar(s+1,DOLINDEX,&one,1);
5610 MesPrint(
"&Merge/shuffle should have a single function or $variable for its argument");
5614 else if ( ( type = GetName(AC.varnames,s,&numfunc,WITHAUTO) ) == CFUNCTION ) {
5615 numfunc += FUNCTION;
5618 else if ( type != -1 ) {
5619 if ( type != CDUBIOUS ) {
5620 NameConflict(type,s);
5621 type = MakeDubious(AC.varnames,s,&numfunc);
5626 MesPrint(
"&%s is not a function",s);
5627 numfunc = AddFunction(s,0,0,0,0,0,-1,-1) + FUNCTION;
5630 Add4Com(TYPEMERGE,numfunc,option);
5643int CoStuffle(UBYTE *inp)
5645 UBYTE *s = inp, *ss, c;
5647 WORD numfunc, option = 0;
5648 if ( tolower(s[0]) ==
'o' && tolower(s[1]) ==
'n' && tolower(s[2]) ==
'c' &&
5649 tolower(s[3]) ==
'e' && tolower(s[4]) ==
',' ) {
5652 else if ( tolower(s[0]) ==
'a' && tolower(s[1]) ==
'l' && tolower(s[2]) ==
'l' &&
5653 tolower(s[3]) ==
',' ) {
5659 if ( ( type = GetName(AC.dollarnames,s+1,&numfunc,NOAUTO) ) == CDOLLAR )
5662 MesPrint(
"&%s is undefined",s);
5663 numfunc = AddDollar(s+1,DOLINDEX,&one,1);
5667 if ( *ss !=
'+' && *ss !=
'-' && ss[1] != 0 ) {
5668 MesPrint(
"&Stuffle should have a single function or $variable for its argument, followed by either + or -");
5671 if ( *ss ==
'-' ) option += 2;
5673 else if ( ( type = GetName(AC.varnames,s,&numfunc,WITHAUTO) ) == CFUNCTION ) {
5674 numfunc += FUNCTION;
5677 else if ( type != -1 ) {
5678 if ( type != CDUBIOUS ) {
5679 NameConflict(type,s);
5680 type = MakeDubious(AC.varnames,s,&numfunc);
5685 MesPrint(
"&%s is not a function",s);
5686 numfunc = AddFunction(s,0,0,0,0,0,-1,-1) + FUNCTION;
5689 Add4Com(TYPESTUFFLE,numfunc,option);
5698int CoProcessBucket(UBYTE *s)
5701 while ( *s ==
',' || *s ==
'=' ) s++;
5703 if ( *s && *s !=
' ' && *s !=
'\t' ) {
5704 MesPrint(
"&Numerical value expected for ProcessBucketSize");
5707 AC.ProcessBucketSize = x;
5716int CoThreadBucket(UBYTE *s)
5719 while ( *s ==
',' || *s ==
'=' ) s++;
5721 if ( *s && *s !=
' ' && *s !=
'\t' ) {
5722 MesPrint(
"&Numerical value expected for ThreadBucketSize");
5726 Warning(
"Negative of zero value not allowed for ThreadBucketSize. Adjusted to 1.");
5729 AC.ThreadBucketSize = x;
5731 if ( AS.MultiThreaded ) MakeThreadBuckets(-1,1);
5746int DoArgPlode(UBYTE *s,
int par)
5749 WORD numfunc, type, error = 0, *w, n;
5755 while ( *s ==
',' ) s++;
5758 MesPrint(
"&We don't do dollar variables yet in ArgImplode/ArgExplode");
5762 if ( ( s =
SkipAName(s) ) == 0 )
return(1);
5764 if ( ( type = GetName(AC.varnames,t,&numfunc,WITHAUTO) ) == CFUNCTION ) {
5765 numfunc += FUNCTION;
5767 else if ( type != -1 ) {
5768 if ( type != CDUBIOUS ) {
5769 NameConflict(type,t);
5770 type = MakeDubious(AC.varnames,t,&numfunc);
5775 MesPrint(
"&%s is not a function",t);
5776 numfunc = AddFunction(s,0,0,0,0,0,-1,-1) + FUNCTION;
5783 for ( i = 2; i < FUNHEAD; i++ ) *w++ = 0;
5785 if ( *s && *s !=
',' ) {
5786 MesPrint(
"&Illegal character in ArgImplode/ArgExplode statement: %s",s);
5789 while ( *s ==
',' ) s++;
5791 n = w - AT.WorkPointer;
5792 AT.WorkPointer[1] = n;
5802int CoArgExplode(UBYTE *s) {
return(DoArgPlode(s,TYPEARGEXPLODE)); }
5809int CoArgImplode(UBYTE *s) {
return(DoArgPlode(s,TYPEARGIMPLODE)); }
5816int CoClearTable(UBYTE *s)
5819 int j, type, error = 0;
5823 MesPrint(
"&The ClearTable statement needs at least one (table) argument.");
5830 if ( ( ( type = GetName(AC.varnames,t,&numfun,WITHAUTO) ) != CFUNCTION )
5831 && type != CDUBIOUS ) {
5832nofunc: MesPrint(
"&%s is not a table",t);
5834 if ( type < 0 ) numfun = AddFunction(t,0,0,0,0,0,-1,-1);
5836 if ( *s ==
',' ) s++;
5843 else if ( ( T = functions[numfun].tabl ) == 0 )
goto nofunc;
5846 if ( *s ==
',' ) s++;
5882 if ( TT->
mm ) M_free(TT->
mm,
"tableminmax");
5883 if ( TT->
flags ) M_free(TT->
flags,
"tableflags");
5898int CoDenominators(UBYTE *s)
5903 if ( t == 0 )
goto syntaxerror;
5904 t1 = t;
while ( *t1 ==
',' || *t1 ==
' ' || *t1 ==
'\t' ) t1++;
5905 if ( *t1 )
goto syntaxerror;
5907 if ( ( ( type = GetName(AC.varnames,s,&numfun,WITHAUTO) ) != CFUNCTION )
5908 || ( functions[numfun].spec != 0 ) ) {
5910 if ( GetName(AC.exprnames,s,&numfun,NOAUTO) == NAMENOTFOUND )
5911 AddFunction(s,0,0,0,0,0,-1,-1);
5915 Add3Com(TYPEDENOMINATORS,numfun+FUNCTION);
5918 MesPrint(
"&Denominators statement needs one regular function for its argument");
5927int CoDropCoefficient(UBYTE *s)
5930 Add2Com(TYPEDROPCOEFFICIENT)
5933 MesPrint(
"&Illegal argument in DropCoefficient statement: '%s'",s);
5941int CoDropSymbols(UBYTE *s)
5944 Add2Com(TYPEDROPSYMBOLS)
5947 MesPrint(
"&Illegal argument in DropSymbols statement: '%s'",s);
5964int CoToPolynomial(UBYTE *inp)
5967 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
5968 if ( ( AC.topolynomialflag & ~TOPOLYNOMIALFLAG ) != 0 ) {
5969 MesPrint(
"&ToPolynomial statement and FactArg statement are not allowed in the same module");
5972 if ( AO.OptimizeResult.code != NULL ) {
5973 MesPrint(
"&Using ToPolynomial statement when there are still optimization results active.");
5974 MesPrint(
"&Please use #ClearOptimize instruction first.");
5975 MesPrint(
"&This will loose the optimized expression.");
5979 Add3Com(TYPETOPOLYNOMIAL,DOALL)
5983 WORD *funnums = 0, type, num;
5986 if ( s == 0 )
return(1);
5988 if ( StrICmp(inp,(UBYTE *)
"onlyfunctions") ) {
5989 MesPrint(
"&Illegal option %s in ToPolynomial statement",inp);
5995 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
6001 funnums = (WORD *)Malloc1(((LONG)(s-inp)+3)*
sizeof(WORD),
"ToPlynomial");
6004 if ( s == 0 )
return(1);
6006 type = GetName(AC.varnames,inp,&num,WITHAUTO);
6007 if ( type != CFUNCTION ) {
6008 MesPrint(
"&%s is not a function in ToPolynomial statement",inp);
6011 funnums[3+numargs++] = num+FUNCTION;
6014 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
6016 funnums[0] = TYPETOPOLYNOMIAL;
6017 funnums[1] = numargs+3;
6018 funnums[2] = ONLYFUNCTIONS;
6021 if ( funnums ) M_free(funnums,
"ToPolynomial");
6023 AC.topolynomialflag |= TOPOLYNOMIALFLAG;
6026 AC.mparallelflag |= NOPARALLEL_CONVPOLY;
6039int CoFromPolynomial(UBYTE *inp)
6041 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
6043 if ( AO.OptimizeResult.code != NULL ) {
6044 MesPrint(
"&Using FromPolynomial statement when there are still optimization results active.");
6045 MesPrint(
"&Please use #ClearOptimize instruction first.");
6046 MesPrint(
"&This will loose the optimized expression.");
6049 Add2Com(TYPEFROMPOLYNOMIAL)
6052 MesPrint(
"&Illegal argument in FromPolynomial statement: '%s'",inp);
6065int CoArgToExtraSymbol(UBYTE *s)
6067 CBUF *C = cbuf + AC.cbufnum;
6071 if ( ( AC.topolynomialflag & ~TOPOLYNOMIALFLAG ) != 0 ) {
6072 MesPrint(
"&ArgToExtraSymbol statement and FactArg statement are not allowed in the same module");
6075 if ( AO.OptimizeResult.code != NULL ) {
6076 MesPrint(
"&Using ArgToExtraSymbol statement when there are still optimization results active.");
6077 MesPrint(
"&Please use #ClearOptimize instruction first.");
6078 MesPrint(
"&This will loose the optimized expression.");
6083 int tonumber = ConsumeOption(&s,
"tonumber");
6085 int ret = DoArgument(s,TYPEARGTOEXTRASYMBOL);
6086 if ( ret )
return(ret);
6092 lhs = C->
lhs[C->numlhs];
6093 if ( lhs[4] != 1 ) {
6094 Warning(
"scale parameter (^n) is ignored in ArgToExtraSymbol");
6098 AC.topolynomialflag |= TOPOLYNOMIALFLAG;
6104 AC.mparallelflag |= NOPARALLEL_CONVPOLY;
6115int CoExtraSymbols(UBYTE *inp)
6117 UBYTE *arg1, *arg2, c, *s;
6118 WORD i, j, type, number;
6119 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
6120 if ( FG.cTable[*inp] != 0 ) {
6121 MesPrint(
"&Illegal argument in ExtraSymbols statement: '%s'",inp);
6125 while ( FG.cTable[*inp] == 0 ) inp++;
6127 if ( ( StrICmp(arg1,(UBYTE *)
"array") == 0 )
6128 || ( StrICmp(arg1,(UBYTE *)
"vector") == 0 ) ) {
6129 AC.extrasymbols = 1;
6131 else if ( StrICmp(arg1,(UBYTE *)
"underscore") == 0 ) {
6132 AC.extrasymbols = 0;
6140 MesPrint(
"&Illegal keyword in ExtraSymbols statement: '%s'",arg1);
6144 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
6145 if ( FG.cTable[*inp] != 0 ) {
6146 MesPrint(
"&Illegal argument in ExtraSymbols statement: '%s'",inp);
6150 while ( FG.cTable[*inp] <= 1 ) inp++;
6152 MesPrint(
"&Illegal end of ExtraSymbols statement: '%s'",inp);
6159 if ( AC.extrasymbols == 1 ) {
6160 type = GetName(AC.varnames,arg2,&number,NOAUTO);
6161 if ( type != NAMENOTFOUND ) {
6162 MesPrint(
"&ExtraSymbols statement: '%s' has already been declared before",arg2);
6166 else if ( AC.extrasymbols == 0 ) {
6167 if ( *arg2 ==
'N' ) {
6169 while ( FG.cTable[*s] == 1 ) s++;
6171 MesPrint(
"&ExtraSymbols statement: '%s' creates conflicts with summed indices",arg2);
6176 if ( AC.extrasym ) { M_free(AC.extrasym,
"extrasym"); AC.extrasym = 0; }
6178 AC.extrasym = (UBYTE *)Malloc1(i*
sizeof(UBYTE),
"extrasym");
6179 for ( j = 0; j < i; j++ ) AC.extrasym[j] = arg2[j];
6188WORD *GetIfDollarFactor(UBYTE **inp, WORD *w)
6194 if ( FG.cTable[*s] == 1 ) {
6196 while ( FG.cTable[*s] == 1 ) {
6197 x = 10*x + *s++ -
'0';
6198 if ( x >= MAXPOSITIVE ) {
6199 MesPrint(
"&Value in dollar factor too large");
6200 while ( FG.cTable[*s] == 1 ) s++;
6205 *w++ = IFDOLLAREXTRA;
6212 MesPrint(
"&Factor indicator for $-variable should be a number or a $-variable.");
6216 while ( FG.cTable[*s] < 2 ) s++;
6218 if ( GetName(AC.dollarnames,name,&number,NOAUTO) == NAMENOTFOUND ) {
6219 MesPrint(
"&dollar in if statement should have been defined previously");
6223 *w++ = IFDOLLAREXTRA;
6229 if ( ( w = GetIfDollarFactor(inp,w) ) == 0 )
return(0);
6232 MesPrint(
"&unmatched [] in $ in if statement");
6246UBYTE *GetDoParam(UBYTE *inp, WORD **wp,
int par)
6251 if ( FG.cTable[*inp] == 1 ) {
6253 while ( *inp >=
'0' && *inp <=
'9' ) {
6254 x = 10*x + *inp++ -
'0';
6255 if ( x > MAXPOSITIVE ) {
6257 MesPrint(
"&Value in dollar factor too large");
6260 MesPrint(
"&Value in do loop boundaries too large");
6262 while ( FG.cTable[*inp] == 1 ) inp++;
6271 *(*wp)++ = DOLLAREXPR2;
6272 *(*wp)++ = -((WORD)x)-1;
6276 if ( *inp !=
'$' ) {
6280 while ( FG.cTable[*inp] < 2 ) inp++;
6282 if ( GetName(AC.dollarnames,name,&number,NOAUTO) == NAMENOTFOUND ) {
6284 MesPrint(
"&dollar in print statement should have been defined previously");
6287 MesPrint(
"&dollar in do loop boundaries should have been defined previously");
6293 *(*wp)++ = DOLLAREXPRESSION;
6297 *(*wp)++ = DOLLAREXPR2;
6302 inp = GetDoParam(inp,wp,0);
6303 if ( inp == 0 )
return(0);
6304 if ( *inp !=
']' ) {
6306 MesPrint(
"&unmatched [] in $ in print statement");
6309 MesPrint(
"&unmatched [] in do loop boundaries");
6326 CBUF *C = cbuf+AC.cbufnum;
6330 if ( AC.doloopstack == 0 ) {
6331 AC.doloopstacksize = 20;
6332 AC.doloopstack = (WORD *)Malloc1(AC.doloopstacksize*2*
sizeof(WORD),
"doloop stack");
6333 AC.doloopnest = AC.doloopstack + AC.doloopstacksize;
6335 if ( AC.dolooplevel >= AC.doloopstacksize ) {
6336 WORD *newstack, *newnest, newsize;
6337 newsize = AC.doloopstacksize * 2;
6338 newstack = (WORD *)Malloc1(newsize*2*
sizeof(WORD),
"doloop stack");
6339 newnest = newstack + newsize;
6340 for ( i = 0; i < newsize; i++ ) {
6341 newstack[i] = AC.doloopstack[i];
6342 newnest[i] = AC.doloopnest[i];
6344 M_free(AC.doloopstack,
"doloop stack");
6345 AC.doloopstack = newstack;
6346 AC.doloopnest = newnest;
6347 AC.doloopstacksize = newsize;
6349 AC.doloopnest[AC.dolooplevel] = NestingChecksum();
6357 while ( *inp ==
',' ) inp++;
6358 if ( *inp !=
'$' ) {
6360 MesPrint(
"&do loop parameter should be a dollar variable");
6365 if ( FG.cTable[*inp] != 0 ) {
6367 MesPrint(
"&illegal name for do loop parameter");
6369 while ( FG.cTable[*inp] < 2 ) inp++;
6371 if ( GetName(AC.dollarnames,name,&numparam,NOAUTO) == NAMENOTFOUND ) {
6372 numparam = AddDollar(name,DOLUNDEFINED,0,0);
6379 while ( *inp ==
',' ) inp++;
6380 if ( *inp !=
'=' )
goto IllSyntax;
6382 while ( *inp ==
',' ) inp++;
6386 inp = GetDoParam(inp,&w,1);
6387 if ( inp == 0 || *inp !=
',' )
goto IllSyntax;
6388 while ( *inp ==
',' ) inp++;
6392 inp = GetDoParam(inp,&w,1);
6393 if ( inp == 0 || ( *inp != 0 && *inp !=
',' ) )
goto IllSyntax;
6397 if ( *inp !=
',' ) {
6398 if ( *inp == 0 ) { *w++ = SNUMBER; *w++ = 1; }
6399 else goto IllSyntax;
6402 while ( *inp ==
',' ) inp++;
6403 inp = GetDoParam(inp,&w,1);
6405 if ( inp == 0 || *inp != 0 )
goto IllSyntax;
6407 AT.WorkPointer[1] = w - AT.WorkPointer;
6411 AddNtoL(AT.WorkPointer[1],AT.WorkPointer);
6412 AC.doloopstack[AC.dolooplevel++] = C->numlhs;
6417 MesPrint(
"&Illegal syntax for do statement");
6426int CoEndDo(UBYTE *inp)
6428 CBUF *C = cbuf+AC.cbufnum;
6430 while ( *inp ==
',' ) inp++;
6432 MesPrint(
"&Illegal syntax for EndDo statement");
6435 if ( AC.dolooplevel <= 0 ) {
6436 MesPrint(
"&EndDo without corresponding Do statement");
6440 scratch[0] = TYPEENDDOLOOP;
6442 scratch[2] = AC.doloopstack[AC.dolooplevel];
6444 cbuf[AC.cbufnum].lhs[AC.doloopstack[AC.dolooplevel]][3] = C->numlhs;
6445 if ( AC.doloopnest[AC.dolooplevel] != NestingChecksum() ) {
6457int CoFactDollar(UBYTE *inp)
6460 if ( *inp ==
'$' ) {
6461 if ( GetName(AC.dollarnames,inp+1,&numdollar,NOAUTO) != CDOLLAR ) {
6462 MesPrint(
"&%s is undefined",inp);
6463 numdollar = AddDollar(inp+1,DOLINDEX,&one,1);
6468 MesPrint(
"&FactDollar should have a single $variable for its argument");
6474 MesPrint(
"&%s is not a $-variable",inp);
6477 Add3Com(TYPEFACTOR,numdollar);
6486int CoFactorize(UBYTE *s) {
return(DoFactorize(s,1)); }
6493int CoNFactorize(UBYTE *s) {
return(DoFactorize(s,0)); }
6500int CoUnFactorize(UBYTE *s) {
return(DoFactorize(s,3)); }
6507int CoNUnFactorize(UBYTE *s) {
return(DoFactorize(s,2)); }
6514int DoFactorize(UBYTE *s,
int par)
6520 int error = 0, keepzeroflag = 0;
6523 while ( *s !=
')' && *s ) {
6524 if ( FG.cTable[*s] == 0 ) {
6525 t = s;
while ( FG.cTable[*s] == 0 ) s++;
6527 if ( StrICmp((UBYTE *)
"keepzero",t) == 0 ) {
6531 MesPrint(
"&Illegal option in [N][Un]Factorize statement: %s",t);
6536 while ( *s ==
',' ) s++;
6537 if ( *s && *s !=
')' && FG.cTable[*s] != 0 ) {
6538 MesPrint(
"&Illegal character in option field of [N][Un]Factorize statement");
6544 while ( *s ==
',' || *s ==
' ' ) s++;
6547 for ( i = NumExpressions-1; i >= 0; i-- ) {
6549 if ( e->replace >= 0 ) {
6550 e = Expressions + e->replace;
6552 if ( e->status == LOCALEXPRESSION || e->status == GLOBALEXPRESSION
6553 || e->status == UNHIDELEXPRESSION || e->status == UNHIDEGEXPRESSION
6554 || e->status == INTOHIDELEXPRESSION || e->status == INTOHIDEGEXPRESSION
6558 e->vflags &= ~TOBEFACTORED;
6561 e->vflags |= TOBEFACTORED;
6562 e->vflags &= ~TOBEUNFACTORED;
6565 e->vflags &= ~TOBEUNFACTORED;
6568 e->vflags |= TOBEUNFACTORED;
6569 e->vflags &= ~TOBEFACTORED;
6573 if ( ( e->vflags & TOBEFACTORED ) != 0 ) {
6574 if ( keepzeroflag ) e->vflags |= KEEPZERO;
6575 else e->vflags &= ~KEEPZERO;
6577 else e->vflags &= ~KEEPZERO;
6582 while ( *s ==
',' ) s++;
6583 if ( *s == 0 )
break;
6584 if ( *s ==
'[' || FG.cTable[*s] == 0 ) {
6587 MesPrint(
"&Improper name for an expression: '%s'",t);
6591 if ( GetName(AC.exprnames,t,&number,NOAUTO) == CEXPRESSION ) {
6592 e = Expressions+number;
6593 if ( e->replace >= 0 ) {
6594 e = Expressions + e->replace;
6596 if ( e->status == LOCALEXPRESSION || e->status == GLOBALEXPRESSION
6597 || e->status == UNHIDELEXPRESSION || e->status == UNHIDEGEXPRESSION
6598 || e->status == INTOHIDELEXPRESSION || e->status == INTOHIDEGEXPRESSION
6602 e->vflags &= ~TOBEFACTORED;
6605 e->vflags |= TOBEFACTORED;
6606 e->vflags &= ~TOBEUNFACTORED;
6609 e->vflags &= ~TOBEUNFACTORED;
6612 e->vflags |= TOBEUNFACTORED;
6613 e->vflags &= ~TOBEFACTORED;
6617 if ( ( e->vflags & TOBEFACTORED ) != 0 ) {
6618 if ( keepzeroflag ) e->vflags |= KEEPZERO;
6619 else e->vflags &= ~KEEPZERO;
6621 else e->vflags &= ~KEEPZERO;
6623 else if ( GetName(AC.varnames,t,&number,NOAUTO) != NAMENOTFOUND ) {
6624 MesPrint(
"&%s is not an expression",t);
6630 MesPrint(
"&Illegal object in (N)Factorize statement");
6632 while ( *s && *s !=
',' ) s++;
6633 if ( *s == 0 )
break;
6647int CoOptimizeOption(UBYTE *s)
6649 UBYTE *name, *t1, *t2, c1, c2, *value, *u;
6652 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
6654 name = s;
while ( FG.cTable[*s] == 0 ) s++;
6656 while ( *s ==
' ' || *s ==
'\t' ) s++;
6659 MesPrint(
"&Correct use in Format,Optimize statement is Optionname=value");
6661 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' || *s ==
'=' ) s++;
6667 while ( *s ==
' ' || *s ==
'\t' ) s++;
6668 if ( *s == 0 )
goto correctuse;
6670 while ( FG.cTable[*s] <= 1 || *s==
'.' || *s==
'*' || *s ==
'(' || *s ==
')' ) {
6671 if ( *s ==
'(' ) { SKIPBRA4(s) }
6675 while ( *s ==
' ' || *s ==
'\t' ) s++;
6676 if ( *s && *s !=
',' )
goto correctuse;
6679 while ( *s ==
' ' || *s ==
'\t' ) s++;
6685 if ( StrICmp(name,(UBYTE *)
"horner") == 0 ) {
6686 if ( StrICmp(value,(UBYTE *)
"occurrence") == 0 ) {
6687 AO.Optimize.horner = O_OCCURRENCE;
6689 else if ( StrICmp(value,(UBYTE *)
"mcts") == 0 ) {
6690 AO.Optimize.horner = O_MCTS;
6692 else if ( StrICmp(value,(UBYTE *)
"sa") == 0 ) {
6693 AO.Optimize.horner = O_SIMULATED_ANNEALING;
6696 AO.Optimize.horner = -1;
6697 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6701 else if ( StrICmp(name,(UBYTE *)
"hornerdirection") == 0 ) {
6702 if ( StrICmp(value,(UBYTE *)
"forward") == 0 ) {
6703 AO.Optimize.hornerdirection = O_FORWARD;
6705 else if ( StrICmp(value,(UBYTE *)
"backward") == 0 ) {
6706 AO.Optimize.hornerdirection = O_BACKWARD;
6708 else if ( StrICmp(value,(UBYTE *)
"forwardorbackward") == 0 ) {
6709 AO.Optimize.hornerdirection = O_FORWARDORBACKWARD;
6711 else if ( StrICmp(value,(UBYTE *)
"forwardandbackward") == 0 ) {
6712 AO.Optimize.hornerdirection = O_FORWARDANDBACKWARD;
6715 AO.Optimize.method = -1;
6716 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6720 else if ( StrICmp(name,(UBYTE *)
"method") == 0 ) {
6721 if ( StrICmp(value,(UBYTE *)
"none") == 0 ) {
6722 AO.Optimize.method = O_NONE;
6724 else if ( StrICmp(value,(UBYTE *)
"cse") == 0 ) {
6725 AO.Optimize.method = O_CSE;
6727 else if ( StrICmp(value,(UBYTE *)
"csegreedy") == 0 ) {
6728 AO.Optimize.method = O_CSEGREEDY;
6730 else if ( StrICmp(value,(UBYTE *)
"greedy") == 0 ) {
6731 AO.Optimize.method = O_GREEDY;
6734 AO.Optimize.method = -1;
6735 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6739 else if ( StrICmp(name,(UBYTE *)
"timelimit") == 0 ) {
6741 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6743 MesPrint(
"&Option TimeLimit in Format,Optimize statement should be a positive number: %s",value);
6744 AO.Optimize.mctstimelimit = 0;
6745 AO.Optimize.greedytimelimit = 0;
6749 AO.Optimize.mctstimelimit = x/2;
6750 AO.Optimize.greedytimelimit = x/2;
6753 else if ( StrICmp(name,(UBYTE *)
"mctstimelimit") == 0 ) {
6755 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6757 MesPrint(
"&Option MCTSTimeLimit in Format,Optimize statement should be a positive number: %s",value);
6758 AO.Optimize.mctstimelimit = 0;
6762 AO.Optimize.mctstimelimit = x;
6765 else if ( StrICmp(name,(UBYTE *)
"mctsnumexpand") == 0 ) {
6768 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6769 if ( *u ==
'*' || *u ==
'x' || *u ==
'X' ) {
6772 while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6776 MesPrint(
"&Option MCTSNumExpand in Format,Optimize statement should be a positive number: %s",value);
6777 AO.Optimize.mctsnumexpand= 0;
6778 AO.Optimize.mctsnumrepeat= 1;
6782 AO.Optimize.mctsnumexpand= x;
6783 AO.Optimize.mctsnumrepeat= y;
6786 else if ( StrICmp(name,(UBYTE *)
"mctsnumrepeat") == 0 ) {
6788 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6790 MesPrint(
"&Option MCTSNumExpand in Format,Optimize statement should be a positive number: %s",value);
6791 AO.Optimize.mctsnumrepeat= 1;
6795 AO.Optimize.mctsnumrepeat= x;
6798 else if ( StrICmp(name,(UBYTE *)
"mctsnumkeep") == 0 ) {
6800 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6802 MesPrint(
"&Option MCTSNumKeep in Format,Optimize statement should be a positive number: %s",value);
6803 AO.Optimize.mctsnumkeep= 0;
6807 AO.Optimize.mctsnumkeep= x;
6810 else if ( StrICmp(name,(UBYTE *)
"mctsconstant") == 0 ) {
6812 if ( sscanf ((
char*)value,
"%lf", &d) != 1 ) {
6813 MesPrint(
"&Option MCTSConstant in Format,Optimize statement should be a positive number: %s",value);
6814 AO.Optimize.mctsconstant.fval = 0;
6818 AO.Optimize.mctsconstant.fval = d;
6821 else if ( StrICmp(name,(UBYTE *)
"greedytimelimit") == 0 ) {
6823 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6825 MesPrint(
"&Option GreedyTimeLimit in Format,Optimize statement should be a positive number: %s",value);
6826 AO.Optimize.greedytimelimit = 0;
6830 AO.Optimize.greedytimelimit = x;
6833 else if ( StrICmp(name,(UBYTE *)
"greedyminnum") == 0 ) {
6835 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6837 MesPrint(
"&Option GreedyMinNum in Format,Optimize statement should be a positive number: %s",value);
6838 AO.Optimize.greedyminnum= 0;
6842 AO.Optimize.greedyminnum= x;
6845 else if ( StrICmp(name,(UBYTE *)
"greedymaxperc") == 0 ) {
6847 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6849 MesPrint(
"&Option GreedyMaxPerc in Format,Optimize statement should be a positive number: %s",value);
6850 AO.Optimize.greedymaxperc= 0;
6854 AO.Optimize.greedymaxperc= x;
6857 else if ( StrICmp(name,(UBYTE *)
"stats") == 0 ) {
6858 if ( StrICmp(value,(UBYTE *)
"on") == 0 ) {
6859 AO.Optimize.printstats = 1;
6861 else if ( StrICmp(value,(UBYTE *)
"off") == 0 ) {
6862 AO.Optimize.printstats = 0;
6865 AO.Optimize.printstats = 0;
6866 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6870 else if ( StrICmp(name,(UBYTE *)
"printscheme") == 0 ) {
6871 if ( StrICmp(value,(UBYTE *)
"on") == 0 ) {
6872 AO.Optimize.schemeflags |= 1;
6874 else if ( StrICmp(value,(UBYTE *)
"off") == 0 ) {
6875 AO.Optimize.schemeflags &= ~1;
6878 AO.Optimize.schemeflags &= ~1;
6879 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6883 else if ( StrICmp(name,(UBYTE *)
"debugflag") == 0 ) {
6891 if ( FG.cTable[*u] == 1 ) {
6892 while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6894 MesPrint(
"&Numerical value for DebugFlag in Format,Optimize statement should be a nonnegative number: %s",value);
6895 AO.Optimize.debugflags = 0;
6899 AO.Optimize.debugflags = x;
6902 else if ( StrICmp(value,(UBYTE *)
"on") == 0 ) {
6903 AO.Optimize.debugflags = 1;
6905 else if ( StrICmp(value,(UBYTE *)
"off") == 0 ) {
6906 AO.Optimize.debugflags = 0;
6909 AO.Optimize.debugflags = 0;
6910 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6914 else if ( StrICmp(name,(UBYTE *)
"scheme") == 0 ) {
6921 MesPrint(
"&Option Scheme in Format,Optimize statement should be an array of names or integers between (): %s",value);
6926 while ( *ss ==
' ' || *ss ==
'\t' || *ss ==
',' ) ss++;
6927 if ( FG.cTable[*ss] == 0 || *ss ==
'$' || *ss ==
'[' ) {
6928 s1 = u; SKIPBRA3(s1)
6929 if ( *s1 !=
')' )
goto noscheme;
6930 while ( ss < s1 ) {
if ( *ss++ ==
',' ) AO.schemenum++; }
6931 *ss++ = 0;
while ( *ss ==
' ' ) ss++;
6932 if ( *ss != 0 )
goto noscheme;
6934 if ( AO.schemenum < 1 ) {
6935 MesPrint(
"&Option Scheme in Format,Optimize statement should have at least one name or number between ()");
6939 if ( AO.inscheme ) M_free(AO.inscheme,
"Horner input scheme");
6940 AO.inscheme = (WORD *)Malloc1((AO.schemenum+1)*
sizeof(WORD),
"Horner input scheme");
6941 while ( *ss ==
' ' || *ss ==
'\t' || *ss ==
',' ) ss++;
6944 if ( *ss == 0 )
break;
6945 s1 = ss; ss =
SkipAName(s1); c = *ss; *ss = 0;
6947 if ( ss[-1] ==
'_' ) {
6952 u1 = s1; u2 = AC.extrasym;
6953 while ( *u1 == *u2 ) { u1++; u2++; }
6956 while ( *u1 >=
'0' && *u1 <=
'9' ) numsym = 10*numsym + *u1++ -
'0';
6957 if ( u1 != ss-1 || numsym == 0 || AC.extrasymbols != 0 ) {
6958 MesPrint(
"&Improper use of extra symbol in scheme format option");
6961 numsym = MAXVARIABLES-numsym;
6966 else if ( *s1 ==
'$' ) {
6969 if ( ( numdollar = GetDollar(s1+1) ) < 0 ) {
6970 MesPrint(
"&Undefined variable %s",s1);
6973 else if ( ( numsym = DolToSymbol(BHEAD numdollar) ) < 0 ) {
6974 MesPrint(
"&$%s does not evaluate to a symbol",s1);
6980 else if ( c ==
'(' ) {
6981 if ( StrCmp(s1,AC.extrasym) == 0 ) {
6982 if ( (AC.extrasymbols&1) != 1 ) {
6983 MesPrint(
"&Improper use of extra symbol in scheme format option");
6988 while ( *ss >=
'0' && *ss <=
'9' ) numsym = 10*numsym + *ss++ -
'0';
6990 MesPrint(
"&Extra symbol should have a number for its argument.");
6993 numsym = MAXVARIABLES-numsym;
6998 type = GetName(AC.varnames,s1,&numsym,WITHAUTO);
6999 if ( ( type != CSYMBOL ) && type != CDUBIOUS ) {
7000 MesPrint(
"&%s is not a symbol",s1);
7002 if ( type < 0 ) numsym = AddSymbol(s1,-MAXPOWER,MAXPOWER,0,0);
7006 AO.inscheme[AO.schemenum++] = numsym;
7007 while ( *ss ==
' ' || *ss ==
'\t' || *ss ==
',' ) ss++;
7011 else if ( StrICmp(name,(UBYTE *)
"mctsdecaymode") == 0 ) {
7014 if ( FG.cTable[*u] == 1 ) {
7015 while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
7017 MesPrint(
"&Option MCTSDecayMode in Format,Optimize statement should be a nonnegative integer: %s",value);
7018 AO.Optimize.mctsdecaymode = 0;
7022 AO.Optimize.mctsdecaymode = x;
7026 AO.Optimize.mctsdecaymode = 0;
7027 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
7031 else if ( StrICmp(name,(UBYTE *)
"saiter") == 0 ) {
7033 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
7035 MesPrint(
"&Option SAIter in Format,Optimize statement should be a positive integer: %s",value);
7036 AO.Optimize.saIter = 0;
7040 AO.Optimize.saIter= x;
7043 else if ( StrICmp(name,(UBYTE *)
"samaxt") == 0 ) {
7045 if ( sscanf ((
char*)value,
"%lf", &d) != 1 ) {
7046 MesPrint(
"&Option SAMaxT in Format,Optimize statement should be a positive number: %s",value);
7047 AO.Optimize.saMaxT.fval = 0;
7051 AO.Optimize.saMaxT.fval = d;
7054 else if ( StrICmp(name,(UBYTE *)
"samint") == 0 ) {
7056 if ( sscanf ((
char*)value,
"%lf", &d) != 1 ) {
7057 MesPrint(
"&Option SAMinT in Format,Optimize statement should be a positive number: %s",value);
7058 AO.Optimize.saMinT.fval = 0;
7062 AO.Optimize.saMinT.fval = d;
7066 MesPrint(
"&Unrecognized option name in Format,Optimize statement: %s",name);
7083int CoPutInside(UBYTE *inp) {
return(DoPutInside(inp,1)); }
7084int CoAntiPutInside(UBYTE *inp) {
return(DoPutInside(inp,-1)); }
7086int DoPutInside(UBYTE *inp,
int par)
7090 WORD *to, type, c1,c2,funnum, *WorkSave;
7092 while ( *inp ==
' ' || *inp ==
'\t' || *inp ==
',' ) inp++;
7097 if ( p == 0 )
return(1);
7099 type = GetName(AC.varnames,inp,&funnum,WITHAUTO);
7100 if ( type != CFUNCTION || functions[funnum].tabl != 0 || functions[funnum].spec ) {
7101 MesPrint(
"&PutInside/AntiPutInside expects a regular function for its first argument");
7102 MesPrint(
"&Argument is %s",inp);
7108 while ( *inp ==
' ' || *inp ==
'\t' || *inp ==
',' ) inp++;
7112 tocompiler[0] = TYPEPUTINSIDE;
7115 tocompiler[3] = funnum;
7119 MesPrint(
"&AntiPutInside needs inside information.");
7124 WorkSave = to = AT.WorkPointer;
7125 *to++ = TYPEPUTINSIDE;
7131 while ( *inp ==
' ' || *inp ==
'\t' || *inp ==
',' ) inp++;
7132 if ( *inp == 0 )
break;
7134 if ( p == 0 ) { error = 1;
break; }
7136 type = GetName(AC.varnames,inp,&c1,WITHAUTO);
7138 if ( type == CVECTOR || type == CDUBIOUS ) {
7142 if ( p == 0 )
return(1);
7144 type = GetName(AC.varnames,inp,&c2,WITHAUTO);
7145 if ( type != CVECTOR && type != CDUBIOUS ) {
7146 MesPrint(
"&Not a vector in dotproduct in PutInside/AntiPutInside statement: %s",inp);
7149 else type = CDOTPRODUCT;
7152 MesPrint(
"&Illegal use of . after %s in PutInside/AntiPutInside statement",inp);
7160 *to++ = SYMBOL; *to++ = 4; *to++ = c1; *to++ = 1;
break;
7162 *to++ = INDEX; *to++ = 3; *to++ = AM.OffsetVector + c1;
break;
7164 *to++ = c1+FUNCTION; *to++ = FUNHEAD; *to++ = 0;
7168 *to++ = DOTPRODUCT; *to++ = 5; *to++ = c1 + AM.OffsetVector;
7169 *to++ = c2 + AM.OffsetVector; *to++ = 1;
break;
7171 *to++ = DELTA; *to++ = 4; *to++ = EMPTYINDEX; *to++ = EMPTYINDEX;
break;
7173 MesPrint(
"&Illegal variable request for %s in PutInside/AntiPutInside statement",inp);
7179 *to++ = 1; *to++ = 1; *to++ = 3;
7180 AT.WorkPointer[1] = to - AT.WorkPointer;
7181 AT.WorkPointer[4] = AT.WorkPointer[1]-4;
7182 AT.WorkPointer = to;
7183 AC.BracketNormalize = 1;
7184 if ( Normalize(BHEAD WorkSave+4) ) { error = 1; }
7186 WorkSave[1] = WorkSave[4]+4;
7187 to = WorkSave + WorkSave[1] - 1;
7191 AddNtoL(WorkSave[1],WorkSave);
7193 AC.BracketNormalize = 0;
7194 AT.WorkPointer = WorkSave;
7206int CoSwitch(UBYTE *s)
7211 if ( GetName(AC.dollarnames,s+1,&numdollar,NOAUTO) != CDOLLAR ) {
7212 MesPrint(
"&%s is undefined in switch statement",s);
7213 numdollar = AddDollar(s+1,DOLINDEX,&one,1);
7218 MesPrint(
"&Switch should have a single $variable for its argument");
7224 MesPrint(
"&%s is not a $-variable in switch statement",s);
7233 if ( AC.SwitchInArray >= AC.MaxSwitch ) DoubleSwitchBuffers();
7234 AC.SwitchHeap[AC.SwitchLevel] = AC.SwitchInArray;
7235 sw = AC.SwitchArray + AC.SwitchInArray;
7237 sw->iflevel = AC.IfLevel;
7238 sw->whilelevel = AC.WhileLevel;
7239 sw->nestingsum = NestingChecksum();
7241 Add4Com(TYPESWITCH,numdollar,AC.SwitchInArray);
7254 SWITCH *sw = AC.SwitchArray + AC.SwitchHeap[AC.SwitchLevel];
7255 WORD x = 0, sign = 1;
7256 while ( *s ==
',' ) s++;
7258 while ( *s ==
'-' || *s ==
'+' ) {
7259 if ( *s ==
'-' ) sign = -sign;
7262 while ( FG.cTable[*s] == 1 ) { x = 10*x + *s++ -
'0'; }
7265 if ( sw->iflevel != AC.IfLevel || sw->whilelevel != AC.WhileLevel
7266 || sw->nestingsum != NestingChecksum() ) {
7267 MesPrint(
"&Illegal nesting of switch/case/default with if/while/repeat/loop/argument/term/...");
7273 if ( sw->numcases >= sw->tablesize ) {
7277 if ( sw->tablesize == 0 ) newsize = 10;
7278 else newsize = 2*sw->tablesize;
7281 for ( i = 0; i < sw->tablesize; i++ ) newtable[i] = sw->table[i];
7282 M_free(sw->table,
"Switch table");
7284 sw->table = newtable;
7285 sw->tablesize = newsize;
7287 if ( sw->numcases == 0 ) { sw->mincase = sw->maxcase = x; }
7288 else if ( x > sw->maxcase ) sw->maxcase = x;
7289 else if ( x < sw->mincase ) sw->mincase = x;
7290 sw->table[sw->numcases].ncase = x;
7291 sw->table[sw->numcases].value = cbuf[AC.cbufnum].numlhs;
7292 sw->table[sw->numcases].compbuffer = AC.cbufnum;
7302int CoBreak(UBYTE *s)
7309 SWITCH *sw = AC.SwitchArray + AC.SwitchHeap[AC.SwitchLevel];
7310 if ( sw->iflevel != AC.IfLevel || sw->whilelevel != AC.WhileLevel
7311 || sw->nestingsum != NestingChecksum() ) {
7312 MesPrint(
"&Illegal nesting of switch/case/default with if/while/repeat/loop/argument/term/...");
7316 MesPrint(
"&No parameters allowed in Break statement");
7319 Add3Com(TYPEENDSWITCH,AC.SwitchHeap[AC.SwitchLevel]);
7328int CoDefault(UBYTE *s)
7334 SWITCH *sw = AC.SwitchArray + AC.SwitchHeap[AC.SwitchLevel];
7335 if ( sw->iflevel != AC.IfLevel || sw->whilelevel != AC.WhileLevel
7336 || sw->nestingsum != NestingChecksum() ) {
7337 MesPrint(
"&Illegal nesting of switch/case/default with if/while/repeat/loop/argument/term/...");
7341 MesPrint(
"&No parameters allowed in Default statement");
7344 sw->defaultcase.ncase = 0;
7345 sw->defaultcase.value = cbuf[AC.cbufnum].numlhs;
7346 sw->defaultcase.compbuffer = AC.cbufnum;
7355int CoEndSwitch(UBYTE *s)
7364 SWITCH *sw = AC.SwitchArray + AC.SwitchHeap[AC.SwitchLevel];
7366 WORD totcases = sw->maxcase-sw->mincase+1;
7367 while ( *s ==
',' ) s++;
7370 MesPrint(
"&No parameters allowed in EndSwitch statement");
7373 if ( sw->iflevel != AC.IfLevel || sw->whilelevel != AC.WhileLevel
7374 || sw->nestingsum != NestingChecksum() ) {
7375 MesPrint(
"&Illegal nesting of switch/case/default with if/while/repeat/loop/argument/term/...");
7378 if ( sw->defaultcase.value == 0 ) CoDefault(s);
7379 if ( totcases > sw->numcases*AM.jumpratio ) {
7381 sw->typetable = SPARSETABLE;
7385 SwitchSplitMerge(sw->table,sw->numcases);
7389 sw->caseoffset = sw->mincase;
7390 sw->typetable = DENSETABLE;
7392 for ( i = 0; i < totcases; i++ ) {
7393 ntable[i].ncase = i+sw->caseoffset;
7394 ntable[i].value = sw->defaultcase.value;
7395 ntable[i].compbuffer = sw->defaultcase.compbuffer;
7397 for ( i = 0; i < sw->numcases; i++ ) {
7398 ntable[sw->table[i].ncase-sw->caseoffset] = sw->table[i];
7400 M_free(sw->table,
"Switch table");
7402 sw->numcases = totcases;
7404 sw->endswitch.ncase = 0;
7405 sw->endswitch.value = cbuf[AC.cbufnum].numlhs;
7406 sw->endswitch.compbuffer = AC.cbufnum;
7407 if ( sw->defaultcase.value == 0 ) {
7408 sw->defaultcase = sw->endswitch;
7410 Add3Com(TYPEENDSWITCH,AC.SwitchHeap[AC.SwitchLevel]);
7423int CoSetUserFlag(UBYTE *s)
7426 while ( *s && ( *s ==
',' || *s ==
' ' || *s ==
'\t' ) ) s++;
7427 while ( *s && ( FG.cTable[*s] == 1 ) ) {
7429 while ( *s && ( FG.cTable[*s] == 1 ) ) x = 10*x+(*s++ -
'0');
7430 if ( x < 1 || x > BITSINWORD ) {
7431 MesPrint(
"&Flag number %d outside the permitted range 1-%d.",BITSINWORD);
7435 Add3Com(TYPESETUSERFLAG,x-1);
7437 while ( *s && ( *s ==
',' || *s ==
' ' || *s ==
'\t' ) ) s++;
7440 MesPrint(
"&Illegal character in SetUserFlag statement: %s",s);
7451int CoClearUserFlag(UBYTE *s)
7454 while ( *s && ( *s ==
',' || *s ==
' ' || *s ==
'\t' ) ) s++;
7455 while ( *s && ( FG.cTable[*s] == 1 ) ) {
7457 while ( *s && ( FG.cTable[*s] == 1 ) ) x = 10*x+(*s++ -
'0');
7458 if ( x < 1 || x > BITSINWORD ) {
7459 MesPrint(
"&Flag number %d outside the permitted range 1-%d.",BITSINWORD);
7463 Add3Com(TYPECLEARUSERFLAG,x);
7465 while ( *s && ( *s ==
',' || *s ==
' ' || *s ==
'\t' ) ) s++;
7468 MesPrint(
"&Illegal character in SetUserFlag statement: %s",s);
7488int CoCreateAllLoops(UBYTE *s)
7491 UBYTE *inname, *outname, *stype, c;
7492 WORD infun, outfun, x, type, tensorflag, typenum;
7493 WORD *WorkSave, *to;
7494 while ( *s ==
',' || *s ==
' ' ) s++;
7497 if ( ( ( type = GetName(AC.varnames,inname,&infun,WITHAUTO) ) != CFUNCTION )
7498 || ( ( functions[infun].spec != 0 ) && ( functions[infun].spec != TENSORFUNCTION ) ) ) {
7499 MesPrint(
"&%s should be a regular function or a tensor.",inname);
7501 if ( GetName(AC.exprnames,s,&infun,NOAUTO) == NAMENOTFOUND )
7502 AddFunction(s,0,0,0,0,0,-1,-1);
7508 while ( *s ==
',' || *s ==
' ' ) s++;
7511 if ( ( ( type = GetName(AC.varnames,outname,&outfun,WITHAUTO) ) != CFUNCTION )
7512 || ( ( functions[outfun].spec != 0 ) && ( functions[outfun].spec != TENSORFUNCTION ) ) ) {
7513 MesPrint(
"&%s should be a regular function or a tensor.",outname);
7515 if ( GetName(AC.exprnames,s,&outfun,NOAUTO) == NAMENOTFOUND )
7516 AddFunction(s,0,0,0,0,0,-1,-1);
7522 if ( functions[infun].spec == TENSORFUNCTION ||
7523 functions[outfun].spec == TENSORFUNCTION ) tensorflag = 1;
7524 else tensorflag = 0;
7528 while ( *s ==
',' || *s ==
' ' ) s++;
7530 while ( FG.cTable[*s] == 0 ) s++;
7532 if ( StrICmp(stype,(UBYTE *)
"type") != 0 || c !=
'=' ) {
7533 MesPrint(
"&In CreateAllLoops statement: expected type=vartype.");
7538 while ( FG.cTable[*s] == 0 ) s++;
7540 if ( StrICmp(stype,(UBYTE *)
"vector") == 0 ) {
7543 else if ( StrICmp(stype,(UBYTE *)
"index") == 0 ) {
7546 else if ( StrICmp(stype,(UBYTE *)
"symbol") == 0 ) {
7547 if ( tensorflag )
goto notintensor;
7550 else if ( StrICmp(stype,(UBYTE *)
"snumber") == 0 ) {
7551 if ( tensorflag )
goto notintensor;
7555 MesPrint(
"&Unknown/not allowed variable type in CreateAllLoops: %s",stype);
7559 while ( *s ==
',' || *s ==
' ' ) s++;
7562 while ( FG.cTable[*s] == 0 ) s++;
7564 if ( StrICmp(stype,(UBYTE *)
"ifnoloop") != 0 || c !=
'=' ) {
7565 MesPrint(
"&Unrecognised option in CreateAllLoops statement: %s",stype);
7570 if ( FG.cTable[*s] == 1 ) {
7572 do { x = 10*x + (*s++-
'0'); }
while (FG.cTable[*s] == 1);
7574 if ( x != 0 && x != 1 ) {
7575 MesPrint(
"&Only options allowed for ifnoloop are 0 or 1.");
7578 WorkSave = to = AT.WorkPointer;
7579 *to++ = TYPEALLLOOPS;
7586 AddNtoL(WorkSave[1],WorkSave);
7590 MesPrint(
"&Variable type not allowed in tensors: %s",stype);
7608int CoCreateAllPaths(UBYTE *s)
7611 UBYTE *endname,*inname, *outname, *stype, c;
7612 WORD endfun, infun, outfun, x, type, tensorflag, typenum;
7613 WORD *WorkSave, *to;
7614 while ( *s ==
',' || *s ==
' ' ) s++;
7617 if ( ( ( type = GetName(AC.varnames,endname,&endfun,WITHAUTO) ) != CFUNCTION )
7618 || ( ( functions[endfun].spec != 0 ) && ( functions[endfun].spec != TENSORFUNCTION ) ) ) {
7619 MesPrint(
"&%s should be a regular function or a tensor.",endname);
7621 if ( GetName(AC.exprnames,s,&endfun,NOAUTO) == NAMENOTFOUND )
7622 AddFunction(s,0,0,0,0,0,-1,-1);
7628 while ( *s ==
',' || *s ==
' ' ) s++;
7631 if ( ( ( type = GetName(AC.varnames,inname,&infun,WITHAUTO) ) != CFUNCTION )
7632 || ( ( functions[infun].spec != 0 ) && ( functions[infun].spec != TENSORFUNCTION ) ) ) {
7633 MesPrint(
"&%s should be a regular function or a tensor.",inname);
7635 if ( GetName(AC.exprnames,s,&infun,NOAUTO) == NAMENOTFOUND )
7636 AddFunction(s,0,0,0,0,0,-1,-1);
7642 while ( *s ==
',' || *s ==
' ' ) s++;
7645 if ( ( ( type = GetName(AC.varnames,outname,&outfun,WITHAUTO) ) != CFUNCTION )
7646 || ( ( functions[outfun].spec != 0 ) && ( functions[outfun].spec != TENSORFUNCTION ) ) ) {
7647 MesPrint(
"&%s should be a regular function or a tensor.",outname);
7649 if ( GetName(AC.exprnames,s,&outfun,NOAUTO) == NAMENOTFOUND )
7650 AddFunction(s,0,0,0,0,0,-1,-1);
7656 if ( functions[infun].spec == TENSORFUNCTION ||
7657 functions[outfun].spec == TENSORFUNCTION ) tensorflag = 1;
7658 else tensorflag = 0;
7662 while ( *s ==
',' || *s ==
' ' ) s++;
7664 while ( FG.cTable[*s] == 0 ) s++;
7666 if ( StrICmp(stype,(UBYTE *)
"type") != 0 || c !=
'=' ) {
7667 MesPrint(
"&In CreateAllPaths statement: expected type=vartype.");
7672 while ( FG.cTable[*s] == 0 ) s++;
7674 if ( StrICmp(stype,(UBYTE *)
"vector") == 0 ) {
7677 else if ( StrICmp(stype,(UBYTE *)
"index") == 0 ) {
7680 else if ( StrICmp(stype,(UBYTE *)
"symbol") == 0 ) {
7681 if ( tensorflag )
goto notintensor;
7684 else if ( StrICmp(stype,(UBYTE *)
"snumber") == 0 ) {
7685 if ( tensorflag )
goto notintensor;
7689 MesPrint(
"&Unknown/not allowed variable type in CreateAllPaths: %s",stype);
7693 while ( *s ==
',' || *s ==
' ' ) s++;
7696 while ( FG.cTable[*s] == 0 ) s++;
7698 if ( StrICmp(stype,(UBYTE *)
"ifnopath") != 0 || c !=
'=' ) {
7699 MesPrint(
"&Unrecognised option in CreateAllPaths statement: %s",stype);
7704 if ( FG.cTable[*s] == 1 ) {
7706 do { x = 10*x + (*s++-
'0'); }
while (FG.cTable[*s] == 1);
7708 if ( x != 0 && x != 1 ) {
7709 MesPrint(
"&Only options allowed for ifnopath are 0 or 1.");
7712 WorkSave = to = AT.WorkPointer;
7713 *to++ = TYPEALLPATHS;
7721 AddNtoL(WorkSave[1],WorkSave);
7725 MesPrint(
"&CreateAllPaths: Variable type not allowed in tensors: %s",stype);
7736int CoCreateAll(UBYTE *s)
7739 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
7741 while ( FG.cTable[*s] == 0 ) s++;
7742 if ( *s !=
' ' && *s !=
',' && *s !=
'\t' ) {
7743 MesPrint(
"&Illegal subkey in CoCreate statement.");
7747 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
7748 if ( StrICmp(subkey,(UBYTE *)
"loops") == 0 ) {
7749 return(CoCreateAllLoops(s));
7751 else if ( StrICmp(subkey,(UBYTE *)
"paths") == 0 ) {
7752 return(CoCreateAllPaths(s));
7763 MesPrint(
"&Illegal subkey in CoCreate statement: %s.",subkey);
UBYTE * SkipAName(UBYTE *s)
void PrintDeprecation(const char *, const char *)
void AddPotModdollar(WORD)
LONG EndSort(PHEAD WORD *, int)
int Generator(PHEAD WORD *, WORD)
void LowerSortLevel(void)