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 ,{
"innertest", &(AC.InnerTest), 1, 0}
139 ,{
"wtimestats", &(AC.WTimeStatsFlag), 1, 0}
140 ,{
"sortreallocate", &(AC.SortReallocateFlag), 1, 0}
141 ,{
"backtrace", &(AC.PrintBacktraceFlag), 1, 0}
142 ,{
"flint", &(AC.FlintPolyFlag), 1, 0}
143 ,{
"humanstats", &(AC.HumanStatsFlag), 1, 0}
144 ,{
"humanstatistics", &(AC.HumanStatsFlag), 1, 0}
145 ,{
"grccverbose", &(AC.GrccVerbose), 1, 0}
146 ,{
"sortverbose", &(AC.SortVerbose), 1, 0}
156int CoFormat(UBYTE *s)
161 while ( *s ==
' ' || *s ==
',' ) s++;
164 AC.OutputSpaces = NORMALFORMAT;
170 if ( *s ==
'O' || *s ==
'o' ) {
171 if ( ( FG.cTable[s[1]] == 1 ) ||
172 ( s[1] ==
'=' && FG.cTable[s[2]] == 1 ) ) {
173 s++;
if ( *s ==
'=' ) s++;
175 while ( *s >=
'0' && *s <=
'9' ) x = 10*x + *s++ -
'0';
176 while ( *s ==
',' ) s++;
177 AO.OptimizationLevel = x;
178 AO.Optimize.greedytimelimit = 0;
179 AO.Optimize.mctstimelimit = 0;
180 AO.Optimize.printstats = 0;
181 AO.Optimize.debugflags = 0;
182 AO.Optimize.schemeflags = 0;
183 AO.Optimize.mctsdecaymode = 1;
185 M_free(AO.inscheme,
"Horner input scheme");
186 AO.inscheme = 0; AO.schemenum = 0;
192 AO.Optimize.mctsconstant.fval = -1.0;
193 AO.Optimize.horner = O_OCCURRENCE;
194 AO.Optimize.hornerdirection = O_FORWARDORBACKWARD;
195 AO.Optimize.method = O_CSE;
198 AO.Optimize.horner = O_OCCURRENCE;
199 AO.Optimize.hornerdirection = O_FORWARDORBACKWARD;
200 AO.Optimize.method = O_GREEDY;
201 AO.Optimize.greedyminnum = 10;
202 AO.Optimize.greedymaxperc = 5;
205 AO.Optimize.mctsconstant.fval = 1.0;
206 AO.Optimize.horner = O_MCTS;
207 AO.Optimize.hornerdirection = O_FORWARDORBACKWARD;
208 AO.Optimize.method = O_GREEDY;
209 AO.Optimize.mctsnumexpand = 1000;
210 AO.Optimize.mctsnumkeep = 10;
211 AO.Optimize.mctsnumrepeat = 1;
212 AO.Optimize.greedyminnum = 10;
213 AO.Optimize.greedymaxperc = 5;
216 AO.Optimize.horner = O_SIMULATED_ANNEALING;
217 AO.Optimize.saIter = 1000;
218 AO.Optimize.saMaxT.fval = 2000;
219 AO.Optimize.saMinT.fval = 1;
223 MesPrint(
"&Illegal optimization specification in format statement");
226 if ( error == 0 && *s != 0 && x > 0 )
return(CoOptimizeOption(s));
232 while ( FG.cTable[*s] == 0 ) s++;
234 if ( StrICont(ss,(UBYTE *)
"optimize") == 0 ) {
236 while ( *s ==
',' ) s++;
237 if ( *s ==
'=' ) s++;
238 AO.OptimizationLevel = 3;
239 AO.Optimize.mctsconstant.fval = 1.0;
240 AO.Optimize.horner = O_MCTS;
241 AO.Optimize.hornerdirection = O_FORWARDORBACKWARD;
242 AO.Optimize.method = O_GREEDY;
243 AO.Optimize.mctstimelimit = 0;
244 AO.Optimize.mctsnumexpand = 1000;
245 AO.Optimize.mctsnumkeep = 10;
246 AO.Optimize.mctsnumrepeat = 1;
247 AO.Optimize.greedytimelimit = 0;
248 AO.Optimize.greedyminnum = 10;
249 AO.Optimize.greedymaxperc = 5;
250 AO.Optimize.printstats = 0;
251 AO.Optimize.debugflags = 0;
252 AO.Optimize.schemeflags = 0;
253 AO.Optimize.mctsdecaymode = 1;
255 M_free(AO.inscheme,
"Horner input scheme");
256 AO.inscheme = 0; AO.schemenum = 0;
258 return(CoOptimizeOption(s));
262 MesPrint(
"&Illegal optimization specification in format statement");
268 else if ( FG.cTable[*s] == 1 ) {
270 while ( FG.cTable[*s] == 1 ) x = 10*x + *s++ -
'0';
271 if ( x <= 0 || x >= MAXLINELENGTH ) {
273 MesPrint(
"&Illegal value for linesize: %d",x);
277 MesPrint(
" ... Too small value for linesize corrected to 39");
290 MesPrint(
"&Illegal linesize field in format statement");
294 key = FindKeyWord(s,formatoptions,
295 sizeof(formatoptions)/
sizeof(
KEYWORD));
297 if ( key->type == FORTRANMODE || key->type == PFORTRANMODE || key->type == DOUBLEFORTRANMODE
298 || key->type == QUADRUPLEFORTRANMODE || key->type == VORTRANMODE ) {
299 if (AC.LineLength > 72) AC.LineLength = 72;
301 if ( key->flags == 0 ) {
302 if ( key->type == FORTRANMODE || key->type == PFORTRANMODE
303 || key->type == DOUBLEFORTRANMODE || key->type == ALLINTEGERDOUBLE
304 || key->type == QUADRUPLEFORTRANMODE || key->type == VORTRANMODE ) {
305 AC.IsFortran90 = ISNOTFORTRAN90;
306 if ( AC.Fortran90Kind ) {
307 M_free(AC.Fortran90Kind,
"Fortran90 Kind");
308 AC.Fortran90Kind = 0;
311 if ( ( key->type == ALLINTEGERDOUBLE ) && AO.DoubleFlag != 0 ) {
316 AC.OutputMode = key->type & NODOUBLEMASK;
317 if ( ( key->type & DOUBLEPRECISIONFLAG ) != 0 ) {
320 else if ( ( key->type & QUADRUPLEPRECISIONFLAG ) != 0 ) {
325 else if ( key->flags == 1 ) {
326 AC.OutputMode = AC.OutNumberType = key->type;
328 else if ( key->flags == 2 ) {
329 while ( FG.cTable[*s] == 0 ) s++;
330 if ( *s == 0 ) AC.OutNumberType = 10;
331 else if ( *s ==
',' ) {
334 while ( FG.cTable[*s] == 1 ) x = 10*x + *s++ -
'0';
337 MesPrint(
"&Illegal float format specifier");
342 MesPrint(
"& ... float format value corrected to 3");
346 MesPrint(
"& ... float format value corrected to 100");
348 AC.OutNumberType = x;
352 else if ( key->flags == 3 ) {
353 AC.OutputSpaces = key->type;
355 else if ( key->flags == 4 ) {
356 AC.IsFortran90 = ISFORTRAN90;
357 if ( AC.Fortran90Kind ) {
358 M_free(AC.Fortran90Kind,
"Fortran90 Kind");
359 AC.Fortran90Kind = 0;
361 while ( FG.cTable[*s] <= 1 ) s++;
364 while ( *ss && *ss !=
',' ) ss++;
366 MesPrint(
"&No white space or comma's allowed in Fortran90 option: %s",s); error = 1;
369 AC.Fortran90Kind = strDup1(s,
"Fortran90 Kind");
373 AC.OutputMode = key->type & NODOUBLEMASK;
376 else if ( key->flags == 5 ) {
381 while ( FG.cTable[*s] == 0 ) s++;
382 while ( *s ==
' ' || *s ==
'\t' || *s ==
',' ) s++;
386 else if ( tolower(*s) ==
'o' && tolower(s[1]) ==
'f'
387 && tolower(s[2]) ==
'f' ) {
390 while ( *s ==
' ' || *s ==
'\t' || *s ==
',' ) s++;
391 if ( *s ) { s = ss;
goto WrongOption; }
394 else if ( FG.cTable[*s] == 1 ) {
396 ParseNumber(AO.FloatPrec,s)
401 if ( tolower(*s) ==
'd' ) { s++; }
402 else if ( tolower(*s) ==
'b' ) { AO.FloatPrec = AO.FloatPrec*log10(2.0); s++; }
403 else { s = ss;
goto WrongOption; }
404 while ( *s ==
' ' || *s ==
'\t' || *s ==
',' ) s++;
405 if ( *s ) { s = ss;
goto WrongOption; }
408WrongOption: MesPrint(
"&Illegal option in Format FloatPrecision: %s",s);
414 else if ( ( *s ==
'c' || *s ==
'C' ) && ( FG.cTable[s[1]] == 1 ) ) {
417 while ( *ss >=
'0' && *ss <=
'9' ) x = 10*x + *ss++ -
'0';
418 if ( *ss != 0 )
goto Unknown;
419 AC.OutputMode = CMODE;
423Unknown: MesPrint(
"&Unknown option: %s",s); error = 1;
436int CoCollect(UBYTE *s)
442 AC.AltCollectFun = 0;
443 if ( t == 0 )
goto syntaxerror;
444 t1 = t;
while ( *t1 ==
',' || *t1 ==
' ' || *t1 ==
'\t' ) t1++;
446 if ( *t1 && ( FG.cTable[*t1] == 0 || *t1 ==
'[' ) ) {
448 if ( t2 == 0 )
goto syntaxerror;
450 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
454 if ( *t && FG.cTable[*t] == 1 ) {
455 while ( *t >=
'0' && *t <=
'9' ) x = 10*x + *t++ -
'0';
456 if ( x > 100 ) x = 100;
457 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
458 if ( *t )
goto syntaxerror;
461 if ( *t )
goto syntaxerror;
464 if ( ( ( type = GetName(AC.varnames,s,&numfun,WITHAUTO) ) != CFUNCTION )
465 || ( functions[numfun].spec != 0 ) ) {
466 MesPrint(
"&%s should be a regular function",s);
468 if ( GetName(AC.exprnames,s,&numfun,NOAUTO) == NAMENOTFOUND )
469 AddFunction(s,0,0,0,0,0,-1,-1);
473 AC.CollectFun = numfun+FUNCTION;
474 AC.CollectPercentage = (WORD)x;
476 if ( ( ( type = GetName(AC.varnames,t1,&numfun,WITHAUTO) ) != CFUNCTION )
477 || ( functions[numfun].spec != 0 ) ) {
478 MesPrint(
"&%s should be a regular function",t1);
480 if ( GetName(AC.exprnames,t1,&numfun,NOAUTO) == NAMENOTFOUND )
481 AddFunction(t1,0,0,0,0,0,-1,-1);
485 AC.AltCollectFun = numfun+FUNCTION;
489 MesPrint(
"&Collect statement needs one or two functions (and a percentage) for its argument(s)");
498int setonoff(UBYTE *s,
int *flag,
int onvalue,
int offvalue)
500 if ( StrICmp(s,(UBYTE *)
"on") == 0 ) *flag = onvalue;
501 else if ( StrICmp(s,(UBYTE *)
"off") == 0 ) *flag = offvalue;
503 MesPrint(
"&Unknown option: %s, on or off expected",s);
514int CoCompress(UBYTE *s)
518 if ( StrICmp(s,(UBYTE *)
"on") == 0 ) {
522 else if ( StrICmp(s,(UBYTE *)
"off") == 0 ) {
527 t = s;
while ( FG.cTable[*t] <= 1 ) t++;
529 if ( StrICmp(s,(UBYTE *)
"gzip") == 0 ) {
531 Warning(
"gzip compression not supported on this platform");
535 AR.gzipCompress = GZIPDEFAULT;
538 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
540 if ( FG.cTable[*s] == 1 ) {
541 AR.gzipCompress = *s -
'0';
543 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
544 if ( *s == 0 )
return(0);
546 MesPrint(
"&Unknown gzip option: %s, a digit was expected",t);
551 MesPrint(
"&Unknown option: %s, on, off or gzip expected",s);
563int CoFlags(UBYTE *s,
int value)
567 MesPrint(
"&Proper syntax is: On/Off Flag,number[s];");
570 while ( *s ==
',' ) {
571 do { s++; }
while ( *s ==
',' );
573 if ( FG.cTable[*s] != 1 ) {
574 MesPrint(
"&Proper syntax is: On/Off Flag,number[s];");
578 while ( FG.cTable[*s] == 1 ) { i = 10*i + *s++ -
'0'; }
579 if ( i <= 0 || i > MAXFLAGS ) {
580 MesPrint(
"&The number of a flag in On/Off Flag should be in the range 0-%d",(
int)MAXFLAGS);
584 AC.debugFlags[i] = value;
587 MesPrint(
"&Proper syntax is: On/Off Flag,number[s];");
602 int i, num =
sizeof(onoffoptions)/
sizeof(
KEYWORD);
604 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
605 if ( *s == 0 )
return(0);
606 if ( chartype[*s] != 0 ) {
607 MesPrint(
"&Illegal character or option encountered in OFF statement");
610 t = s;
while ( chartype[*s] == 0 ) s++;
612 for ( i = 0; i < num; i++ ) {
613 if ( StrICont(t,(UBYTE *)(onoffoptions[i].name)) == 0 )
break;
616 MesPrint(
"&Unrecognized option in OFF statement: %s",t);
619 else if ( StrICont(t,(UBYTE *)
"compress") == 0 ) {
622 else if ( StrICont(t,(UBYTE *)
"checkpoint") == 0 ) {
624 AC.CheckpointInterval = 0;
625 if ( AC.CheckpointRunBefore ) { free(AC.CheckpointRunBefore); AC.CheckpointRunBefore = NULL; }
626 if ( AC.CheckpointRunAfter ) { free(AC.CheckpointRunAfter); AC.CheckpointRunAfter = NULL; }
627 if ( AC.NoShowInput == 0 ) MesPrint(
"Checkpoints deactivated.");
629 else if ( StrICont(t,(UBYTE *)
"threads") == 0 ) {
630 AS.MultiThreaded = 0;
632 else if ( StrICont(t,(UBYTE *)
"flag") == 0 ) {
634 return(CoFlags(s,0));
636 else if ( StrICont(t,(UBYTE *)
"innertest") == 0 ) {
639 if ( AC.TestValue ) {
640 M_free(AC.TestValue,
"InnerTest");
644 else if ( StrICont(t,(UBYTE *)
"sortreallocate") == 0 ) {
645 if ( AC.SortReallocateFlag == 2 ) {
653 *onoffoptions[i].var = onoffoptions[i].flags;
654 AR.SortType = AC.SortType;
655 AC.mparallelflag = AC.parallelflag | AM.hparallelflag;
668 int i, num =
sizeof(onoffoptions)/
sizeof(
KEYWORD);
671 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
672 if ( *s == 0 )
return(0);
673 if ( chartype[*s] != 0 ) {
674 MesPrint(
"&Illegal character or option encountered in ON statement");
677 t = s;
while ( chartype[*s] == 0 ) s++;
679 for ( i = 0; i < num; i++ ) {
680 if ( StrICont(t,(UBYTE *)(onoffoptions[i].name)) == 0 )
break;
683 MesPrint(
"&Unrecognized option in ON statement: %s",t);
686 if ( StrICont(t,(UBYTE *)
"backtrace") == 0 ) {
687#ifndef ENABLE_BACKTRACE
688 Warning(
"backtrace not supported on this platform");
691 else if ( StrICont(t,(UBYTE *)
"compress") == 0 ) {
694 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
697 while ( FG.cTable[*s] <= 1 ) s++;
699 if ( StrICmp(t,(UBYTE *)
"gzip") == 0 ) {
701 Warning(
"gzip compression not supported on this platform");
705 ZWRAP_useZSTDcompression(0);
708 else if ( StrICmp(t,(UBYTE *)
"zstd") == 0 ) {
710 ZWRAP_useZSTDcompression(1);
712 Warning(
"zstd compression not supported on this platform");
716 MesPrint(
"&Unrecognized option in ON compress statement: %s",t);
721 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
722 if ( FG.cTable[*s] == 1 ) {
723 AR.gzipCompress = *s++ -
'0';
724 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
726 MesPrint(
"&Unrecognized option in ON compress gzip/zstd statement: %s",t);
730 else if ( *s == 0 ) {
731 AR.gzipCompress = GZIPDEFAULT;
734 MesPrint(
"&Unrecognized option in ON compress gzip/zstd statement: %s, single digit expected",t);
739 else if ( StrICont(t,(UBYTE *)
"checkpoint") == 0 ) {
741 AC.CheckpointInterval = 0;
742 if ( AC.CheckpointRunBefore ) { free(AC.CheckpointRunBefore); AC.CheckpointRunBefore = NULL; }
743 if ( AC.CheckpointRunAfter ) { free(AC.CheckpointRunAfter); AC.CheckpointRunAfter = NULL; }
746 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
747 if ( FG.cTable[*s] == 1 ) {
750 do { interval = 10*interval + *s++ -
'0'; }
while ( FG.cTable[*s] == 1 );
751 if ( *s ==
's' || *s ==
'S' ) {
754 else if ( *s ==
'm' || *s ==
'M' ) {
757 else if ( *s ==
'h' || *s ==
'H' ) {
758 interval *= 3600; s++;
760 else if ( *s ==
'd' || *s ==
'D' ) {
761 interval *= 86400; s++;
763 if ( *s !=
',' && FG.cTable[*s] != 6 && FG.cTable[*s] != 10 ) {
764 MesPrint(
"&Unrecognized time interval in ON Checkpoint statement: %s", t);
767 AC.CheckpointInterval = interval * 100;
769 else if ( FG.cTable[*s] == 0 ) {
772 while ( FG.cTable[*s] == 0 ) s++;
774 if ( StrICmp(t,(UBYTE *)
"run") == 0 ) {
777 else if ( StrICmp(t,(UBYTE *)
"runafter") == 0 ) {
780 else if ( StrICmp(t,(UBYTE *)
"runbefore") == 0 ) {
784 MesPrint(
"&Unrecognized option in ON Checkpoint statement: %s", t);
788 if ( *s !=
'=' && FG.cTable[*(s+1)] != 9 ) {
789 MesPrint(
"&Unrecognized option in ON Checkpoint statement: %s", t);
795 if ( FG.cTable[*s] == 9 ) {
798 if ( AC.CheckpointRunBefore ) {
799 free(AC.CheckpointRunBefore); AC.CheckpointRunBefore = NULL;
802 AC.CheckpointRunBefore = Malloc1(s-t+1,
"AC.CheckpointRunBefore");
803 StrCopy(t, (UBYTE*)AC.CheckpointRunBefore);
807 if ( AC.CheckpointRunAfter ) {
808 free(AC.CheckpointRunAfter); AC.CheckpointRunAfter = NULL;
811 AC.CheckpointRunAfter = Malloc1(s-t+1,
"AC.CheckpointRunAfter");
812 StrCopy(t, (UBYTE*)AC.CheckpointRunAfter);
820 if ( FG.cTable[*s] != 9 ) {
821 MesPrint(
"&Unrecognized option in ON Checkpoint statement: %s", t);
845 else if ( StrICont(t,(UBYTE *)
"indentspace") == 0 ) {
847 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
850 while ( FG.cTable[*s] == 1 ) { i = 10*i + *s++ -
'0'; }
852 MesPrint(
"&Unrecognized option in ON IndentSpace statement: %s",t);
856 Warning(
"IndentSpace parameter adjusted to 40");
862 AO.IndentSpace = AM.ggIndentSpace;
866 else if ( ( StrICont(t,(UBYTE *)
"fewerstats") == 0 ) ||
867 ( StrICont(t,(UBYTE *)
"fewerstatistics") == 0 ) ) {
869 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
872 while ( FG.cTable[*s] == 1 ) { i = 10*i + *s++ -
'0'; }
874 MesPrint(
"&Unrecognized option in ON FewerStatistics statement: %s",t);
877 if ( i > AM.S0->MaxPatches ) {
879 MesPrint(
"&Warning: FewerStatistics parameter greater than MaxPatches(=%d). Adjusted to %d"
880 ,AM.S0->MaxPatches,(AM.S0->MaxPatches+1)/2);
881 i = (AM.S0->MaxPatches+1)/2;
883 AC.ShortStatsMax = i;
886 AC.ShortStatsMax = 10;
890 else if ( StrICont(t,(UBYTE *)
"threads") == 0 ) {
891 if ( AM.totalnumberofthreads > 1 ) AS.MultiThreaded = 1;
893 else if ( StrICont(t,(UBYTE *)
"flag") == 0 ) {
895 return(CoFlags(s,1));
897 else if ( StrICont(t,(UBYTE *)
"innertest") == 0 ) {
900 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
902 t = s;
while ( *t ) t++;
903 while ( t[-1] ==
' ' || t[-1] ==
'\t' ) t--;
905 if ( AC.TestValue ) M_free(AC.TestValue,
"InnerTest");
906 AC.TestValue = strDup1(s,
"InnerTest");
909 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
912 if ( AC.TestValue ) {
913 M_free(AC.TestValue,
"InnerTest");
918 else if ( StrICont(t,(UBYTE *)
"flint") == 0 ) {
920 MesPrint(
"&Warning: FORM was not built with FLINT support.");
921 MesPrint(
"Statement has no effect.");
925 *onoffoptions[i].var = onoffoptions[i].type;
926 AR.SortType = AC.SortType;
927 AC.mparallelflag = AC.parallelflag | AM.hparallelflag;
936int CoInsideFirst(UBYTE *s) {
return(setonoff(s,&AC.insidefirst,1,0)); }
943int CoProperCount(UBYTE *s) {
return(setonoff(s,&AC.BottomLevel,1,0)); }
950int CoDelete(UBYTE *s)
953 if ( StrICmp(s,(UBYTE *)
"storage") == 0 ) {
954 if ( DeleteStore(1) < 0 ) {
955 MesPrint(
"&Cannot restart storage file");
961 while ( *t && *t !=
',' && *t !=
'>' ) t++;
963 if ( ( StrICmp(s,(UBYTE *)
"extrasymbols") == 0 )
964 || ( StrICmp(s,(UBYTE *)
"extrasymbol") == 0 ) ) {
972 if ( FG.cTable[*s] != 1 )
goto unknown;
973 while ( *s <=
'9' && *s >=
'0' ) x = 10*x + *s++ -
'0';
974 if ( *s )
goto unknown;
976 else if ( *s )
goto unknown;
977 if ( x < AM.gnumextrasym ) x = AM.gnumextrasym;
978 PruneExtraSymbols(x);
983 MesPrint(
"&Unknown option: %s",s);
997 if ( StrICmp(s,(UBYTE *)
"brackets") == 0 ) AC.ComDefer = 1;
998 else { MesPrint(
"&Unknown option: '%s'",s);
return(1); }
1007int CoFixIndex(UBYTE *s)
1009 int x, y, error = 0;
1011 if ( FG.cTable[*s] != 1 ) {
1012proper: MesPrint(
"&Proper syntax is: FixIndex,number:value[,number,value];");
1016 if ( *s !=
':' )
goto proper;
1018 if ( *s !=
'-' && *s !=
'+' && FG.cTable[*s] != 1 )
goto proper;
1019 ParseSignedNumber(y,s)
1020 if ( *s && *s !=
',' )
goto proper;
1021 while ( *s ==
',' ) s++;
1022 if ( x >= AM.OffsetIndex ) {
1023 MesPrint(
"&Fixed index out of allowed range. Change ConstIndex in setup file?");
1024 MesPrint(
"&Current value of ConstIndex = %d",AM.OffsetIndex-1);
1027 if ( y != (
int)((WORD)y) ) {
1028 MesPrint(
"&Value of d_(%d,%d) outside range for this computer",x,x);
1031 if ( error == 0 ) AC.FixIndices[x] = y;
1041int CoMetric(UBYTE *s)
1042{ DUMMYUSE(s); MesPrint(
"&The metric statement does not do anything yet");
return(1); }
1049int DoPrint(UBYTE *s,
int par)
1051 int i, error = 0, numdol = 0, type;
1055 WORD numexpr, tofile = 0, *w, par2 = 0;
1056 CBUF *C = cbuf + AC.cbufnum;
1057 while ( *s ==
',' ) s++;
1058 if ( ( *s ==
'+' || *s ==
'-' ) && ( s[1] ==
'f' || s[1] ==
'F' ) ) {
1059 t = s + 2;
while ( *t ==
' ' || *t ==
',' ) t++;
1061 if ( *s ==
'+' ) { tofile = 1; handle = AC.LogHandle; }
1065 else if ( *s ==
'<' ) {
1068 while ( *s && *s !=
'>' ) s++;
1070 MesPrint(
"&Improper filename in print statement");
1075 if ( ( handle = GetChannel((
char *)filename,1) ) < 0 )
return(1);
1076 SKIPBLANKS(s)
if ( *s ==
',' ) s++; SKIPBLANKS(s)
1077 if ( *s ==
'+' && ( s[1] ==
's' || s[1] ==
'S' ) ) {
1079 par2 |= PRINTONETERM;
1080 if ( *s ==
's' || *s ==
'S' ) {
1082 par2 |= PRINTONEFUNCTION;
1083 if ( *s ==
's' || *s ==
'S' ) {
1088 SKIPBLANKS(s)
if ( *s ==
',' ) s++; SKIPBLANKS(s)
1091 if ( par == PRINTON && *s ==
'"' ) {
1093 if ( tofile == 1 ) code[0] = TYPEFPRINT;
1094 else code[0] = TYPEPRINT;
1098 while ( *s && *s !=
'"' ) {
1099 if ( *s ==
'\\' ) s++;
1100 if ( *s ==
'%' && s[1] ==
'$' ) numdol++;
1104 MesPrint(
"&String in print statement should be enclosed in \"");
1108 AddComString(3,code,name,1);
1110 while ( *s ==
',' ) {
1113 s++; name = s;
while ( FG.cTable[*s] <= 1 ) s++;
1115 type = GetName(AC.dollarnames,name,&numexpr,NOAUTO);
1116 if ( type == NAMENOTFOUND ) {
1117 MesPrint(
"&$ variable %s not (yet) defined",name);
1121 C->
lhs[C->numlhs][1] += 2;
1122 *(C->
Pointer)++ = DOLLAREXPRESSION;
1128 MesPrint(
"&Illegal object in print statement");
1136 s = GetDoParam(s,&(C->
Pointer),-1);
1137 if ( s == 0 )
return(1);
1139 MesPrint(
"&unmatched [] in $ factor");
1147 MesPrint(
"&Illegal object in print statement");
1151 MesPrint(
"&More $ variables asked for than provided");
1159 for ( e = Expressions, i = NumExpressions; i > 0; i--, e++ ) {
1160 if ( e->status == LOCALEXPRESSION || e->status ==
1161 GLOBALEXPRESSION || e->status == UNHIDELEXPRESSION
1162 || e->status == UNHIDEGEXPRESSION ) e->printflag = par;
1169 if ( tolower(*s) ==
'f' ) par |= PRINTLFILE;
1170 else if ( tolower(*s) ==
's' ) {
1171 if ( tolower(s[1]) ==
's' ) {
1172 if ( tolower(s[2]) ==
's' ) {
1173 par |= PRINTONEFUNCTION | PRINTONETERM | PRINTALL;
1176 else if ( ( par & 3 ) < 2 ) par |= PRINTONEFUNCTION | PRINTONETERM;
1180 if ( ( par & 3 ) < 2 ) par |= PRINTONETERM;
1184illeg: MesPrint(
"&Illegal option in (n)print statement");
1188 if ( *s == 0 )
goto AllExpr;
1190 else if ( *s ==
'-' ) {
1192 if ( tolower(*s) ==
'f' ) par &= ~PRINTLFILE;
1193 else if ( tolower(*s) ==
's' ) {
1194 if ( tolower(s[1]) ==
's' ) {
1195 if ( tolower(s[2]) ==
's' ) {
1199 else if ( ( par & 3 ) < 2 ) {
1200 par &= ~PRINTONEFUNCTION;
1206 if ( ( par & 3 ) < 2 ) {
1207 par &= ~PRINTONETERM;
1208 par &= ~PRINTONEFUNCTION;
1215 if ( *s == 0 )
goto AllExpr;
1217 else if ( FG.cTable[*s] == 0 || *s ==
'[' ) {
1220 MesPrint(
"&Improper name in (n)print statement");
1224 if ( ( GetName(AC.exprnames,name,&numexpr,NOAUTO) == CEXPRESSION )
1225 && ( Expressions[numexpr].status == LOCALEXPRESSION
1226 || Expressions[numexpr].status == GLOBALEXPRESSION ) ) {
1228 if ( c ==
'[' && s[1] ==
']' ) {
1229 Expressions[numexpr].printflag = par | PRINTCONTENTS;
1233 Expressions[numexpr].printflag = par;
1235 else if ( GetLastExprName(name,&numexpr)
1236 && ( Expressions[numexpr].status == LOCALEXPRESSION
1237 || Expressions[numexpr].status == GLOBALEXPRESSION
1238 || Expressions[numexpr].status == UNHIDELEXPRESSION
1239 || Expressions[numexpr].status == UNHIDEGEXPRESSION
1244 MesPrint(
"&%s is not the name of an active expression",name);
1248 if ( c == 0 )
return(0);
1249 if ( c ==
'-' || c ==
'+' ) s--;
1251 else if ( *s ==
',' ) s++;
1253 MesPrint(
"&Illegal object in (n)print statement");
1265int CoPrint(UBYTE *s) {
return(DoPrint(s,PRINTON)); }
1272int CoPrintB(UBYTE *s) {
return(DoPrint(s,PRINTCONTENT)); }
1279int CoNPrint(UBYTE *s) {
return(DoPrint(s,PRINTOFF)); }
1286int CoPushHide(UBYTE *s)
1291 if ( AR.Fscr[2].PObuffer == 0 ) {
1292 ScratchBuf = (WORD *)Malloc1(AM.HideSize*
sizeof(WORD),
"hidesize");
1293 AR.Fscr[2].POsize = AM.HideSize *
sizeof(WORD);
1294 AR.Fscr[2].POfull = AR.Fscr[2].POfill = AR.Fscr[2].PObuffer = ScratchBuf;
1295 AR.Fscr[2].POstop = AR.Fscr[2].PObuffer + AM.HideSize;
1296 PUTZERO(AR.Fscr[2].POposition);
1298 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
1301 MesPrint(
"&PushHide statement should have no arguments");
1304 for ( i = 0; i < NumExpressions; i++ ) {
1305 switch ( Expressions[i].status ) {
1306 case DROPLEXPRESSION:
1307 case SKIPLEXPRESSION:
1308 case LOCALEXPRESSION:
1309 Expressions[i].status = HIDELEXPRESSION;
1310 Expressions[i].hidelevel = AC.HideLevel-1;
1312 case DROPGEXPRESSION:
1313 case SKIPGEXPRESSION:
1314 case GLOBALEXPRESSION:
1315 Expressions[i].status = HIDEGEXPRESSION;
1316 Expressions[i].hidelevel = AC.HideLevel-1;
1330int CoPopHide(UBYTE *s)
1333 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
1334 if ( AC.HideLevel <= 0 ) {
1335 MesPrint(
"&PopHide statement without corresponding PushHide statement");
1340 MesPrint(
"&PopHide statement should have no arguments");
1343 for ( i = 0; i < NumExpressions; i++ ) {
1344 switch ( Expressions[i].status ) {
1345 case HIDDENLEXPRESSION:
1346 if ( Expressions[i].hidelevel > AC.HideLevel )
1347 Expressions[i].status = UNHIDELEXPRESSION;
1349 case HIDDENGEXPRESSION:
1350 if ( Expressions[i].hidelevel > AC.HideLevel )
1351 Expressions[i].status = UNHIDEGEXPRESSION;
1365int SetExprCases(
int par,
int setunset,
int val)
1370 case SKIPLEXPRESSION:
1371 if ( !setunset ) val = LOCALEXPRESSION;
1373 case SKIPGEXPRESSION:
1374 if ( !setunset ) val = GLOBALEXPRESSION;
1376 case LOCALEXPRESSION:
1377 if ( setunset ) val = SKIPLEXPRESSION;
1379 case GLOBALEXPRESSION:
1380 if ( setunset ) val = SKIPGEXPRESSION;
1382 case INTOHIDEGEXPRESSION:
1383 case INTOHIDELEXPRESSION:
1390 case SKIPLEXPRESSION:
1391 case LOCALEXPRESSION:
1392 case HIDELEXPRESSION:
1393 if ( setunset ) val = DROPLEXPRESSION;
1395 case DROPLEXPRESSION:
1396 if ( !setunset ) val = LOCALEXPRESSION;
1398 case SKIPGEXPRESSION:
1399 case GLOBALEXPRESSION:
1400 case HIDEGEXPRESSION:
1401 if ( setunset ) val = DROPGEXPRESSION;
1403 case DROPGEXPRESSION:
1404 if ( !setunset ) val = GLOBALEXPRESSION;
1406 case HIDDENLEXPRESSION:
1407 case UNHIDELEXPRESSION:
1408 if ( setunset ) val = DROPHLEXPRESSION;
1410 case HIDDENGEXPRESSION:
1411 case UNHIDEGEXPRESSION:
1412 if ( setunset ) val = DROPHGEXPRESSION;
1414 case DROPHLEXPRESSION:
1415 if ( !setunset ) val = HIDDENLEXPRESSION;
1417 case DROPHGEXPRESSION:
1418 if ( !setunset ) val = HIDDENGEXPRESSION;
1420 case INTOHIDEGEXPRESSION:
1421 case INTOHIDELEXPRESSION:
1428 case DROPLEXPRESSION:
1429 case SKIPLEXPRESSION:
1430 case LOCALEXPRESSION:
1431 if ( setunset ) val = HIDELEXPRESSION;
1433 case HIDELEXPRESSION:
1434 if ( !setunset ) val = LOCALEXPRESSION;
1436 case DROPGEXPRESSION:
1437 case SKIPGEXPRESSION:
1438 case GLOBALEXPRESSION:
1439 if ( setunset ) val = HIDEGEXPRESSION;
1441 case HIDEGEXPRESSION:
1442 if ( !setunset ) val = GLOBALEXPRESSION;
1444 case INTOHIDEGEXPRESSION:
1445 case INTOHIDELEXPRESSION:
1452 case HIDDENLEXPRESSION:
1453 case DROPHLEXPRESSION:
1454 if ( setunset ) val = UNHIDELEXPRESSION;
1456 case UNHIDELEXPRESSION:
1457 if ( !setunset ) val = HIDDENLEXPRESSION;
1459 case HIDDENGEXPRESSION:
1460 case DROPHGEXPRESSION:
1461 if ( setunset ) val = UNHIDEGEXPRESSION;
1463 case UNHIDEGEXPRESSION:
1464 if ( !setunset ) val = HIDDENGEXPRESSION;
1466 case INTOHIDEGEXPRESSION:
1467 case INTOHIDELEXPRESSION:
1474 case HIDDENLEXPRESSION:
1475 case HIDDENGEXPRESSION:
1476 MesPrint(
"&Expression is already hidden");
1478 case DROPHLEXPRESSION:
1479 case DROPHGEXPRESSION:
1480 case UNHIDELEXPRESSION:
1481 case UNHIDEGEXPRESSION:
1483 MesPrint(
"&Cannot unhide/drop and put intohide expression in the same module");
1487 case LOCALEXPRESSION:
1488 case DROPLEXPRESSION:
1489 case SKIPLEXPRESSION:
1490 case HIDELEXPRESSION:
1491 if ( setunset ) val = INTOHIDELEXPRESSION;
1493 case GLOBALEXPRESSION:
1494 case DROPGEXPRESSION:
1495 case SKIPGEXPRESSION:
1496 case HIDEGEXPRESSION:
1497 if ( setunset ) val = INTOHIDEGEXPRESSION;
1499 case INTOHIDELEXPRESSION:
1500 if ( !setunset ) val = LOCALEXPRESSION;
1502 case INTOHIDEGEXPRESSION:
1503 if ( !setunset ) val = GLOBALEXPRESSION;
1520int SetExpr(UBYTE *s,
int setunset,
int par)
1526 for ( i = 0; i < NumExpressions; i++ ) {
1527 w = &(Expressions[i].status);
1528 *w = SetExprCases(par,setunset,*w);
1529 if ( *w < 0 ) error = 1;
1530 if ( ( par == HIDE || par == INTOHIDE ) && setunset == 1 )
1531 Expressions[i].hidelevel = AC.HideLevel;
1536 if ( *s ==
',' ) { s++;
continue; }
1537 if ( *s ==
'0' ) { s++;
continue; }
1540 MesPrint(
"&Improper name for an expression: '%s'",name);
1544 if ( GetName(AC.exprnames,name,&numexpr,NOAUTO) == CEXPRESSION ) {
1545 w = &(Expressions[numexpr].status);
1546 *w = SetExprCases(par,setunset,*w);
1547 if ( *w < 0 ) error = 1;
1548 if ( ( par == HIDE || par == INTOHIDE ) && setunset == 1 )
1549 Expressions[numexpr].hidelevel = AC.HideLevel;
1551 else if ( GetName(AC.varnames,name,&numexpr,NOAUTO) != NAMENOTFOUND ) {
1552 MesPrint(
"&%s is not an expression",name);
1565int CoDrop(UBYTE *s) {
return(SetExpr(s,1,DROP)); }
1572int CoNoDrop(UBYTE *s) {
return(SetExpr(s,0,DROP)); }
1579int CoSkip(UBYTE *s) {
return(SetExpr(s,1,SKIP)); }
1586int CoNoSkip(UBYTE *s) {
return(SetExpr(s,0,SKIP)); }
1593int CoHide(UBYTE *inp) {
1596 if ( AR.Fscr[2].PObuffer == 0 ) {
1597 ScratchBuf = (WORD *)Malloc1(AM.HideSize*
sizeof(WORD),
"hidesize");
1598 AR.Fscr[2].POsize = AM.HideSize *
sizeof(WORD);
1599 AR.Fscr[2].POfull = AR.Fscr[2].POfill = AR.Fscr[2].PObuffer = ScratchBuf;
1600 AR.Fscr[2].POstop = AR.Fscr[2].PObuffer + AM.HideSize;
1601 PUTZERO(AR.Fscr[2].POposition);
1603 return(SetExpr(inp,1,HIDE));
1611int CoIntoHide(UBYTE *inp) {
1614 if ( AR.Fscr[2].PObuffer == 0 ) {
1615 ScratchBuf = (WORD *)Malloc1(AM.HideSize*
sizeof(WORD),
"hidesize");
1616 AR.Fscr[2].POsize = AM.HideSize *
sizeof(WORD);
1617 AR.Fscr[2].POfull = AR.Fscr[2].POfill = AR.Fscr[2].PObuffer = ScratchBuf;
1618 AR.Fscr[2].POstop = AR.Fscr[2].PObuffer + AM.HideSize;
1619 PUTZERO(AR.Fscr[2].POposition);
1621 return(SetExpr(inp,1,INTOHIDE));
1629int CoNoIntoHide(UBYTE *inp) {
return(SetExpr(inp,0,INTOHIDE)); }
1636int CoNoHide(UBYTE *inp) {
return(SetExpr(inp,0,HIDE)); }
1643int CoUnHide(UBYTE *inp) {
return(SetExpr(inp,1,UNHIDE)); }
1650int CoNoUnHide(UBYTE *inp) {
return(SetExpr(inp,0,UNHIDE)); }
1657void AddToCom(
int n, WORD *array)
1659 CBUF *C = cbuf+AC.cbufnum;
1661 MesPrint(
" %a",n,array);
1664 while ( --n >= 0 ) *(C->
Pointer)++ = *array++;
1672int AddComString(
int n, WORD *array, UBYTE *thestring,
int par)
1674 CBUF *C = cbuf+AC.cbufnum;
1675 UBYTE *s = thestring, *w;
1680 int i, numchars = 0, size, zeroes;
1682 if ( *s ==
'\\' ) s++;
1683 else if ( par == 1 &&
1684 ( ( *s ==
'%' && s[1] !=
't' && s[1] !=
'T' && s[1] !=
'$' &&
1685 s[1] !=
'w' && s[1] !=
'W' && s[1] !=
'r' && s[1] != 0 ) || *s ==
'#'
1686 || *s ==
'@' || *s ==
'&' ) ) {
1692 size = numchars/
sizeof(WORD)+1;
1699 for ( i = 1; i < n; i++ ) *(C->
Pointer)++ = array[i];
1705 zeroes = size*
sizeof(WORD)-numchars;
1708 if ( *s ==
'\\' ) s++;
1709 else if ( par == 1 && ( ( *s ==
'%' &&
1710 s[1] !=
't' && s[1] !=
'T' && s[1] !=
'$' &&
1711 s[1] !=
'w' && s[1] !=
'W' && s[1] !=
'r' && s[1] != 0 ) || *s ==
'#'
1712 || *s ==
'@' || *s ==
'&' ) ) {
1717 while ( --zeroes >= 0 ) *w++ = 0;
1720 MesPrint(
"LH: %a",size+1+n,cc);
1721 MesPrint(
" %s",thestring);
1731int Add2ComStrings(
int n, WORD *array, UBYTE *string1, UBYTE *string2)
1733 CBUF *C = cbuf+AC.cbufnum;
1734 UBYTE *s1 = string1, *s2 = string2, *w;
1735 int i, num1chars = 0, num2chars = 0, size1, size2, zeroes1, zeroes2;
1737 while ( *s1 ) { s1++; num1chars++; }
1738 size1 = num1chars/
sizeof(WORD)+1;
1740 while ( *s2 ) { s2++; num2chars++; }
1741 size2 = num2chars/
sizeof(WORD)+1;
1746 *(C->
Pointer)++ = size1+size2+n+3;
1747 for ( i = 1; i < n; i++ ) *(C->
Pointer)++ = array[i];
1750 zeroes1 = size1*
sizeof(WORD)-num1chars;
1752 while ( *s1 ) { *w++ = *s1++; }
1753 while ( --zeroes1 >= 0 ) *w++ = 0;
1758 zeroes2 = size2*
sizeof(WORD)-num2chars;
1760 while ( *s2 ) { *w++ = *s2++; }
1761 while ( --zeroes2 >= 0 ) *w++ = 0;
1772int CoDiscard(UBYTE *s)
1775 Add2Com(TYPEDISCARD)
1778 MesPrint(
"&Illegal argument in discard statement: '%s'",s);
1793static WORD ccarray[5] = { TYPEOPERATION,5,CONTRACT,0,0 };
1795int CoContract(UBYTE *s)
1801 if ( *s !=
',' && *s ) {
1802proper: MesPrint(
"&Illegal number in contract statement");
1808 else ccarray[4] = 0;
1809 if ( FG.cTable[*s] == 1 ) {
1811 if ( *s )
goto proper;
1814 else if ( *s )
goto proper;
1815 else ccarray[3] = -1;
1824int CoGoTo(UBYTE *inp)
1828 while ( FG.cTable[*s] <= 1 ) s++;
1830 MesPrint(
"&Label should be an alpha-numeric string");
1834 Add3Com(TYPEGOTO,x);
1843int CoLabel(UBYTE *inp)
1847 while ( FG.cTable[*s] <= 1 ) s++;
1849 MesPrint(
"&Label should be an alpha-numeric string");
1853 if ( AC.Labels[x] >= 0 ) {
1854 MesPrint(
"&Label %s defined more than once",AC.LabelNames[x]);
1857 AC.Labels[x] = cbuf[AC.cbufnum].numlhs;
1870int DoArgument(UBYTE *s,
int par)
1873 UBYTE *name, *t, *v, c;
1874 WORD *oldworkpointer = AT.WorkPointer, *w, *ww, number, *scale;
1875 int error = 0, zeroflag, type, x;
1876 AC.lhdollarflag = 0;
1877 while ( *s ==
',' ) s++;
1883 if ( AC.arglevel >= MAXNEST ) {
1884 MesPrint(
"@Nesting of argument statements more than %d levels"
1888 AC.argsumcheck[AC.arglevel] = NestingChecksum();
1889 AC.argstack[AC.arglevel] = cbuf[AC.cbufnum].Pointer
1890 - cbuf[AC.cbufnum].Buffer + 2;
1892 *w++ = cbuf[AC.cbufnum].numlhs;
1897 case TYPESPLITFIRSTARG:
1898 case TYPESPLITLASTARG:
1900 case TYPEARGTOEXTRASYMBOL:
1901 *w++ = cbuf[AC.cbufnum].numlhs+1;
1909 s++; ParseSignedNumber(x,s)
1910 while ( *s ==
',' ) s++;
1914 t = s+1; SKIPBRA3(s)
1915 if ( par == TYPEARG ) {
1916 MesPrint(
"&Illegal () entry in argument statement");
1917 error = 1; s++;
goto skipbracks;
1919 else if ( par == TYPESPLITFIRSTARG ) {
1920 MesPrint(
"&Illegal () entry in splitfirstarg statement");
1921 error = 1; s++;
goto skipbracks;
1923 else if ( par == TYPESPLITLASTARG ) {
1924 MesPrint(
"&Illegal () entry in splitlastarg statement");
1925 error = 1; s++;
goto skipbracks;
1930 MesPrint(
"&Wildcarding not allowed in this type of statement");
1936 if ( *t ==
'(' && v[-1] ==
')' ) {
1938 if ( par == TYPESPLITARG ) oldworkpointer[0] = TYPESPLITARG2;
1939 else if ( par == TYPEFACTARG ) oldworkpointer[0] = TYPEFACTARG2;
1940 else if ( par == TYPENORM4 ) oldworkpointer[0] = TYPENORM4;
1941 else if ( par == TYPENORM ) {
1942 if ( *t ==
'-' ) { oldworkpointer[0] = TYPENORM3; t++; }
1943 else { oldworkpointer[0] = TYPENORM2; *scale = 0; }
1947 CBUF *C = cbuf+AC.cbufnum;
1948 WORD oldnumrhs = C->numrhs, oldnumlhs = C->numlhs;
1949 WORD prototype[SUBEXPSIZE+40];
1954 prototype[0] = SUBEXPRESSION;
1955 prototype[1] = SUBEXPSIZE;
1956 prototype[2] = C->numrhs+1;
1958 prototype[4] = AC.cbufnum;
1959 AT.WorkPointer += TYPEARGHEADSIZE+1;
1961 if ( ( retcode = CompileAlgebra(t,LHSIDE,prototype) ) < 0 )
1964 prototype[2] = retcode;
1965 ww = C->
lhs[retcode];
1966 AC.lhdollarflag = 0;
1968 *w++ = -2; *w++ = 0;
1970 else if ( ww[ww[0]] != 0 ) {
1971 MesPrint(
"&There should be only one term between ()");
1974 else if (
NewSort(BHEAD0) ) {
if ( !error ) error = 1; }
1977 if ( !error ) error = 1;
1980 AN.RepPoint = AT.RepCount + 1;
1983 while ( --i >= 0 ) *m++ = *mm++;
1984 mm = AT.WorkPointer; AT.WorkPointer = m;
1985 AR.Cnumlhs = C->numlhs;
1989 else if (
EndSort(BHEAD mm,0) < 0 ) {
1991 AT.WorkPointer = mm;
1993 else if ( *mm == 0 ) {
1994 *w++ = -2; *w++ = 0;
1995 AT.WorkPointer = mm;
1997 else if ( mm[mm[0]] != 0 ) {
1999 AT.WorkPointer = mm;
2002 AT.WorkPointer = mm;
2004 if ( par == TYPEFACTARG ) {
2005 if ( *mm != ABS(m[-1])+1 ) {
2008 mm[-1] = -*mm-1; w += *mm+1;
2016 { mm[-1] = -*mm-1; w += *mm+1; }
2018 oldworkpointer[1] = w - oldworkpointer;
2022 oldworkpointer[5] = AC.lhdollarflag;
2025 C->numrhs = oldnumrhs;
2026 C->numlhs = oldnumlhs;
2031 if ( *s == 0 ) { *w++ = 0; *w++ = 2; *w++ = 1; }
2034 if ( *s ==
',' ) { s++;
continue; }
2035 ww = w; *w++ = 0; w++;
2036 if ( FG.cTable[*s] > 1 && *s !=
'[' && *s !=
'{' ) {
2037 MesPrint(
"&Illegal parameters in statement");
2041 while ( FG.cTable[*s] == 0 || *s ==
'[' || *s ==
'{' ) {
2046 number = DoTempSet(name,s);
2047 name--; *s++ = c; c = *s; *s = 0;
2053 MesPrint(
"&Illegal name '%s'",name);
2057 if ( ( type = GetName(AC.varnames,name,&number,WITHAUTO) ) == CSET ) {
2058doset:
if ( Sets[number].type != CFUNCTION )
goto nofun;
2061 r1 = SetElements + Sets[number].first;
2062 r2 = SetElements + Sets[number].last;
2064 if ( *r1++ == FLOATFUN ) {
2065 MesPrint(
"&Illegal use of argument environment and float_.");
2070 *w++ = CSET; *w++ = number;
2072 else if ( type == CFUNCTION ) {
2074 if ( (number + FUNCTION) == FLOATFUN ) {
2075 MesPrint(
"&Illegal use of argument environment and float_.");
2079 *w++ = CFUNCTION; *w++ = number + FUNCTION;
2082nofun: MesPrint(
"&%s is not a function or a set of functions"
2088 while ( *s ==
',' ) s++;
2091 ww = w; w++; zeroflag = 0;
2092 while ( FG.cTable[*s] == 1 ) {
2094 if ( *s && *s !=
',' ) {
2095 MesPrint(
"&Illegal separator after number");
2097 while ( *s && *s !=
',' ) s++;
2099 while ( *s ==
',' ) s++;
2100 if ( x == 0 ) zeroflag = 1;
2101 if ( !zeroflag ) *w++ = (WORD)x;
2106 oldworkpointer[1] = w - oldworkpointer;
2107 if ( par == TYPEARG ) {
2108 AC.argstack[AC.arglevel-1] = cbuf[AC.cbufnum].Pointer
2109 - cbuf[AC.cbufnum].Buffer + 2;
2111 AddNtoL(oldworkpointer[1],oldworkpointer);
2112 AT.WorkPointer = oldworkpointer;
2121int CoArgument(UBYTE *s) {
return(DoArgument(s,TYPEARG)); }
2128int CoEndArgument(UBYTE *s)
2130 CBUF *C = cbuf+AC.cbufnum;
2131 while ( *s ==
',' ) s++;
2133 MesPrint(
"&Illegal syntax for EndArgument statement");
2136 if ( AC.arglevel <= 0 ) {
2137 MesPrint(
"&EndArgument without corresponding Argument statement");
2141 cbuf[AC.cbufnum].Buffer[AC.argstack[AC.arglevel]] = C->numlhs;
2142 if ( AC.argsumcheck[AC.arglevel] != NestingChecksum() ) {
2154int CoInside(UBYTE *s) {
return(ExecInside(s)); }
2161int CoEndInside(UBYTE *s)
2163 CBUF *C = cbuf+AC.cbufnum;
2164 while ( *s ==
',' ) s++;
2166 MesPrint(
"&Illegal syntax for EndInside statement");
2169 if ( AC.insidelevel <= 0 ) {
2170 MesPrint(
"&EndInside without corresponding Inside statement");
2174 cbuf[AC.cbufnum].Buffer[AC.insidestack[AC.insidelevel]] = C->numlhs;
2175 if ( AC.insidesumcheck[AC.insidelevel] != NestingChecksum() ) {
2187int CoNormalize(UBYTE *s) {
return(DoArgument(s,TYPENORM)); }
2194int CoMakeInteger(UBYTE *s) {
return(DoArgument(s,TYPENORM4)); }
2201int CoSplitArg(UBYTE *s) {
return(DoArgument(s,TYPESPLITARG)); }
2208int CoSplitFirstArg(UBYTE *s) {
return(DoArgument(s,TYPESPLITFIRSTARG)); }
2215int CoSplitLastArg(UBYTE *s) {
return(DoArgument(s,TYPESPLITLASTARG)); }
2222int CoFactArg(UBYTE *s) {
2223 if ( ( AC.topolynomialflag & TOPOLYNOMIALFLAG ) != 0 ) {
2224 MesPrint(
"&ToPolynomial statement and FactArg statement are not allowed in the same module");
2227 AC.topolynomialflag |= FACTARGFLAG;
2228 return(DoArgument(s,TYPEFACTARG));
2242int DoSymmetrize(UBYTE *s,
int par)
2245 int extra = 0, error = 0, err, fix, x, groupsize, num, i;
2247 WORD funnum, *w, *ww, type;
2251 MesPrint(
"&Improper function name");
2255 if ( c !=
',' || ( FG.cTable[s[1]] != 0 && s[1] !=
'[' ) )
break;
2256 if ( par <= 0 && StrICmp(name,(UBYTE *)
"cyclic") == 0 ) extra = 2;
2257 else if ( par <= 0 && StrICmp(name,(UBYTE *)
"rcyclic") == 0 ) extra = 6;
2259 MesPrint(
"&Illegal option: '%s'",name);
2264 if ( ( err = GetVar(name,&type,&funnum,CFUNCTION,WITHAUTO) ) == NAMENOTFOUND ) {
2265 MesPrint(
"&Undefined function: %s",name);
2266 AddFunction(name,0,0,0,0,0,-1,-1);
2271 if ( err == -1 ) error = 1;
2275 if ( *s ==
',' || *s ==
'(' || *s == 0 ) fix = -1;
2276 else if ( FG.cTable[*s] == 1 ) {
2279 Warning(
"Restriction to zero arguments removed");
2282 MesPrint(
"&Illegal character after :");
2288 *w++ = TYPEOPERATION;
2297 w += 2; ww = w; groupsize = -1;
2298 while ( *s ==
',' ) s++;
2302 while ( *s && *s !=
')' ) {
2303 if ( *s ==
',' ) { s++;
continue; }
2304 if ( FG.cTable[*s] != 1 )
goto illarg;
2306 if ( x <= 0 || ( fix > 0 && x > fix ) )
goto illnum;
2311 MesPrint(
"&Improper termination of statement");
2314 if ( groupsize < 0 ) groupsize = num;
2315 else if ( groupsize != num )
goto group;
2318 else if ( FG.cTable[*s] == 1 ) {
2319 if ( groupsize < 0 ) groupsize = 1;
2320 else if ( groupsize != 1 ) {
2321group: MesPrint(
"&All groups should have the same number of arguments");
2325 if ( x <= 0 || ( fix > 0 && x > fix ) ) {
2326illnum: MesPrint(
"&Illegal argument number: %d",x);
2332illarg: MesPrint(
"&Illegal argument");
2335 while ( *s ==
',' ) s++;
2344 for ( i = 0; i < fix; i++ ) *w++ = i;
2350 ww[-2] = (w-ww)/groupsize;
2352 AT.WorkPointer[1] = w - AT.WorkPointer;
2353 AddNtoL(AT.WorkPointer[1],AT.WorkPointer);
2362int CoSymmetrize(UBYTE *s) {
return(DoSymmetrize(s,SYMMETRIC)); }
2369int CoAntiSymmetrize(UBYTE *s) {
return(DoSymmetrize(s,ANTISYMMETRIC)); }
2376int CoCycleSymmetrize(UBYTE *s) {
return(DoSymmetrize(s,CYCLESYMMETRIC)); }
2383int CoRCycleSymmetrize(UBYTE *s) {
return(DoSymmetrize(s,RCYCLESYMMETRIC)); }
2390int CoWrite(UBYTE *s)
2396 if ( ( ( s =
SkipAName(s) ) == 0 ) || *s != 0 ) {
2397 MesPrint(
"&Proper use of write statement is: write option");
2402 MesPrint(
"&Unrecognized option in write statement");
2405 *key->var = key->type;
2406 AR.SortType = AC.SortType;
2415int CoNWrite(UBYTE *s)
2421 if ( ( ( s =
SkipAName(s) ) == 0 ) || *s != 0 ) {
2422 MesPrint(
"&Proper use of nwrite statement is: nwrite option");
2427 MesPrint(
"&Unrecognized option in nwrite statement");
2430 *key->var = key->flags;
2431 AR.SortType = AC.SortType;
2440static WORD ratstring[6] = { TYPEOPERATION, 6, RATIO, 0, 0, 0 };
2442int CoRatio(UBYTE *s)
2445 int i, type, error = 0;
2448 for ( i = 0; i < 3; i++ ) {
2453 if ( ( ( type = GetName(AC.varnames,t,&numsym,WITHAUTO) ) != CSYMBOL )
2454 && type != CDUBIOUS ) {
2455 MesPrint(
"&%s is not a symbol",t);
2457 if ( type < 0 ) numsym = AddSymbol(t,-MAXPOWER,MAXPOWER,0,0);
2460 if ( *s ==
',' ) s++;
2464 MesPrint(
"&The ratio statement needs three symbols for its arguments");
2482int CoRedefine(UBYTE *s)
2484 UBYTE *name, c, *args = 0;
2488 if ( FG.cTable[*s] || ( s =
SkipAName(s) ) == 0 || s[-1] ==
'_' ) {
2489 MesPrint(
"&Illegal name for preprocessor variable in redefine statement");
2493 for ( numprevar = NumPre-1; numprevar >= 0; numprevar-- ) {
2494 if ( StrCmp(name,PreVar[numprevar].name) == 0 )
break;
2496 if ( numprevar < 0 ) {
2497 MesPrint(
"&There is no preprocessor variable with the name `%s'",name);
2509 if ( chartype[*s] != 0 )
goto illarg;
2511 while ( chartype[*s] <= 1 ) s++;
2512 while ( *s ==
' ' || *s ==
'\t' ) s++;
2513 if ( *s ==
')' )
break;
2514 if ( *s !=
',' )
goto illargs;
2516 while ( *s ==
' ' || *s ==
'\t' ) s++;
2519 while ( *s ==
' ' || *s ==
'\t' ) s++;
2521 while ( *s ==
',' ) s++;
2523encl: MesPrint(
"&Value for %s should be enclosed in double quotes"
2524 ,PreVar[numprevar].name);
2528 while ( *s && *s !=
'"' ) {
if ( *s ==
'\\' ) s++; s++; }
2529 if ( *s !=
'"' )
goto encl;
2531 code[0] = TYPEREDEFPRE; code[1] = numprevar;
2535 Add2ComStrings(2,code,name,args);
2547 for ( j = 0; j < AC.numpfirstnum; j++ ) {
2548 if ( numprevar == AC.pfirstnum[j] )
break;
2550 if ( j >= AC.numpfirstnum ) {
2551 if ( j >= AC.sizepfirstnum ) {
2552 if ( AC.sizepfirstnum <= 0 ) { AC.sizepfirstnum = 10; }
2553 else { AC.sizepfirstnum = 2 * AC.sizepfirstnum; }
2554 newin = (LONG *)Malloc1(AC.sizepfirstnum*(
sizeof(WORD)+
sizeof(LONG)),
"AC.pfirstnum");
2555 newpf = (WORD *)(newin+AC.sizepfirstnum);
2556 for ( j = 0; j < AC.numpfirstnum; j++ ) {
2557 newpf[j] = AC.pfirstnum[j];
2558 newin[j] = AC.inputnumbers[j];
2560 if ( AC.inputnumbers ) M_free(AC.inputnumbers,
"AC.pfirstnum");
2561 AC.inputnumbers = newin;
2562 AC.pfirstnum = newpf;
2564 AC.pfirstnum[AC.numpfirstnum] = numprevar;
2565 AC.inputnumbers[AC.numpfirstnum] = -1;
2572 MesPrint(
"&Illegally formed name in argument of redefine statement");
2575 MesPrint(
"&Illegally formed arguments in redefine statement");
2587int CoRenumber(UBYTE *s)
2591 while ( *s ==
',' ) s++;
2593 if ( *s == 0 ) { x = 0; }
2594 else ParseNumber(x,s)
2595 if ( *s == 0 && x >= 0 && x <= 1 ) {
2596 Add3Com(TYPERENUMBER,x);
2599 MesPrint(
"&Illegal argument in Renumber statement: '%s'",inp);
2610 CBUF *C = cbuf+AC.cbufnum;
2611 UBYTE *ss = 0, c, *t;
2612 int error = 0, i = 0, type, x;
2613 WORD numindex,number;
2617 t++; s++;
while ( FG.cTable[*s] < 2 ) s++;
2619 if ( ( number = GetDollar(t) ) < 0 ) {
2620 MesPrint(
"&Undefined variable $%s",t);
2621 if ( !error ) error = 1;
2622 number = AddDollar(t,0,0,0);
2627 if ( ( s =
SkipAName(s) ) == 0 )
return(1);
2629 if ( ( ( type = GetOName(AC.exprnames,t,&numindex,NOAUTO) ) != NAMENOTFOUND )
2630 || ( ( type = GetOName(AC.varnames,t,&numindex,WITHAUTO) ) != CINDEX ) ) {
2631 if ( type != NAMENOTFOUND ) error = NameConflict(type,t);
2633 MesPrint(
"&%s should have been declared as an index",t);
2635 numindex = AddIndex(s,AC.lDefDim,AC.lDefDim4) + AM.OffsetIndex;
2639 Add3Com(TYPESUM,numindex);
2641 if ( *s == 0 )
break;
2643 MesPrint(
"&Illegal separator between objects in sum statement.");
2647 if ( FG.cTable[*s] == 0 || *s ==
'[' || *s ==
'$' ) {
2648 while ( FG.cTable[*s] == 0 || *s ==
'[' || *s ==
'$' ) {
2652 while ( FG.cTable[*s] < 2 ) s++;
2654 if ( ( number = GetDollar(t) ) < 0 ) {
2655 MesPrint(
"&Undefined variable $%s",t);
2656 if ( !error ) error = 1;
2657 number = AddDollar(t,0,0,0);
2663 if ( ( s =
SkipAName(s) ) == 0 )
return(1);
2665 if ( ( ( type = GetOName(AC.exprnames,t,&numindex,NOAUTO) ) != NAMENOTFOUND )
2666 || ( ( type = GetOName(AC.varnames,t,&numindex,WITHAUTO) ) != CINDEX ) ) {
2667 if ( type != NAMENOTFOUND ) error = NameConflict(type,t);
2669 MesPrint(
"&%s should have been declared as an index",t);
2671 numindex = AddIndex(s,AC.lDefDim,AC.lDefDim4) + AM.OffsetIndex;
2679 if ( *s == 0 )
return(error);
2681 MesPrint(
"&Illegal separator between objects in sum statement.");
2686 if ( FG.cTable[*s] == 1 ) {
2690 else if ( FG.cTable[*s] == 1 ) {
2691 while ( FG.cTable[*s] == 1 ) {
2694 while( FG.cTable[*s] == 1 ) x = 10*x + *s++ -
'0';
2695 if ( *s && *s !=
',' ) {
2696 MesPrint(
"&%s is not a legal fixed index",t);
2699 else if ( x >= AM.OffsetIndex ) {
2700 MesPrint(
"&%d is too large to be a fixed index",x);
2709 if ( *s == 0 )
break;
2714 MesPrint(
"&Illegal object in sum statement");
2726static WORD cttarray[7] = { TYPEOPERATION,7,TENVEC,0,0,1,0 };
2728int CoToTensor(UBYTE *s)
2731 int type, j, nargs, error = 0;
2732 WORD number, dol[2] = { 0, 0 };
2744 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
2745 if ( *s == 0 )
break;
2752 if ( ( s =
SkipAName(s) ) == 0 )
goto syntax_error;
2755 if ( ( s =
SkipAName(s) ) == 0 )
goto syntax_error;
2759 if ( nargs < 2 )
goto not_enough_arguments;
2764 for ( j = 2; j < nargs; j++ ) {
2765 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
2774 if ( FG.cTable[*s] == 0 || *s ==
'[' || *s ==
'_' ) {
2776 if ( ( s =
SkipAName(s) ) == 0 )
goto syntax_error;
2778 type = GetName(AC.varnames,t,&number,WITHAUTO);
2779 if ( type == CVECTOR ) {
2783 cttarray[6] = DoTempSet(t,s);
2787 else if ( type != CSET ) {
2788 MesPrint(
"&%s is not the name of a set or a vector",t);
2792 cttarray[6] = number;
2794 else if ( *s ==
'{' ) {
2795 t = ++s; SKIPBRA2(s) *s = 0;
2796 cttarray[6] = DoTempSet(t,s);
2799 if ( cttarray[6] < 0 ) {
2802 if ( AC.wildflag ) {
2803 MesPrint(
"&Improper use of wildcard(s) in set specification");
2812 if ( ( s =
SkipAName(s) ) == 0 )
goto syntax_error;
2814 if ( StrICmp(t,(UBYTE *)
"nosquare") == 0 ) cttarray[5] |= 2;
2815 else if ( StrICmp(t,(UBYTE *)
"functions") == 0 ) cttarray[5] |= 4;
2817 MesPrint(
"&Unrecognized option in ToTensor statement: '%s'",t);
2827 for ( j = 0; j < 2; j++ ) {
2828 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
2830 if ( ( s =
SkipAName(s) ) == 0 )
goto syntax_error;
2832 if ( t[0] ==
'$' ) {
2833 dol[j] = GetDollar(t+1);
2834 if ( dol[j] < 0 ) dol[j] = AddDollar(t+1,DOLUNDEFINED,0,0);
2836 type = GetName(AC.varnames,t,&number,WITHAUTO);
2837 if ( type == CVECTOR ) {
2838 cttarray[4] = number + AM.OffsetVector;
2840 else if ( type == CFUNCTION && ( functions[number].spec > 0 ) ) {
2841 cttarray[3] = number + FUNCTION;
2844 MesPrint(
"&%s is not a vector or a tensor",t);
2850 if ( cttarray[3] == 0 || cttarray[4] == 0 ) {
2851 if ( dol[0] == 0 && dol[1] == 0 ) {
2852 goto not_enough_arguments;
2854 else if ( cttarray[3] ) {
2855 if ( dol[1] ) cttarray[4] = dol[1];
2856 else if ( dol[0] ) { cttarray[4] = dol[0]; }
2858 goto not_enough_arguments;
2861 else if ( cttarray[4] ) {
2862 if ( dol[1] ) { cttarray[3] = -dol[1]; }
2863 else if ( dol[0] ) cttarray[3] = -dol[0];
2865 goto not_enough_arguments;
2869 if ( dol[0] == 0 || dol[1] == 0 ) {
2870 goto not_enough_arguments;
2873 cttarray[3] = -dol[0]; cttarray[4] = dol[1];
2877 AddNtoL(cttarray[1],cttarray);
2881 MesPrint(
"&Syntax error in ToTensor statement");
2884not_enough_arguments:
2885 MesPrint(
"&ToTensor statement needs a vector and a tensor");
2894static WORD ctvarray[6] = { TYPEOPERATION,6,TENVEC,0,0,0 };
2896int CoToVector(UBYTE *s)
2899 int j, type, error = 0;
2900 WORD number, dol[2];
2901 dol[0] = dol[1] = 0;
2902 ctvarray[3] = ctvarray[4] = ctvarray[5] = 0;
2903 for ( j = 0; j < 2; j++ ) {
2906proper: MesPrint(
"&Arguments of ToVector statement should be a vector and a tensor");
2911 dol[j] = GetDollar(t+1);
2912 if ( dol[j] < 0 ) dol[j] = AddDollar(t+1,DOLUNDEFINED,0,0);
2914 else if ( ( type = GetName(AC.varnames,t,&number,WITHAUTO) ) == CVECTOR )
2915 ctvarray[4] = number + AM.OffsetVector;
2916 else if ( type == CFUNCTION && ( functions[number].spec > 0 ) )
2917 ctvarray[3] = number+FUNCTION;
2919 MesPrint(
"&%s is not a vector or a tensor",t);
2922 *s = c;
if ( *s && *s !=
',' )
goto proper;
2925 if ( *s != 0 )
goto proper;
2926 if ( ctvarray[3] == 0 || ctvarray[4] == 0 ) {
2927 if ( dol[0] == 0 && dol[1] == 0 ) {
2928 MesPrint(
"&ToVector statement needs a vector and a tensor");
2931 else if ( ctvarray[3] ) {
2932 if ( dol[1] ) ctvarray[4] = dol[1];
2933 else if ( dol[0] ) ctvarray[4] = dol[0];
2935 MesPrint(
"&ToVector statement needs a vector and a tensor");
2939 else if ( ctvarray[4] ) {
2940 if ( dol[1] ) ctvarray[3] = -dol[1];
2941 else if ( dol[0] ) ctvarray[3] = -dol[0];
2943 MesPrint(
"&ToVector statement needs a vector and a tensor");
2948 if ( dol[0] == 0 || dol[1] == 0 ) {
2949 MesPrint(
"&ToVector statement needs a vector and a tensor");
2953 ctvarray[3] = -dol[0]; ctvarray[4] = dol[1];
2966int CoTrace4(UBYTE *s)
2968 int error = 0, type, option = CHISHOLM;
2970 WORD numindex, one = 1;
2974 if ( FG.cTable[*s] == 1 )
break;
2976proper: MesPrint(
"&Proper syntax for Trace4 is 'Trace4[,options],index;'");
2979 if ( *s == 0 )
break;
2981 if ( ( key = FindKeyWord(t,trace4options,
2982 sizeof(trace4options)/
sizeof(
KEYWORD)) ) == 0 )
break;
2984 option |= key->type;
2985 option &= ~key->flags;
2987 if ( ( *s++ = c ) !=
',' ) {
2988 MesPrint(
"&Illegal separator in Trace4 statement");
2991 if ( *s == 0 )
goto proper;
2994 if ( FG.cTable[*s] == 1 ) {
2996 ParseNumber(numindex,s)
2998 MesPrint(
"&Last argument of Trace4 should be an index");
3001 if ( numindex >= AM.OffsetIndex ) {
3002 MesPrint(
"&fixed index >= %d. Change value of OffsetIndex in setup file"
3007 else if ( *s ==
'$' ) {
3008 if ( ( type = GetName(AC.dollarnames,s+1,&numindex,NOAUTO) ) == CDOLLAR )
3009 numindex = -numindex;
3011 MesPrint(
"&%s is undefined",s);
3012 numindex = AddDollar(s+1,DOLINDEX,&one,1);
3017 MesPrint(
"&Trace4 should have a single index or $variable for its argument");
3021 else if ( ( type = GetName(AC.varnames,s,&numindex,WITHAUTO) ) == CINDEX ) {
3022 numindex += AM.OffsetIndex;
3025 else if ( type != -1 ) {
3026 if ( type != CDUBIOUS ) {
3027 if ( ( FG.cTable[*s] != 0 ) && ( *s !=
'[' ) ) {
3028 if ( *s ==
'+' && FG.cTable[s[1]] == 1 ) { s++;
goto retry; }
3031 NameConflict(type,s);
3032 type = MakeDubious(AC.varnames,s,&numindex);
3037 MesPrint(
"&%s is not an index",s);
3038 numindex = AddIndex(s,AC.lDefDim,AC.lDefDim4) + AM.OffsetIndex;
3041 if ( error )
return(error);
3042 if ( ( option & CHISHOLM ) != 0 )
3043 Add4Com(TYPECHISHOLM,numindex,(option & ALSOREVERSE));
3044 Add5Com(TYPEOPERATION,TAKETRACE,4 + (option & NOTRICK),numindex);
3053int CoTraceN(UBYTE *s)
3055 WORD numindex, one = 1;
3057 if ( FG.cTable[*s] == 1 ) {
3059 ParseNumber(numindex,s)
3061proper: MesPrint(
"&TraceN should have a single index for its argument");
3064 if ( numindex >= AM.OffsetIndex ) {
3065 MesPrint(
"&fixed index >= %d. Change value of OffsetIndex in setup file"
3070 else if ( *s ==
'$' ) {
3071 if ( ( type = GetName(AC.dollarnames,s+1,&numindex,NOAUTO) ) == CDOLLAR )
3072 numindex = -numindex;
3074 MesPrint(
"&%s is undefined",s);
3075 numindex = AddDollar(s+1,DOLINDEX,&one,1);
3080 MesPrint(
"&TraceN should have a single index or $variable for its argument");
3084 else if ( ( type = GetName(AC.varnames,s,&numindex,WITHAUTO) ) == CINDEX ) {
3085 numindex += AM.OffsetIndex;
3088 else if ( type != -1 ) {
3089 if ( type != CDUBIOUS ) {
3090 if ( ( FG.cTable[*s] != 0 ) && ( *s !=
'[' ) ) {
3091 if ( *s ==
'+' && FG.cTable[s[1]] == 1 ) { s++;
goto retry; }
3094 NameConflict(type,s);
3095 type = MakeDubious(AC.varnames,s,&numindex);
3100 MesPrint(
"&%s is not an index",s);
3101 numindex = AddIndex(s,AC.lDefDim,AC.lDefDim4) + AM.OffsetIndex;
3104 Add5Com(TYPEOPERATION,TAKETRACE,0,numindex);
3113int CoChisholm(UBYTE *s)
3115 int error = 0, type, option = CHISHOLM;
3117 WORD numindex, one = 1;
3121 if ( FG.cTable[*s] == 1 )
break;
3123proper: MesPrint(
"&Proper syntax for Chisholm is 'Chisholm[,options],index;'");
3126 if ( *s == 0 )
break;
3128 if ( ( key = FindKeyWord(t,chisoptions,
3129 sizeof(chisoptions)/
sizeof(
KEYWORD)) ) == 0 )
break;
3131 option |= key->type;
3132 option &= ~key->flags;
3134 if ( ( *s++ = c ) !=
',' ) {
3135 MesPrint(
"&Illegal separator in Chisholm statement");
3138 if ( *s == 0 )
goto proper;
3141 if ( FG.cTable[*s] == 1 ) {
3142 ParseNumber(numindex,s)
3144 MesPrint(
"&Last argument of Chisholm should be an index");
3147 if ( numindex >= AM.OffsetIndex ) {
3148 MesPrint(
"&fixed index >= %d. Change value of OffsetIndex in setup file"
3153 else if ( *s ==
'$' ) {
3154 if ( ( type = GetName(AC.dollarnames,s+1,&numindex,NOAUTO) ) == CDOLLAR )
3155 numindex = -numindex;
3157 MesPrint(
"&%s is undefined",s);
3158 numindex = AddDollar(s+1,DOLINDEX,&one,1);
3163 MesPrint(
"&Chisholm should have a single index or $variable for its argument");
3167 else if ( ( type = GetName(AC.varnames,s,&numindex,WITHAUTO) ) == CINDEX ) {
3168 numindex += AM.OffsetIndex;
3171 else if ( type != -1 ) {
3172 if ( type != CDUBIOUS ) {
3173 NameConflict(type,s);
3174 type = MakeDubious(AC.varnames,s,&numindex);
3179 MesPrint(
"&%s is not an index",s);
3180 numindex = AddIndex(s,AC.lDefDim,AC.lDefDim4) + AM.OffsetIndex;
3183 if ( error )
return(error);
3184 Add4Com(TYPECHISHOLM,numindex,(option & ALSOREVERSE));
3195int DoChain(UBYTE *s,
int option)
3199 if ( ( type = GetName(AC.dollarnames,s+1,&numfunc,NOAUTO) ) == CDOLLAR )
3202 MesPrint(
"&%s is undefined",s);
3203 numfunc = AddDollar(s+1,DOLINDEX,&one,1);
3208 MesPrint(
"&ChainIn/ChainOut should have a single function or $variable for its argument");
3212 else if ( ( type = GetName(AC.varnames,s,&numfunc,WITHAUTO) ) == CFUNCTION ) {
3213 numfunc += FUNCTION;
3216 else if ( type != -1 ) {
3217 if ( type != CDUBIOUS ) {
3218 NameConflict(type,s);
3219 type = MakeDubious(AC.varnames,s,&numfunc);
3224 MesPrint(
"&%s is not a function",s);
3225 numfunc = AddFunction(s,0,0,0,0,0,-1,-1) + FUNCTION;
3228 Add3Com(option,numfunc);
3239int CoChainin(UBYTE *s)
3241 return(DoChain(s,TYPECHAININ));
3251int CoChainout(UBYTE *s)
3253 return(DoChain(s,TYPECHAINOUT));
3264 WORD code = TYPEEXIT;
3265 while ( *s ==
',' ) s++;
3267 Add3Com(TYPEEXIT,0);
3272 while ( *s ) {
if ( *s ==
'\\' ) s++; s++; }
3273 if ( name[-1] !=
'"' || s[-1] !=
'"' ) {
3274 MesPrint(
"&Illegal syntax for exit statement");
3278 AddComString(1,&code,name,0);
3288int CoInParallel(UBYTE *s)
3290 return(DoInParallel(s,1));
3298int CoNotInParallel(UBYTE *s)
3300 return(DoInParallel(s,0));
3313int DoInParallel(UBYTE *s,
int par)
3326 AC.inparallelflag = par;
3328 for ( i = NumExpressions-1; i >= 0; i-- ) {
3330 if ( e->status == LOCALEXPRESSION || e->status == GLOBALEXPRESSION
3331 || e->status == UNHIDELEXPRESSION || e->status == UNHIDEGEXPRESSION
3340 while ( *s ==
',' ) s++;
3341 if ( *s == 0 )
break;
3342 if ( *s ==
'[' || FG.cTable[*s] == 0 ) {
3345 MesPrint(
"&Improper name for an expression: '%s'",t);
3349 if ( GetName(AC.exprnames,t,&number,NOAUTO) == CEXPRESSION ) {
3351 e = Expressions+number;
3352 if ( e->status == LOCALEXPRESSION || e->status == GLOBALEXPRESSION
3353 || e->status == UNHIDELEXPRESSION || e->status == UNHIDEGEXPRESSION
3359 else if ( GetName(AC.varnames,t,&number,NOAUTO) != NAMENOTFOUND ) {
3360 MesPrint(
"&%s is not an expression",t);
3366 MesPrint(
"&Illegal object in InParallel statement");
3368 while ( *s && *s !=
',' ) s++;
3369 if ( *s == 0 )
break;
3382int CoInExpression(UBYTE *s)
3389 if ( AC.inexprlevel >= MAXNEST ) {
3390 MesPrint(
"@Nesting of inexpression statements more than %d levels",(WORD)MAXNEST);
3393 AC.inexprsumcheck[AC.inexprlevel] = NestingChecksum();
3394 AC.inexprstack[AC.inexprlevel] = cbuf[AC.cbufnum].Pointer
3395 - cbuf[AC.cbufnum].Buffer + 2;
3397 *w++ = TYPEINEXPRESSION;
3400 while ( *s ==
',' ) s++;
3401 if ( *s == 0 )
break;
3402 if ( *s ==
'[' || FG.cTable[*s] == 0 ) {
3405 MesPrint(
"&Improper name for an expression: '%s'",t);
3409 if ( GetName(AC.exprnames,t,&number,NOAUTO) == CEXPRESSION ) {
3412 else if ( GetName(AC.varnames,t,&number,NOAUTO) != NAMENOTFOUND ) {
3413 MesPrint(
"&%s is not an expression",t);
3419 MesPrint(
"&Illegal object in InExpression statement");
3421 while ( *s && *s !=
',' ) s++;
3422 if ( *s == 0 )
break;
3425 AT.WorkPointer[1] = w - AT.WorkPointer;
3426 AddNtoL(AT.WorkPointer[1],AT.WorkPointer);
3435int CoEndInExpression(UBYTE *s)
3437 CBUF *C = cbuf+AC.cbufnum;
3438 while ( *s ==
',' ) s++;
3440 MesPrint(
"&Illegal syntax for EndInExpression statement");
3443 if ( AC.inexprlevel <= 0 ) {
3444 MesPrint(
"&EndInExpression without corresponding InExpression statement");
3448 cbuf[AC.cbufnum].Buffer[AC.inexprstack[AC.inexprlevel]] = C->numlhs;
3449 if ( AC.inexprsumcheck[AC.inexprlevel] != NestingChecksum() ) {
3461int CoSetExitFlag(UBYTE *s)
3464 MesPrint(
"&Illegal syntax for the SetExitFlag statement");
3467 Add2Com(TYPESETEXIT);
3475int CoTryReplace(UBYTE *p)
3479 WORD *w, error = 0, i, which = -1, c1, minvec = 0;
3496 if ( *p ==
'-' && minvec == 0 && which == (CVECTOR+1) ) {
3499 if ( *p ==
'[' || FG.cTable[*p] == 0 ) {
3501 if ( ( p =
SkipAName(p) ) == 0 )
return(1);
3503 i = GetName(AC.varnames,name,&c1,WITHAUTO);
3504 if ( which >= 0 && i >= 0 && i != CDUBIOUS && which != (i+1) ) {
3505 MesPrint(
"&Illegal combination of objects in TryReplace");
3508 else if ( minvec && i != CVECTOR && i != CDUBIOUS ) {
3509 MesPrint(
"&Currently a - sign can be used only with a vector in TryReplace");
3513 case CSYMBOL: *w++ = -SYMBOL; *w++ = c1;
break;
3515 if ( minvec ) *w++ = -MINVECTOR;
3516 else *w++ = -VECTOR;
3517 *w++ = c1 + AM.OffsetVector;
3520 case CINDEX: *w++ = -INDEX; *w++ = c1 + AM.OffsetIndex;
3521 if ( c1 >= AM.WilInd && c ==
'?' ) { *p++ = c; c = *p; }
3523 case CFUNCTION: *w++ = -c1-FUNCTION;
break;
3524 case CDUBIOUS: minvec = 0; error = 1;
break;
3526 MesPrint(
"&Illegal object type in TryReplace: %s",name);
3531 if ( which < 0 ) which = i+1;
3534 if ( *p ==
',' ) p++;
3538 MesPrint(
"&Illegal object in TryReplace");
3540 while ( *p && *p !=
',' ) {
3541 if ( *p ==
'(' ) SKIPBRA3(p)
3542 else if ( *p ==
'{' ) SKIPBRA2(p)
3543 else if ( *p ==
'[' ) SKIPBRA1(p)
3547 if ( *p ==
',' ) p++;
3548 if ( which < 0 ) which = 0;
3552 MesPrint(
"&Odd number of arguments in TryReplace");
3555 i = w - AT.WorkPointer;
3556 AT.WorkPointer[1] = i;
3557 AT.WorkPointer[2] = i - 3;
3558 AT.WorkPointer[4] = i - 3;
3559 AddNtoL((
int)i,AT.WorkPointer);
3578int CoModulus(UBYTE *inp)
3581 int Retval = 0, sign = 1;
3583 while ( *inp ==
',' || *inp ==
' ' || *inp ==
'\t' ) inp++;
3586 if ( AC.modpowers ) M_free(AC.modpowers,
"AC.modpowers");
3588 AN.ncmod = AC.ncmod = 0;
3589 if ( AC.halfmod ) M_free(AC.halfmod,
"halfmod");
3590 AC.halfmod = 0; AC.nhalfmod = 0;
3591 if ( AC.modinverses ) M_free(AC.modinverses,
"modinverses");
3597 if ( AT.aux_ != 0 ) {
3598 MesPrint(
"&Simultaneous use of floating point and modulus arithmetic makes no sense.");
3603 if ( *inp ==
'-' ) {
3608 while ( FG.cTable[*inp] == 0 ) {
3610 while ( FG.cTable[*inp] == 0 ) inp++;
3612 if ( StrICmp(p,(UBYTE *)
"nofunctions") == 0 ) {
3613 AC.modmode &= ~ALSOFUNARGS;
3615 else if ( StrICmp(p,(UBYTE *)
"alsofunctions") == 0 ) {
3616 AC.modmode |= ALSOFUNARGS;
3618 else if ( StrICmp(p,(UBYTE *)
"coefficientsonly") == 0 ) {
3619 AC.modmode &= ~ALSOFUNARGS;
3620 AC.modmode &= ~ALSOPOWERS;
3623 else if ( StrICmp(p,(UBYTE *)
"plusmin") == 0 ) {
3624 AC.modmode |= POSNEG;
3626 else if ( StrICmp(p,(UBYTE *)
"positive") == 0 ) {
3627 AC.modmode &= ~POSNEG;
3629 else if ( StrICmp(p,(UBYTE *)
"inversetable") == 0 ) {
3630 AC.modmode |= INVERSETABLE;
3632 else if ( StrICmp(p,(UBYTE *)
"noinversetable") == 0 ) {
3633 AC.modmode &= ~INVERSETABLE;
3635 else if ( StrICmp(p,(UBYTE *)
"nodollars") == 0 ) {
3636 AC.modmode &= ~ALSODOLLARS;
3638 else if ( StrICmp(p,(UBYTE *)
"alsodollars") == 0 ) {
3639 AC.modmode |= ALSODOLLARS;
3641 else if ( StrICmp(p,(UBYTE *)
"printpowersof") == 0 ) {
3643 if ( *inp !=
'(' ) {
3645 MesPrint(
"&Bad syntax in argument of PrintPowersOf(number) in Modulus statement");
3648 while ( *inp ==
',' || *inp ==
' ' || *inp ==
'\t' ) inp++;
3650 if ( FG.cTable[*inp] != 1 )
goto badsyntax;
3651 do { inp++; }
while ( FG.cTable[*inp] == 1 );
3653 if ( GetLong(p,(UWORD *)AC.powmod,&AC.npowmod) ) Retval = -1;
3654 if ( TakeModulus((UWORD *)AC.powmod,&AC.npowmod,AC.cmod,AC.ncmod,NOUNPACK) ) Retval = -1;
3655 if ( AC.npowmod == 0 ) {
3656 MesPrint(
"&Improper value for generator");
3659 if ( MakeModTable() ) Retval = -1;
3662 while ( *inp ==
',' || *inp ==
' ' || *inp ==
'\t' ) inp++;
3663 if ( *inp !=
')' )
goto badsyntax;
3667 else if ( StrICmp(p,(UBYTE *)
"alsopowers") == 0 ) {
3668 AC.modmode |= ALSOPOWERS;
3671 else if ( StrICmp(p,(UBYTE *)
"nopowers") == 0 ) {
3672 AC.modmode &= ~ALSOPOWERS;
3676 MesPrint(
"&Unrecognized option %s in Modulus statement",inp);
3680 while ( *inp ==
',' || *inp ==
' ' || *inp ==
'\t' ) inp++;
3682 MesPrint(
"&Modulus statement with no value!!!");
3688 if ( FG.cTable[*inp] != 1 ) {
3689 MesPrint(
"&Invalid value for modulus:%s",inp);
3690 if ( AC.modpowers ) M_free(AC.modpowers,
"AC.modpowers");
3692 AN.ncmod = AC.ncmod = 0;
3693 if ( AC.halfmod ) M_free(AC.halfmod,
"halfmod");
3694 AC.halfmod = 0; AC.nhalfmod = 0;
3695 if ( AC.modinverses ) M_free(AC.modinverses,
"modinverses");
3699 do { inp++; }
while ( FG.cTable[*inp] == 1 );
3701 Retval = GetLong(p,(UWORD *)AC.cmod,&AC.ncmod);
3702 if ( Retval == 0 && AC.ncmod == 0 )
goto SwitchOff;
3703 if ( sign < 0 ) AC.ncmod = -AC.ncmod;
3704 AN.ncmod = AC.ncmod;
3705 if ( ( AC.modmode & INVERSETABLE ) != 0 )
MakeInverses();
3706 if ( AC.halfmod ) M_free(AC.halfmod,
"halfmod");
3707 AC.halfmod = 0; AC.nhalfmod = 0;
3716int CoRepeat(UBYTE *inp)
3719 AC.RepSumCheck[AC.RepLevel] = NestingChecksum();
3721 if ( AC.RepLevel > AM.RepMax ) {
3722 MesPrint(
"&Too many repeat levels. Maximum is %d",AM.RepMax);
3725 Add3Com(TYPEREPEAT,-1)
3726 while ( *inp == ' ' || *inp == ',' || *inp == '\t' ) inp++;
3728 error = CompileStatement(inp);
3729 if ( CoEndRepeat(inp) ) error = 1;
3739int CoEndRepeat(UBYTE *inp)
3741 CBUF *C = cbuf+AC.cbufnum;
3742 int level, error = 0, repeatlevel = 0;
3745 if ( AC.RepLevel < 0 ) {
3746 MesPrint(
"&EndRepeat without Repeat");
3750 else if ( AC.RepSumCheck[AC.RepLevel] != NestingChecksum() ) {
3754 level = C->numlhs+1;
3755 while ( level > 0 ) {
3756 if ( C->
lhs[--level][0] == TYPEREPEAT ) {
3757 if ( repeatlevel == 0 ) {
3758 Add3Com(TYPEENDREPEAT,level)
3763 else if ( C->
lhs[level][0] == TYPEENDREPEAT ) repeatlevel++;
3777int DoBrackets(UBYTE *inp,
int par)
3781 WORD *to, i, type, *w, error = 0;
3782 WORD c1,c2, *WorkSave;
3785 WorkSave = to = AT.WorkPointer;
3787 if ( AT.BrackBuf == 0 ) {
3788 AR.MaxBracket = 100;
3789 AT.BrackBuf = (WORD *)Malloc1(
sizeof(WORD)*(AR.MaxBracket+1),
"bracket buffer");
3793 AC.bracketindexflag = 0;
3794 AT.bracketindexflag = 0;
3795 if ( *p ==
'+' || *p ==
'-' ) p++;
3796 if ( p[-1] ==
',' && *p ) p--;
3797 if ( p[-1] ==
'+' && *p ) { biflag = 1;
if ( *p !=
',' ) { *--p =
','; } }
3798 else if ( p[-1] ==
'-' && *p ) { biflag = -1;
if ( *p !=
',' ) { *--p =
','; } }
3800 while ( *p ==
',' ) {
3801redo: AR.BracketOn++;
3802 while ( *p ==
',' ) p++;
3803 if ( *p == 0 )
break;
3805 p++;
while ( *p ==
'0' ) p++;
3810 if ( p == 0 )
return(1);
3813 type = GetName(AC.varnames,inp,&c1,WITHAUTO);
3815 if ( type == CVECTOR || type == CDUBIOUS ) {
3819 if ( p == 0 )
return(1);
3822 type = GetName(AC.varnames,inp,&c2,WITHAUTO);
3823 if ( type != CVECTOR && type != CDUBIOUS ) {
3824 MesPrint(
"&Not a vector in dotproduct in bracket statement: %s",inp);
3827 else type = CDOTPRODUCT;
3830 MesPrint(
"&Illegal use of . after %s in bracket statement",inp);
3838 *to++ = SYMBOL; *to++ = 4; *to++ = c1; *to++ = 1;
break;
3840 *to++ = INDEX; *to++ = 3; *to++ = AM.OffsetVector + c1;
break;
3842 *to++ = c1+FUNCTION; *to++ = FUNHEAD; *to++ = 0;
3846 *to++ = DOTPRODUCT; *to++ = 5; *to++ = c1 + AM.OffsetVector;
3847 *to++ = c2 + AM.OffsetVector; *to++ = 1;
break;
3849 *to++ = DELTA; *to++ = 4; *to++ = EMPTYINDEX; *to++ = EMPTYINDEX;
break;
3851 *to++ = SETSET; *to++ = 4; *to++ = c1; *to++ = Sets[c1].type;
break;
3853 MesPrint(
"&Illegal bracket request for %s",pp);
3859 MesCerr(
"separator",p);
3860 AC.BracketNormalize = 0;
3861 AT.WorkPointer = WorkSave;
3865 *to++ = 1; *to++ = 1; *to++ = 3;
3866 *AT.WorkPointer = to - AT.WorkPointer;
3867 AT.WorkPointer = to;
3868 AC.BracketNormalize = 1;
3869 if ( BracketNormalize(BHEAD WorkSave) ) { error = 1; AR.BracketOn = 0; }
3872 if ( *w == 4 || !*w ) { AR.BracketOn = 0; }
3875 if ( i < 0 ) i = -i;
3878 if ( i > AR.MaxBracket ) {
3880 newbuf = (WORD *)Malloc1(
sizeof(WORD)*(i+1),
"bracket buffer");
3882 if ( AT.BrackBuf != 0 ) M_free(AT.BrackBuf,
"bracket buffer");
3883 AT.BrackBuf = newbuf;
3889 AC.BracketNormalize = 0;
3890 if ( par == 1 ) AR.BracketOn = -AR.BracketOn;
3892 AC.bracketindexflag = biflag;
3893 AT.bracketindexflag = biflag;
3895 AT.WorkPointer = WorkSave;
3904int CoBracket(UBYTE *inp)
3905{
return(DoBrackets(inp,0)); }
3912int CoAntiBracket(UBYTE *inp)
3913{
return(DoBrackets(inp,1)); }
3923int CoMultiBracket(UBYTE *inp)
3926 int i, error = 0, error1, type, num;
3930 if ( *inp !=
':' ) {
3931 MesPrint(
"&Illegal Multiple Bracket separator: %s",inp);
3935 if ( AC.MultiBracketBuf == 0 ) {
3936 AC.MultiBracketBuf = (WORD **)Malloc1(
sizeof(WORD *)*MAXMULTIBRACKETLEVELS,
"multi bracket buffer");
3937 for ( i = 0; i < MAXMULTIBRACKETLEVELS; i++ ) {
3938 AC.MultiBracketBuf[i] = 0;
3942 for ( i = 0; i < MAXMULTIBRACKETLEVELS; i++ ) {
3943 if ( AC.MultiBracketBuf[i] ) {
3944 M_free(AC.MultiBracketBuf[i],
"bracket buffer i");
3945 AC.MultiBracketBuf[i] = 0;
3948 AC.MultiBracketLevels = 0;
3950 AC.MultiBracketLevels = 0;
3954 if ( AT.BrackBuf == 0 ) {
3955 AR.MaxBracket = 100;
3956 AT.BrackBuf = (WORD *)Malloc1(
sizeof(WORD)*(AR.MaxBracket+1),
"bracket buffer");
3960 AC.bracketindexflag = 0;
3961 AT.bracketindexflag = 0;
3965 for ( i = 0; i < MAXMULTIBRACKETLEVELS; i++ ) {
3966 if ( *inp == 0 )
goto RegEnd;
3971 while ( *s && *s !=
':' ) {
3972 if ( *s ==
'[' ) { SKIPBRA1(s) s++; }
3973 else if ( *s ==
'{' ) { SKIPBRA2(s) s++; }
3977 if ( StrICont(inp,(UBYTE *)
"antibrackets") == 0 ) { type = 1; }
3978 else if ( StrICont(inp,(UBYTE *)
"brackets") == 0 ) { type = 0; }
3980 MesPrint(
"&Illegal (anti)bracket specification in MultiBracket statement");
3981 if ( error == 0 ) error = 1;
3984 while ( FG.cTable[*inp] == 0 ) inp++;
3985 if ( *inp !=
',' ) {
3986 MesPrint(
"&Illegal separator after (anti)bracket specification in MultiBracket statement");
3987 if ( error == 0 ) error = 1;
3994 error1 = DoBrackets(inp, type);
3995 if ( error < 0 )
return(error1);
3996 if ( error1 > error ) error = error1;
4000 if ( AR.BracketOn ) {
4001 num = AT.BrackBuf[0];
4002 to = AC.MultiBracketBuf[i] = (WORD *)Malloc1((num+2)*
sizeof(WORD),
"bracket buffer i");
4004 *to++ = AR.BracketOn;
4012 *s = c;
if ( c ==
':' ) s++;
4018 MesPrint(
"&More than %d levels in MultiBracket statement",(WORD)MAXMULTIBRACKETLEVELS);
4019 if ( error == 0 ) error = 1;
4022 AC.MultiBracketLevels = i;
4025 AC.bracketindexflag = 0;
4026 AT.bracketindexflag = 0;
4055WORD *CountComp(UBYTE *inp, WORD *to)
4059 WORD *w, mini = 0, type, c1, c2;
4067 while ( *p ==
',' ) {
4069 if ( *p ==
'[' || FG.cTable[*p] == 0 ) {
4070 if ( ( p =
SkipAName(inp) ) == 0 )
return(0);
4072 type = GetName(AC.varnames,inp,&c1,WITHAUTO);
4074 if ( type == CVECTOR || type == CDUBIOUS ) {
4078 if ( p == 0 )
return(0);
4081 type = GetName(AC.varnames,inp,&c2,WITHAUTO);
4082 if ( type != CVECTOR && type != CDUBIOUS ) {
4083 MesPrint(
"&Not a vector in dotproduct in if statement: %s",inp);
4086 else type = CDOTPRODUCT;
4089 MesPrint(
"&Illegal use of . after %s in if statement",inp);
4090 if ( type == NAMENOTFOUND )
4091 MesPrint(
"&%s is not a properly declared variable",inp);
4094 while ( *p && *p !=
')' && *p !=
',' ) p++;
4095 if ( *p ==
',' && FG.cTable[p[1]] == 1 ) {
4097 while ( *p && *p !=
')' && *p !=
',' ) p++;
4105 *w++ = SYMBOL; *w++ = 4; *w++ = c1;
4106Sgetnum:
if ( *p !=
',' ) {
4107 MesCerr(
"sequence",p);
4108 while ( *p && *p !=
')' && *p !=
',' ) p++;
4112 ParseSignedNumber(mini,p)
4113 if ( FG.cTable[p[-1]] != 1 || ( *p && *p !=
')' && *p !=
',' ) ) {
4114 while ( *p && *p !=
')' && *p !=
',' ) p++;
4117 MesPrint(
"&Improper value in count: %s",inp);
4119 while ( *p && *p !=
')' && *p !=
',' ) p++;
4124 *w++ = FUNCTION; *w++ = 4; *w++ = c1+FUNCTION;
goto Sgetnum;
4126 *w++ = DOTPRODUCT; *w++ = 5;
4127 *w++ = c2 + AM.OffsetVector;
4128 *w++ = c1 + AM.OffsetVector;
4131 *w++ = VECTOR; *w++ = 5;
4132 *w++ = c1 + AM.OffsetVector;
4134 *w++ = VECTBIT | DOTPBIT | FUNBIT;
4137 else if ( *p ==
'+' ) {
4140 while ( *p && *p !=
',' ) {
4141 if ( *p ==
'v' || *p ==
'V' ) {
4144 else if ( *p ==
'd' || *p ==
'D' ) {
4147 else if ( *p ==
'f' || *p ==
'F'
4148 || *p ==
't' || *p ==
'T' ) {
4151 else if ( *p ==
'?' ) {
4155 if ( p == 0 )
return(0);
4156 if ( ( c1 = DoTempSet(inp+1,p) ) < 0 )
return(0);
4157 if ( Sets[c1].type != CFUNCTION ) {
4158 MesPrint(
"&set type conflict: Function expected");
4166 if ( p == 0 )
return(0);
4168 type = GetName(AC.varnames,inp,&c1,WITHAUTO);
4170 if ( type != CSET && type != CDUBIOUS ) {
4171 MesPrint(
"&%s is not a set",inp);
4181 MesCerr(
"specifier for vector",p);
4189 MesCerr(
"specifier for vector",p);
4190 while ( *p && *p !=
')' && *p !=
',' ) p++;
4192 *w++ = VECTBIT | DOTPBIT | FUNBIT;
4199 MesPrint(
"&%s is not a symbol, function, vector or dotproduct",inp);
4201skipfield:
while ( *p && *p !=
')' && *p !=
',' ) p++;
4202 if ( *p && FG.cTable[p[1]] == 1 ) {
4204 while ( *p && *p !=
')' && *p !=
',' ) p++;
4211 while ( *p && *p !=
',' ) p++;
4216 if ( *p ==
')' ) p++;
4217 if ( *p ) { MesCerr(
"end of statement",p);
return(0); }
4218 if ( error )
return(0);
4243static UWORD *CIscratC = 0;
4248 int error = 0, level;
4249 WORD *w, *ww, *u, *s, *OldWork, *OldSpace = AT.WorkSpace;
4251 WORD lenpp, lenlev, ncoef, i, number;
4252 UBYTE *p, *pp, *ppp, c;
4253 CBUF *C = cbuf+AC.cbufnum;
4258 if ( *inp ==
'(' && inp[1] ==
',' ) inp += 2;
4259 else if ( *inp ==
'(' ) inp++;
4261 if ( CIscratC == 0 )
4262 CIscratC = (UWORD *)Malloc1((AM.MaxTal+2)*
sizeof(UWORD),
"CoIf");
4265 if ( AC.IfLevel >= AC.MaxIf ) DoubleIfBuffers();
4266 AC.IfCount[lenpp++] = 0;
4274 AC.IfSumCheck[AC.IfLevel] = NestingChecksum();
4276 w = OldWork = AT.WorkPointer;
4284 if ( FG.cTable[*p] == 1 ) {
4285 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4287 pp = CheckFloat(p,&spec);
4291 MesPrint(
"&The floating point system has not been started: %s",p);
4292 if ( !error ) error = 1;
4295 WORD *ow = AT.WorkPointer;
4298 ReadFloat((SBYTE *)p);
4301 AT.WorkPointer[0] = IFFLOATNUMBER;
4302 w = AT.WorkPointer + AT.WorkPointer[1];
4303 AT.WorkPointer = ow;
4304 if ( level ) w[FUNHEAD+3] = -w[FUNHEAD+3];
4306 goto DoneWithNumber;
4321 if ( GetLong(p,(UWORD *)w,&ncoef) ) { ncoef = 1; error = 1; }
4323 while ( FG.cTable[*++p] == 1 );
4326 if ( FG.cTable[*p] != 1 ) {
4327 MesCerr(
"sequence",p); error = 1;
goto OnlyNum;
4329 if ( GetLong(p,CIscratC,&ncoef) ) {
4330 ncoef = 1; error = 1;
4332 while ( FG.cTable[*++p] == 1 );
4334 MesPrint(
"&Division by zero!");
4339 if ( Simplify(BHEAD (UWORD *)w,(WORD *)(w-1),
4340 CIscratC,&ncoef) ) error = 1;
4347 s = (WORD *)CIscratC;
4349 while ( --i >= 0 ) *w++ = 0;
4354 while ( --i >= 0 ) *w++ = 0;
4355 s = (WORD *)CIscratC;
4367 while ( --ncoef >= 0 ) *w++ = 0;
4370 u[1] = WORDDIF(w,u);
4371 u[2] = (u[1] - 3)/2;
4372 if ( level ) u[2] = -u[2];
4378 else if ( *p ==
'+' ) { p++;
goto ReDo; }
4379 else if ( *p ==
'-' ) { level ^= 1; p++;
goto ReDo; }
4380 else if ( *p ==
'c' || *p ==
'C' ) {
4381 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4382 while ( FG.cTable[*++p] == 0 );
4384 if ( !StrICmp(inp,(UBYTE *)
"count") ) {
4387 MesPrint(
"&no ( after count");
4393 c = *++p; *p = 0; *inp =
',';
4394 w = CountComp(inp,w);
4396 if ( w == 0 ) { error = 1;
goto endofif; }
4399 else if ( ConWord(inp,(UBYTE *)
"coefficient") && ( p - inp ) > 3 ) {
4408 else if ( *p ==
'm' || *p ==
'M' ) {
4409 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4410 while ( !FG.cTable[*++p] );
4412 if ( !StrICmp(inp,(UBYTE *)
"match") ) {
4415 MesPrint(
"&no ( after match");
4426 AT.WorkSpace = AT.WorkPointer = w;
4428 while ( FG.cTable[*ppp] == 0 && ppp < p ) ppp++;
4429 if ( *ppp ==
',' ) AC.idoption = 0;
4430 else AC.idoption = SUBMULTI;
4431 level = CoIdExpression(inp,TYPEIF);
4432 AT.WorkSpace = OldSpace;
4433 AT.WorkPointer = OldWork;
4435 if ( level < 0 ) { error = -1;
goto endofif; }
4441 s = u = C->
lhs[C->numlhs];
4442 while ( u < C->Pointer ) *w++ = *u++;
4448 else if ( !StrICmp(inp,(UBYTE *)
"multipleof") ) {
4449 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4452 MesPrint(
"&no ( after multipleof");
4453 error = 1;
goto endofif;
4456 if ( FG.cTable[*p] != 1 ) {
4457Nomulof: MesPrint(
"&multipleof needs a short positive integer argument");
4458 error = 1;
goto endofif;
4461 if ( *p !=
')' || x <= 0 || x > MAXPOSITIVE )
goto Nomulof;
4463 *w++ = MULTIPLEOF; *w++ = 3; *w++ = (WORD)x;
4468NoGood: MesPrint(
"&Unrecognized word: %s",inp);
4472 if ( c ==
'(' ) SKIPBRA4(p)
4477 else if ( *p ==
'f' || *p ==
'F' ) {
4478 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4479 while ( FG.cTable[*++p] == 0 );
4481 if ( !StrICmp(inp,(UBYTE *)
"findloop") ) {
4484 MesPrint(
"&no ( after findloop");
4490 c = *++p; *p = 0; *inp =
',';
4491 if ( CoFindLoop(inp) ) { error = 1;
goto endofif; }
4492 s = u = C->
lhs[C->numlhs];
4493 while ( u < C->Pointer ) *w++ = *u++;
4496 if ( w == 0 ) { error = 1;
goto endofif; }
4499 else if ( !StrICmp(inp,(UBYTE *)
"flag") ) {
4500 UBYTE cc = c, *pppp;
4503 MesPrint(
"&no ( after flag");
4509 cc = *++p; *p = 0; *inp =
','; pppp = p;
4511 *w++ = IFUSERFLAG; *w++ = 0;
4514 while ( *inp ==
',' ) inp++;
4515 if ( *inp == 0 || *inp ==
')' )
break;
4516 while ( *inp >=
'0' && *inp <=
'9' ) x = 10*x+(*inp++-
'0');
4517 if ( x < 1 || x > BITSINWORD ) {
4518 MesPrint(
"&Flag number %d outside the permitted range 1-%d.",BITSINWORD);
4524 p = pppp; *p = cc; *inp =
'(';
4527 MesPrint(
"&The userflag condition in the if statement needs arguments.");
4535 else if ( *p ==
'e' || *p ==
'E' ) {
4536 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4537 while ( FG.cTable[*++p] == 0 );
4539 if ( !StrICmp(inp,(UBYTE *)
"expression") ) {
4542 MesPrint(
"&no ( after expression");
4546 p++; ww = w; *w++ = IFEXPRESSION; w++;
4547 while ( *p !=
')' ) {
4548 if ( *p ==
',' ) { p++;
continue; }
4549 if ( *p ==
'[' || FG.cTable[*p] == 0 ) {
4552 MesPrint(
"&Improper name for an expression: '%s'",pp);
4557 if ( GetName(AC.exprnames,pp,&number,NOAUTO) == CEXPRESSION ) {
4560 else if ( GetName(AC.varnames,pp,&number,NOAUTO) != NAMENOTFOUND ) {
4561 MesPrint(
"&%s is not an expression",pp);
4568 MesPrint(
"&Illegal object in Expression in if-statement");
4570 while ( *p && *p !=
',' && *p !=
')' ) p++;
4571 if ( *p == 0 || *p ==
')' )
break;
4581 else if ( *p ==
'i' || *p ==
'I' ) {
4582 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4583 while ( FG.cTable[*++p] == 0 );
4585 if ( !StrICmp(inp,(UBYTE *)
"isfactorized") ) {
4588 ww = w; *w++ = IFISFACTORIZED; w++;
4591 p++; ww = w; *w++ = IFISFACTORIZED; w++;
4592 while ( *p !=
')' ) {
4593 if ( *p ==
',' ) { p++;
continue; }
4594 if ( *p ==
'[' || FG.cTable[*p] == 0 ) {
4597 MesPrint(
"&Improper name for an expression: '%s'",pp);
4602 if ( GetName(AC.exprnames,pp,&number,NOAUTO) == CEXPRESSION ) {
4605 else if ( GetName(AC.varnames,pp,&number,NOAUTO) != NAMENOTFOUND ) {
4606 MesPrint(
"&%s is not an expression",pp);
4613 MesPrint(
"&Illegal object in IsFactorized in if-statement");
4615 while ( *p && *p !=
',' && *p !=
')' ) p++;
4616 if ( *p == 0 || *p ==
')' )
break;
4627 else if ( *p ==
'o' || *p ==
'O' ) {
4639 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4640 while ( FG.cTable[*++p] == 0 );
4641 c = cc = *p; *p = 0;
4642 if ( !StrICmp(inp,(UBYTE *)
"occurs") ) {
4646 MesPrint(
"&no ( after occurs");
4652 cc = *++p; *p = 0; *inp =
','; pp = p;
4654 *w++ = IFOCCURS; *w++ = 0;
4656 while ( *inp ==
',' ) inp++;
4657 if ( *inp == 0 || *inp ==
')' )
break;
4663 if ( *inp ==
'[' || FG.cTable[*inp] == 0 ) {
4664 if ( ( p =
SkipAName(inp) ) == 0 )
return(0);
4666 type = GetName(AC.varnames,inp,&c1,WITHAUTO);
4668 if ( type == CVECTOR || type == CDUBIOUS ) {
4672 if ( p == 0 )
return(0);
4675 type = GetName(AC.varnames,inp,&c2,WITHAUTO);
4676 if ( type != CVECTOR && type != CDUBIOUS ) {
4677 MesPrint(
"&Not a vector in dotproduct in if statement: %s",inp);
4680 else type = CDOTPRODUCT;
4683 MesPrint(
"&Illegal use of . after %s in if statement",inp);
4684 if ( type == NAMENOTFOUND )
4685 MesPrint(
"&%s is not a properly declared variable",inp);
4688 while ( *p && *p !=
')' && *p !=
',' ) p++;
4689 if ( *p ==
',' && FG.cTable[p[1]] == 1 ) {
4691 while ( *p && *p !=
')' && *p !=
',' ) p++;
4704 *w++ = c1 + AM.OffsetIndex;
4708 *w++ = c1 + AM.OffsetVector;
4712 *w++ = c1 + AM.OffsetVector;
4713 *w++ = c2 + AM.OffsetVector;
4720 MesPrint(
"&Illegal variable %s in occurs condition in if statement",inp);
4727 MesPrint(
"&Illegal object %s in occurs condition in if statement",inp);
4733 p = pp; *p = cc; *inp =
'(';
4736 MesPrint(
"&The occurs condition in the if statement needs arguments.");
4743 else if ( *p ==
'$' ) {
4744 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4746 while ( FG.cTable[*p] == 0 || FG.cTable[*p] == 1 ) p++;
4748 if ( ( i = GetDollar(inp) ) < 0 ) {
4749 MesPrint(
"&undefined dollar expression %s",inp);
4751 i = AddDollar(inp,DOLUNDEFINED,0,0);
4754 *w++ = IFDOLLAR; *w++ = 3; *w++ = i;
4760 if ( ( w = GetIfDollarFactor(&p,w) ) == 0 ) {
4764 else if ( *p !=
']' ) {
4774 else if ( *p ==
'.' ) {
4775 pp = CheckFloat(p,&spec);
4776 if ( pp > p )
goto HaveFloat;
4779 else if ( *p ==
'(' ) {
4781 MesCerr(
"parenthesis",p);
4786 if ( ++lenlev >= AC.MaxIf ) DoubleIfBuffers();
4787 AC.IfCount[lenpp++] = w-OldWork;
4792 else if ( *p ==
')' ) {
4793 if ( gotexp == 0 ) { MesCerr(
"position for )",p); error = 1; }
4795 u = AC.IfCount[--lenpp]+OldWork;
4798 if ( lenlev <= 0 ) {
4799 AT.WorkSpace = OldSpace;
4800 AT.WorkPointer = OldWork;
4804 MesPrint(
"&unmatched parenthesis in if/while ()");
4806 while ( *++p ==
')' );
4809 level = CompileStatement(p);
4810 if ( level ) error = level;
4812 if ( CoEndIf(p) && error == 0 ) error = 1;
4818 else if ( *p ==
'>' ) {
4819 if ( gotexp == 0 )
goto NoExp;
4820 if ( p[1] ==
'=' ) { *w++ = GREATEREQUAL; *w++ = 2; p += 2; }
4821 else { *w++ = GREATER; *w++ = 2; p++; }
4824 else if ( *p ==
'<' ) {
4825 if ( gotexp == 0 )
goto NoExp;
4826 if ( p[1] ==
'=' ) { *w++ = LESSEQUAL; *w++ = 2; p += 2; }
4827 else { *w++ = LESS; *w++ = 2; p++; }
4830 else if ( *p ==
'=' ) {
4831 if ( gotexp == 0 )
goto NoExp;
4832 if ( p[1] ==
'=' ) p++;
4833 *w++ = EQUAL; *w++ = 2; p++;
4836 else if ( *p ==
'!' && p[1] ==
'=' ) {
4837 if ( gotexp == 0 ) { p++;
goto NoExp; }
4838 *w++ = NOTEQUAL; *w++ = 2; p += 2;
4841 else if ( *p ==
'|' && p[1] ==
'|' ) {
4842 if ( gotexp == 0 ) { p++;
goto NoExp; }
4843 *w++ = ORCOND; *w++ = 2; p += 2;
4846 else if ( *p ==
'&' && p[1] ==
'&' ) {
4847 if ( gotexp == 0 ) {
4850 MesCerr(
"sequence",p);
4854 *w++ = ANDCOND; *w++ = 2; p += 2;
4858 else if ( *p == 0 ) {
4859 MesPrint(
"&Unmatched parentheses");
4864 if ( FG.cTable[*p] == 0 ) {
4867 while ( ( ij = FG.cTable[*++p] ) == 0 || ij == 1 );
4871 MesCerr(
"sequence",p);
4888 CBUF *C = cbuf+AC.cbufnum;
4890 while ( *p ==
',' ) p++;
4891 if ( tolower(*p) ==
'i' && tolower(p[1]) ==
'f' && p[2] ==
'(' )
4892 return(CoElseIf(p+2));
4893 MesPrint(
"&No extra text allowed as part of an else statement");
4896 if ( AC.IfLevel <= 0 ) { MesPrint(
"&else statement without if");
return(1); }
4897 if ( AC.IfSumCheck[AC.IfLevel-1] != NestingChecksum() - 1 ) {
4901 Add3Com(TYPEELSE,AC.IfLevel)
4902 C->Buffer[AC.IfStack[-1]] = C->numlhs;
4903 AC.IfStack[-1] = C->Pointer - C->Buffer - 1;
4912int CoElseIf(UBYTE *inp)
4914 CBUF *C = cbuf+AC.cbufnum;
4915 if ( AC.IfLevel <= 0 ) { MesPrint(
"&elseif statement without if");
return(1); }
4916 Add3Com(TYPEELSE,-AC.IfLevel)
4918 C->Buffer[*--AC.IfStack] = C->numlhs;
4939int CoEndIf(UBYTE *inp)
4941 CBUF *C = cbuf+AC.cbufnum;
4942 WORD i = C->numlhs, to, k = -AC.IfLevel;
4944 while ( *inp ==
',' ) inp++;
4947 MesPrint(
"&No extra text allowed as part of an endif/elseif statement");
4949 if ( AC.IfLevel <= 0 ) {
4950 MesPrint(
"&Endif statement without corresponding if");
return(1);
4953 C->
Buffer[*--AC.IfStack] = i+1;
4954 if ( AC.IfSumCheck[AC.IfLevel] != NestingChecksum() ) {
4958 Add3Com(TYPEENDIF,i+1)
4964 if ( C->
lhs[i][0] == TYPEELSE && C->
lhs[i][2] == to ) to = i;
4965 if ( C->
lhs[i][0] == TYPEIF ) {
4966 if ( C->
lhs[i][2] == to ) {
4968 if ( i <= 0 || C->lhs[i][0] != TYPEELSE
4969 || C->
lhs[i][2] != k )
break;
4970 C->
lhs[i][2] = C->numlhs;
4984int CoWhile(UBYTE *inp)
4986 CBUF *C = cbuf+AC.cbufnum;
4987 WORD startnum = C->numlhs + 1;
4991 if ( C->numlhs > startnum && C->
lhs[startnum][2] == C->numlhs
4992 && C->
lhs[C->numlhs][0] == TYPEENDIF ) {
4993 C->
lhs[C->numlhs][2] = startnum-1;
4996 else C->
lhs[startnum][2] = startnum;
5005int CoEndWhile(UBYTE *inp)
5009 CBUF *C = cbuf+AC.cbufnum;
5010 if ( AC.WhileLevel <= 0 ) {
5011 MesPrint(
"&EndWhile statement without corresponding While");
return(1);
5014 i = C->
Buffer[AC.IfStack[-1]];
5015 error = CoEndIf(inp);
5016 C->
lhs[C->numlhs][2] = i - 1;
5027static char *messfind[] = {
5028 "Findloop(function,arguments=#,loopsize(=#|<#)[,include=index])"
5029 ,
"Replaceloop,function,arguments=#,loopsize(=#|<#),outfun=function[,include=index]"
5031static WORD comfindloop[7] = { TYPEFINDLOOP,7,0,0,0,0,0 };
5033int DoFindLoop(UBYTE *inp,
int mode)
5036 WORD funnum, nargs = 0, nloop = 0, indexnum = 0, outfun = 0;
5037 int type, aflag, lflag, indflag, outflag, error = 0, sym;
5038 while ( *inp ==
',' ) inp++;
5041 MesPrint(
"&Proper syntax is:");
5042 MesPrint(
"%s",messfind[mode]);
5046 if ( ( ( type = GetName(AC.varnames,inp,&funnum,WITHAUTO) ) == NAMENOTFOUND )
5047 || type != CFUNCTION || ( ( sym = (functions[funnum].symmetric) & ~REVERSEORDER )
5048 != SYMMETRIC && sym != ANTISYMMETRIC ) ) {
5049 MesPrint(
"&%s should be a (anti)symmetric function or tensor",inp);
5054 aflag = lflag = indflag = outflag = 0;
5055 while ( *inp ==
',' ) {
5056 while ( *inp ==
',' ) inp++;
5058 if ( ( s =
SkipAName(inp) ) == 0 )
goto syntax;
5060 if ( StrICont(inp,(UBYTE *)
"arguments") == 0 ) {
5061 if ( c !=
'=' )
goto syntax;
5063 NeedNumber(nargs,s,syntax)
5067 else if ( StrICont(inp,(UBYTE *)
"loopsize") == 0 ) {
5068 if ( c !=
'=' && c !=
'<' )
goto syntax;
5070 if ( FG.cTable[*s] == 1 ) {
5071 NeedNumber(nloop,s,syntax)
5073 MesPrint(
"&loopsize should be at least 2");
5076 if ( c ==
'<' ) nloop = -nloop;
5078 else if ( tolower(*s) ==
'a' && tolower(s[1]) ==
'l'
5079 && tolower(s[2]) ==
'l' && FG.cTable[s[3]] > 1 ) {
5081 if ( c !=
'=' )
goto syntax;
5086 else if ( StrICont(inp,(UBYTE *)
"include") == 0 ) {
5087 if ( c !=
'=' )
goto syntax;
5089 if ( ( inp =
SkipAName(s) ) == 0 )
goto syntax;
5091 if ( ( type = GetName(AC.varnames,s,&indexnum,WITHAUTO) ) != CINDEX ) {
5092 MesPrint(
"&%s is not a proper index",s);
5095 else if ( indexnum < WILDOFFSET
5096 && indices[indexnum].dimension == 0 ) {
5097 MesPrint(
"&%s should be a summable index",s);
5100 indexnum += AM.OffsetIndex;
5104 else if ( StrICont(inp,(UBYTE *)
"outfun") == 0 ) {
5105 if ( c !=
'=' )
goto syntax;
5107 if ( ( inp =
SkipAName(s) ) == 0 )
goto syntax;
5109 if ( ( type = GetName(AC.varnames,s,&outfun,WITHAUTO) ) != CFUNCTION ) {
5110 MesPrint(
"&%s is not a proper function or tensor",s);
5118 MesPrint(
"&Unrecognized option in FindLoop or ReplaceLoop: %s",inp);
5121 while ( *inp && *inp !=
',' ) inp++;
5124 if ( *inp != 0 && mode == REPLACELOOP )
goto syntax;
5125 if ( mode == FINDLOOP && outflag > 0 ) {
5126 MesPrint(
"&outflag option is illegal in FindLoop");
5129 if ( mode == REPLACELOOP && outflag == 0 )
goto syntax;
5130 if ( aflag == 0 || lflag == 0 )
goto syntax;
5131 comfindloop[3] = funnum;
5132 comfindloop[4] = nloop;
5133 comfindloop[5] = nargs;
5134 comfindloop[6] = outfun;
5137 if ( mode == 0 ) comfindloop[2] = indexnum + 5;
5138 else comfindloop[2] = -indexnum - 5;
5140 else comfindloop[2] = mode;
5141 AddNtoL(comfindloop[1],comfindloop);
5150int CoFindLoop(UBYTE *inp)
5151{
return(DoFindLoop(inp,FINDLOOP)); }
5158int CoReplaceLoop(UBYTE *inp)
5160 int error = DoFindLoop(inp,REPLACELOOP);
5172static UBYTE *FunPowOptions[] = {
5173 (UBYTE *)
"nofunpowers"
5174 ,(UBYTE *)
"commutingonly"
5175 ,(UBYTE *)
"allfunpowers"
5178int CoFunPowers(UBYTE *inp)
5181 int i, maxoptions =
sizeof(FunPowOptions)/
sizeof(UBYTE *);
5182 while ( *inp ==
',' ) inp++;
5184 inp =
SkipAName(inp); c = *inp; *inp = 0;
5185 for ( i = 0; i < maxoptions; i++ ) {
5186 if ( StrICont(option,FunPowOptions[i]) == 0 ) {
5189 MesPrint(
"&Illegal FunPowers statement");
5196 MesPrint(
"&Illegal option in FunPowers statement: %s",option);
5205int CoUnitTrace(UBYTE *s)
5208 if ( FG.cTable[*s] == 1 ) {
5211nogood: MesPrint(
"&Value of UnitTrace should be a (positive) number or a symbol");
5214 AC.lUniTrace[0] = SNUMBER;
5215 AC.lUniTrace[2] = num;
5218 if ( GetName(AC.varnames,s,&num,WITHAUTO) == CSYMBOL ) {
5219 AC.lUniTrace[0] = SYMBOL;
5220 AC.lUniTrace[2] = num;
5225 if ( *s )
goto nogood;
5227 AC.lUnitTrace = num;
5243 WORD *w = AT.WorkPointer;
5245 while ( *s ==
',' ) s++;
5247 MesPrint(
"&Illegal syntax for Term statement");
5250 if ( AC.termlevel+1 >= AC.maxtermlevel ) {
5251 if ( AC.maxtermlevel <= 0 ) {
5252 AC.maxtermlevel = 20;
5253 AC.termstack = (LONG *)Malloc1(AC.maxtermlevel*
sizeof(LONG),
"termstack");
5254 AC.termsortstack = (LONG *)Malloc1(AC.maxtermlevel*
sizeof(LONG),
"termsortstack");
5255 AC.termsumcheck = (WORD *)Malloc1(AC.maxtermlevel*
sizeof(WORD),
"termsumcheck");
5258 DoubleBuffer((
void **)AC.termstack,(
void **)AC.termstack+AC.maxtermlevel,
5259 sizeof(LONG),
"doubling termstack");
5260 DoubleBuffer((
void **)AC.termsortstack,
5261 (
void **)AC.termsortstack+AC.maxtermlevel,
5262 sizeof(LONG),
"doubling termsortstack");
5263 DoubleBuffer((
void **)AC.termsumcheck,
5264 (
void **)AC.termsumcheck+AC.maxtermlevel,
5265 sizeof(LONG),
"doubling termsumcheck");
5266 AC.maxtermlevel *= 2;
5269 AC.termsumcheck[AC.termlevel] = NestingChecksum();
5270 AC.termstack[AC.termlevel] = cbuf[AC.cbufnum].Pointer
5271 - cbuf[AC.cbufnum].Buffer + 2;
5272 AC.termsortstack[AC.termlevel] = AC.termstack[AC.termlevel] + 1;
5276 *w++ = cbuf[AC.cbufnum].numlhs;
5277 *w++ = cbuf[AC.cbufnum].numlhs;
5278 AT.WorkPointer[1] = w - AT.WorkPointer;
5279 AddNtoL(AT.WorkPointer[1],AT.WorkPointer);
5288int CoEndTerm(UBYTE *s)
5290 CBUF *C = cbuf+AC.cbufnum;
5291 while ( *s ==
',' ) s++;
5293 MesPrint(
"&Illegal syntax for EndTerm statement");
5296 if ( AC.termlevel <= 0 ) {
5297 MesPrint(
"&EndTerm without corresponding Argument statement");
5301 cbuf[AC.cbufnum].Buffer[AC.termstack[AC.termlevel]] = C->numlhs;
5302 cbuf[AC.cbufnum].Buffer[AC.termsortstack[AC.termlevel]] = C->numlhs;
5303 if ( AC.termsumcheck[AC.termlevel] != NestingChecksum() ) {
5318 WORD *w = AT.WorkPointer;
5320 while ( *s ==
',' ) s++;
5322 MesPrint(
"&Illegal syntax for Sort statement");
5325 if ( AC.termlevel <= 0 ) {
5326 MesPrint(
"&The Sort statement can only be used inside a term environment");
5329 if ( error )
return(error);
5333 cbuf[AC.cbufnum].Buffer[AC.termsortstack[AC.termlevel-1]] =
5334 *w = cbuf[AC.cbufnum].numlhs+1;
5336 AC.termsortstack[AC.termlevel-1] = cbuf[AC.cbufnum].Pointer
5337 - cbuf[AC.cbufnum].Buffer + 3;
5338 if ( AC.termsumcheck[AC.termlevel-1] != NestingChecksum() - 1 ) {
5342 AT.WorkPointer[1] = w - AT.WorkPointer;
5343 AddNtoL(AT.WorkPointer[1],AT.WorkPointer);
5354int CoPolyFun(UBYTE *s)
5358 int type, error = 0;
5360 AR.PolyFun = AC.lPolyFun = 0;
5361 AR.PolyFunInv = AC.lPolyFunInv = 0;
5362 AR.PolyFunType = AC.lPolyFunType = 0;
5363 AR.PolyFunExp = AC.lPolyFunExp = 0;
5364 AR.PolyFunVar = AC.lPolyFunVar = 0;
5365 AR.PolyFunPow = AC.lPolyFunPow = 0;
5366 if ( *s == 0 ) {
return(0); }
5368 if ( t == 0 || *t != 0 ) {
5369 MesPrint(
"&PolyFun statement needs a single commuting function for its argument");
5372 if ( ( ( type = GetName(AC.varnames,s,&numfun,WITHAUTO) ) != CFUNCTION )
5373 || ( functions[numfun].spec != 0 ) || ( functions[numfun].commute != 0 ) ) {
5374 MesPrint(
"&%s should be a regular commuting function",s);
5376 if ( GetName(AC.exprnames,s,&numfun,NOAUTO) == NAMENOTFOUND )
5377 AddFunction(s,0,0,0,0,0,-1,-1);
5382 AR.PolyFun = AC.lPolyFun = numfun+FUNCTION;
5383 AR.PolyFunType = AC.lPolyFunType = 1;
5386 if ( mpfaux_ != 0 ) {
5387 MesPrint(
"&Simultaneous use of PolyFun and float_ is not allowed.");
5401int CoPolyRatFun(UBYTE *s)
5405 int type, error = 0;
5407 AR.PolyFun = AC.lPolyFun = 0;
5408 AR.PolyFunInv = AC.lPolyFunInv = 0;
5409 AR.PolyFunType = AC.lPolyFunType = 0;
5410 AR.PolyFunExp = AC.lPolyFunExp = 0;
5411 AR.PolyFunVar = AC.lPolyFunVar = 0;
5412 AR.PolyFunPow = AC.lPolyFunPow = 0;
5413 if ( *s == 0 )
return(error);
5415 if ( t == 0 )
goto NumErr;
5418 if ( mpfaux_ != 0 ) {
5419 MesPrint(
"&Simultaneous use of PolyFun and float_ is not allowed.");
5423 if ( ( ( type = GetName(AC.varnames,s,&numfun,WITHAUTO) ) != CFUNCTION )
5424 || ( functions[numfun].spec != 0 ) || ( functions[numfun].commute != 0 ) ) {
5425 MesPrint(
"&%s should be a regular commuting function",s);
5427 if ( GetName(AC.exprnames,s,&numfun,NOAUTO) == NAMENOTFOUND )
5428 AddFunction(s,0,0,0,0,0,-1,-1);
5432 AR.PolyFun = AC.lPolyFun = numfun+FUNCTION;
5433 AR.PolyFunInv = AC.lPolyFunInv = 0;
5434 AR.PolyFunType = AC.lPolyFunType = 2;
5435 AC.PolyRatFunChanged = 1;
5436 if ( c == 0 )
return(error);
5438 if ( *t ==
'-' ) { AC.PolyRatFunChanged = 0; t++; }
5439 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5440 if ( *t == 0 )
return(error);
5444 if ( t == 0 )
goto NumErr;
5446 if ( ( ( type = GetName(AC.varnames,s,&numfun,WITHAUTO) ) != CFUNCTION )
5447 || ( functions[numfun].spec != 0 ) || ( functions[numfun].commute != 0 ) ) {
5448 MesPrint(
"&%s should be a regular commuting function",s);
5450 if ( GetName(AC.exprnames,s,&numfun,NOAUTO) == NAMENOTFOUND )
5451 AddFunction(s,0,0,0,0,0,-1,-1);
5455 AR.PolyFunInv = AC.lPolyFunInv = numfun+FUNCTION;
5456 if ( c == 0 )
return(error);
5458 if ( *t ==
'-' ) { AC.PolyRatFunChanged = 0; t++; }
5459 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5460 if ( *t == 0 )
return(error);
5464 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5472 if ( t == 0 )
goto NumErr;
5474 if ( ( StrICmp(s,(UBYTE *)
"divergence") == 0 )
5475 || ( StrICmp(s,(UBYTE *)
"finddivergence") == 0 ) ) {
5477 MesPrint(
"&Illegal option field in PolyRatFun statement.");
5481 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5484 if ( t == 0 )
goto NumErr;
5486 if ( ( type = GetName(AC.varnames,s,&AC.lPolyFunVar,WITHAUTO) ) != CSYMBOL ) {
5487 MesPrint(
"&Illegal symbol %s in option field in PolyRatFun statement.",s);
5491 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5493 MesPrint(
"&Illegal termination of option in PolyRatFun statement.");
5496 AR.PolyFunExp = AC.lPolyFunExp = 1;
5497 AR.PolyFunVar = AC.lPolyFunVar;
5498 symbols[AC.lPolyFunVar].minpower = -MAXPOWER;
5499 symbols[AC.lPolyFunVar].maxpower = MAXPOWER;
5501 else if ( StrICmp(s,(UBYTE *)
"expand") == 0 ) {
5502 WORD x = 0, etype = 2;
5504 MesPrint(
"&Illegal option field in PolyRatFun statement.");
5508 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5511 if ( t == 0 )
goto NumErr;
5513 if ( ( type = GetName(AC.varnames,s,&AC.lPolyFunVar,WITHAUTO) ) != CSYMBOL ) {
5514 MesPrint(
"&Illegal symbol %s in option field in PolyRatFun statement.",s);
5518 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5519 if ( *t >
'9' || *t <
'0' ) {
5520 MesPrint(
"&Illegal option field in PolyRatFun statement.");
5523 while ( *t <=
'9' && *t >=
'0' ) x = 10*x + *t++ -
'0';
5524 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5528 if ( t == 0 )
goto ParErr;
5530 if ( StrICmp(s,(UBYTE *)
"fixed") == 0 ) {
5533 else if ( StrICmp(s,(UBYTE *)
"relative") == 0 ) {
5537 MesPrint(
"&Illegal termination of option in PolyRatFun statement.");
5541 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5543 MesPrint(
"&Illegal termination of option in PolyRatFun statement.");
5547 AR.PolyFunExp = AC.lPolyFunExp = etype;
5548 AR.PolyFunVar = AC.lPolyFunVar;
5549 AR.PolyFunPow = AC.lPolyFunPow = x;
5550 symbols[AC.lPolyFunVar].minpower = -MAXPOWER;
5551 symbols[AC.lPolyFunVar].maxpower = MAXPOWER;
5554ParErr: MesPrint(
"&Illegal option %s in PolyRatFun statement.",s);
5558 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5559 if ( *t == 0 )
return(error);
5562 MesPrint(
"&PolyRatFun statement needs one or two commuting function(s) for its argument(s)");
5571int CoMerge(UBYTE *inp)
5575 WORD numfunc, option = 0;
5576 if ( tolower(s[0]) ==
'o' && tolower(s[1]) ==
'n' && tolower(s[2]) ==
'c' &&
5577 tolower(s[3]) ==
'e' && tolower(s[4]) ==
',' ) {
5580 else if ( tolower(s[0]) ==
'a' && tolower(s[1]) ==
'l' && tolower(s[2]) ==
'l' &&
5581 tolower(s[3]) ==
',' ) {
5585 if ( ( type = GetName(AC.dollarnames,s+1,&numfunc,NOAUTO) ) == CDOLLAR )
5588 MesPrint(
"&%s is undefined",s);
5589 numfunc = AddDollar(s+1,DOLINDEX,&one,1);
5594 MesPrint(
"&Merge/shuffle should have a single function or $variable for its argument");
5598 else if ( ( type = GetName(AC.varnames,s,&numfunc,WITHAUTO) ) == CFUNCTION ) {
5599 numfunc += FUNCTION;
5602 else if ( type != -1 ) {
5603 if ( type != CDUBIOUS ) {
5604 NameConflict(type,s);
5605 type = MakeDubious(AC.varnames,s,&numfunc);
5610 MesPrint(
"&%s is not a function",s);
5611 numfunc = AddFunction(s,0,0,0,0,0,-1,-1) + FUNCTION;
5614 Add4Com(TYPEMERGE,numfunc,option);
5627int CoStuffle(UBYTE *inp)
5629 UBYTE *s = inp, *ss, c;
5631 WORD numfunc, option = 0;
5632 if ( tolower(s[0]) ==
'o' && tolower(s[1]) ==
'n' && tolower(s[2]) ==
'c' &&
5633 tolower(s[3]) ==
'e' && tolower(s[4]) ==
',' ) {
5636 else if ( tolower(s[0]) ==
'a' && tolower(s[1]) ==
'l' && tolower(s[2]) ==
'l' &&
5637 tolower(s[3]) ==
',' ) {
5643 if ( ( type = GetName(AC.dollarnames,s+1,&numfunc,NOAUTO) ) == CDOLLAR )
5646 MesPrint(
"&%s is undefined",s);
5647 numfunc = AddDollar(s+1,DOLINDEX,&one,1);
5651 if ( *ss !=
'+' && *ss !=
'-' && ss[1] != 0 ) {
5652 MesPrint(
"&Stuffle should have a single function or $variable for its argument, followed by either + or -");
5655 if ( *ss ==
'-' ) option += 2;
5657 else if ( ( type = GetName(AC.varnames,s,&numfunc,WITHAUTO) ) == CFUNCTION ) {
5658 numfunc += FUNCTION;
5661 else if ( type != -1 ) {
5662 if ( type != CDUBIOUS ) {
5663 NameConflict(type,s);
5664 type = MakeDubious(AC.varnames,s,&numfunc);
5669 MesPrint(
"&%s is not a function",s);
5670 numfunc = AddFunction(s,0,0,0,0,0,-1,-1) + FUNCTION;
5673 Add4Com(TYPESTUFFLE,numfunc,option);
5682int CoProcessBucket(UBYTE *s)
5685 while ( *s ==
',' || *s ==
'=' ) s++;
5687 if ( *s && *s !=
' ' && *s !=
'\t' ) {
5688 MesPrint(
"&Numerical value expected for ProcessBucketSize");
5691 AC.ProcessBucketSize = x;
5700int CoThreadBucket(UBYTE *s)
5703 while ( *s ==
',' || *s ==
'=' ) s++;
5705 if ( *s && *s !=
' ' && *s !=
'\t' ) {
5706 MesPrint(
"&Numerical value expected for ThreadBucketSize");
5710 Warning(
"Negative of zero value not allowed for ThreadBucketSize. Adjusted to 1.");
5713 AC.ThreadBucketSize = x;
5715 if ( AS.MultiThreaded ) MakeThreadBuckets(-1,1);
5730int DoArgPlode(UBYTE *s,
int par)
5733 WORD numfunc, type, error = 0, *w, n;
5739 while ( *s ==
',' ) s++;
5742 MesPrint(
"&We don't do dollar variables yet in ArgImplode/ArgExplode");
5746 if ( ( s =
SkipAName(s) ) == 0 )
return(1);
5748 if ( ( type = GetName(AC.varnames,t,&numfunc,WITHAUTO) ) == CFUNCTION ) {
5749 numfunc += FUNCTION;
5751 else if ( type != -1 ) {
5752 if ( type != CDUBIOUS ) {
5753 NameConflict(type,t);
5754 type = MakeDubious(AC.varnames,t,&numfunc);
5759 MesPrint(
"&%s is not a function",t);
5760 numfunc = AddFunction(s,0,0,0,0,0,-1,-1) + FUNCTION;
5767 for ( i = 2; i < FUNHEAD; i++ ) *w++ = 0;
5769 if ( *s && *s !=
',' ) {
5770 MesPrint(
"&Illegal character in ArgImplode/ArgExplode statement: %s",s);
5773 while ( *s ==
',' ) s++;
5775 n = w - AT.WorkPointer;
5776 AT.WorkPointer[1] = n;
5786int CoArgExplode(UBYTE *s) {
return(DoArgPlode(s,TYPEARGEXPLODE)); }
5793int CoArgImplode(UBYTE *s) {
return(DoArgPlode(s,TYPEARGIMPLODE)); }
5800int CoClearTable(UBYTE *s)
5803 int j, type, error = 0;
5807 MesPrint(
"&The ClearTable statement needs at least one (table) argument.");
5814 if ( ( ( type = GetName(AC.varnames,t,&numfun,WITHAUTO) ) != CFUNCTION )
5815 && type != CDUBIOUS ) {
5816nofunc: MesPrint(
"&%s is not a table",t);
5818 if ( type < 0 ) numfun = AddFunction(t,0,0,0,0,0,-1,-1);
5820 if ( *s ==
',' ) s++;
5827 else if ( ( T = functions[numfun].tabl ) == 0 )
goto nofunc;
5830 if ( *s ==
',' ) s++;
5866 if ( TT->
mm ) M_free(TT->
mm,
"tableminmax");
5867 if ( TT->
flags ) M_free(TT->
flags,
"tableflags");
5882int CoDenominators(UBYTE *s)
5887 if ( t == 0 )
goto syntaxerror;
5888 t1 = t;
while ( *t1 ==
',' || *t1 ==
' ' || *t1 ==
'\t' ) t1++;
5889 if ( *t1 )
goto syntaxerror;
5891 if ( ( ( type = GetName(AC.varnames,s,&numfun,WITHAUTO) ) != CFUNCTION )
5892 || ( functions[numfun].spec != 0 ) ) {
5894 if ( GetName(AC.exprnames,s,&numfun,NOAUTO) == NAMENOTFOUND )
5895 AddFunction(s,0,0,0,0,0,-1,-1);
5899 Add3Com(TYPEDENOMINATORS,numfun+FUNCTION);
5902 MesPrint(
"&Denominators statement needs one regular function for its argument");
5911int CoDropCoefficient(UBYTE *s)
5914 Add2Com(TYPEDROPCOEFFICIENT)
5917 MesPrint(
"&Illegal argument in DropCoefficient statement: '%s'",s);
5925int CoDropSymbols(UBYTE *s)
5928 Add2Com(TYPEDROPSYMBOLS)
5931 MesPrint(
"&Illegal argument in DropSymbols statement: '%s'",s);
5948int CoToPolynomial(UBYTE *inp)
5951 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
5952 if ( ( AC.topolynomialflag & ~TOPOLYNOMIALFLAG ) != 0 ) {
5953 MesPrint(
"&ToPolynomial statement and FactArg statement are not allowed in the same module");
5956 if ( AO.OptimizeResult.code != NULL ) {
5957 MesPrint(
"&Using ToPolynomial statement when there are still optimization results active.");
5958 MesPrint(
"&Please use #ClearOptimize instruction first.");
5959 MesPrint(
"&This will loose the optimized expression.");
5963 Add3Com(TYPETOPOLYNOMIAL,DOALL)
5967 WORD *funnums = 0, type, num;
5970 if ( s == 0 )
return(1);
5972 if ( StrICmp(inp,(UBYTE *)
"onlyfunctions") ) {
5973 MesPrint(
"&Illegal option %s in ToPolynomial statement",inp);
5979 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
5985 funnums = (WORD *)Malloc1(((LONG)(s-inp)+3)*
sizeof(WORD),
"ToPlynomial");
5988 if ( s == 0 )
return(1);
5990 type = GetName(AC.varnames,inp,&num,WITHAUTO);
5991 if ( type != CFUNCTION ) {
5992 MesPrint(
"&%s is not a function in ToPolynomial statement",inp);
5995 funnums[3+numargs++] = num+FUNCTION;
5998 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
6000 funnums[0] = TYPETOPOLYNOMIAL;
6001 funnums[1] = numargs+3;
6002 funnums[2] = ONLYFUNCTIONS;
6005 if ( funnums ) M_free(funnums,
"ToPolynomial");
6007 AC.topolynomialflag |= TOPOLYNOMIALFLAG;
6010 AC.mparallelflag |= NOPARALLEL_CONVPOLY;
6023int CoFromPolynomial(UBYTE *inp)
6025 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
6027 if ( AO.OptimizeResult.code != NULL ) {
6028 MesPrint(
"&Using FromPolynomial statement when there are still optimization results active.");
6029 MesPrint(
"&Please use #ClearOptimize instruction first.");
6030 MesPrint(
"&This will loose the optimized expression.");
6033 Add2Com(TYPEFROMPOLYNOMIAL)
6036 MesPrint(
"&Illegal argument in FromPolynomial statement: '%s'",inp);
6049int CoArgToExtraSymbol(UBYTE *s)
6051 CBUF *C = cbuf + AC.cbufnum;
6055 if ( ( AC.topolynomialflag & ~TOPOLYNOMIALFLAG ) != 0 ) {
6056 MesPrint(
"&ArgToExtraSymbol statement and FactArg statement are not allowed in the same module");
6059 if ( AO.OptimizeResult.code != NULL ) {
6060 MesPrint(
"&Using ArgToExtraSymbol statement when there are still optimization results active.");
6061 MesPrint(
"&Please use #ClearOptimize instruction first.");
6062 MesPrint(
"&This will loose the optimized expression.");
6067 int tonumber = ConsumeOption(&s,
"tonumber");
6069 int ret = DoArgument(s,TYPEARGTOEXTRASYMBOL);
6070 if ( ret )
return(ret);
6076 lhs = C->
lhs[C->numlhs];
6077 if ( lhs[4] != 1 ) {
6078 Warning(
"scale parameter (^n) is ignored in ArgToExtraSymbol");
6082 AC.topolynomialflag |= TOPOLYNOMIALFLAG;
6088 AC.mparallelflag |= NOPARALLEL_CONVPOLY;
6099int CoExtraSymbols(UBYTE *inp)
6101 UBYTE *arg1, *arg2, c, *s;
6102 WORD i, j, type, number;
6103 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
6104 if ( FG.cTable[*inp] != 0 ) {
6105 MesPrint(
"&Illegal argument in ExtraSymbols statement: '%s'",inp);
6109 while ( FG.cTable[*inp] == 0 ) inp++;
6111 if ( ( StrICmp(arg1,(UBYTE *)
"array") == 0 )
6112 || ( StrICmp(arg1,(UBYTE *)
"vector") == 0 ) ) {
6113 AC.extrasymbols = 1;
6115 else if ( StrICmp(arg1,(UBYTE *)
"underscore") == 0 ) {
6116 AC.extrasymbols = 0;
6124 MesPrint(
"&Illegal keyword in ExtraSymbols statement: '%s'",arg1);
6128 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
6129 if ( FG.cTable[*inp] != 0 ) {
6130 MesPrint(
"&Illegal argument in ExtraSymbols statement: '%s'",inp);
6134 while ( FG.cTable[*inp] <= 1 ) inp++;
6136 MesPrint(
"&Illegal end of ExtraSymbols statement: '%s'",inp);
6143 if ( AC.extrasymbols == 1 ) {
6144 type = GetName(AC.varnames,arg2,&number,NOAUTO);
6145 if ( type != NAMENOTFOUND ) {
6146 MesPrint(
"&ExtraSymbols statement: '%s' has already been declared before",arg2);
6150 else if ( AC.extrasymbols == 0 ) {
6151 if ( *arg2 ==
'N' ) {
6153 while ( FG.cTable[*s] == 1 ) s++;
6155 MesPrint(
"&ExtraSymbols statement: '%s' creates conflicts with summed indices",arg2);
6160 if ( AC.extrasym ) { M_free(AC.extrasym,
"extrasym"); AC.extrasym = 0; }
6162 AC.extrasym = (UBYTE *)Malloc1(i*
sizeof(UBYTE),
"extrasym");
6163 for ( j = 0; j < i; j++ ) AC.extrasym[j] = arg2[j];
6172WORD *GetIfDollarFactor(UBYTE **inp, WORD *w)
6178 if ( FG.cTable[*s] == 1 ) {
6180 while ( FG.cTable[*s] == 1 ) {
6181 x = 10*x + *s++ -
'0';
6182 if ( x >= MAXPOSITIVE ) {
6183 MesPrint(
"&Value in dollar factor too large");
6184 while ( FG.cTable[*s] == 1 ) s++;
6189 *w++ = IFDOLLAREXTRA;
6196 MesPrint(
"&Factor indicator for $-variable should be a number or a $-variable.");
6200 while ( FG.cTable[*s] < 2 ) s++;
6202 if ( GetName(AC.dollarnames,name,&number,NOAUTO) == NAMENOTFOUND ) {
6203 MesPrint(
"&dollar in if statement should have been defined previously");
6207 *w++ = IFDOLLAREXTRA;
6213 if ( ( w = GetIfDollarFactor(inp,w) ) == 0 )
return(0);
6216 MesPrint(
"&unmatched [] in $ in if statement");
6230UBYTE *GetDoParam(UBYTE *inp, WORD **wp,
int par)
6235 if ( FG.cTable[*inp] == 1 ) {
6237 while ( *inp >=
'0' && *inp <=
'9' ) {
6238 x = 10*x + *inp++ -
'0';
6239 if ( x > MAXPOSITIVE ) {
6241 MesPrint(
"&Value in dollar factor too large");
6244 MesPrint(
"&Value in do loop boundaries too large");
6246 while ( FG.cTable[*inp] == 1 ) inp++;
6255 *(*wp)++ = DOLLAREXPR2;
6256 *(*wp)++ = -((WORD)x)-1;
6260 if ( *inp !=
'$' ) {
6264 while ( FG.cTable[*inp] < 2 ) inp++;
6266 if ( GetName(AC.dollarnames,name,&number,NOAUTO) == NAMENOTFOUND ) {
6268 MesPrint(
"&dollar in print statement should have been defined previously");
6271 MesPrint(
"&dollar in do loop boundaries should have been defined previously");
6277 *(*wp)++ = DOLLAREXPRESSION;
6281 *(*wp)++ = DOLLAREXPR2;
6286 inp = GetDoParam(inp,wp,0);
6287 if ( inp == 0 )
return(0);
6288 if ( *inp !=
']' ) {
6290 MesPrint(
"&unmatched [] in $ in print statement");
6293 MesPrint(
"&unmatched [] in do loop boundaries");
6310 CBUF *C = cbuf+AC.cbufnum;
6314 if ( AC.doloopstack == 0 ) {
6315 AC.doloopstacksize = 20;
6316 AC.doloopstack = (WORD *)Malloc1(AC.doloopstacksize*2*
sizeof(WORD),
"doloop stack");
6317 AC.doloopnest = AC.doloopstack + AC.doloopstacksize;
6319 if ( AC.dolooplevel >= AC.doloopstacksize ) {
6320 WORD *newstack, *newnest, newsize;
6321 newsize = AC.doloopstacksize * 2;
6322 newstack = (WORD *)Malloc1(newsize*2*
sizeof(WORD),
"doloop stack");
6323 newnest = newstack + newsize;
6324 for ( i = 0; i < newsize; i++ ) {
6325 newstack[i] = AC.doloopstack[i];
6326 newnest[i] = AC.doloopnest[i];
6328 M_free(AC.doloopstack,
"doloop stack");
6329 AC.doloopstack = newstack;
6330 AC.doloopnest = newnest;
6331 AC.doloopstacksize = newsize;
6333 AC.doloopnest[AC.dolooplevel] = NestingChecksum();
6341 while ( *inp ==
',' ) inp++;
6342 if ( *inp !=
'$' ) {
6344 MesPrint(
"&do loop parameter should be a dollar variable");
6349 if ( FG.cTable[*inp] != 0 ) {
6351 MesPrint(
"&illegal name for do loop parameter");
6353 while ( FG.cTable[*inp] < 2 ) inp++;
6355 if ( GetName(AC.dollarnames,name,&numparam,NOAUTO) == NAMENOTFOUND ) {
6356 numparam = AddDollar(name,DOLUNDEFINED,0,0);
6363 while ( *inp ==
',' ) inp++;
6364 if ( *inp !=
'=' )
goto IllSyntax;
6366 while ( *inp ==
',' ) inp++;
6370 inp = GetDoParam(inp,&w,1);
6371 if ( inp == 0 || *inp !=
',' )
goto IllSyntax;
6372 while ( *inp ==
',' ) inp++;
6376 inp = GetDoParam(inp,&w,1);
6377 if ( inp == 0 || ( *inp != 0 && *inp !=
',' ) )
goto IllSyntax;
6381 if ( *inp !=
',' ) {
6382 if ( *inp == 0 ) { *w++ = SNUMBER; *w++ = 1; }
6383 else goto IllSyntax;
6386 while ( *inp ==
',' ) inp++;
6387 inp = GetDoParam(inp,&w,1);
6389 if ( inp == 0 || *inp != 0 )
goto IllSyntax;
6391 AT.WorkPointer[1] = w - AT.WorkPointer;
6395 AddNtoL(AT.WorkPointer[1],AT.WorkPointer);
6396 AC.doloopstack[AC.dolooplevel++] = C->numlhs;
6401 MesPrint(
"&Illegal syntax for do statement");
6410int CoEndDo(UBYTE *inp)
6412 CBUF *C = cbuf+AC.cbufnum;
6414 while ( *inp ==
',' ) inp++;
6416 MesPrint(
"&Illegal syntax for EndDo statement");
6419 if ( AC.dolooplevel <= 0 ) {
6420 MesPrint(
"&EndDo without corresponding Do statement");
6424 scratch[0] = TYPEENDDOLOOP;
6426 scratch[2] = AC.doloopstack[AC.dolooplevel];
6428 cbuf[AC.cbufnum].lhs[AC.doloopstack[AC.dolooplevel]][3] = C->numlhs;
6429 if ( AC.doloopnest[AC.dolooplevel] != NestingChecksum() ) {
6441int CoFactDollar(UBYTE *inp)
6444 if ( *inp ==
'$' ) {
6445 if ( GetName(AC.dollarnames,inp+1,&numdollar,NOAUTO) != CDOLLAR ) {
6446 MesPrint(
"&%s is undefined",inp);
6447 numdollar = AddDollar(inp+1,DOLINDEX,&one,1);
6452 MesPrint(
"&FactDollar should have a single $variable for its argument");
6458 MesPrint(
"&%s is not a $-variable",inp);
6461 Add3Com(TYPEFACTOR,numdollar);
6470int CoFactorize(UBYTE *s) {
return(DoFactorize(s,1)); }
6477int CoNFactorize(UBYTE *s) {
return(DoFactorize(s,0)); }
6484int CoUnFactorize(UBYTE *s) {
return(DoFactorize(s,3)); }
6491int CoNUnFactorize(UBYTE *s) {
return(DoFactorize(s,2)); }
6498int DoFactorize(UBYTE *s,
int par)
6504 int error = 0, keepzeroflag = 0;
6507 while ( *s !=
')' && *s ) {
6508 if ( FG.cTable[*s] == 0 ) {
6509 t = s;
while ( FG.cTable[*s] == 0 ) s++;
6511 if ( StrICmp((UBYTE *)
"keepzero",t) == 0 ) {
6515 MesPrint(
"&Illegal option in [N][Un]Factorize statement: %s",t);
6520 while ( *s ==
',' ) s++;
6521 if ( *s && *s !=
')' && FG.cTable[*s] != 0 ) {
6522 MesPrint(
"&Illegal character in option field of [N][Un]Factorize statement");
6528 while ( *s ==
',' || *s ==
' ' ) s++;
6531 for ( i = NumExpressions-1; i >= 0; i-- ) {
6533 if ( e->replace >= 0 ) {
6534 e = Expressions + e->replace;
6536 if ( e->status == LOCALEXPRESSION || e->status == GLOBALEXPRESSION
6537 || e->status == UNHIDELEXPRESSION || e->status == UNHIDEGEXPRESSION
6538 || e->status == INTOHIDELEXPRESSION || e->status == INTOHIDEGEXPRESSION
6542 e->vflags &= ~TOBEFACTORED;
6545 e->vflags |= TOBEFACTORED;
6546 e->vflags &= ~TOBEUNFACTORED;
6549 e->vflags &= ~TOBEUNFACTORED;
6552 e->vflags |= TOBEUNFACTORED;
6553 e->vflags &= ~TOBEFACTORED;
6557 if ( ( e->vflags & TOBEFACTORED ) != 0 ) {
6558 if ( keepzeroflag ) e->vflags |= KEEPZERO;
6559 else e->vflags &= ~KEEPZERO;
6561 else e->vflags &= ~KEEPZERO;
6566 while ( *s ==
',' ) s++;
6567 if ( *s == 0 )
break;
6568 if ( *s ==
'[' || FG.cTable[*s] == 0 ) {
6571 MesPrint(
"&Improper name for an expression: '%s'",t);
6575 if ( GetName(AC.exprnames,t,&number,NOAUTO) == CEXPRESSION ) {
6576 e = Expressions+number;
6577 if ( e->replace >= 0 ) {
6578 e = Expressions + e->replace;
6580 if ( e->status == LOCALEXPRESSION || e->status == GLOBALEXPRESSION
6581 || e->status == UNHIDELEXPRESSION || e->status == UNHIDEGEXPRESSION
6582 || e->status == INTOHIDELEXPRESSION || e->status == INTOHIDEGEXPRESSION
6586 e->vflags &= ~TOBEFACTORED;
6589 e->vflags |= TOBEFACTORED;
6590 e->vflags &= ~TOBEUNFACTORED;
6593 e->vflags &= ~TOBEUNFACTORED;
6596 e->vflags |= TOBEUNFACTORED;
6597 e->vflags &= ~TOBEFACTORED;
6601 if ( ( e->vflags & TOBEFACTORED ) != 0 ) {
6602 if ( keepzeroflag ) e->vflags |= KEEPZERO;
6603 else e->vflags &= ~KEEPZERO;
6605 else e->vflags &= ~KEEPZERO;
6607 else if ( GetName(AC.varnames,t,&number,NOAUTO) != NAMENOTFOUND ) {
6608 MesPrint(
"&%s is not an expression",t);
6614 MesPrint(
"&Illegal object in (N)Factorize statement");
6616 while ( *s && *s !=
',' ) s++;
6617 if ( *s == 0 )
break;
6631int CoOptimizeOption(UBYTE *s)
6633 UBYTE *name, *t1, *t2, c1, c2, *value, *u;
6636 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
6638 name = s;
while ( FG.cTable[*s] == 0 ) s++;
6640 while ( *s ==
' ' || *s ==
'\t' ) s++;
6643 MesPrint(
"&Correct use in Format,Optimize statement is Optionname=value");
6645 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' || *s ==
'=' ) s++;
6651 while ( *s ==
' ' || *s ==
'\t' ) s++;
6652 if ( *s == 0 )
goto correctuse;
6654 while ( FG.cTable[*s] <= 1 || *s==
'.' || *s==
'*' || *s ==
'(' || *s ==
')' ) {
6655 if ( *s ==
'(' ) { SKIPBRA4(s) }
6659 while ( *s ==
' ' || *s ==
'\t' ) s++;
6660 if ( *s && *s !=
',' )
goto correctuse;
6663 while ( *s ==
' ' || *s ==
'\t' ) s++;
6669 if ( StrICmp(name,(UBYTE *)
"horner") == 0 ) {
6670 if ( StrICmp(value,(UBYTE *)
"occurrence") == 0 ) {
6671 AO.Optimize.horner = O_OCCURRENCE;
6673 else if ( StrICmp(value,(UBYTE *)
"mcts") == 0 ) {
6674 AO.Optimize.horner = O_MCTS;
6676 else if ( StrICmp(value,(UBYTE *)
"sa") == 0 ) {
6677 AO.Optimize.horner = O_SIMULATED_ANNEALING;
6680 AO.Optimize.horner = -1;
6681 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6685 else if ( StrICmp(name,(UBYTE *)
"hornerdirection") == 0 ) {
6686 if ( StrICmp(value,(UBYTE *)
"forward") == 0 ) {
6687 AO.Optimize.hornerdirection = O_FORWARD;
6689 else if ( StrICmp(value,(UBYTE *)
"backward") == 0 ) {
6690 AO.Optimize.hornerdirection = O_BACKWARD;
6692 else if ( StrICmp(value,(UBYTE *)
"forwardorbackward") == 0 ) {
6693 AO.Optimize.hornerdirection = O_FORWARDORBACKWARD;
6695 else if ( StrICmp(value,(UBYTE *)
"forwardandbackward") == 0 ) {
6696 AO.Optimize.hornerdirection = O_FORWARDANDBACKWARD;
6699 AO.Optimize.method = -1;
6700 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6704 else if ( StrICmp(name,(UBYTE *)
"method") == 0 ) {
6705 if ( StrICmp(value,(UBYTE *)
"none") == 0 ) {
6706 AO.Optimize.method = O_NONE;
6708 else if ( StrICmp(value,(UBYTE *)
"cse") == 0 ) {
6709 AO.Optimize.method = O_CSE;
6711 else if ( StrICmp(value,(UBYTE *)
"csegreedy") == 0 ) {
6712 AO.Optimize.method = O_CSEGREEDY;
6714 else if ( StrICmp(value,(UBYTE *)
"greedy") == 0 ) {
6715 AO.Optimize.method = O_GREEDY;
6718 AO.Optimize.method = -1;
6719 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6723 else if ( StrICmp(name,(UBYTE *)
"timelimit") == 0 ) {
6725 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6727 MesPrint(
"&Option TimeLimit in Format,Optimize statement should be a positive number: %s",value);
6728 AO.Optimize.mctstimelimit = 0;
6729 AO.Optimize.greedytimelimit = 0;
6733 AO.Optimize.mctstimelimit = x/2;
6734 AO.Optimize.greedytimelimit = x/2;
6737 else if ( StrICmp(name,(UBYTE *)
"mctstimelimit") == 0 ) {
6739 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6741 MesPrint(
"&Option MCTSTimeLimit in Format,Optimize statement should be a positive number: %s",value);
6742 AO.Optimize.mctstimelimit = 0;
6746 AO.Optimize.mctstimelimit = x;
6749 else if ( StrICmp(name,(UBYTE *)
"mctsnumexpand") == 0 ) {
6752 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6753 if ( *u ==
'*' || *u ==
'x' || *u ==
'X' ) {
6756 while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6760 MesPrint(
"&Option MCTSNumExpand in Format,Optimize statement should be a positive number: %s",value);
6761 AO.Optimize.mctsnumexpand= 0;
6762 AO.Optimize.mctsnumrepeat= 1;
6766 AO.Optimize.mctsnumexpand= x;
6767 AO.Optimize.mctsnumrepeat= y;
6770 else if ( StrICmp(name,(UBYTE *)
"mctsnumrepeat") == 0 ) {
6772 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6774 MesPrint(
"&Option MCTSNumExpand in Format,Optimize statement should be a positive number: %s",value);
6775 AO.Optimize.mctsnumrepeat= 1;
6779 AO.Optimize.mctsnumrepeat= x;
6782 else if ( StrICmp(name,(UBYTE *)
"mctsnumkeep") == 0 ) {
6784 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6786 MesPrint(
"&Option MCTSNumKeep in Format,Optimize statement should be a positive number: %s",value);
6787 AO.Optimize.mctsnumkeep= 0;
6791 AO.Optimize.mctsnumkeep= x;
6794 else if ( StrICmp(name,(UBYTE *)
"mctsconstant") == 0 ) {
6796 if ( sscanf ((
char*)value,
"%lf", &d) != 1 ) {
6797 MesPrint(
"&Option MCTSConstant in Format,Optimize statement should be a positive number: %s",value);
6798 AO.Optimize.mctsconstant.fval = 0;
6802 AO.Optimize.mctsconstant.fval = d;
6805 else if ( StrICmp(name,(UBYTE *)
"greedytimelimit") == 0 ) {
6807 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6809 MesPrint(
"&Option GreedyTimeLimit in Format,Optimize statement should be a positive number: %s",value);
6810 AO.Optimize.greedytimelimit = 0;
6814 AO.Optimize.greedytimelimit = x;
6817 else if ( StrICmp(name,(UBYTE *)
"greedyminnum") == 0 ) {
6819 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6821 MesPrint(
"&Option GreedyMinNum in Format,Optimize statement should be a positive number: %s",value);
6822 AO.Optimize.greedyminnum= 0;
6826 AO.Optimize.greedyminnum= x;
6829 else if ( StrICmp(name,(UBYTE *)
"greedymaxperc") == 0 ) {
6831 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6833 MesPrint(
"&Option GreedyMaxPerc in Format,Optimize statement should be a positive number: %s",value);
6834 AO.Optimize.greedymaxperc= 0;
6838 AO.Optimize.greedymaxperc= x;
6841 else if ( StrICmp(name,(UBYTE *)
"stats") == 0 ) {
6842 if ( StrICmp(value,(UBYTE *)
"on") == 0 ) {
6843 AO.Optimize.printstats = 1;
6845 else if ( StrICmp(value,(UBYTE *)
"off") == 0 ) {
6846 AO.Optimize.printstats = 0;
6849 AO.Optimize.printstats = 0;
6850 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6854 else if ( StrICmp(name,(UBYTE *)
"printscheme") == 0 ) {
6855 if ( StrICmp(value,(UBYTE *)
"on") == 0 ) {
6856 AO.Optimize.schemeflags |= 1;
6858 else if ( StrICmp(value,(UBYTE *)
"off") == 0 ) {
6859 AO.Optimize.schemeflags &= ~1;
6862 AO.Optimize.schemeflags &= ~1;
6863 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6867 else if ( StrICmp(name,(UBYTE *)
"debugflag") == 0 ) {
6875 if ( FG.cTable[*u] == 1 ) {
6876 while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6878 MesPrint(
"&Numerical value for DebugFlag in Format,Optimize statement should be a nonnegative number: %s",value);
6879 AO.Optimize.debugflags = 0;
6883 AO.Optimize.debugflags = x;
6886 else if ( StrICmp(value,(UBYTE *)
"on") == 0 ) {
6887 AO.Optimize.debugflags = 1;
6889 else if ( StrICmp(value,(UBYTE *)
"off") == 0 ) {
6890 AO.Optimize.debugflags = 0;
6893 AO.Optimize.debugflags = 0;
6894 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6898 else if ( StrICmp(name,(UBYTE *)
"scheme") == 0 ) {
6905 MesPrint(
"&Option Scheme in Format,Optimize statement should be an array of names or integers between (): %s",value);
6910 while ( *ss ==
' ' || *ss ==
'\t' || *ss ==
',' ) ss++;
6911 if ( FG.cTable[*ss] == 0 || *ss ==
'$' || *ss ==
'[' ) {
6912 s1 = u; SKIPBRA3(s1)
6913 if ( *s1 !=
')' )
goto noscheme;
6914 while ( ss < s1 ) {
if ( *ss++ ==
',' ) AO.schemenum++; }
6915 *ss++ = 0;
while ( *ss ==
' ' ) ss++;
6916 if ( *ss != 0 )
goto noscheme;
6918 if ( AO.schemenum < 1 ) {
6919 MesPrint(
"&Option Scheme in Format,Optimize statement should have at least one name or number between ()");
6923 if ( AO.inscheme ) M_free(AO.inscheme,
"Horner input scheme");
6924 AO.inscheme = (WORD *)Malloc1((AO.schemenum+1)*
sizeof(WORD),
"Horner input scheme");
6925 while ( *ss ==
' ' || *ss ==
'\t' || *ss ==
',' ) ss++;
6928 if ( *ss == 0 )
break;
6929 s1 = ss; ss =
SkipAName(s1); c = *ss; *ss = 0;
6931 if ( ss[-1] ==
'_' ) {
6936 u1 = s1; u2 = AC.extrasym;
6937 while ( *u1 == *u2 ) { u1++; u2++; }
6940 while ( *u1 >=
'0' && *u1 <=
'9' ) numsym = 10*numsym + *u1++ -
'0';
6941 if ( u1 != ss-1 || numsym == 0 || AC.extrasymbols != 0 ) {
6942 MesPrint(
"&Improper use of extra symbol in scheme format option");
6945 numsym = MAXVARIABLES-numsym;
6950 else if ( *s1 ==
'$' ) {
6953 if ( ( numdollar = GetDollar(s1+1) ) < 0 ) {
6954 MesPrint(
"&Undefined variable %s",s1);
6957 else if ( ( numsym = DolToSymbol(BHEAD numdollar) ) < 0 ) {
6958 MesPrint(
"&$%s does not evaluate to a symbol",s1);
6964 else if ( c ==
'(' ) {
6965 if ( StrCmp(s1,AC.extrasym) == 0 ) {
6966 if ( (AC.extrasymbols&1) != 1 ) {
6967 MesPrint(
"&Improper use of extra symbol in scheme format option");
6972 while ( *ss >=
'0' && *ss <=
'9' ) numsym = 10*numsym + *ss++ -
'0';
6974 MesPrint(
"&Extra symbol should have a number for its argument.");
6977 numsym = MAXVARIABLES-numsym;
6982 type = GetName(AC.varnames,s1,&numsym,WITHAUTO);
6983 if ( ( type != CSYMBOL ) && type != CDUBIOUS ) {
6984 MesPrint(
"&%s is not a symbol",s1);
6986 if ( type < 0 ) numsym = AddSymbol(s1,-MAXPOWER,MAXPOWER,0,0);
6990 AO.inscheme[AO.schemenum++] = numsym;
6991 while ( *ss ==
' ' || *ss ==
'\t' || *ss ==
',' ) ss++;
6995 else if ( StrICmp(name,(UBYTE *)
"mctsdecaymode") == 0 ) {
6998 if ( FG.cTable[*u] == 1 ) {
6999 while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
7001 MesPrint(
"&Option MCTSDecayMode in Format,Optimize statement should be a nonnegative integer: %s",value);
7002 AO.Optimize.mctsdecaymode = 0;
7006 AO.Optimize.mctsdecaymode = x;
7010 AO.Optimize.mctsdecaymode = 0;
7011 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
7015 else if ( StrICmp(name,(UBYTE *)
"saiter") == 0 ) {
7017 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
7019 MesPrint(
"&Option SAIter in Format,Optimize statement should be a positive integer: %s",value);
7020 AO.Optimize.saIter = 0;
7024 AO.Optimize.saIter= x;
7027 else if ( StrICmp(name,(UBYTE *)
"samaxt") == 0 ) {
7029 if ( sscanf ((
char*)value,
"%lf", &d) != 1 ) {
7030 MesPrint(
"&Option SAMaxT in Format,Optimize statement should be a positive number: %s",value);
7031 AO.Optimize.saMaxT.fval = 0;
7035 AO.Optimize.saMaxT.fval = d;
7038 else if ( StrICmp(name,(UBYTE *)
"samint") == 0 ) {
7040 if ( sscanf ((
char*)value,
"%lf", &d) != 1 ) {
7041 MesPrint(
"&Option SAMinT in Format,Optimize statement should be a positive number: %s",value);
7042 AO.Optimize.saMinT.fval = 0;
7046 AO.Optimize.saMinT.fval = d;
7050 MesPrint(
"&Unrecognized option name in Format,Optimize statement: %s",name);
7067int CoPutInside(UBYTE *inp) {
return(DoPutInside(inp,1)); }
7068int CoAntiPutInside(UBYTE *inp) {
return(DoPutInside(inp,-1)); }
7070int DoPutInside(UBYTE *inp,
int par)
7074 WORD *to, type, c1,c2,funnum, *WorkSave;
7076 while ( *inp ==
' ' || *inp ==
'\t' || *inp ==
',' ) inp++;
7081 if ( p == 0 )
return(1);
7083 type = GetName(AC.varnames,inp,&funnum,WITHAUTO);
7084 if ( type != CFUNCTION || functions[funnum].tabl != 0 || functions[funnum].spec ) {
7085 MesPrint(
"&PutInside/AntiPutInside expects a regular function for its first argument");
7086 MesPrint(
"&Argument is %s",inp);
7092 while ( *inp ==
' ' || *inp ==
'\t' || *inp ==
',' ) inp++;
7096 tocompiler[0] = TYPEPUTINSIDE;
7099 tocompiler[3] = funnum;
7103 MesPrint(
"&AntiPutInside needs inside information.");
7108 WorkSave = to = AT.WorkPointer;
7109 *to++ = TYPEPUTINSIDE;
7115 while ( *inp ==
' ' || *inp ==
'\t' || *inp ==
',' ) inp++;
7116 if ( *inp == 0 )
break;
7118 if ( p == 0 ) { error = 1;
break; }
7120 type = GetName(AC.varnames,inp,&c1,WITHAUTO);
7122 if ( type == CVECTOR || type == CDUBIOUS ) {
7126 if ( p == 0 )
return(1);
7128 type = GetName(AC.varnames,inp,&c2,WITHAUTO);
7129 if ( type != CVECTOR && type != CDUBIOUS ) {
7130 MesPrint(
"&Not a vector in dotproduct in PutInside/AntiPutInside statement: %s",inp);
7133 else type = CDOTPRODUCT;
7136 MesPrint(
"&Illegal use of . after %s in PutInside/AntiPutInside statement",inp);
7144 *to++ = SYMBOL; *to++ = 4; *to++ = c1; *to++ = 1;
break;
7146 *to++ = INDEX; *to++ = 3; *to++ = AM.OffsetVector + c1;
break;
7148 *to++ = c1+FUNCTION; *to++ = FUNHEAD; *to++ = 0;
7152 *to++ = DOTPRODUCT; *to++ = 5; *to++ = c1 + AM.OffsetVector;
7153 *to++ = c2 + AM.OffsetVector; *to++ = 1;
break;
7155 *to++ = DELTA; *to++ = 4; *to++ = EMPTYINDEX; *to++ = EMPTYINDEX;
break;
7157 MesPrint(
"&Illegal variable request for %s in PutInside/AntiPutInside statement",inp);
7163 *to++ = 1; *to++ = 1; *to++ = 3;
7164 AT.WorkPointer[1] = to - AT.WorkPointer;
7165 AT.WorkPointer[4] = AT.WorkPointer[1]-4;
7166 AT.WorkPointer = to;
7167 AC.BracketNormalize = 1;
7168 if ( Normalize(BHEAD WorkSave+4) ) { error = 1; }
7170 WorkSave[1] = WorkSave[4]+4;
7171 to = WorkSave + WorkSave[1] - 1;
7175 AddNtoL(WorkSave[1],WorkSave);
7177 AC.BracketNormalize = 0;
7178 AT.WorkPointer = WorkSave;
7190int CoSwitch(UBYTE *s)
7195 if ( GetName(AC.dollarnames,s+1,&numdollar,NOAUTO) != CDOLLAR ) {
7196 MesPrint(
"&%s is undefined in switch statement",s);
7197 numdollar = AddDollar(s+1,DOLINDEX,&one,1);
7202 MesPrint(
"&Switch should have a single $variable for its argument");
7208 MesPrint(
"&%s is not a $-variable in switch statement",s);
7217 if ( AC.SwitchInArray >= AC.MaxSwitch ) DoubleSwitchBuffers();
7218 AC.SwitchHeap[AC.SwitchLevel] = AC.SwitchInArray;
7219 sw = AC.SwitchArray + AC.SwitchInArray;
7221 sw->iflevel = AC.IfLevel;
7222 sw->whilelevel = AC.WhileLevel;
7223 sw->nestingsum = NestingChecksum();
7225 Add4Com(TYPESWITCH,numdollar,AC.SwitchInArray);
7238 SWITCH *sw = AC.SwitchArray + AC.SwitchHeap[AC.SwitchLevel];
7239 WORD x = 0, sign = 1;
7240 while ( *s ==
',' ) s++;
7242 while ( *s ==
'-' || *s ==
'+' ) {
7243 if ( *s ==
'-' ) sign = -sign;
7246 while ( FG.cTable[*s] == 1 ) { x = 10*x + *s++ -
'0'; }
7249 if ( sw->iflevel != AC.IfLevel || sw->whilelevel != AC.WhileLevel
7250 || sw->nestingsum != NestingChecksum() ) {
7251 MesPrint(
"&Illegal nesting of switch/case/default with if/while/repeat/loop/argument/term/...");
7257 if ( sw->numcases >= sw->tablesize ) {
7261 if ( sw->tablesize == 0 ) newsize = 10;
7262 else newsize = 2*sw->tablesize;
7265 for ( i = 0; i < sw->tablesize; i++ ) newtable[i] = sw->table[i];
7266 M_free(sw->table,
"Switch table");
7268 sw->table = newtable;
7269 sw->tablesize = newsize;
7271 if ( sw->numcases == 0 ) { sw->mincase = sw->maxcase = x; }
7272 else if ( x > sw->maxcase ) sw->maxcase = x;
7273 else if ( x < sw->mincase ) sw->mincase = x;
7274 sw->table[sw->numcases].ncase = x;
7275 sw->table[sw->numcases].value = cbuf[AC.cbufnum].numlhs;
7276 sw->table[sw->numcases].compbuffer = AC.cbufnum;
7286int CoBreak(UBYTE *s)
7293 SWITCH *sw = AC.SwitchArray + AC.SwitchHeap[AC.SwitchLevel];
7294 if ( sw->iflevel != AC.IfLevel || sw->whilelevel != AC.WhileLevel
7295 || sw->nestingsum != NestingChecksum() ) {
7296 MesPrint(
"&Illegal nesting of switch/case/default with if/while/repeat/loop/argument/term/...");
7300 MesPrint(
"&No parameters allowed in Break statement");
7303 Add3Com(TYPEENDSWITCH,AC.SwitchHeap[AC.SwitchLevel]);
7312int CoDefault(UBYTE *s)
7318 SWITCH *sw = AC.SwitchArray + AC.SwitchHeap[AC.SwitchLevel];
7319 if ( sw->iflevel != AC.IfLevel || sw->whilelevel != AC.WhileLevel
7320 || sw->nestingsum != NestingChecksum() ) {
7321 MesPrint(
"&Illegal nesting of switch/case/default with if/while/repeat/loop/argument/term/...");
7325 MesPrint(
"&No parameters allowed in Default statement");
7328 sw->defaultcase.ncase = 0;
7329 sw->defaultcase.value = cbuf[AC.cbufnum].numlhs;
7330 sw->defaultcase.compbuffer = AC.cbufnum;
7339int CoEndSwitch(UBYTE *s)
7348 SWITCH *sw = AC.SwitchArray + AC.SwitchHeap[AC.SwitchLevel];
7350 WORD totcases = sw->maxcase-sw->mincase+1;
7351 while ( *s ==
',' ) s++;
7354 MesPrint(
"&No parameters allowed in EndSwitch statement");
7357 if ( sw->iflevel != AC.IfLevel || sw->whilelevel != AC.WhileLevel
7358 || sw->nestingsum != NestingChecksum() ) {
7359 MesPrint(
"&Illegal nesting of switch/case/default with if/while/repeat/loop/argument/term/...");
7362 if ( sw->defaultcase.value == 0 ) CoDefault(s);
7363 if ( totcases > sw->numcases*AM.jumpratio ) {
7365 sw->typetable = SPARSETABLE;
7369 SwitchSplitMerge(sw->table,sw->numcases);
7373 sw->caseoffset = sw->mincase;
7374 sw->typetable = DENSETABLE;
7376 for ( i = 0; i < totcases; i++ ) {
7377 ntable[i].ncase = i+sw->caseoffset;
7378 ntable[i].value = sw->defaultcase.value;
7379 ntable[i].compbuffer = sw->defaultcase.compbuffer;
7381 for ( i = 0; i < sw->numcases; i++ ) {
7382 ntable[sw->table[i].ncase-sw->caseoffset] = sw->table[i];
7384 M_free(sw->table,
"Switch table");
7386 sw->numcases = totcases;
7388 sw->endswitch.ncase = 0;
7389 sw->endswitch.value = cbuf[AC.cbufnum].numlhs;
7390 sw->endswitch.compbuffer = AC.cbufnum;
7391 if ( sw->defaultcase.value == 0 ) {
7392 sw->defaultcase = sw->endswitch;
7394 Add3Com(TYPEENDSWITCH,AC.SwitchHeap[AC.SwitchLevel]);
7407int CoSetUserFlag(UBYTE *s)
7410 while ( *s && ( *s ==
',' || *s ==
' ' || *s ==
'\t' ) ) s++;
7411 while ( *s && ( FG.cTable[*s] == 1 ) ) {
7413 while ( *s && ( FG.cTable[*s] == 1 ) ) x = 10*x+(*s++ -
'0');
7414 if ( x < 1 || x > BITSINWORD ) {
7415 MesPrint(
"&Flag number %d outside the permitted range 1-%d.",BITSINWORD);
7419 Add3Com(TYPESETUSERFLAG,x-1);
7421 while ( *s && ( *s ==
',' || *s ==
' ' || *s ==
'\t' ) ) s++;
7424 MesPrint(
"&Illegal character in SetUserFlag statement: %s",s);
7435int CoClearUserFlag(UBYTE *s)
7438 while ( *s && ( *s ==
',' || *s ==
' ' || *s ==
'\t' ) ) s++;
7439 while ( *s && ( FG.cTable[*s] == 1 ) ) {
7441 while ( *s && ( FG.cTable[*s] == 1 ) ) x = 10*x+(*s++ -
'0');
7442 if ( x < 1 || x > BITSINWORD ) {
7443 MesPrint(
"&Flag number %d outside the permitted range 1-%d.",BITSINWORD);
7447 Add3Com(TYPECLEARUSERFLAG,x);
7449 while ( *s && ( *s ==
',' || *s ==
' ' || *s ==
'\t' ) ) s++;
7452 MesPrint(
"&Illegal character in SetUserFlag statement: %s",s);
7472int CoCreateAllLoops(UBYTE *s)
7475 UBYTE *inname, *outname, *stype, c;
7476 WORD infun, outfun, x, type, tensorflag, typenum;
7477 WORD *WorkSave, *to;
7478 while ( *s ==
',' || *s ==
' ' ) s++;
7481 if ( ( ( type = GetName(AC.varnames,inname,&infun,WITHAUTO) ) != CFUNCTION )
7482 || ( ( functions[infun].spec != 0 ) && ( functions[infun].spec != TENSORFUNCTION ) ) ) {
7483 MesPrint(
"&%s should be a regular function or a tensor.",inname);
7485 if ( GetName(AC.exprnames,s,&infun,NOAUTO) == NAMENOTFOUND )
7486 AddFunction(s,0,0,0,0,0,-1,-1);
7492 while ( *s ==
',' || *s ==
' ' ) s++;
7495 if ( ( ( type = GetName(AC.varnames,outname,&outfun,WITHAUTO) ) != CFUNCTION )
7496 || ( ( functions[outfun].spec != 0 ) && ( functions[outfun].spec != TENSORFUNCTION ) ) ) {
7497 MesPrint(
"&%s should be a regular function or a tensor.",outname);
7499 if ( GetName(AC.exprnames,s,&outfun,NOAUTO) == NAMENOTFOUND )
7500 AddFunction(s,0,0,0,0,0,-1,-1);
7506 if ( functions[infun].spec == TENSORFUNCTION ||
7507 functions[outfun].spec == TENSORFUNCTION ) tensorflag = 1;
7508 else tensorflag = 0;
7512 while ( *s ==
',' || *s ==
' ' ) s++;
7514 while ( FG.cTable[*s] == 0 ) s++;
7516 if ( StrICmp(stype,(UBYTE *)
"type") != 0 || c !=
'=' ) {
7517 MesPrint(
"&In CreateAllLoops statement: expected type=vartype.");
7522 while ( FG.cTable[*s] == 0 ) s++;
7524 if ( StrICmp(stype,(UBYTE *)
"vector") == 0 ) {
7527 else if ( StrICmp(stype,(UBYTE *)
"index") == 0 ) {
7530 else if ( StrICmp(stype,(UBYTE *)
"symbol") == 0 ) {
7531 if ( tensorflag )
goto notintensor;
7534 else if ( StrICmp(stype,(UBYTE *)
"snumber") == 0 ) {
7535 if ( tensorflag )
goto notintensor;
7539 MesPrint(
"&Unknown/not allowed variable type in CreateAllLoops: %s",stype);
7543 while ( *s ==
',' || *s ==
' ' ) s++;
7546 while ( FG.cTable[*s] == 0 ) s++;
7548 if ( StrICmp(stype,(UBYTE *)
"ifnoloop") != 0 || c !=
'=' ) {
7549 MesPrint(
"&Unrecognised option in CreateAllLoops statement: %s",stype);
7554 if ( FG.cTable[*s] == 1 ) {
7556 do { x = 10*x + (*s++-
'0'); }
while (FG.cTable[*s] == 1);
7558 if ( x != 0 && x != 1 ) {
7559 MesPrint(
"&Only options allowed for ifnoloop are 0 or 1.");
7562 WorkSave = to = AT.WorkPointer;
7563 *to++ = TYPEALLLOOPS;
7570 AddNtoL(WorkSave[1],WorkSave);
7574 MesPrint(
"&Variable type not allowed in tensors: %s",stype);
7592int CoCreateAllPaths(UBYTE *s)
7595 UBYTE *endname,*inname, *outname, *stype, c;
7596 WORD endfun, infun, outfun, x, type, tensorflag, typenum;
7597 WORD *WorkSave, *to;
7598 while ( *s ==
',' || *s ==
' ' ) s++;
7601 if ( ( ( type = GetName(AC.varnames,endname,&endfun,WITHAUTO) ) != CFUNCTION )
7602 || ( ( functions[endfun].spec != 0 ) && ( functions[endfun].spec != TENSORFUNCTION ) ) ) {
7603 MesPrint(
"&%s should be a regular function or a tensor.",endname);
7605 if ( GetName(AC.exprnames,s,&endfun,NOAUTO) == NAMENOTFOUND )
7606 AddFunction(s,0,0,0,0,0,-1,-1);
7612 while ( *s ==
',' || *s ==
' ' ) s++;
7615 if ( ( ( type = GetName(AC.varnames,inname,&infun,WITHAUTO) ) != CFUNCTION )
7616 || ( ( functions[infun].spec != 0 ) && ( functions[infun].spec != TENSORFUNCTION ) ) ) {
7617 MesPrint(
"&%s should be a regular function or a tensor.",inname);
7619 if ( GetName(AC.exprnames,s,&infun,NOAUTO) == NAMENOTFOUND )
7620 AddFunction(s,0,0,0,0,0,-1,-1);
7626 while ( *s ==
',' || *s ==
' ' ) s++;
7629 if ( ( ( type = GetName(AC.varnames,outname,&outfun,WITHAUTO) ) != CFUNCTION )
7630 || ( ( functions[outfun].spec != 0 ) && ( functions[outfun].spec != TENSORFUNCTION ) ) ) {
7631 MesPrint(
"&%s should be a regular function or a tensor.",outname);
7633 if ( GetName(AC.exprnames,s,&outfun,NOAUTO) == NAMENOTFOUND )
7634 AddFunction(s,0,0,0,0,0,-1,-1);
7640 if ( functions[infun].spec == TENSORFUNCTION ||
7641 functions[outfun].spec == TENSORFUNCTION ) tensorflag = 1;
7642 else tensorflag = 0;
7646 while ( *s ==
',' || *s ==
' ' ) s++;
7648 while ( FG.cTable[*s] == 0 ) s++;
7650 if ( StrICmp(stype,(UBYTE *)
"type") != 0 || c !=
'=' ) {
7651 MesPrint(
"&In CreateAllPaths statement: expected type=vartype.");
7656 while ( FG.cTable[*s] == 0 ) s++;
7658 if ( StrICmp(stype,(UBYTE *)
"vector") == 0 ) {
7661 else if ( StrICmp(stype,(UBYTE *)
"index") == 0 ) {
7664 else if ( StrICmp(stype,(UBYTE *)
"symbol") == 0 ) {
7665 if ( tensorflag )
goto notintensor;
7668 else if ( StrICmp(stype,(UBYTE *)
"snumber") == 0 ) {
7669 if ( tensorflag )
goto notintensor;
7673 MesPrint(
"&Unknown/not allowed variable type in CreateAllPaths: %s",stype);
7677 while ( *s ==
',' || *s ==
' ' ) s++;
7680 while ( FG.cTable[*s] == 0 ) s++;
7682 if ( StrICmp(stype,(UBYTE *)
"ifnopath") != 0 || c !=
'=' ) {
7683 MesPrint(
"&Unrecognised option in CreateAllPaths statement: %s",stype);
7688 if ( FG.cTable[*s] == 1 ) {
7690 do { x = 10*x + (*s++-
'0'); }
while (FG.cTable[*s] == 1);
7692 if ( x != 0 && x != 1 ) {
7693 MesPrint(
"&Only options allowed for ifnopath are 0 or 1.");
7696 WorkSave = to = AT.WorkPointer;
7697 *to++ = TYPEALLPATHS;
7705 AddNtoL(WorkSave[1],WorkSave);
7709 MesPrint(
"&CreateAllPaths: Variable type not allowed in tensors: %s",stype);
7720int CoCreateAll(UBYTE *s)
7723 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
7725 while ( FG.cTable[*s] == 0 ) s++;
7726 if ( *s !=
' ' && *s !=
',' && *s !=
'\t' ) {
7727 MesPrint(
"&Illegal subkey in CoCreate statement.");
7731 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
7732 if ( StrICmp(subkey,(UBYTE *)
"loops") == 0 ) {
7733 return(CoCreateAllLoops(s));
7735 else if ( StrICmp(subkey,(UBYTE *)
"paths") == 0 ) {
7736 return(CoCreateAllPaths(s));
7747 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)