47static KEYWORD formatoptions[] = {
48 {
"allfloat", (TFUN)0, ALLINTEGERDOUBLE, 0}
49 ,{
"c", (TFUN)0, CMODE, 0}
50 ,{
"doublefortran", (TFUN)0, DOUBLEFORTRANMODE, 0}
51 ,{
"float", (TFUN)0, 0, 2}
53 ,{
"floatprecision", (TFUN)0, 0, 5}
55 ,{
"fortran", (TFUN)0, FORTRANMODE, 0}
56 ,{
"fortran90", (TFUN)0, FORTRANMODE, 4}
57 ,{
"maple", (TFUN)0, MAPLEMODE, 0}
58 ,{
"mathematica", (TFUN)0, MATHEMATICAMODE, 0}
59 ,{
"normal", (TFUN)0, NORMALFORMAT, 1}
60 ,{
"nospaces", (TFUN)0, NOSPACEFORMAT, 3}
61 ,{
"pfortran", (TFUN)0, PFORTRANMODE, 0}
62 ,{
"quadfortran", (TFUN)0, QUADRUPLEFORTRANMODE, 0}
63 ,{
"quadruplefortran", (TFUN)0, QUADRUPLEFORTRANMODE, 0}
64 ,{
"rational", (TFUN)0, RATIONALMODE, 1}
65 ,{
"reduce", (TFUN)0, REDUCEMODE, 0}
66 ,{
"spaces", (TFUN)0, NORMALFORMAT, 3}
67 ,{
"vortran", (TFUN)0, VORTRANMODE, 0}
70static KEYWORD trace4options[] = {
71 {
"contract", (TFUN)0, CHISHOLM, 0 }
72 ,{
"nocontract", (TFUN)0, 0, CHISHOLM }
73 ,{
"nosymmetrize",(TFUN)0, 0, ALSOREVERSE}
74 ,{
"notrick", (TFUN)0, NOTRICK, 0 }
75 ,{
"symmetrize", (TFUN)0, ALSOREVERSE, 0 }
76 ,{
"trick", (TFUN)0, 0, NOTRICK }
80 {
"nosymmetrize",(TFUN)0, 0, ALSOREVERSE}
81 ,{
"symmetrize", (TFUN)0, ALSOREVERSE, 0 }
85 {
"stats", &(AC.StatsFlag), 1, 0}
86 ,{
"statistics", &(AC.StatsFlag), 1, 0}
87 ,{
"shortstats", &(AC.ShortStats), 1, 0}
88 ,{
"shortstatistics",&(AC.ShortStats), 1, 0}
89 ,{
"warnings", &(AC.WarnFlag), 1, 0}
90 ,{
"allwarnings", &(AC.WarnFlag), 2, 0}
91 ,{
"setup", &(AC.SetupFlag), 1, 0}
92 ,{
"names", &(AC.NamesFlag), 1, 0}
93 ,{
"allnames", &(AC.NamesFlag), 2, 0}
94 ,{
"codes", &(AC.CodesFlag), 1, 0}
95 ,{
"highfirst", &(AC.SortType), SORTHIGHFIRST, SORTLOWFIRST}
96 ,{
"lowfirst", &(AC.SortType), SORTLOWFIRST, SORTHIGHFIRST}
97 ,{
"powerfirst", &(AC.SortType), SORTPOWERFIRST, SORTHIGHFIRST}
98 ,{
"tokens", &(AC.TokensWriteFlag),1, 0}
102 {
"compress", &(AC.NoCompress), 0, 1}
103 ,{
"checkpoint", &(AC.CheckpointFlag), 1, 0}
104 ,{
"insidefirst", &(AC.insidefirst), 1, 0}
105 ,{
"propercount", &(AC.BottomLevel), 1, 0}
106 ,{
"stats", &(AC.StatsFlag), 1, 0}
107 ,{
"statistics", &(AC.StatsFlag), 1, 0}
108 ,{
"shortstats", &(AC.ShortStats), 1, 0}
109 ,{
"shortstatistics",&(AC.ShortStats), 1, 0}
110 ,{
"names", &(AC.NamesFlag), 1, 0}
111 ,{
"allnames", &(AC.NamesFlag), 2, 0}
112 ,{
"warnings", &(AC.WarnFlag), 1, 0}
113 ,{
"allwarnings", &(AC.WarnFlag), 2, 0}
114 ,{
"highfirst", &(AC.SortType), SORTHIGHFIRST, SORTLOWFIRST}
115 ,{
"lowfirst", &(AC.SortType), SORTLOWFIRST, SORTHIGHFIRST}
116 ,{
"powerfirst", &(AC.SortType), SORTPOWERFIRST, SORTHIGHFIRST}
117 ,{
"setup", &(AC.SetupFlag), 1, 0}
118 ,{
"codes", &(AC.CodesFlag), 1, 0}
119 ,{
"tokens", &(AC.TokensWriteFlag),1,0}
120 ,{
"properorder", &(AC.properorderflag),1,0}
121 ,{
"threadloadbalancing",&(AC.ThreadBalancing),1, 0}
122 ,{
"threads", &(AC.ThreadsFlag),1, 0}
123 ,{
"threadsortfilesynch",&(AC.ThreadSortFileSynch),1, 0}
124 ,{
"threadstats", &(AC.ThreadStats),1, 0}
125 ,{
"finalstats", &(AC.FinalStats),1, 0}
126 ,{
"fewerstats", &(AC.ShortStatsMax), 10, 0}
127 ,{
"fewerstatistics",&(AC.ShortStatsMax), 10, 0}
128 ,{
"processstats", &(AC.ProcessStats),1, 0}
129 ,{
"oldparallelstats",&(AC.OldParallelStats),1,0}
130 ,{
"parallel", &(AC.parallelflag),PARALLELFLAG,NOPARALLEL_USER}
131 ,{
"nospacesinnumbers",&(AO.NoSpacesInNumbers),1,0}
132 ,{
"indentspace", &(AO.IndentSpace),INDENTSPACE,0}
133 ,{
"totalsize", &(AM.PrintTotalSize), 1, 0}
134 ,{
"flag", (
int *)&(AC.debugFlags), 1, 0}
135 ,{
"oldfactarg", &(AC.OldFactArgFlag), 1, 0}
136 ,{
"memdebugflag", &(AC.MemDebugFlag), 1, 0}
137 ,{
"oldgcd", &(AC.OldGCDflag), 1, 0}
138 ,{
"oldprfsign", &(AC.OldPRFSignFlag), 1, 0}
139 ,{
"innertest", &(AC.InnerTest), 1, 0}
140 ,{
"wtimestats", &(AC.WTimeStatsFlag), 1, 0}
141 ,{
"sortreallocate", &(AC.SortReallocateFlag), 1, 0}
142 ,{
"backtrace", &(AC.PrintBacktraceFlag), 1, 0}
143 ,{
"flint", &(AC.FlintPolyFlag), 1, 0}
144 ,{
"humanstats", &(AC.HumanStatsFlag), 1, 0}
145 ,{
"humanstatistics", &(AC.HumanStatsFlag), 1, 0}
146 ,{
"grccverbose", &(AC.GrccVerbose), 1, 0}
147 ,{
"sortverbose", &(AC.SortVerbose), 1, 0}
157int CoFormat(UBYTE *s)
162 while ( *s ==
' ' || *s ==
',' ) s++;
165 AC.OutputSpaces = NORMALFORMAT;
171 if ( *s ==
'O' || *s ==
'o' ) {
172 if ( ( FG.cTable[s[1]] == 1 ) ||
173 ( s[1] ==
'=' && FG.cTable[s[2]] == 1 ) ) {
174 s++;
if ( *s ==
'=' ) s++;
176 while ( *s >=
'0' && *s <=
'9' ) x = 10*x + *s++ -
'0';
177 while ( *s ==
',' ) s++;
178 AO.OptimizationLevel = x;
179 AO.Optimize.greedytimelimit = 0;
180 AO.Optimize.mctstimelimit = 0;
181 AO.Optimize.printstats = 0;
182 AO.Optimize.debugflags = 0;
183 AO.Optimize.schemeflags = 0;
184 AO.Optimize.mctsdecaymode = 1;
186 M_free(AO.inscheme,
"Horner input scheme");
187 AO.inscheme = 0; AO.schemenum = 0;
193 AO.Optimize.mctsconstant.fval = -1.0;
194 AO.Optimize.horner = O_OCCURRENCE;
195 AO.Optimize.hornerdirection = O_FORWARDORBACKWARD;
196 AO.Optimize.method = O_CSE;
199 AO.Optimize.horner = O_OCCURRENCE;
200 AO.Optimize.hornerdirection = O_FORWARDORBACKWARD;
201 AO.Optimize.method = O_GREEDY;
202 AO.Optimize.greedyminnum = 10;
203 AO.Optimize.greedymaxperc = 5;
206 AO.Optimize.mctsconstant.fval = 1.0;
207 AO.Optimize.horner = O_MCTS;
208 AO.Optimize.hornerdirection = O_FORWARDORBACKWARD;
209 AO.Optimize.method = O_GREEDY;
210 AO.Optimize.mctsnumexpand = 1000;
211 AO.Optimize.mctsnumkeep = 10;
212 AO.Optimize.mctsnumrepeat = 1;
213 AO.Optimize.greedyminnum = 10;
214 AO.Optimize.greedymaxperc = 5;
217 AO.Optimize.horner = O_SIMULATED_ANNEALING;
218 AO.Optimize.saIter = 1000;
219 AO.Optimize.saMaxT.fval = 2000;
220 AO.Optimize.saMinT.fval = 1;
224 MesPrint(
"&Illegal optimization specification in format statement");
227 if ( error == 0 && *s != 0 && x > 0 )
return(CoOptimizeOption(s));
233 while ( FG.cTable[*s] == 0 ) s++;
235 if ( StrICont(ss,(UBYTE *)
"optimize") == 0 ) {
237 while ( *s ==
',' ) s++;
238 if ( *s ==
'=' ) s++;
239 AO.OptimizationLevel = 3;
240 AO.Optimize.mctsconstant.fval = 1.0;
241 AO.Optimize.horner = O_MCTS;
242 AO.Optimize.hornerdirection = O_FORWARDORBACKWARD;
243 AO.Optimize.method = O_GREEDY;
244 AO.Optimize.mctstimelimit = 0;
245 AO.Optimize.mctsnumexpand = 1000;
246 AO.Optimize.mctsnumkeep = 10;
247 AO.Optimize.mctsnumrepeat = 1;
248 AO.Optimize.greedytimelimit = 0;
249 AO.Optimize.greedyminnum = 10;
250 AO.Optimize.greedymaxperc = 5;
251 AO.Optimize.printstats = 0;
252 AO.Optimize.debugflags = 0;
253 AO.Optimize.schemeflags = 0;
254 AO.Optimize.mctsdecaymode = 1;
256 M_free(AO.inscheme,
"Horner input scheme");
257 AO.inscheme = 0; AO.schemenum = 0;
259 return(CoOptimizeOption(s));
263 MesPrint(
"&Illegal optimization specification in format statement");
269 else if ( FG.cTable[*s] == 1 ) {
271 while ( FG.cTable[*s] == 1 ) x = 10*x + *s++ -
'0';
272 if ( x <= 0 || x >= MAXLINELENGTH ) {
274 MesPrint(
"&Illegal value for linesize: %d",x);
278 MesPrint(
" ... Too small value for linesize corrected to 39");
291 MesPrint(
"&Illegal linesize field in format statement");
295 key = FindKeyWord(s,formatoptions,
296 sizeof(formatoptions)/
sizeof(
KEYWORD));
298 if ( key->type == FORTRANMODE || key->type == PFORTRANMODE || key->type == DOUBLEFORTRANMODE
299 || key->type == QUADRUPLEFORTRANMODE || key->type == VORTRANMODE ) {
300 if (AC.LineLength > 72) AC.LineLength = 72;
302 if ( key->flags == 0 ) {
303 if ( key->type == FORTRANMODE || key->type == PFORTRANMODE
304 || key->type == DOUBLEFORTRANMODE || key->type == ALLINTEGERDOUBLE
305 || key->type == QUADRUPLEFORTRANMODE || key->type == VORTRANMODE ) {
306 AC.IsFortran90 = ISNOTFORTRAN90;
307 if ( AC.Fortran90Kind ) {
308 M_free(AC.Fortran90Kind,
"Fortran90 Kind");
309 AC.Fortran90Kind = 0;
312 if ( ( key->type == ALLINTEGERDOUBLE ) && AO.DoubleFlag != 0 ) {
317 AC.OutputMode = key->type & NODOUBLEMASK;
318 if ( ( key->type & DOUBLEPRECISIONFLAG ) != 0 ) {
321 else if ( ( key->type & QUADRUPLEPRECISIONFLAG ) != 0 ) {
326 else if ( key->flags == 1 ) {
327 AC.OutputMode = AC.OutNumberType = key->type;
329 else if ( key->flags == 2 ) {
330 while ( FG.cTable[*s] == 0 ) s++;
331 if ( *s == 0 ) AC.OutNumberType = 10;
332 else if ( *s ==
',' ) {
335 while ( FG.cTable[*s] == 1 ) x = 10*x + *s++ -
'0';
338 MesPrint(
"&Illegal float format specifier");
343 MesPrint(
"& ... float format value corrected to 3");
347 MesPrint(
"& ... float format value corrected to 100");
349 AC.OutNumberType = x;
353 else if ( key->flags == 3 ) {
354 AC.OutputSpaces = key->type;
356 else if ( key->flags == 4 ) {
357 AC.IsFortran90 = ISFORTRAN90;
358 if ( AC.Fortran90Kind ) {
359 M_free(AC.Fortran90Kind,
"Fortran90 Kind");
360 AC.Fortran90Kind = 0;
362 while ( FG.cTable[*s] <= 1 ) s++;
365 while ( *ss && *ss !=
',' ) ss++;
367 MesPrint(
"&No white space or comma's allowed in Fortran90 option: %s",s); error = 1;
370 AC.Fortran90Kind = strDup1(s,
"Fortran90 Kind");
374 AC.OutputMode = key->type & NODOUBLEMASK;
377 else if ( key->flags == 5 ) {
382 while ( FG.cTable[*s] == 0 ) s++;
383 while ( *s ==
' ' || *s ==
'\t' || *s ==
',' ) s++;
387 else if ( tolower(*s) ==
'o' && tolower(s[1]) ==
'f'
388 && tolower(s[2]) ==
'f' ) {
391 while ( *s ==
' ' || *s ==
'\t' || *s ==
',' ) s++;
392 if ( *s ) { s = ss;
goto WrongOption; }
395 else if ( FG.cTable[*s] == 1 ) {
397 ParseNumber(AO.FloatPrec,s)
402 if ( tolower(*s) ==
'd' ) { s++; }
403 else if ( tolower(*s) ==
'b' ) { AO.FloatPrec = AO.FloatPrec*log10(2.0); s++; }
404 else { s = ss;
goto WrongOption; }
405 while ( *s ==
' ' || *s ==
'\t' || *s ==
',' ) s++;
406 if ( *s ) { s = ss;
goto WrongOption; }
409WrongOption: MesPrint(
"&Illegal option in Format FloatPrecision: %s",s);
415 else if ( ( *s ==
'c' || *s ==
'C' ) && ( FG.cTable[s[1]] == 1 ) ) {
418 while ( *ss >=
'0' && *ss <=
'9' ) x = 10*x + *ss++ -
'0';
419 if ( *ss != 0 )
goto Unknown;
420 AC.OutputMode = CMODE;
424Unknown: MesPrint(
"&Unknown option: %s",s); error = 1;
437int CoCollect(UBYTE *s)
443 AC.AltCollectFun = 0;
444 if ( t == 0 )
goto syntaxerror;
445 t1 = t;
while ( *t1 ==
',' || *t1 ==
' ' || *t1 ==
'\t' ) t1++;
447 if ( *t1 && ( FG.cTable[*t1] == 0 || *t1 ==
'[' ) ) {
449 if ( t2 == 0 )
goto syntaxerror;
451 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
455 if ( *t && FG.cTable[*t] == 1 ) {
456 while ( *t >=
'0' && *t <=
'9' ) x = 10*x + *t++ -
'0';
457 if ( x > 100 ) x = 100;
458 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
459 if ( *t )
goto syntaxerror;
462 if ( *t )
goto syntaxerror;
465 if ( ( ( type = GetName(AC.varnames,s,&numfun,WITHAUTO) ) != CFUNCTION )
466 || ( functions[numfun].spec != 0 ) ) {
467 MesPrint(
"&%s should be a regular function",s);
469 if ( GetName(AC.exprnames,s,&numfun,NOAUTO) == NAMENOTFOUND )
470 AddFunction(s,0,0,0,0,0,-1,-1);
474 AC.CollectFun = numfun+FUNCTION;
475 AC.CollectPercentage = (WORD)x;
477 if ( ( ( type = GetName(AC.varnames,t1,&numfun,WITHAUTO) ) != CFUNCTION )
478 || ( functions[numfun].spec != 0 ) ) {
479 MesPrint(
"&%s should be a regular function",t1);
481 if ( GetName(AC.exprnames,t1,&numfun,NOAUTO) == NAMENOTFOUND )
482 AddFunction(t1,0,0,0,0,0,-1,-1);
486 AC.AltCollectFun = numfun+FUNCTION;
490 MesPrint(
"&Collect statement needs one or two functions (and a percentage) for its argument(s)");
499int setonoff(UBYTE *s,
int *flag,
int onvalue,
int offvalue)
501 if ( StrICmp(s,(UBYTE *)
"on") == 0 ) *flag = onvalue;
502 else if ( StrICmp(s,(UBYTE *)
"off") == 0 ) *flag = offvalue;
504 MesPrint(
"&Unknown option: %s, on or off expected",s);
515int CoCompress(UBYTE *s)
519 if ( StrICmp(s,(UBYTE *)
"on") == 0 ) {
523 else if ( StrICmp(s,(UBYTE *)
"off") == 0 ) {
528 t = s;
while ( FG.cTable[*t] <= 1 ) t++;
530 if ( StrICmp(s,(UBYTE *)
"gzip") == 0 ) {
532 Warning(
"gzip compression not supported on this platform");
536 AR.gzipCompress = GZIPDEFAULT;
539 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
541 if ( FG.cTable[*s] == 1 ) {
542 AR.gzipCompress = *s -
'0';
544 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
545 if ( *s == 0 )
return(0);
547 MesPrint(
"&Unknown gzip option: %s, a digit was expected",t);
552 MesPrint(
"&Unknown option: %s, on, off or gzip expected",s);
564int CoFlags(UBYTE *s,
int value)
568 MesPrint(
"&Proper syntax is: On/Off Flag,number[s];");
571 while ( *s ==
',' ) {
572 do { s++; }
while ( *s ==
',' );
574 if ( FG.cTable[*s] != 1 ) {
575 MesPrint(
"&Proper syntax is: On/Off Flag,number[s];");
579 while ( FG.cTable[*s] == 1 ) { i = 10*i + *s++ -
'0'; }
580 if ( i <= 0 || i > MAXFLAGS ) {
581 MesPrint(
"&The number of a flag in On/Off Flag should be in the range 0-%d",(
int)MAXFLAGS);
585 AC.debugFlags[i] = value;
588 MesPrint(
"&Proper syntax is: On/Off Flag,number[s];");
603 int i, num =
sizeof(onoffoptions)/
sizeof(
KEYWORD);
605 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
606 if ( *s == 0 )
return(0);
607 if ( chartype[*s] != 0 ) {
608 MesPrint(
"&Illegal character or option encountered in OFF statement");
611 t = s;
while ( chartype[*s] == 0 ) s++;
613 for ( i = 0; i < num; i++ ) {
614 if ( StrICont(t,(UBYTE *)(onoffoptions[i].name)) == 0 )
break;
617 MesPrint(
"&Unrecognized option in OFF statement: %s",t);
620 else if ( StrICont(t,(UBYTE *)
"compress") == 0 ) {
623 else if ( StrICont(t,(UBYTE *)
"checkpoint") == 0 ) {
625 AC.CheckpointInterval = 0;
626 if ( AC.CheckpointRunBefore ) { free(AC.CheckpointRunBefore); AC.CheckpointRunBefore = NULL; }
627 if ( AC.CheckpointRunAfter ) { free(AC.CheckpointRunAfter); AC.CheckpointRunAfter = NULL; }
628 if ( AC.NoShowInput == 0 ) MesPrint(
"Checkpoints deactivated.");
630 else if ( StrICont(t,(UBYTE *)
"threads") == 0 ) {
631 AS.MultiThreaded = 0;
633 else if ( StrICont(t,(UBYTE *)
"flag") == 0 ) {
635 return(CoFlags(s,0));
637 else if ( StrICont(t,(UBYTE *)
"innertest") == 0 ) {
640 if ( AC.TestValue ) {
641 M_free(AC.TestValue,
"InnerTest");
645 else if ( StrICont(t,(UBYTE *)
"sortreallocate") == 0 ) {
646 if ( AC.SortReallocateFlag == 2 ) {
654 *onoffoptions[i].var = onoffoptions[i].flags;
655 AR.SortType = AC.SortType;
656 AC.mparallelflag = AC.parallelflag | AM.hparallelflag;
669 int i, num =
sizeof(onoffoptions)/
sizeof(
KEYWORD);
672 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
673 if ( *s == 0 )
return(0);
674 if ( chartype[*s] != 0 ) {
675 MesPrint(
"&Illegal character or option encountered in ON statement");
678 t = s;
while ( chartype[*s] == 0 ) s++;
680 for ( i = 0; i < num; i++ ) {
681 if ( StrICont(t,(UBYTE *)(onoffoptions[i].name)) == 0 )
break;
684 MesPrint(
"&Unrecognized option in ON statement: %s",t);
687 if ( StrICont(t,(UBYTE *)
"backtrace") == 0 ) {
688#ifndef ENABLE_BACKTRACE
689 Warning(
"backtrace not supported on this platform");
692 else if ( StrICont(t,(UBYTE *)
"compress") == 0 ) {
695 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
698 while ( FG.cTable[*s] <= 1 ) s++;
700 if ( StrICmp(t,(UBYTE *)
"gzip") == 0 ) {
702 Warning(
"gzip compression not supported on this platform");
706 ZWRAP_useZSTDcompression(0);
709 else if ( StrICmp(t,(UBYTE *)
"zstd") == 0 ) {
711 ZWRAP_useZSTDcompression(1);
713 Warning(
"zstd compression not supported on this platform");
717 MesPrint(
"&Unrecognized option in ON compress statement: %s",t);
722 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
723 if ( FG.cTable[*s] == 1 ) {
724 AR.gzipCompress = *s++ -
'0';
725 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
727 MesPrint(
"&Unrecognized option in ON compress gzip/zstd statement: %s",t);
731 else if ( *s == 0 ) {
732 AR.gzipCompress = GZIPDEFAULT;
735 MesPrint(
"&Unrecognized option in ON compress gzip/zstd statement: %s, single digit expected",t);
740 else if ( StrICont(t,(UBYTE *)
"checkpoint") == 0 ) {
742 AC.CheckpointInterval = 0;
743 if ( AC.CheckpointRunBefore ) { free(AC.CheckpointRunBefore); AC.CheckpointRunBefore = NULL; }
744 if ( AC.CheckpointRunAfter ) { free(AC.CheckpointRunAfter); AC.CheckpointRunAfter = NULL; }
747 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
748 if ( FG.cTable[*s] == 1 ) {
751 do { interval = 10*interval + *s++ -
'0'; }
while ( FG.cTable[*s] == 1 );
752 if ( *s ==
's' || *s ==
'S' ) {
755 else if ( *s ==
'm' || *s ==
'M' ) {
758 else if ( *s ==
'h' || *s ==
'H' ) {
759 interval *= 3600; s++;
761 else if ( *s ==
'd' || *s ==
'D' ) {
762 interval *= 86400; s++;
764 if ( *s !=
',' && FG.cTable[*s] != 6 && FG.cTable[*s] != 10 ) {
765 MesPrint(
"&Unrecognized time interval in ON Checkpoint statement: %s", t);
768 AC.CheckpointInterval = interval * 100;
770 else if ( FG.cTable[*s] == 0 ) {
773 while ( FG.cTable[*s] == 0 ) s++;
775 if ( StrICmp(t,(UBYTE *)
"run") == 0 ) {
778 else if ( StrICmp(t,(UBYTE *)
"runafter") == 0 ) {
781 else if ( StrICmp(t,(UBYTE *)
"runbefore") == 0 ) {
785 MesPrint(
"&Unrecognized option in ON Checkpoint statement: %s", t);
789 if ( *s !=
'=' && FG.cTable[*(s+1)] != 9 ) {
790 MesPrint(
"&Unrecognized option in ON Checkpoint statement: %s", t);
796 if ( FG.cTable[*s] == 9 ) {
799 if ( AC.CheckpointRunBefore ) {
800 free(AC.CheckpointRunBefore); AC.CheckpointRunBefore = NULL;
803 AC.CheckpointRunBefore = Malloc1(s-t+1,
"AC.CheckpointRunBefore");
804 StrCopy(t, (UBYTE*)AC.CheckpointRunBefore);
808 if ( AC.CheckpointRunAfter ) {
809 free(AC.CheckpointRunAfter); AC.CheckpointRunAfter = NULL;
812 AC.CheckpointRunAfter = Malloc1(s-t+1,
"AC.CheckpointRunAfter");
813 StrCopy(t, (UBYTE*)AC.CheckpointRunAfter);
821 if ( FG.cTable[*s] != 9 ) {
822 MesPrint(
"&Unrecognized option in ON Checkpoint statement: %s", t);
846 else if ( StrICont(t,(UBYTE *)
"indentspace") == 0 ) {
848 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
851 while ( FG.cTable[*s] == 1 ) { i = 10*i + *s++ -
'0'; }
853 MesPrint(
"&Unrecognized option in ON IndentSpace statement: %s",t);
857 Warning(
"IndentSpace parameter adjusted to 40");
863 AO.IndentSpace = AM.ggIndentSpace;
867 else if ( ( StrICont(t,(UBYTE *)
"fewerstats") == 0 ) ||
868 ( StrICont(t,(UBYTE *)
"fewerstatistics") == 0 ) ) {
870 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
873 while ( FG.cTable[*s] == 1 ) { i = 10*i + *s++ -
'0'; }
875 MesPrint(
"&Unrecognized option in ON FewerStatistics statement: %s",t);
878 if ( i > AM.S0->MaxPatches ) {
880 MesPrint(
"&Warning: FewerStatistics parameter greater than MaxPatches(=%d). Adjusted to %d"
881 ,AM.S0->MaxPatches,(AM.S0->MaxPatches+1)/2);
882 i = (AM.S0->MaxPatches+1)/2;
884 AC.ShortStatsMax = i;
887 AC.ShortStatsMax = 10;
891 else if ( StrICont(t,(UBYTE *)
"threads") == 0 ) {
892 if ( AM.totalnumberofthreads > 1 ) AS.MultiThreaded = 1;
894 else if ( StrICont(t,(UBYTE *)
"flag") == 0 ) {
896 return(CoFlags(s,1));
898 else if ( StrICont(t,(UBYTE *)
"innertest") == 0 ) {
901 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
903 t = s;
while ( *t ) t++;
904 while ( t[-1] ==
' ' || t[-1] ==
'\t' ) t--;
906 if ( AC.TestValue ) M_free(AC.TestValue,
"InnerTest");
907 AC.TestValue = strDup1(s,
"InnerTest");
910 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
913 if ( AC.TestValue ) {
914 M_free(AC.TestValue,
"InnerTest");
919 else if ( StrICont(t,(UBYTE *)
"flint") == 0 ) {
921 MesPrint(
"&Warning: FORM was not built with FLINT support.");
922 MesPrint(
"Statement has no effect.");
926 *onoffoptions[i].var = onoffoptions[i].type;
927 AR.SortType = AC.SortType;
928 AC.mparallelflag = AC.parallelflag | AM.hparallelflag;
937int CoInsideFirst(UBYTE *s) {
return(setonoff(s,&AC.insidefirst,1,0)); }
944int CoProperCount(UBYTE *s) {
return(setonoff(s,&AC.BottomLevel,1,0)); }
951int CoDelete(UBYTE *s)
954 if ( StrICmp(s,(UBYTE *)
"storage") == 0 ) {
955 if ( DeleteStore(1) < 0 ) {
957 MesPrint(
"!>Cannot restart storage file");
964 while ( *t && *t !=
',' && *t !=
'>' ) t++;
966 if ( ( StrICmp(s,(UBYTE *)
"extrasymbols") == 0 )
967 || ( StrICmp(s,(UBYTE *)
"extrasymbol") == 0 ) ) {
975 if ( FG.cTable[*s] != 1 )
goto unknown;
976 while ( *s <=
'9' && *s >=
'0' ) x = 10*x + *s++ -
'0';
977 if ( *s )
goto unknown;
979 else if ( *s )
goto unknown;
980 if ( x < AM.gnumextrasym ) x = AM.gnumextrasym;
981 PruneExtraSymbols(x);
986 MesPrint(
"&Unknown option: %s",s);
1000 if ( StrICmp(s,(UBYTE *)
"brackets") == 0 ) AC.ComDefer = 1;
1001 else { MesPrint(
"&Unknown option: '%s'",s);
return(1); }
1010int CoFixIndex(UBYTE *s)
1012 int x, y, error = 0;
1014 if ( FG.cTable[*s] != 1 ) {
1015proper: MesPrint(
"&Proper syntax is: FixIndex,number:value[,number,value];");
1019 if ( *s !=
':' )
goto proper;
1021 if ( *s !=
'-' && *s !=
'+' && FG.cTable[*s] != 1 )
goto proper;
1022 ParseSignedNumber(y,s)
1023 if ( *s && *s !=
',' )
goto proper;
1024 while ( *s ==
',' ) s++;
1025 if ( x >= AM.OffsetIndex ) {
1026 MesPrint(
"&Fixed index out of allowed range. Change ConstIndex in setup file?");
1027 MesPrint(
"&Current value of ConstIndex = %d",AM.OffsetIndex-1);
1030 if ( y != (
int)((WORD)y) ) {
1031 MesPrint(
"&Value of d_(%d,%d) outside range for this computer",x,x);
1034 if ( error == 0 ) AC.FixIndices[x] = y;
1044int CoMetric(UBYTE *s)
1045{ DUMMYUSE(s); MesPrint(
"&The metric statement does not do anything yet");
return(1); }
1052int DoPrint(UBYTE *s,
int par)
1054 int i, error = 0, numdol = 0, type;
1058 WORD numexpr, tofile = 0, *w, par2 = 0;
1059 CBUF *C = cbuf + AC.cbufnum;
1060 while ( *s ==
',' ) s++;
1061 if ( ( *s ==
'+' || *s ==
'-' ) && ( s[1] ==
'f' || s[1] ==
'F' ) ) {
1062 t = s + 2;
while ( *t ==
' ' || *t ==
',' ) t++;
1064 if ( *s ==
'+' ) { tofile = 1; handle = AC.LogHandle; }
1068 else if ( *s ==
'<' ) {
1071 while ( *s && *s !=
'>' ) s++;
1073 MesPrint(
"&Improper filename in print statement");
1078 if ( ( handle = GetChannel((
char *)filename,1) ) < 0 )
return(1);
1079 SKIPBLANKS(s)
if ( *s ==
',' ) s++; SKIPBLANKS(s)
1080 if ( *s ==
'+' && ( s[1] ==
's' || s[1] ==
'S' ) ) {
1082 par2 |= PRINTONETERM;
1083 if ( *s ==
's' || *s ==
'S' ) {
1085 par2 |= PRINTONEFUNCTION;
1086 if ( *s ==
's' || *s ==
'S' ) {
1091 SKIPBLANKS(s)
if ( *s ==
',' ) s++; SKIPBLANKS(s)
1094 if ( par == PRINTON && *s ==
'"' ) {
1096 if ( tofile == 1 ) code[0] = TYPEFPRINT;
1097 else code[0] = TYPEPRINT;
1101 while ( *s && *s !=
'"' ) {
1102 if ( *s ==
'\\' ) s++;
1103 if ( *s ==
'%' && s[1] ==
'$' ) numdol++;
1107 MesPrint(
"&String in print statement should be enclosed in \"");
1111 AddComString(3,code,name,1);
1113 while ( *s ==
',' ) {
1116 s++; name = s;
while ( FG.cTable[*s] <= 1 ) s++;
1118 type = GetName(AC.dollarnames,name,&numexpr,NOAUTO);
1119 if ( type == NAMENOTFOUND ) {
1120 MesPrint(
"&$ variable %s not (yet) defined",name);
1124 C->
lhs[C->numlhs][1] += 2;
1125 *(C->
Pointer)++ = DOLLAREXPRESSION;
1131 MesPrint(
"&Illegal object in print statement");
1139 s = GetDoParam(s,&(C->
Pointer),-1);
1140 if ( s == 0 )
return(1);
1142 MesPrint(
"&unmatched [] in $ factor");
1150 MesPrint(
"&Illegal object in print statement");
1154 MesPrint(
"&More $ variables asked for than provided");
1162 for ( e = Expressions, i = NumExpressions; i > 0; i--, e++ ) {
1163 if ( e->status == LOCALEXPRESSION || e->status ==
1164 GLOBALEXPRESSION || e->status == UNHIDELEXPRESSION
1165 || e->status == UNHIDEGEXPRESSION ) e->printflag = par;
1172 if ( tolower(*s) ==
'f' ) par |= PRINTLFILE;
1173 else if ( tolower(*s) ==
's' ) {
1174 if ( tolower(s[1]) ==
's' ) {
1175 if ( tolower(s[2]) ==
's' ) {
1176 par |= PRINTONEFUNCTION | PRINTONETERM | PRINTALL;
1179 else if ( ( par & 3 ) < 2 ) par |= PRINTONEFUNCTION | PRINTONETERM;
1183 if ( ( par & 3 ) < 2 ) par |= PRINTONETERM;
1187illeg: MesPrint(
"&Illegal option in (n)print statement");
1191 if ( *s == 0 )
goto AllExpr;
1193 else if ( *s ==
'-' ) {
1195 if ( tolower(*s) ==
'f' ) par &= ~PRINTLFILE;
1196 else if ( tolower(*s) ==
's' ) {
1197 if ( tolower(s[1]) ==
's' ) {
1198 if ( tolower(s[2]) ==
's' ) {
1202 else if ( ( par & 3 ) < 2 ) {
1203 par &= ~PRINTONEFUNCTION;
1209 if ( ( par & 3 ) < 2 ) {
1210 par &= ~PRINTONETERM;
1211 par &= ~PRINTONEFUNCTION;
1218 if ( *s == 0 )
goto AllExpr;
1220 else if ( FG.cTable[*s] == 0 || *s ==
'[' ) {
1223 MesPrint(
"&Improper name in (n)print statement");
1227 if ( ( GetName(AC.exprnames,name,&numexpr,NOAUTO) == CEXPRESSION )
1228 && ( Expressions[numexpr].status == LOCALEXPRESSION
1229 || Expressions[numexpr].status == GLOBALEXPRESSION ) ) {
1231 if ( c ==
'[' && s[1] ==
']' ) {
1232 Expressions[numexpr].printflag = par | PRINTCONTENTS;
1236 Expressions[numexpr].printflag = par;
1238 else if ( GetLastExprName(name,&numexpr)
1239 && ( Expressions[numexpr].status == LOCALEXPRESSION
1240 || Expressions[numexpr].status == GLOBALEXPRESSION
1241 || Expressions[numexpr].status == UNHIDELEXPRESSION
1242 || Expressions[numexpr].status == UNHIDEGEXPRESSION
1247 MesPrint(
"&%s is not the name of an active expression",name);
1251 if ( c == 0 )
return(0);
1252 if ( c ==
'-' || c ==
'+' ) s--;
1254 else if ( *s ==
',' ) s++;
1256 MesPrint(
"&Illegal object in (n)print statement");
1268int CoPrint(UBYTE *s) {
return(DoPrint(s,PRINTON)); }
1275int CoPrintB(UBYTE *s) {
return(DoPrint(s,PRINTCONTENT)); }
1282int CoNPrint(UBYTE *s) {
return(DoPrint(s,PRINTOFF)); }
1289int CoPushHide(UBYTE *s)
1294 if ( AR.Fscr[2].PObuffer == 0 ) {
1295 ScratchBuf = (WORD *)Malloc1(AM.HideSize*
sizeof(WORD),
"hidesize");
1296 AR.Fscr[2].POsize = AM.HideSize *
sizeof(WORD);
1297 AR.Fscr[2].POfull = AR.Fscr[2].POfill = AR.Fscr[2].PObuffer = ScratchBuf;
1298 AR.Fscr[2].POstop = AR.Fscr[2].PObuffer + AM.HideSize;
1299 PUTZERO(AR.Fscr[2].POposition);
1301 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
1304 MesPrint(
"&PushHide statement should have no arguments");
1307 for ( i = 0; i < NumExpressions; i++ ) {
1308 switch ( Expressions[i].status ) {
1309 case DROPLEXPRESSION:
1310 case SKIPLEXPRESSION:
1311 case LOCALEXPRESSION:
1312 Expressions[i].status = HIDELEXPRESSION;
1313 Expressions[i].hidelevel = AC.HideLevel-1;
1315 case DROPGEXPRESSION:
1316 case SKIPGEXPRESSION:
1317 case GLOBALEXPRESSION:
1318 Expressions[i].status = HIDEGEXPRESSION;
1319 Expressions[i].hidelevel = AC.HideLevel-1;
1333int CoPopHide(UBYTE *s)
1336 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
1337 if ( AC.HideLevel <= 0 ) {
1338 MesPrint(
"&PopHide statement without corresponding PushHide statement");
1343 MesPrint(
"&PopHide statement should have no arguments");
1346 for ( i = 0; i < NumExpressions; i++ ) {
1347 switch ( Expressions[i].status ) {
1348 case HIDDENLEXPRESSION:
1349 if ( Expressions[i].hidelevel > AC.HideLevel )
1350 Expressions[i].status = UNHIDELEXPRESSION;
1352 case HIDDENGEXPRESSION:
1353 if ( Expressions[i].hidelevel > AC.HideLevel )
1354 Expressions[i].status = UNHIDEGEXPRESSION;
1368int SetExprCases(
int par,
int setunset,
int val)
1373 case SKIPLEXPRESSION:
1374 if ( !setunset ) val = LOCALEXPRESSION;
1376 case SKIPGEXPRESSION:
1377 if ( !setunset ) val = GLOBALEXPRESSION;
1379 case LOCALEXPRESSION:
1380 if ( setunset ) val = SKIPLEXPRESSION;
1382 case GLOBALEXPRESSION:
1383 if ( setunset ) val = SKIPGEXPRESSION;
1385 case INTOHIDEGEXPRESSION:
1386 case INTOHIDELEXPRESSION:
1393 case SKIPLEXPRESSION:
1394 case LOCALEXPRESSION:
1395 case HIDELEXPRESSION:
1396 if ( setunset ) val = DROPLEXPRESSION;
1398 case DROPLEXPRESSION:
1399 if ( !setunset ) val = LOCALEXPRESSION;
1401 case SKIPGEXPRESSION:
1402 case GLOBALEXPRESSION:
1403 case HIDEGEXPRESSION:
1404 if ( setunset ) val = DROPGEXPRESSION;
1406 case DROPGEXPRESSION:
1407 if ( !setunset ) val = GLOBALEXPRESSION;
1409 case HIDDENLEXPRESSION:
1410 case UNHIDELEXPRESSION:
1411 if ( setunset ) val = DROPHLEXPRESSION;
1413 case HIDDENGEXPRESSION:
1414 case UNHIDEGEXPRESSION:
1415 if ( setunset ) val = DROPHGEXPRESSION;
1417 case DROPHLEXPRESSION:
1418 if ( !setunset ) val = HIDDENLEXPRESSION;
1420 case DROPHGEXPRESSION:
1421 if ( !setunset ) val = HIDDENGEXPRESSION;
1423 case INTOHIDEGEXPRESSION:
1424 case INTOHIDELEXPRESSION:
1431 case DROPLEXPRESSION:
1432 case SKIPLEXPRESSION:
1433 case LOCALEXPRESSION:
1434 if ( setunset ) val = HIDELEXPRESSION;
1436 case HIDELEXPRESSION:
1437 if ( !setunset ) val = LOCALEXPRESSION;
1439 case DROPGEXPRESSION:
1440 case SKIPGEXPRESSION:
1441 case GLOBALEXPRESSION:
1442 if ( setunset ) val = HIDEGEXPRESSION;
1444 case HIDEGEXPRESSION:
1445 if ( !setunset ) val = GLOBALEXPRESSION;
1447 case INTOHIDEGEXPRESSION:
1448 case INTOHIDELEXPRESSION:
1455 case HIDDENLEXPRESSION:
1456 case DROPHLEXPRESSION:
1457 if ( setunset ) val = UNHIDELEXPRESSION;
1459 case UNHIDELEXPRESSION:
1460 if ( !setunset ) val = HIDDENLEXPRESSION;
1462 case HIDDENGEXPRESSION:
1463 case DROPHGEXPRESSION:
1464 if ( setunset ) val = UNHIDEGEXPRESSION;
1466 case UNHIDEGEXPRESSION:
1467 if ( !setunset ) val = HIDDENGEXPRESSION;
1469 case INTOHIDEGEXPRESSION:
1470 case INTOHIDELEXPRESSION:
1477 case HIDDENLEXPRESSION:
1478 case HIDDENGEXPRESSION:
1479 MesPrint(
"&Expression is already hidden");
1481 case DROPHLEXPRESSION:
1482 case DROPHGEXPRESSION:
1483 case UNHIDELEXPRESSION:
1484 case UNHIDEGEXPRESSION:
1486 MesPrint(
"&Cannot unhide/drop and put intohide expression in the same module");
1490 case LOCALEXPRESSION:
1491 case DROPLEXPRESSION:
1492 case SKIPLEXPRESSION:
1493 case HIDELEXPRESSION:
1494 if ( setunset ) val = INTOHIDELEXPRESSION;
1496 case GLOBALEXPRESSION:
1497 case DROPGEXPRESSION:
1498 case SKIPGEXPRESSION:
1499 case HIDEGEXPRESSION:
1500 if ( setunset ) val = INTOHIDEGEXPRESSION;
1502 case INTOHIDELEXPRESSION:
1503 if ( !setunset ) val = LOCALEXPRESSION;
1505 case INTOHIDEGEXPRESSION:
1506 if ( !setunset ) val = GLOBALEXPRESSION;
1523int SetExpr(UBYTE *s,
int setunset,
int par)
1529 for ( i = 0; i < NumExpressions; i++ ) {
1530 w = &(Expressions[i].status);
1531 *w = SetExprCases(par,setunset,*w);
1532 if ( *w < 0 ) error = 1;
1533 if ( ( par == HIDE || par == INTOHIDE ) && setunset == 1 )
1534 Expressions[i].hidelevel = AC.HideLevel;
1539 if ( *s ==
',' ) { s++;
continue; }
1540 if ( *s ==
'0' ) { s++;
continue; }
1543 MesPrint(
"&Improper name for an expression: '%s'",name);
1547 if ( GetName(AC.exprnames,name,&numexpr,NOAUTO) == CEXPRESSION ) {
1548 w = &(Expressions[numexpr].status);
1549 *w = SetExprCases(par,setunset,*w);
1550 if ( *w < 0 ) error = 1;
1551 if ( ( par == HIDE || par == INTOHIDE ) && setunset == 1 )
1552 Expressions[numexpr].hidelevel = AC.HideLevel;
1554 else if ( GetName(AC.varnames,name,&numexpr,NOAUTO) != NAMENOTFOUND ) {
1555 MesPrint(
"&%s is not an expression",name);
1568int CoDrop(UBYTE *s) {
return(SetExpr(s,1,DROP)); }
1575int CoNoDrop(UBYTE *s) {
return(SetExpr(s,0,DROP)); }
1582int CoSkip(UBYTE *s) {
return(SetExpr(s,1,SKIP)); }
1589int CoNoSkip(UBYTE *s) {
return(SetExpr(s,0,SKIP)); }
1596int CoHide(UBYTE *inp) {
1599 if ( AR.Fscr[2].PObuffer == 0 ) {
1600 ScratchBuf = (WORD *)Malloc1(AM.HideSize*
sizeof(WORD),
"hidesize");
1601 AR.Fscr[2].POsize = AM.HideSize *
sizeof(WORD);
1602 AR.Fscr[2].POfull = AR.Fscr[2].POfill = AR.Fscr[2].PObuffer = ScratchBuf;
1603 AR.Fscr[2].POstop = AR.Fscr[2].PObuffer + AM.HideSize;
1604 PUTZERO(AR.Fscr[2].POposition);
1606 return(SetExpr(inp,1,HIDE));
1614int CoIntoHide(UBYTE *inp) {
1617 if ( AR.Fscr[2].PObuffer == 0 ) {
1618 ScratchBuf = (WORD *)Malloc1(AM.HideSize*
sizeof(WORD),
"hidesize");
1619 AR.Fscr[2].POsize = AM.HideSize *
sizeof(WORD);
1620 AR.Fscr[2].POfull = AR.Fscr[2].POfill = AR.Fscr[2].PObuffer = ScratchBuf;
1621 AR.Fscr[2].POstop = AR.Fscr[2].PObuffer + AM.HideSize;
1622 PUTZERO(AR.Fscr[2].POposition);
1624 return(SetExpr(inp,1,INTOHIDE));
1632int CoNoIntoHide(UBYTE *inp) {
return(SetExpr(inp,0,INTOHIDE)); }
1639int CoNoHide(UBYTE *inp) {
return(SetExpr(inp,0,HIDE)); }
1646int CoUnHide(UBYTE *inp) {
return(SetExpr(inp,1,UNHIDE)); }
1653int CoNoUnHide(UBYTE *inp) {
return(SetExpr(inp,0,UNHIDE)); }
1660void AddToCom(
int n, WORD *array)
1662 CBUF *C = cbuf+AC.cbufnum;
1664 MesPrint(
" %a",n,array);
1667 while ( --n >= 0 ) *(C->
Pointer)++ = *array++;
1675int AddComString(
int n, WORD *array, UBYTE *thestring,
int par)
1677 CBUF *C = cbuf+AC.cbufnum;
1678 UBYTE *s = thestring, *w;
1683 int i, numchars = 0, size, zeroes;
1685 if ( *s ==
'\\' ) s++;
1686 else if ( par == 1 &&
1687 ( ( *s ==
'%' && s[1] !=
't' && s[1] !=
'T' && s[1] !=
'$' &&
1688 s[1] !=
'w' && s[1] !=
'W' && s[1] !=
'r' && s[1] != 0 ) || *s ==
'#'
1689 || *s ==
'@' || *s ==
'&' ) ) {
1695 size = numchars/
sizeof(WORD)+1;
1702 for ( i = 1; i < n; i++ ) *(C->
Pointer)++ = array[i];
1708 zeroes = size*
sizeof(WORD)-numchars;
1711 if ( *s ==
'\\' ) s++;
1712 else if ( par == 1 && ( ( *s ==
'%' &&
1713 s[1] !=
't' && s[1] !=
'T' && s[1] !=
'$' &&
1714 s[1] !=
'w' && s[1] !=
'W' && s[1] !=
'r' && s[1] != 0 ) || *s ==
'#'
1715 || *s ==
'@' || *s ==
'&' ) ) {
1720 while ( --zeroes >= 0 ) *w++ = 0;
1723 MesPrint(
"LH: %a",size+1+n,cc);
1724 MesPrint(
" %s",thestring);
1734int Add2ComStrings(
int n, WORD *array, UBYTE *string1, UBYTE *string2)
1736 CBUF *C = cbuf+AC.cbufnum;
1737 UBYTE *s1 = string1, *s2 = string2, *w;
1738 int i, num1chars = 0, num2chars = 0, size1, size2, zeroes1, zeroes2;
1740 while ( *s1 ) { s1++; num1chars++; }
1741 size1 = num1chars/
sizeof(WORD)+1;
1743 while ( *s2 ) { s2++; num2chars++; }
1744 size2 = num2chars/
sizeof(WORD)+1;
1749 *(C->
Pointer)++ = size1+size2+n+3;
1750 for ( i = 1; i < n; i++ ) *(C->
Pointer)++ = array[i];
1753 zeroes1 = size1*
sizeof(WORD)-num1chars;
1755 while ( *s1 ) { *w++ = *s1++; }
1756 while ( --zeroes1 >= 0 ) *w++ = 0;
1761 zeroes2 = size2*
sizeof(WORD)-num2chars;
1763 while ( *s2 ) { *w++ = *s2++; }
1764 while ( --zeroes2 >= 0 ) *w++ = 0;
1775int CoDiscard(UBYTE *s)
1778 Add2Com(TYPEDISCARD)
1781 MesPrint(
"&Illegal argument in discard statement: '%s'",s);
1796static WORD ccarray[5] = { TYPEOPERATION,5,CONTRACT,0,0 };
1798int CoContract(UBYTE *s)
1804 if ( *s !=
',' && *s ) {
1805proper: MesPrint(
"&Illegal number in contract statement");
1811 else ccarray[4] = 0;
1812 if ( FG.cTable[*s] == 1 ) {
1814 if ( *s )
goto proper;
1817 else if ( *s )
goto proper;
1818 else ccarray[3] = -1;
1827int CoGoTo(UBYTE *inp)
1831 while ( FG.cTable[*s] <= 1 ) s++;
1833 MesPrint(
"&Label should be an alpha-numeric string");
1837 Add3Com(TYPEGOTO,x);
1846int CoLabel(UBYTE *inp)
1850 while ( FG.cTable[*s] <= 1 ) s++;
1852 MesPrint(
"&Label should be an alpha-numeric string");
1856 if ( AC.Labels[x] >= 0 ) {
1857 MesPrint(
"&Label %s defined more than once",AC.LabelNames[x]);
1860 AC.Labels[x] = cbuf[AC.cbufnum].numlhs;
1873int DoArgument(UBYTE *s,
int par)
1876 UBYTE *name, *t, *v, c;
1877 WORD *oldworkpointer = AT.WorkPointer, *w, *ww, number, *scale;
1878 int error = 0, zeroflag, type, x;
1879 AC.lhdollarflag = 0;
1880 while ( *s ==
',' ) s++;
1886 if ( AC.arglevel >= MAXNEST ) {
1887 MesPrint(
"@Nesting of argument statements more than %d levels"
1891 AC.argsumcheck[AC.arglevel] = NestingChecksum();
1892 AC.argstack[AC.arglevel] = cbuf[AC.cbufnum].Pointer
1893 - cbuf[AC.cbufnum].Buffer + 2;
1895 *w++ = cbuf[AC.cbufnum].numlhs;
1900 case TYPESPLITFIRSTARG:
1901 case TYPESPLITLASTARG:
1903 case TYPEARGTOEXTRASYMBOL:
1904 *w++ = cbuf[AC.cbufnum].numlhs+1;
1912 s++; ParseSignedNumber(x,s)
1913 while ( *s ==
',' ) s++;
1917 t = s+1; SKIPBRA3(s)
1918 if ( par == TYPEARG ) {
1919 MesPrint(
"&Illegal () entry in argument statement");
1920 error = 1; s++;
goto skipbracks;
1922 else if ( par == TYPESPLITFIRSTARG ) {
1923 MesPrint(
"&Illegal () entry in splitfirstarg statement");
1924 error = 1; s++;
goto skipbracks;
1926 else if ( par == TYPESPLITLASTARG ) {
1927 MesPrint(
"&Illegal () entry in splitlastarg statement");
1928 error = 1; s++;
goto skipbracks;
1933 MesPrint(
"&Wildcarding not allowed in this type of statement");
1939 if ( *t ==
'(' && v[-1] ==
')' ) {
1941 if ( par == TYPESPLITARG ) oldworkpointer[0] = TYPESPLITARG2;
1942 else if ( par == TYPEFACTARG ) oldworkpointer[0] = TYPEFACTARG2;
1943 else if ( par == TYPENORM4 ) oldworkpointer[0] = TYPENORM4;
1944 else if ( par == TYPENORM ) {
1945 if ( *t ==
'-' ) { oldworkpointer[0] = TYPENORM3; t++; }
1946 else { oldworkpointer[0] = TYPENORM2; *scale = 0; }
1950 CBUF *C = cbuf+AC.cbufnum;
1951 WORD oldnumrhs = C->numrhs, oldnumlhs = C->numlhs;
1952 WORD prototype[SUBEXPSIZE+40];
1957 prototype[0] = SUBEXPRESSION;
1958 prototype[1] = SUBEXPSIZE;
1959 prototype[2] = C->numrhs+1;
1961 prototype[4] = AC.cbufnum;
1962 AT.WorkPointer += TYPEARGHEADSIZE+1;
1964 if ( ( retcode = CompileAlgebra(t,LHSIDE,prototype) ) < 0 )
1967 prototype[2] = retcode;
1968 ww = C->
lhs[retcode];
1969 AC.lhdollarflag = 0;
1971 *w++ = -2; *w++ = 0;
1973 else if ( ww[ww[0]] != 0 ) {
1974 MesPrint(
"&There should be only one term between ()");
1977 else if (
NewSort(BHEAD0) ) {
if ( !error ) error = 1; }
1980 if ( !error ) error = 1;
1983 AN.RepPoint = AT.RepCount + 1;
1986 while ( --i >= 0 ) *m++ = *mm++;
1987 mm = AT.WorkPointer; AT.WorkPointer = m;
1988 AR.Cnumlhs = C->numlhs;
1992 else if (
EndSort(BHEAD mm,0) < 0 ) {
1994 AT.WorkPointer = mm;
1996 else if ( *mm == 0 ) {
1997 *w++ = -2; *w++ = 0;
1998 AT.WorkPointer = mm;
2000 else if ( mm[mm[0]] != 0 ) {
2002 AT.WorkPointer = mm;
2005 AT.WorkPointer = mm;
2007 if ( par == TYPEFACTARG ) {
2008 if ( *mm != ABS(m[-1])+1 ) {
2011 mm[-1] = -*mm-1; w += *mm+1;
2019 { mm[-1] = -*mm-1; w += *mm+1; }
2021 oldworkpointer[1] = w - oldworkpointer;
2025 oldworkpointer[5] = AC.lhdollarflag;
2028 C->numrhs = oldnumrhs;
2029 C->numlhs = oldnumlhs;
2034 if ( *s == 0 ) { *w++ = 0; *w++ = 2; *w++ = 1; }
2037 if ( *s ==
',' ) { s++;
continue; }
2038 ww = w; *w++ = 0; w++;
2039 if ( FG.cTable[*s] > 1 && *s !=
'[' && *s !=
'{' ) {
2040 MesPrint(
"&Illegal parameters in statement");
2044 while ( FG.cTable[*s] == 0 || *s ==
'[' || *s ==
'{' ) {
2049 number = DoTempSet(name,s);
2050 name--; *s++ = c; c = *s; *s = 0;
2056 MesPrint(
"&Illegal name '%s'",name);
2060 if ( ( type = GetName(AC.varnames,name,&number,WITHAUTO) ) == CSET ) {
2061doset:
if ( Sets[number].type != CFUNCTION )
goto nofun;
2064 r1 = SetElements + Sets[number].first;
2065 r2 = SetElements + Sets[number].last;
2067 if ( *r1++ == FLOATFUN ) {
2068 MesPrint(
"&Illegal use of argument environment and float_.");
2073 *w++ = CSET; *w++ = number;
2075 else if ( type == CFUNCTION ) {
2077 if ( (number + FUNCTION) == FLOATFUN ) {
2078 MesPrint(
"&Illegal use of argument environment and float_.");
2082 *w++ = CFUNCTION; *w++ = number + FUNCTION;
2085nofun: MesPrint(
"&%s is not a function or a set of functions"
2091 while ( *s ==
',' ) s++;
2094 ww = w; w++; zeroflag = 0;
2095 while ( FG.cTable[*s] == 1 ) {
2097 if ( *s && *s !=
',' ) {
2098 MesPrint(
"&Illegal separator after number");
2100 while ( *s && *s !=
',' ) s++;
2102 while ( *s ==
',' ) s++;
2103 if ( x == 0 ) zeroflag = 1;
2104 if ( !zeroflag ) *w++ = (WORD)x;
2109 oldworkpointer[1] = w - oldworkpointer;
2110 if ( par == TYPEARG ) {
2111 AC.argstack[AC.arglevel-1] = cbuf[AC.cbufnum].Pointer
2112 - cbuf[AC.cbufnum].Buffer + 2;
2114 AddNtoL(oldworkpointer[1],oldworkpointer);
2115 AT.WorkPointer = oldworkpointer;
2124int CoArgument(UBYTE *s) {
return(DoArgument(s,TYPEARG)); }
2131int CoEndArgument(UBYTE *s)
2133 CBUF *C = cbuf+AC.cbufnum;
2134 while ( *s ==
',' ) s++;
2136 MesPrint(
"&Illegal syntax for EndArgument statement");
2139 if ( AC.arglevel <= 0 ) {
2140 MesPrint(
"&EndArgument without corresponding Argument statement");
2144 cbuf[AC.cbufnum].Buffer[AC.argstack[AC.arglevel]] = C->numlhs;
2145 if ( AC.argsumcheck[AC.arglevel] != NestingChecksum() ) {
2157int CoInside(UBYTE *s) {
return(ExecInside(s)); }
2164int CoEndInside(UBYTE *s)
2166 CBUF *C = cbuf+AC.cbufnum;
2167 while ( *s ==
',' ) s++;
2169 MesPrint(
"&Illegal syntax for EndInside statement");
2172 if ( AC.insidelevel <= 0 ) {
2173 MesPrint(
"&EndInside without corresponding Inside statement");
2177 cbuf[AC.cbufnum].Buffer[AC.insidestack[AC.insidelevel]] = C->numlhs;
2178 if ( AC.insidesumcheck[AC.insidelevel] != NestingChecksum() ) {
2190int CoNormalize(UBYTE *s) {
return(DoArgument(s,TYPENORM)); }
2197int CoMakeInteger(UBYTE *s) {
return(DoArgument(s,TYPENORM4)); }
2204int CoSplitArg(UBYTE *s) {
return(DoArgument(s,TYPESPLITARG)); }
2211int CoSplitFirstArg(UBYTE *s) {
return(DoArgument(s,TYPESPLITFIRSTARG)); }
2218int CoSplitLastArg(UBYTE *s) {
return(DoArgument(s,TYPESPLITLASTARG)); }
2225int CoFactArg(UBYTE *s) {
2226 if ( ( AC.topolynomialflag & TOPOLYNOMIALFLAG ) != 0 ) {
2227 MesPrint(
"&ToPolynomial statement and FactArg statement are not allowed in the same module");
2230 AC.topolynomialflag |= FACTARGFLAG;
2231 return(DoArgument(s,TYPEFACTARG));
2245int DoSymmetrize(UBYTE *s,
int par)
2248 int extra = 0, error = 0, err, fix, x, groupsize, num, i;
2250 WORD funnum, *w, *ww, type;
2254 MesPrint(
"&Improper function name");
2258 if ( c !=
',' || ( FG.cTable[s[1]] != 0 && s[1] !=
'[' ) )
break;
2259 if ( par <= 0 && StrICmp(name,(UBYTE *)
"cyclic") == 0 ) extra = 2;
2260 else if ( par <= 0 && StrICmp(name,(UBYTE *)
"rcyclic") == 0 ) extra = 6;
2262 MesPrint(
"&Illegal option: '%s'",name);
2267 if ( ( err = GetVar(name,&type,&funnum,CFUNCTION,WITHAUTO) ) == NAMENOTFOUND ) {
2268 MesPrint(
"&Undefined function: %s",name);
2269 AddFunction(name,0,0,0,0,0,-1,-1);
2274 if ( err == -1 ) error = 1;
2278 if ( *s ==
',' || *s ==
'(' || *s == 0 ) fix = -1;
2279 else if ( FG.cTable[*s] == 1 ) {
2282 Warning(
"Restriction to zero arguments removed");
2285 MesPrint(
"&Illegal character after :");
2291 *w++ = TYPEOPERATION;
2300 w += 2; ww = w; groupsize = -1;
2301 while ( *s ==
',' ) s++;
2305 while ( *s && *s !=
')' ) {
2306 if ( *s ==
',' ) { s++;
continue; }
2307 if ( FG.cTable[*s] != 1 )
goto illarg;
2309 if ( x <= 0 || ( fix > 0 && x > fix ) )
goto illnum;
2314 MesPrint(
"&Improper termination of statement");
2317 if ( groupsize < 0 ) groupsize = num;
2318 else if ( groupsize != num )
goto group;
2321 else if ( FG.cTable[*s] == 1 ) {
2322 if ( groupsize < 0 ) groupsize = 1;
2323 else if ( groupsize != 1 ) {
2324group: MesPrint(
"&All groups should have the same number of arguments");
2328 if ( x <= 0 || ( fix > 0 && x > fix ) ) {
2329illnum: MesPrint(
"&Illegal argument number: %d",x);
2335illarg: MesPrint(
"&Illegal argument");
2338 while ( *s ==
',' ) s++;
2347 for ( i = 0; i < fix; i++ ) *w++ = i;
2353 ww[-2] = (w-ww)/groupsize;
2355 AT.WorkPointer[1] = w - AT.WorkPointer;
2356 AddNtoL(AT.WorkPointer[1],AT.WorkPointer);
2365int CoSymmetrize(UBYTE *s) {
return(DoSymmetrize(s,SYMMETRIC)); }
2372int CoAntiSymmetrize(UBYTE *s) {
return(DoSymmetrize(s,ANTISYMMETRIC)); }
2379int CoCycleSymmetrize(UBYTE *s) {
return(DoSymmetrize(s,CYCLESYMMETRIC)); }
2386int CoRCycleSymmetrize(UBYTE *s) {
return(DoSymmetrize(s,RCYCLESYMMETRIC)); }
2393int CoWrite(UBYTE *s)
2399 if ( ( ( s =
SkipAName(s) ) == 0 ) || *s != 0 ) {
2400 MesPrint(
"&Proper use of write statement is: write option");
2405 MesPrint(
"&Unrecognized option in write statement");
2408 *key->var = key->type;
2409 AR.SortType = AC.SortType;
2418int CoNWrite(UBYTE *s)
2424 if ( ( ( s =
SkipAName(s) ) == 0 ) || *s != 0 ) {
2425 MesPrint(
"&Proper use of nwrite statement is: nwrite option");
2430 MesPrint(
"&Unrecognized option in nwrite statement");
2433 *key->var = key->flags;
2434 AR.SortType = AC.SortType;
2443static WORD ratstring[6] = { TYPEOPERATION, 6, RATIO, 0, 0, 0 };
2445int CoRatio(UBYTE *s)
2448 int i, type, error = 0;
2451 for ( i = 0; i < 3; i++ ) {
2456 if ( ( ( type = GetName(AC.varnames,t,&numsym,WITHAUTO) ) != CSYMBOL )
2457 && type != CDUBIOUS ) {
2458 MesPrint(
"&%s is not a symbol",t);
2460 if ( type < 0 ) numsym = AddSymbol(t,-MAXPOWER,MAXPOWER,0,0);
2463 if ( *s ==
',' ) s++;
2467 MesPrint(
"&The ratio statement needs three symbols for its arguments");
2485int CoRedefine(UBYTE *s)
2487 UBYTE *name, c, *args = 0;
2491 if ( FG.cTable[*s] || ( s =
SkipAName(s) ) == 0 || s[-1] ==
'_' ) {
2492 MesPrint(
"&Illegal name for preprocessor variable in redefine statement");
2496 for ( numprevar = NumPre-1; numprevar >= 0; numprevar-- ) {
2497 if ( StrCmp(name,PreVar[numprevar].name) == 0 )
break;
2499 if ( numprevar < 0 ) {
2500 MesPrint(
"&There is no preprocessor variable with the name `%s'",name);
2512 if ( chartype[*s] != 0 )
goto illarg;
2514 while ( chartype[*s] <= 1 ) s++;
2515 while ( *s ==
' ' || *s ==
'\t' ) s++;
2516 if ( *s ==
')' )
break;
2517 if ( *s !=
',' )
goto illargs;
2519 while ( *s ==
' ' || *s ==
'\t' ) s++;
2522 while ( *s ==
' ' || *s ==
'\t' ) s++;
2524 while ( *s ==
',' ) s++;
2526encl: MesPrint(
"&Value for %s should be enclosed in double quotes"
2527 ,PreVar[numprevar].name);
2531 while ( *s && *s !=
'"' ) {
if ( *s ==
'\\' ) s++; s++; }
2532 if ( *s !=
'"' )
goto encl;
2534 code[0] = TYPEREDEFPRE; code[1] = numprevar;
2538 Add2ComStrings(2,code,name,args);
2550 for ( j = 0; j < AC.numpfirstnum; j++ ) {
2551 if ( numprevar == AC.pfirstnum[j] )
break;
2553 if ( j >= AC.numpfirstnum ) {
2554 if ( j >= AC.sizepfirstnum ) {
2555 if ( AC.sizepfirstnum <= 0 ) { AC.sizepfirstnum = 10; }
2556 else { AC.sizepfirstnum = 2 * AC.sizepfirstnum; }
2557 newin = (LONG *)Malloc1(AC.sizepfirstnum*(
sizeof(WORD)+
sizeof(LONG)),
"AC.pfirstnum");
2558 newpf = (WORD *)(newin+AC.sizepfirstnum);
2559 for ( j = 0; j < AC.numpfirstnum; j++ ) {
2560 newpf[j] = AC.pfirstnum[j];
2561 newin[j] = AC.inputnumbers[j];
2563 if ( AC.inputnumbers ) M_free(AC.inputnumbers,
"AC.pfirstnum");
2564 AC.inputnumbers = newin;
2565 AC.pfirstnum = newpf;
2567 AC.pfirstnum[AC.numpfirstnum] = numprevar;
2568 AC.inputnumbers[AC.numpfirstnum] = -1;
2575 MesPrint(
"&Illegally formed name in argument of redefine statement");
2578 MesPrint(
"&Illegally formed arguments in redefine statement");
2590int CoRenumber(UBYTE *s)
2594 while ( *s ==
',' ) s++;
2596 if ( *s == 0 ) { x = 0; }
2597 else ParseNumber(x,s)
2598 if ( *s == 0 && x >= 0 && x <= 1 ) {
2599 Add3Com(TYPERENUMBER,x);
2602 MesPrint(
"&Illegal argument in Renumber statement: '%s'",inp);
2613 CBUF *C = cbuf+AC.cbufnum;
2614 UBYTE *ss = 0, c, *t;
2615 int error = 0, i = 0, type, x;
2616 WORD numindex,number;
2620 t++; s++;
while ( FG.cTable[*s] < 2 ) s++;
2622 if ( ( number = GetDollar(t) ) < 0 ) {
2623 MesPrint(
"&Undefined variable $%s",t);
2624 if ( !error ) error = 1;
2625 number = AddDollar(t,0,0,0);
2630 if ( ( s =
SkipAName(s) ) == 0 )
return(1);
2632 if ( ( ( type = GetOName(AC.exprnames,t,&numindex,NOAUTO) ) != NAMENOTFOUND )
2633 || ( ( type = GetOName(AC.varnames,t,&numindex,WITHAUTO) ) != CINDEX ) ) {
2634 if ( type != NAMENOTFOUND ) error = NameConflict(type,t);
2636 MesPrint(
"&%s should have been declared as an index",t);
2638 numindex = AddIndex(s,AC.lDefDim,AC.lDefDim4) + AM.OffsetIndex;
2642 Add3Com(TYPESUM,numindex);
2644 if ( *s == 0 )
break;
2646 MesPrint(
"&Illegal separator between objects in sum statement.");
2650 if ( FG.cTable[*s] == 0 || *s ==
'[' || *s ==
'$' ) {
2651 while ( FG.cTable[*s] == 0 || *s ==
'[' || *s ==
'$' ) {
2655 while ( FG.cTable[*s] < 2 ) s++;
2657 if ( ( number = GetDollar(t) ) < 0 ) {
2658 MesPrint(
"&Undefined variable $%s",t);
2659 if ( !error ) error = 1;
2660 number = AddDollar(t,0,0,0);
2666 if ( ( s =
SkipAName(s) ) == 0 )
return(1);
2668 if ( ( ( type = GetOName(AC.exprnames,t,&numindex,NOAUTO) ) != NAMENOTFOUND )
2669 || ( ( type = GetOName(AC.varnames,t,&numindex,WITHAUTO) ) != CINDEX ) ) {
2670 if ( type != NAMENOTFOUND ) error = NameConflict(type,t);
2672 MesPrint(
"&%s should have been declared as an index",t);
2674 numindex = AddIndex(s,AC.lDefDim,AC.lDefDim4) + AM.OffsetIndex;
2682 if ( *s == 0 )
return(error);
2684 MesPrint(
"&Illegal separator between objects in sum statement.");
2689 if ( FG.cTable[*s] == 1 ) {
2693 else if ( FG.cTable[*s] == 1 ) {
2694 while ( FG.cTable[*s] == 1 ) {
2697 while( FG.cTable[*s] == 1 ) x = 10*x + *s++ -
'0';
2698 if ( *s && *s !=
',' ) {
2699 MesPrint(
"&%s is not a legal fixed index",t);
2702 else if ( x >= AM.OffsetIndex ) {
2703 MesPrint(
"&%d is too large to be a fixed index",x);
2712 if ( *s == 0 )
break;
2717 MesPrint(
"&Illegal object in sum statement");
2729static WORD cttarray[7] = { TYPEOPERATION,7,TENVEC,0,0,1,0 };
2731int CoToTensor(UBYTE *s)
2734 int type, j, nargs, error = 0;
2735 WORD number, dol[2] = { 0, 0 };
2747 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
2748 if ( *s == 0 )
break;
2755 if ( ( s =
SkipAName(s) ) == 0 )
goto syntax_error;
2758 if ( ( s =
SkipAName(s) ) == 0 )
goto syntax_error;
2762 if ( nargs < 2 )
goto not_enough_arguments;
2767 for ( j = 2; j < nargs; j++ ) {
2768 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
2777 if ( FG.cTable[*s] == 0 || *s ==
'[' || *s ==
'_' ) {
2779 if ( ( s =
SkipAName(s) ) == 0 )
goto syntax_error;
2781 type = GetName(AC.varnames,t,&number,WITHAUTO);
2782 if ( type == CVECTOR ) {
2786 cttarray[6] = DoTempSet(t,s);
2790 else if ( type != CSET ) {
2791 MesPrint(
"&%s is not the name of a set or a vector",t);
2795 cttarray[6] = number;
2797 else if ( *s ==
'{' ) {
2798 t = ++s; SKIPBRA2(s) *s = 0;
2799 cttarray[6] = DoTempSet(t,s);
2802 if ( cttarray[6] < 0 ) {
2805 if ( AC.wildflag ) {
2806 MesPrint(
"&Improper use of wildcard(s) in set specification");
2815 if ( ( s =
SkipAName(s) ) == 0 )
goto syntax_error;
2817 if ( StrICmp(t,(UBYTE *)
"nosquare") == 0 ) cttarray[5] |= 2;
2818 else if ( StrICmp(t,(UBYTE *)
"functions") == 0 ) cttarray[5] |= 4;
2820 MesPrint(
"&Unrecognized option in ToTensor statement: '%s'",t);
2830 for ( j = 0; j < 2; j++ ) {
2831 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
2833 if ( ( s =
SkipAName(s) ) == 0 )
goto syntax_error;
2835 if ( t[0] ==
'$' ) {
2836 dol[j] = GetDollar(t+1);
2837 if ( dol[j] < 0 ) dol[j] = AddDollar(t+1,DOLUNDEFINED,0,0);
2839 type = GetName(AC.varnames,t,&number,WITHAUTO);
2840 if ( type == CVECTOR ) {
2841 cttarray[4] = number + AM.OffsetVector;
2843 else if ( type == CFUNCTION && ( functions[number].spec > 0 ) ) {
2844 cttarray[3] = number + FUNCTION;
2847 MesPrint(
"&%s is not a vector or a tensor",t);
2853 if ( cttarray[3] == 0 || cttarray[4] == 0 ) {
2854 if ( dol[0] == 0 && dol[1] == 0 ) {
2855 goto not_enough_arguments;
2857 else if ( cttarray[3] ) {
2858 if ( dol[1] ) cttarray[4] = dol[1];
2859 else if ( dol[0] ) { cttarray[4] = dol[0]; }
2861 goto not_enough_arguments;
2864 else if ( cttarray[4] ) {
2865 if ( dol[1] ) { cttarray[3] = -dol[1]; }
2866 else if ( dol[0] ) cttarray[3] = -dol[0];
2868 goto not_enough_arguments;
2872 if ( dol[0] == 0 || dol[1] == 0 ) {
2873 goto not_enough_arguments;
2876 cttarray[3] = -dol[0]; cttarray[4] = dol[1];
2880 AddNtoL(cttarray[1],cttarray);
2884 MesPrint(
"&Syntax error in ToTensor statement");
2887not_enough_arguments:
2888 MesPrint(
"&ToTensor statement needs a vector and a tensor");
2897static WORD ctvarray[6] = { TYPEOPERATION,6,TENVEC,0,0,0 };
2899int CoToVector(UBYTE *s)
2902 int j, type, error = 0;
2903 WORD number, dol[2];
2904 dol[0] = dol[1] = 0;
2905 ctvarray[3] = ctvarray[4] = ctvarray[5] = 0;
2906 for ( j = 0; j < 2; j++ ) {
2909proper: MesPrint(
"&Arguments of ToVector statement should be a vector and a tensor");
2914 dol[j] = GetDollar(t+1);
2915 if ( dol[j] < 0 ) dol[j] = AddDollar(t+1,DOLUNDEFINED,0,0);
2917 else if ( ( type = GetName(AC.varnames,t,&number,WITHAUTO) ) == CVECTOR )
2918 ctvarray[4] = number + AM.OffsetVector;
2919 else if ( type == CFUNCTION && ( functions[number].spec > 0 ) )
2920 ctvarray[3] = number+FUNCTION;
2922 MesPrint(
"&%s is not a vector or a tensor",t);
2925 *s = c;
if ( *s && *s !=
',' )
goto proper;
2928 if ( *s != 0 )
goto proper;
2929 if ( ctvarray[3] == 0 || ctvarray[4] == 0 ) {
2930 if ( dol[0] == 0 && dol[1] == 0 ) {
2931 MesPrint(
"&ToVector statement needs a vector and a tensor");
2934 else if ( ctvarray[3] ) {
2935 if ( dol[1] ) ctvarray[4] = dol[1];
2936 else if ( dol[0] ) ctvarray[4] = dol[0];
2938 MesPrint(
"&ToVector statement needs a vector and a tensor");
2942 else if ( ctvarray[4] ) {
2943 if ( dol[1] ) ctvarray[3] = -dol[1];
2944 else if ( dol[0] ) ctvarray[3] = -dol[0];
2946 MesPrint(
"&ToVector statement needs a vector and a tensor");
2951 if ( dol[0] == 0 || dol[1] == 0 ) {
2952 MesPrint(
"&ToVector statement needs a vector and a tensor");
2956 ctvarray[3] = -dol[0]; ctvarray[4] = dol[1];
2969int CoTrace4(UBYTE *s)
2971 int error = 0, type, option = CHISHOLM;
2973 WORD numindex, one = 1;
2977 if ( FG.cTable[*s] == 1 )
break;
2979proper: MesPrint(
"&Proper syntax for Trace4 is 'Trace4[,options],index;'");
2982 if ( *s == 0 )
break;
2984 if ( ( key = FindKeyWord(t,trace4options,
2985 sizeof(trace4options)/
sizeof(
KEYWORD)) ) == 0 )
break;
2987 option |= key->type;
2988 option &= ~key->flags;
2990 if ( ( *s++ = c ) !=
',' ) {
2991 MesPrint(
"&Illegal separator in Trace4 statement");
2994 if ( *s == 0 )
goto proper;
2997 if ( FG.cTable[*s] == 1 ) {
2999 ParseNumber(numindex,s)
3001 MesPrint(
"&Last argument of Trace4 should be an index");
3004 if ( numindex >= AM.OffsetIndex ) {
3005 MesPrint(
"&fixed index >= %d. Change value of OffsetIndex in setup file"
3010 else if ( *s ==
'$' ) {
3011 if ( ( type = GetName(AC.dollarnames,s+1,&numindex,NOAUTO) ) == CDOLLAR )
3012 numindex = -numindex;
3014 MesPrint(
"&%s is undefined",s);
3015 numindex = AddDollar(s+1,DOLINDEX,&one,1);
3020 MesPrint(
"&Trace4 should have a single index or $variable for its argument");
3024 else if ( ( type = GetName(AC.varnames,s,&numindex,WITHAUTO) ) == CINDEX ) {
3025 numindex += AM.OffsetIndex;
3028 else if ( type != -1 ) {
3029 if ( type != CDUBIOUS ) {
3030 if ( ( FG.cTable[*s] != 0 ) && ( *s !=
'[' ) ) {
3031 if ( *s ==
'+' && FG.cTable[s[1]] == 1 ) { s++;
goto retry; }
3034 NameConflict(type,s);
3035 type = MakeDubious(AC.varnames,s,&numindex);
3040 MesPrint(
"&%s is not an index",s);
3041 numindex = AddIndex(s,AC.lDefDim,AC.lDefDim4) + AM.OffsetIndex;
3044 if ( error )
return(error);
3045 if ( ( option & CHISHOLM ) != 0 )
3046 Add4Com(TYPECHISHOLM,numindex,(option & ALSOREVERSE));
3047 Add5Com(TYPEOPERATION,TAKETRACE,4 + (option & NOTRICK),numindex);
3056int CoTraceN(UBYTE *s)
3058 WORD numindex, one = 1;
3060 if ( FG.cTable[*s] == 1 ) {
3062 ParseNumber(numindex,s)
3064proper: MesPrint(
"&TraceN should have a single index for its argument");
3067 if ( numindex >= AM.OffsetIndex ) {
3068 MesPrint(
"&fixed index >= %d. Change value of OffsetIndex in setup file"
3073 else if ( *s ==
'$' ) {
3074 if ( ( type = GetName(AC.dollarnames,s+1,&numindex,NOAUTO) ) == CDOLLAR )
3075 numindex = -numindex;
3077 MesPrint(
"&%s is undefined",s);
3078 numindex = AddDollar(s+1,DOLINDEX,&one,1);
3083 MesPrint(
"&TraceN should have a single index or $variable for its argument");
3087 else if ( ( type = GetName(AC.varnames,s,&numindex,WITHAUTO) ) == CINDEX ) {
3088 numindex += AM.OffsetIndex;
3091 else if ( type != -1 ) {
3092 if ( type != CDUBIOUS ) {
3093 if ( ( FG.cTable[*s] != 0 ) && ( *s !=
'[' ) ) {
3094 if ( *s ==
'+' && FG.cTable[s[1]] == 1 ) { s++;
goto retry; }
3097 NameConflict(type,s);
3098 type = MakeDubious(AC.varnames,s,&numindex);
3103 MesPrint(
"&%s is not an index",s);
3104 numindex = AddIndex(s,AC.lDefDim,AC.lDefDim4) + AM.OffsetIndex;
3107 Add5Com(TYPEOPERATION,TAKETRACE,0,numindex);
3116int CoChisholm(UBYTE *s)
3118 int error = 0, type, option = CHISHOLM;
3120 WORD numindex, one = 1;
3124 if ( FG.cTable[*s] == 1 )
break;
3126proper: MesPrint(
"&Proper syntax for Chisholm is 'Chisholm[,options],index;'");
3129 if ( *s == 0 )
break;
3131 if ( ( key = FindKeyWord(t,chisoptions,
3132 sizeof(chisoptions)/
sizeof(
KEYWORD)) ) == 0 )
break;
3134 option |= key->type;
3135 option &= ~key->flags;
3137 if ( ( *s++ = c ) !=
',' ) {
3138 MesPrint(
"&Illegal separator in Chisholm statement");
3141 if ( *s == 0 )
goto proper;
3144 if ( FG.cTable[*s] == 1 ) {
3145 ParseNumber(numindex,s)
3147 MesPrint(
"&Last argument of Chisholm should be an index");
3150 if ( numindex >= AM.OffsetIndex ) {
3151 MesPrint(
"&fixed index >= %d. Change value of OffsetIndex in setup file"
3156 else if ( *s ==
'$' ) {
3157 if ( ( type = GetName(AC.dollarnames,s+1,&numindex,NOAUTO) ) == CDOLLAR )
3158 numindex = -numindex;
3160 MesPrint(
"&%s is undefined",s);
3161 numindex = AddDollar(s+1,DOLINDEX,&one,1);
3166 MesPrint(
"&Chisholm should have a single index or $variable for its argument");
3170 else if ( ( type = GetName(AC.varnames,s,&numindex,WITHAUTO) ) == CINDEX ) {
3171 numindex += AM.OffsetIndex;
3174 else if ( type != -1 ) {
3175 if ( type != CDUBIOUS ) {
3176 NameConflict(type,s);
3177 type = MakeDubious(AC.varnames,s,&numindex);
3182 MesPrint(
"&%s is not an index",s);
3183 numindex = AddIndex(s,AC.lDefDim,AC.lDefDim4) + AM.OffsetIndex;
3186 if ( error )
return(error);
3187 Add4Com(TYPECHISHOLM,numindex,(option & ALSOREVERSE));
3198int DoChain(UBYTE *s,
int option)
3202 if ( ( type = GetName(AC.dollarnames,s+1,&numfunc,NOAUTO) ) == CDOLLAR )
3205 MesPrint(
"&%s is undefined",s);
3206 numfunc = AddDollar(s+1,DOLINDEX,&one,1);
3211 MesPrint(
"&ChainIn/ChainOut should have a single function or $variable for its argument");
3215 else if ( ( type = GetName(AC.varnames,s,&numfunc,WITHAUTO) ) == CFUNCTION ) {
3216 numfunc += FUNCTION;
3219 else if ( type != -1 ) {
3220 if ( type != CDUBIOUS ) {
3221 NameConflict(type,s);
3222 type = MakeDubious(AC.varnames,s,&numfunc);
3227 MesPrint(
"&%s is not a function",s);
3228 numfunc = AddFunction(s,0,0,0,0,0,-1,-1) + FUNCTION;
3231 Add3Com(option,numfunc);
3242int CoChainin(UBYTE *s)
3244 return(DoChain(s,TYPECHAININ));
3254int CoChainout(UBYTE *s)
3256 return(DoChain(s,TYPECHAINOUT));
3267 WORD code = TYPEEXIT;
3268 while ( *s ==
',' ) s++;
3270 Add3Com(TYPEEXIT,0);
3275 while ( *s ) {
if ( *s ==
'\\' ) s++; s++; }
3276 if ( name[-1] !=
'"' || s[-1] !=
'"' ) {
3277 MesPrint(
"&Illegal syntax for exit statement");
3281 AddComString(1,&code,name,0);
3291int CoInParallel(UBYTE *s)
3293 return(DoInParallel(s,1));
3301int CoNotInParallel(UBYTE *s)
3303 return(DoInParallel(s,0));
3316int DoInParallel(UBYTE *s,
int par)
3329 AC.inparallelflag = par;
3331 for ( i = NumExpressions-1; i >= 0; i-- ) {
3333 if ( e->status == LOCALEXPRESSION || e->status == GLOBALEXPRESSION
3334 || e->status == UNHIDELEXPRESSION || e->status == UNHIDEGEXPRESSION
3343 while ( *s ==
',' ) s++;
3344 if ( *s == 0 )
break;
3345 if ( *s ==
'[' || FG.cTable[*s] == 0 ) {
3348 MesPrint(
"&Improper name for an expression: '%s'",t);
3352 if ( GetName(AC.exprnames,t,&number,NOAUTO) == CEXPRESSION ) {
3354 e = Expressions+number;
3355 if ( e->status == LOCALEXPRESSION || e->status == GLOBALEXPRESSION
3356 || e->status == UNHIDELEXPRESSION || e->status == UNHIDEGEXPRESSION
3362 else if ( GetName(AC.varnames,t,&number,NOAUTO) != NAMENOTFOUND ) {
3363 MesPrint(
"&%s is not an expression",t);
3369 MesPrint(
"&Illegal object in InParallel statement");
3371 while ( *s && *s !=
',' ) s++;
3372 if ( *s == 0 )
break;
3385int CoInExpression(UBYTE *s)
3392 if ( AC.inexprlevel >= MAXNEST ) {
3393 MesPrint(
"@Nesting of inexpression statements more than %d levels",(WORD)MAXNEST);
3396 AC.inexprsumcheck[AC.inexprlevel] = NestingChecksum();
3397 AC.inexprstack[AC.inexprlevel] = cbuf[AC.cbufnum].Pointer
3398 - cbuf[AC.cbufnum].Buffer + 2;
3400 *w++ = TYPEINEXPRESSION;
3403 while ( *s ==
',' ) s++;
3404 if ( *s == 0 )
break;
3405 if ( *s ==
'[' || FG.cTable[*s] == 0 ) {
3408 MesPrint(
"&Improper name for an expression: '%s'",t);
3412 if ( GetName(AC.exprnames,t,&number,NOAUTO) == CEXPRESSION ) {
3415 else if ( GetName(AC.varnames,t,&number,NOAUTO) != NAMENOTFOUND ) {
3416 MesPrint(
"&%s is not an expression",t);
3422 MesPrint(
"&Illegal object in InExpression statement");
3424 while ( *s && *s !=
',' ) s++;
3425 if ( *s == 0 )
break;
3428 AT.WorkPointer[1] = w - AT.WorkPointer;
3429 AddNtoL(AT.WorkPointer[1],AT.WorkPointer);
3438int CoEndInExpression(UBYTE *s)
3440 CBUF *C = cbuf+AC.cbufnum;
3441 while ( *s ==
',' ) s++;
3443 MesPrint(
"&Illegal syntax for EndInExpression statement");
3446 if ( AC.inexprlevel <= 0 ) {
3447 MesPrint(
"&EndInExpression without corresponding InExpression statement");
3451 cbuf[AC.cbufnum].Buffer[AC.inexprstack[AC.inexprlevel]] = C->numlhs;
3452 if ( AC.inexprsumcheck[AC.inexprlevel] != NestingChecksum() ) {
3464int CoSetExitFlag(UBYTE *s)
3467 MesPrint(
"&Illegal syntax for the SetExitFlag statement");
3470 Add2Com(TYPESETEXIT);
3478int CoTryReplace(UBYTE *p)
3482 WORD *w, error = 0, i, which = -1, c1, minvec = 0;
3499 if ( *p ==
'-' && minvec == 0 && which == (CVECTOR+1) ) {
3502 if ( *p ==
'[' || FG.cTable[*p] == 0 ) {
3504 if ( ( p =
SkipAName(p) ) == 0 )
return(1);
3506 i = GetName(AC.varnames,name,&c1,WITHAUTO);
3507 if ( which >= 0 && i >= 0 && i != CDUBIOUS && which != (i+1) ) {
3508 MesPrint(
"&Illegal combination of objects in TryReplace");
3511 else if ( minvec && i != CVECTOR && i != CDUBIOUS ) {
3512 MesPrint(
"&Currently a - sign can be used only with a vector in TryReplace");
3516 case CSYMBOL: *w++ = -SYMBOL; *w++ = c1;
break;
3518 if ( minvec ) *w++ = -MINVECTOR;
3519 else *w++ = -VECTOR;
3520 *w++ = c1 + AM.OffsetVector;
3523 case CINDEX: *w++ = -INDEX; *w++ = c1 + AM.OffsetIndex;
3524 if ( c1 >= AM.WilInd && c ==
'?' ) { *p++ = c; c = *p; }
3526 case CFUNCTION: *w++ = -c1-FUNCTION;
break;
3527 case CDUBIOUS: minvec = 0; error = 1;
break;
3529 MesPrint(
"&Illegal object type in TryReplace: %s",name);
3534 if ( which < 0 ) which = i+1;
3537 if ( *p ==
',' ) p++;
3541 MesPrint(
"&Illegal object in TryReplace");
3543 while ( *p && *p !=
',' ) {
3544 if ( *p ==
'(' ) SKIPBRA3(p)
3545 else if ( *p ==
'{' ) SKIPBRA2(p)
3546 else if ( *p ==
'[' ) SKIPBRA1(p)
3550 if ( *p ==
',' ) p++;
3551 if ( which < 0 ) which = 0;
3555 MesPrint(
"&Odd number of arguments in TryReplace");
3558 i = w - AT.WorkPointer;
3559 AT.WorkPointer[1] = i;
3560 AT.WorkPointer[2] = i - 3;
3561 AT.WorkPointer[4] = i - 3;
3562 AddNtoL((
int)i,AT.WorkPointer);
3581int CoModulus(UBYTE *inp)
3584 int Retval = 0, sign = 1;
3586 while ( *inp ==
',' || *inp ==
' ' || *inp ==
'\t' ) inp++;
3589 if ( AC.modpowers ) M_free(AC.modpowers,
"AC.modpowers");
3591 AN.ncmod = AC.ncmod = 0;
3592 if ( AC.halfmod ) M_free(AC.halfmod,
"halfmod");
3593 AC.halfmod = 0; AC.nhalfmod = 0;
3594 if ( AC.modinverses ) M_free(AC.modinverses,
"modinverses");
3600 if ( AT.aux_ != 0 ) {
3601 MesPrint(
"&Simultaneous use of floating point and modulus arithmetic makes no sense.");
3606 if ( *inp ==
'-' ) {
3611 while ( FG.cTable[*inp] == 0 ) {
3613 while ( FG.cTable[*inp] == 0 ) inp++;
3615 if ( StrICmp(p,(UBYTE *)
"nofunctions") == 0 ) {
3616 AC.modmode &= ~ALSOFUNARGS;
3618 else if ( StrICmp(p,(UBYTE *)
"alsofunctions") == 0 ) {
3619 AC.modmode |= ALSOFUNARGS;
3621 else if ( StrICmp(p,(UBYTE *)
"coefficientsonly") == 0 ) {
3622 AC.modmode &= ~ALSOFUNARGS;
3623 AC.modmode &= ~ALSOPOWERS;
3626 else if ( StrICmp(p,(UBYTE *)
"plusmin") == 0 ) {
3627 AC.modmode |= POSNEG;
3629 else if ( StrICmp(p,(UBYTE *)
"positive") == 0 ) {
3630 AC.modmode &= ~POSNEG;
3632 else if ( StrICmp(p,(UBYTE *)
"inversetable") == 0 ) {
3633 AC.modmode |= INVERSETABLE;
3635 else if ( StrICmp(p,(UBYTE *)
"noinversetable") == 0 ) {
3636 AC.modmode &= ~INVERSETABLE;
3638 else if ( StrICmp(p,(UBYTE *)
"nodollars") == 0 ) {
3639 AC.modmode &= ~ALSODOLLARS;
3641 else if ( StrICmp(p,(UBYTE *)
"alsodollars") == 0 ) {
3642 AC.modmode |= ALSODOLLARS;
3644 else if ( StrICmp(p,(UBYTE *)
"printpowersof") == 0 ) {
3646 if ( *inp !=
'(' ) {
3648 MesPrint(
"&Bad syntax in argument of PrintPowersOf(number) in Modulus statement");
3651 while ( *inp ==
',' || *inp ==
' ' || *inp ==
'\t' ) inp++;
3653 if ( FG.cTable[*inp] != 1 )
goto badsyntax;
3654 do { inp++; }
while ( FG.cTable[*inp] == 1 );
3656 if ( GetLong(p,(UWORD *)AC.powmod,&AC.npowmod) ) Retval = -1;
3657 if ( TakeModulus((UWORD *)AC.powmod,&AC.npowmod,AC.cmod,AC.ncmod,NOUNPACK) ) Retval = -1;
3658 if ( AC.npowmod == 0 ) {
3659 MesPrint(
"&Improper value for generator");
3662 if ( MakeModTable() ) Retval = -1;
3665 while ( *inp ==
',' || *inp ==
' ' || *inp ==
'\t' ) inp++;
3666 if ( *inp !=
')' )
goto badsyntax;
3670 else if ( StrICmp(p,(UBYTE *)
"alsopowers") == 0 ) {
3671 AC.modmode |= ALSOPOWERS;
3674 else if ( StrICmp(p,(UBYTE *)
"nopowers") == 0 ) {
3675 AC.modmode &= ~ALSOPOWERS;
3679 MesPrint(
"&Unrecognized option %s in Modulus statement",inp);
3683 while ( *inp ==
',' || *inp ==
' ' || *inp ==
'\t' ) inp++;
3685 MesPrint(
"&Modulus statement with no value!!!");
3691 if ( FG.cTable[*inp] != 1 ) {
3692 MesPrint(
"&Invalid value for modulus:%s",inp);
3693 if ( AC.modpowers ) M_free(AC.modpowers,
"AC.modpowers");
3695 AN.ncmod = AC.ncmod = 0;
3696 if ( AC.halfmod ) M_free(AC.halfmod,
"halfmod");
3697 AC.halfmod = 0; AC.nhalfmod = 0;
3698 if ( AC.modinverses ) M_free(AC.modinverses,
"modinverses");
3702 do { inp++; }
while ( FG.cTable[*inp] == 1 );
3704 Retval = GetLong(p,(UWORD *)AC.cmod,&AC.ncmod);
3705 if ( Retval == 0 && AC.ncmod == 0 )
goto SwitchOff;
3706 if ( sign < 0 ) AC.ncmod = -AC.ncmod;
3707 AN.ncmod = AC.ncmod;
3708 if ( ( AC.modmode & INVERSETABLE ) != 0 )
MakeInverses();
3709 if ( AC.halfmod ) M_free(AC.halfmod,
"halfmod");
3710 AC.halfmod = 0; AC.nhalfmod = 0;
3719int CoRepeat(UBYTE *inp)
3722 AC.RepSumCheck[AC.RepLevel] = NestingChecksum();
3724 if ( AC.RepLevel > AM.RepMax ) {
3725 MesPrint(
"&Too many repeat levels. Maximum is %d",AM.RepMax);
3728 Add3Com(TYPEREPEAT,-1)
3729 while ( *inp == ' ' || *inp == ',' || *inp == '\t' ) inp++;
3731 error = CompileStatement(inp);
3732 if ( CoEndRepeat(inp) ) error = 1;
3742int CoEndRepeat(UBYTE *inp)
3744 CBUF *C = cbuf+AC.cbufnum;
3745 int level, error = 0, repeatlevel = 0;
3748 if ( AC.RepLevel < 0 ) {
3749 MesPrint(
"&EndRepeat without Repeat");
3753 else if ( AC.RepSumCheck[AC.RepLevel] != NestingChecksum() ) {
3757 level = C->numlhs+1;
3758 while ( level > 0 ) {
3759 if ( C->
lhs[--level][0] == TYPEREPEAT ) {
3760 if ( repeatlevel == 0 ) {
3761 Add3Com(TYPEENDREPEAT,level)
3766 else if ( C->
lhs[level][0] == TYPEENDREPEAT ) repeatlevel++;
3780int DoBrackets(UBYTE *inp,
int par)
3784 WORD *to, i, type, *w, error = 0;
3785 WORD c1,c2, *WorkSave;
3788 WorkSave = to = AT.WorkPointer;
3790 if ( AT.BrackBuf == 0 ) {
3791 AR.MaxBracket = 100;
3792 AT.BrackBuf = (WORD *)Malloc1(
sizeof(WORD)*(AR.MaxBracket+1),
"bracket buffer");
3796 AC.bracketindexflag = 0;
3797 AT.bracketindexflag = 0;
3798 if ( *p ==
'+' || *p ==
'-' ) p++;
3799 if ( p[-1] ==
',' && *p ) p--;
3800 if ( p[-1] ==
'+' && *p ) { biflag = 1;
if ( *p !=
',' ) { *--p =
','; } }
3801 else if ( p[-1] ==
'-' && *p ) { biflag = -1;
if ( *p !=
',' ) { *--p =
','; } }
3803 while ( *p ==
',' ) {
3804redo: AR.BracketOn++;
3805 while ( *p ==
',' ) p++;
3806 if ( *p == 0 )
break;
3808 p++;
while ( *p ==
'0' ) p++;
3813 if ( p == 0 )
return(1);
3816 type = GetName(AC.varnames,inp,&c1,WITHAUTO);
3818 if ( type == CVECTOR || type == CDUBIOUS ) {
3822 if ( p == 0 )
return(1);
3825 type = GetName(AC.varnames,inp,&c2,WITHAUTO);
3826 if ( type != CVECTOR && type != CDUBIOUS ) {
3827 MesPrint(
"&Not a vector in dotproduct in bracket statement: %s",inp);
3830 else type = CDOTPRODUCT;
3833 MesPrint(
"&Illegal use of . after %s in bracket statement",inp);
3841 *to++ = SYMBOL; *to++ = 4; *to++ = c1; *to++ = 1;
break;
3843 *to++ = INDEX; *to++ = 3; *to++ = AM.OffsetVector + c1;
break;
3845 *to++ = c1+FUNCTION; *to++ = FUNHEAD; *to++ = 0;
3849 *to++ = DOTPRODUCT; *to++ = 5; *to++ = c1 + AM.OffsetVector;
3850 *to++ = c2 + AM.OffsetVector; *to++ = 1;
break;
3852 *to++ = DELTA; *to++ = 4; *to++ = EMPTYINDEX; *to++ = EMPTYINDEX;
break;
3854 *to++ = SETSET; *to++ = 4; *to++ = c1; *to++ = Sets[c1].type;
break;
3856 MesPrint(
"&Illegal bracket request for %s",pp);
3862 MesCerr(
"separator",p);
3863 AC.BracketNormalize = 0;
3864 AT.WorkPointer = WorkSave;
3868 *to++ = 1; *to++ = 1; *to++ = 3;
3869 *AT.WorkPointer = to - AT.WorkPointer;
3870 AT.WorkPointer = to;
3871 AC.BracketNormalize = 1;
3872 if ( BracketNormalize(BHEAD WorkSave) ) { error = 1; AR.BracketOn = 0; }
3875 if ( *w == 4 || !*w ) { AR.BracketOn = 0; }
3878 if ( i < 0 ) i = -i;
3881 if ( i > AR.MaxBracket ) {
3883 newbuf = (WORD *)Malloc1(
sizeof(WORD)*(i+1),
"bracket buffer");
3885 if ( AT.BrackBuf != 0 ) M_free(AT.BrackBuf,
"bracket buffer");
3886 AT.BrackBuf = newbuf;
3892 AC.BracketNormalize = 0;
3893 if ( par == 1 ) AR.BracketOn = -AR.BracketOn;
3895 AC.bracketindexflag = biflag;
3896 AT.bracketindexflag = biflag;
3898 AT.WorkPointer = WorkSave;
3907int CoBracket(UBYTE *inp)
3908{
return(DoBrackets(inp,0)); }
3915int CoAntiBracket(UBYTE *inp)
3916{
return(DoBrackets(inp,1)); }
3926int CoMultiBracket(UBYTE *inp)
3929 int i, error = 0, error1, type, num;
3933 if ( *inp !=
':' ) {
3934 MesPrint(
"&Illegal Multiple Bracket separator: %s",inp);
3938 if ( AC.MultiBracketBuf == 0 ) {
3939 AC.MultiBracketBuf = (WORD **)Malloc1(
sizeof(WORD *)*MAXMULTIBRACKETLEVELS,
"multi bracket buffer");
3940 for ( i = 0; i < MAXMULTIBRACKETLEVELS; i++ ) {
3941 AC.MultiBracketBuf[i] = 0;
3945 for ( i = 0; i < MAXMULTIBRACKETLEVELS; i++ ) {
3946 if ( AC.MultiBracketBuf[i] ) {
3947 M_free(AC.MultiBracketBuf[i],
"bracket buffer i");
3948 AC.MultiBracketBuf[i] = 0;
3951 AC.MultiBracketLevels = 0;
3953 AC.MultiBracketLevels = 0;
3957 if ( AT.BrackBuf == 0 ) {
3958 AR.MaxBracket = 100;
3959 AT.BrackBuf = (WORD *)Malloc1(
sizeof(WORD)*(AR.MaxBracket+1),
"bracket buffer");
3963 AC.bracketindexflag = 0;
3964 AT.bracketindexflag = 0;
3968 for ( i = 0; i < MAXMULTIBRACKETLEVELS; i++ ) {
3969 if ( *inp == 0 )
goto RegEnd;
3974 while ( *s && *s !=
':' ) {
3975 if ( *s ==
'[' ) { SKIPBRA1(s) s++; }
3976 else if ( *s ==
'{' ) { SKIPBRA2(s) s++; }
3980 if ( StrICont(inp,(UBYTE *)
"antibrackets") == 0 ) { type = 1; }
3981 else if ( StrICont(inp,(UBYTE *)
"brackets") == 0 ) { type = 0; }
3983 MesPrint(
"&Illegal (anti)bracket specification in MultiBracket statement");
3984 if ( error == 0 ) error = 1;
3987 while ( FG.cTable[*inp] == 0 ) inp++;
3988 if ( *inp !=
',' ) {
3989 MesPrint(
"&Illegal separator after (anti)bracket specification in MultiBracket statement");
3990 if ( error == 0 ) error = 1;
3997 error1 = DoBrackets(inp, type);
3998 if ( error < 0 )
return(error1);
3999 if ( error1 > error ) error = error1;
4003 if ( AR.BracketOn ) {
4004 num = AT.BrackBuf[0];
4005 to = AC.MultiBracketBuf[i] = (WORD *)Malloc1((num+2)*
sizeof(WORD),
"bracket buffer i");
4007 *to++ = AR.BracketOn;
4015 *s = c;
if ( c ==
':' ) s++;
4021 MesPrint(
"&More than %d levels in MultiBracket statement",(WORD)MAXMULTIBRACKETLEVELS);
4022 if ( error == 0 ) error = 1;
4025 AC.MultiBracketLevels = i;
4028 AC.bracketindexflag = 0;
4029 AT.bracketindexflag = 0;
4058WORD *CountComp(UBYTE *inp, WORD *to)
4062 WORD *w, mini = 0, type, c1, c2;
4070 while ( *p ==
',' ) {
4072 if ( *p ==
'[' || FG.cTable[*p] == 0 ) {
4073 if ( ( p =
SkipAName(inp) ) == 0 )
return(0);
4075 type = GetName(AC.varnames,inp,&c1,WITHAUTO);
4077 if ( type == CVECTOR || type == CDUBIOUS ) {
4081 if ( p == 0 )
return(0);
4084 type = GetName(AC.varnames,inp,&c2,WITHAUTO);
4085 if ( type != CVECTOR && type != CDUBIOUS ) {
4086 MesPrint(
"&Not a vector in dotproduct in if statement: %s",inp);
4089 else type = CDOTPRODUCT;
4092 MesPrint(
"&Illegal use of . after %s in if statement",inp);
4093 if ( type == NAMENOTFOUND )
4094 MesPrint(
"&%s is not a properly declared variable",inp);
4097 while ( *p && *p !=
')' && *p !=
',' ) p++;
4098 if ( *p ==
',' && FG.cTable[p[1]] == 1 ) {
4100 while ( *p && *p !=
')' && *p !=
',' ) p++;
4108 *w++ = SYMBOL; *w++ = 4; *w++ = c1;
4109Sgetnum:
if ( *p !=
',' ) {
4110 MesCerr(
"sequence",p);
4111 while ( *p && *p !=
')' && *p !=
',' ) p++;
4115 ParseSignedNumber(mini,p)
4116 if ( FG.cTable[p[-1]] != 1 || ( *p && *p !=
')' && *p !=
',' ) ) {
4117 while ( *p && *p !=
')' && *p !=
',' ) p++;
4120 MesPrint(
"&Improper value in count: %s",inp);
4122 while ( *p && *p !=
')' && *p !=
',' ) p++;
4127 *w++ = FUNCTION; *w++ = 4; *w++ = c1+FUNCTION;
goto Sgetnum;
4129 *w++ = DOTPRODUCT; *w++ = 5;
4130 *w++ = c2 + AM.OffsetVector;
4131 *w++ = c1 + AM.OffsetVector;
4134 *w++ = VECTOR; *w++ = 5;
4135 *w++ = c1 + AM.OffsetVector;
4137 *w++ = VECTBIT | DOTPBIT | FUNBIT;
4140 else if ( *p ==
'+' ) {
4143 while ( *p && *p !=
',' ) {
4144 if ( *p ==
'v' || *p ==
'V' ) {
4147 else if ( *p ==
'd' || *p ==
'D' ) {
4150 else if ( *p ==
'f' || *p ==
'F'
4151 || *p ==
't' || *p ==
'T' ) {
4154 else if ( *p ==
'?' ) {
4158 if ( p == 0 )
return(0);
4159 if ( ( c1 = DoTempSet(inp+1,p) ) < 0 )
return(0);
4160 if ( Sets[c1].type != CFUNCTION ) {
4161 MesPrint(
"&set type conflict: Function expected");
4169 if ( p == 0 )
return(0);
4171 type = GetName(AC.varnames,inp,&c1,WITHAUTO);
4173 if ( type != CSET && type != CDUBIOUS ) {
4174 MesPrint(
"&%s is not a set",inp);
4184 MesCerr(
"specifier for vector",p);
4192 MesCerr(
"specifier for vector",p);
4193 while ( *p && *p !=
')' && *p !=
',' ) p++;
4195 *w++ = VECTBIT | DOTPBIT | FUNBIT;
4202 MesPrint(
"&%s is not a symbol, function, vector or dotproduct",inp);
4204skipfield:
while ( *p && *p !=
')' && *p !=
',' ) p++;
4205 if ( *p && FG.cTable[p[1]] == 1 ) {
4207 while ( *p && *p !=
')' && *p !=
',' ) p++;
4214 while ( *p && *p !=
',' ) p++;
4219 if ( *p ==
')' ) p++;
4220 if ( *p ) { MesCerr(
"end of statement",p);
return(0); }
4221 if ( error )
return(0);
4246static UWORD *CIscratC = 0;
4251 int error = 0, level;
4252 WORD *w, *ww, *u, *s, *OldWork, *OldSpace = AT.WorkSpace;
4254 WORD lenpp, lenlev, ncoef, i, number;
4255 UBYTE *p, *pp, *ppp, c;
4256 CBUF *C = cbuf+AC.cbufnum;
4263 if ( *inp ==
'(' && inp[1] ==
',' ) inp += 2;
4264 else if ( *inp ==
'(' ) inp++;
4266 if ( CIscratC == 0 )
4267 CIscratC = (UWORD *)Malloc1((AM.MaxTal+2)*
sizeof(UWORD),
"CoIf");
4270 if ( AC.IfLevel >= AC.MaxIf ) DoubleIfBuffers();
4271 AC.IfCount[lenpp++] = 0;
4279 AC.IfSumCheck[AC.IfLevel] = NestingChecksum();
4281 w = OldWork = AT.WorkPointer;
4289 if ( FG.cTable[*p] == 1 ) {
4290 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4293 pp = CheckFloat(p,&spec);
4297 MesPrint(
"&The floating point system has not been started: %s",p);
4298 if ( !error ) error = 1;
4301 WORD *ow = AT.WorkPointer;
4304 ReadFloat((SBYTE *)p);
4307 AT.WorkPointer[0] = IFFLOATNUMBER;
4308 w = AT.WorkPointer + AT.WorkPointer[1];
4309 AT.WorkPointer = ow;
4310 if ( level ) w[FUNHEAD+3] = -w[FUNHEAD+3];
4312 goto DoneWithNumber;
4327 if ( GetLong(p,(UWORD *)w,&ncoef) ) { ncoef = 1; error = 1; }
4329 while ( FG.cTable[*++p] == 1 );
4332 if ( FG.cTable[*p] != 1 ) {
4333 MesCerr(
"sequence",p); error = 1;
goto OnlyNum;
4335 if ( GetLong(p,CIscratC,&ncoef) ) {
4336 ncoef = 1; error = 1;
4338 while ( FG.cTable[*++p] == 1 );
4340 MesPrint(
"&Division by zero!");
4345 if ( Simplify(BHEAD (UWORD *)w,(WORD *)(w-1),
4346 CIscratC,&ncoef) ) error = 1;
4353 s = (WORD *)CIscratC;
4355 while ( --i >= 0 ) *w++ = 0;
4360 while ( --i >= 0 ) *w++ = 0;
4361 s = (WORD *)CIscratC;
4373 while ( --ncoef >= 0 ) *w++ = 0;
4376 u[1] = WORDDIF(w,u);
4377 u[2] = (u[1] - 3)/2;
4378 if ( level ) u[2] = -u[2];
4386 else if ( *p ==
'+' ) { p++;
goto ReDo; }
4387 else if ( *p ==
'-' ) { level ^= 1; p++;
goto ReDo; }
4388 else if ( *p ==
'c' || *p ==
'C' ) {
4389 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4390 while ( FG.cTable[*++p] == 0 );
4392 if ( !StrICmp(inp,(UBYTE *)
"count") ) {
4395 MesPrint(
"&no ( after count");
4401 c = *++p; *p = 0; *inp =
',';
4402 w = CountComp(inp,w);
4404 if ( w == 0 ) { error = 1;
goto endofif; }
4407 else if ( ConWord(inp,(UBYTE *)
"coefficient") && ( p - inp ) > 3 ) {
4416 else if ( *p ==
'm' || *p ==
'M' ) {
4417 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4418 while ( !FG.cTable[*++p] );
4420 if ( !StrICmp(inp,(UBYTE *)
"match") ) {
4423 MesPrint(
"&no ( after match");
4434 AT.WorkSpace = AT.WorkPointer = w;
4436 while ( FG.cTable[*ppp] == 0 && ppp < p ) ppp++;
4437 if ( *ppp ==
',' ) AC.idoption = 0;
4438 else AC.idoption = SUBMULTI;
4439 level = CoIdExpression(inp,TYPEIF);
4440 AT.WorkSpace = OldSpace;
4441 AT.WorkPointer = OldWork;
4443 if ( level < 0 ) { error = -1;
goto endofif; }
4449 s = u = C->
lhs[C->numlhs];
4450 while ( u < C->Pointer ) *w++ = *u++;
4456 else if ( !StrICmp(inp,(UBYTE *)
"multipleof") ) {
4457 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4460 MesPrint(
"&no ( after multipleof");
4461 error = 1;
goto endofif;
4464 if ( FG.cTable[*p] != 1 ) {
4465Nomulof: MesPrint(
"&multipleof needs a short positive integer argument");
4466 error = 1;
goto endofif;
4469 if ( *p !=
')' || x <= 0 || x > MAXPOSITIVE )
goto Nomulof;
4471 *w++ = MULTIPLEOF; *w++ = 3; *w++ = (WORD)x;
4476NoGood: MesPrint(
"&Unrecognized word: %s",inp);
4480 if ( c ==
'(' ) SKIPBRA4(p)
4485 else if ( *p ==
'f' || *p ==
'F' ) {
4486 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4487 while ( FG.cTable[*++p] == 0 );
4489 if ( !StrICmp(inp,(UBYTE *)
"findloop") ) {
4492 MesPrint(
"&no ( after findloop");
4498 c = *++p; *p = 0; *inp =
',';
4499 if ( CoFindLoop(inp) ) { error = 1;
goto endofif; }
4500 s = u = C->
lhs[C->numlhs];
4501 while ( u < C->Pointer ) *w++ = *u++;
4504 if ( w == 0 ) { error = 1;
goto endofif; }
4507 else if ( !StrICmp(inp,(UBYTE *)
"flag") ) {
4508 UBYTE cc = c, *pppp;
4511 MesPrint(
"&no ( after flag");
4517 cc = *++p; *p = 0; *inp =
','; pppp = p;
4519 *w++ = IFUSERFLAG; *w++ = 0;
4522 while ( *inp ==
',' ) inp++;
4523 if ( *inp == 0 || *inp ==
')' )
break;
4524 while ( *inp >=
'0' && *inp <=
'9' ) x = 10*x+(*inp++-
'0');
4525 if ( x < 1 || x > BITSINWORD ) {
4526 MesPrint(
"&Flag number %d outside the permitted range 1-%d.",BITSINWORD);
4532 p = pppp; *p = cc; *inp =
'(';
4535 MesPrint(
"&The userflag condition in the if statement needs arguments.");
4543 else if ( *p ==
'e' || *p ==
'E' ) {
4544 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4545 while ( FG.cTable[*++p] == 0 );
4547 if ( !StrICmp(inp,(UBYTE *)
"expression") ) {
4550 MesPrint(
"&no ( after expression");
4554 p++; ww = w; *w++ = IFEXPRESSION; w++;
4555 while ( *p !=
')' ) {
4556 if ( *p ==
',' ) { p++;
continue; }
4557 if ( *p ==
'[' || FG.cTable[*p] == 0 ) {
4560 MesPrint(
"&Improper name for an expression: '%s'",pp);
4565 if ( GetName(AC.exprnames,pp,&number,NOAUTO) == CEXPRESSION ) {
4568 else if ( GetName(AC.varnames,pp,&number,NOAUTO) != NAMENOTFOUND ) {
4569 MesPrint(
"&%s is not an expression",pp);
4576 MesPrint(
"&Illegal object in Expression in if-statement");
4578 while ( *p && *p !=
',' && *p !=
')' ) p++;
4579 if ( *p == 0 || *p ==
')' )
break;
4589 else if ( *p ==
'i' || *p ==
'I' ) {
4590 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4591 while ( FG.cTable[*++p] == 0 );
4593 if ( !StrICmp(inp,(UBYTE *)
"isfactorized") ) {
4596 ww = w; *w++ = IFISFACTORIZED; w++;
4599 p++; ww = w; *w++ = IFISFACTORIZED; w++;
4600 while ( *p !=
')' ) {
4601 if ( *p ==
',' ) { p++;
continue; }
4602 if ( *p ==
'[' || FG.cTable[*p] == 0 ) {
4605 MesPrint(
"&Improper name for an expression: '%s'",pp);
4610 if ( GetName(AC.exprnames,pp,&number,NOAUTO) == CEXPRESSION ) {
4613 else if ( GetName(AC.varnames,pp,&number,NOAUTO) != NAMENOTFOUND ) {
4614 MesPrint(
"&%s is not an expression",pp);
4621 MesPrint(
"&Illegal object in IsFactorized in if-statement");
4623 while ( *p && *p !=
',' && *p !=
')' ) p++;
4624 if ( *p == 0 || *p ==
')' )
break;
4635 else if ( *p ==
'o' || *p ==
'O' ) {
4647 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4648 while ( FG.cTable[*++p] == 0 );
4649 c = cc = *p; *p = 0;
4650 if ( !StrICmp(inp,(UBYTE *)
"occurs") ) {
4654 MesPrint(
"&no ( after occurs");
4660 cc = *++p; *p = 0; *inp =
','; pp = p;
4662 *w++ = IFOCCURS; *w++ = 0;
4664 while ( *inp ==
',' ) inp++;
4665 if ( *inp == 0 || *inp ==
')' )
break;
4671 if ( *inp ==
'[' || FG.cTable[*inp] == 0 ) {
4672 if ( ( p =
SkipAName(inp) ) == 0 )
return(0);
4674 type = GetName(AC.varnames,inp,&c1,WITHAUTO);
4676 if ( type == CVECTOR || type == CDUBIOUS ) {
4680 if ( p == 0 )
return(0);
4683 type = GetName(AC.varnames,inp,&c2,WITHAUTO);
4684 if ( type != CVECTOR && type != CDUBIOUS ) {
4685 MesPrint(
"&Not a vector in dotproduct in if statement: %s",inp);
4688 else type = CDOTPRODUCT;
4691 MesPrint(
"&Illegal use of . after %s in if statement",inp);
4692 if ( type == NAMENOTFOUND )
4693 MesPrint(
"&%s is not a properly declared variable",inp);
4696 while ( *p && *p !=
')' && *p !=
',' ) p++;
4697 if ( *p ==
',' && FG.cTable[p[1]] == 1 ) {
4699 while ( *p && *p !=
')' && *p !=
',' ) p++;
4712 *w++ = c1 + AM.OffsetIndex;
4716 *w++ = c1 + AM.OffsetVector;
4720 *w++ = c1 + AM.OffsetVector;
4721 *w++ = c2 + AM.OffsetVector;
4728 MesPrint(
"&Illegal variable %s in occurs condition in if statement",inp);
4735 MesPrint(
"&Illegal object %s in occurs condition in if statement",inp);
4741 p = pp; *p = cc; *inp =
'(';
4744 MesPrint(
"&The occurs condition in the if statement needs arguments.");
4751 else if ( *p ==
'$' ) {
4752 if ( gotexp == 1 ) { MesCerr(
"position for )",p); error = 1; }
4754 while ( FG.cTable[*p] == 0 || FG.cTable[*p] == 1 ) p++;
4756 if ( ( i = GetDollar(inp) ) < 0 ) {
4757 MesPrint(
"&undefined dollar expression %s",inp);
4759 i = AddDollar(inp,DOLUNDEFINED,0,0);
4762 *w++ = IFDOLLAR; *w++ = 3; *w++ = i;
4768 if ( ( w = GetIfDollarFactor(&p,w) ) == 0 ) {
4772 else if ( *p !=
']' ) {
4783 else if ( *p ==
'.' ) {
4784 pp = CheckFloat(p,&spec);
4785 if ( pp > p )
goto HaveFloat;
4789 else if ( *p ==
'(' ) {
4791 MesCerr(
"parenthesis",p);
4796 if ( ++lenlev >= AC.MaxIf ) DoubleIfBuffers();
4797 AC.IfCount[lenpp++] = w-OldWork;
4802 else if ( *p ==
')' ) {
4803 if ( gotexp == 0 ) { MesCerr(
"position for )",p); error = 1; }
4805 u = AC.IfCount[--lenpp]+OldWork;
4808 if ( lenlev <= 0 ) {
4809 AT.WorkSpace = OldSpace;
4810 AT.WorkPointer = OldWork;
4814 MesPrint(
"&unmatched parenthesis in if/while ()");
4816 while ( *++p ==
')' );
4819 level = CompileStatement(p);
4820 if ( level ) error = level;
4822 if ( CoEndIf(p) && error == 0 ) error = 1;
4828 else if ( *p ==
'>' ) {
4829 if ( gotexp == 0 )
goto NoExp;
4830 if ( p[1] ==
'=' ) { *w++ = GREATEREQUAL; *w++ = 2; p += 2; }
4831 else { *w++ = GREATER; *w++ = 2; p++; }
4834 else if ( *p ==
'<' ) {
4835 if ( gotexp == 0 )
goto NoExp;
4836 if ( p[1] ==
'=' ) { *w++ = LESSEQUAL; *w++ = 2; p += 2; }
4837 else { *w++ = LESS; *w++ = 2; p++; }
4840 else if ( *p ==
'=' ) {
4841 if ( gotexp == 0 )
goto NoExp;
4842 if ( p[1] ==
'=' ) p++;
4843 *w++ = EQUAL; *w++ = 2; p++;
4846 else if ( *p ==
'!' && p[1] ==
'=' ) {
4847 if ( gotexp == 0 ) { p++;
goto NoExp; }
4848 *w++ = NOTEQUAL; *w++ = 2; p += 2;
4851 else if ( *p ==
'|' && p[1] ==
'|' ) {
4852 if ( gotexp == 0 ) { p++;
goto NoExp; }
4853 *w++ = ORCOND; *w++ = 2; p += 2;
4856 else if ( *p ==
'&' && p[1] ==
'&' ) {
4857 if ( gotexp == 0 ) {
4860 MesCerr(
"sequence",p);
4864 *w++ = ANDCOND; *w++ = 2; p += 2;
4868 else if ( *p == 0 ) {
4869 MesPrint(
"&Unmatched parentheses");
4874 if ( FG.cTable[*p] == 0 ) {
4877 while ( ( ij = FG.cTable[*++p] ) == 0 || ij == 1 );
4881 MesCerr(
"sequence",p);
4898 CBUF *C = cbuf+AC.cbufnum;
4900 while ( *p ==
',' ) p++;
4901 if ( tolower(*p) ==
'i' && tolower(p[1]) ==
'f' && p[2] ==
'(' )
4902 return(CoElseIf(p+2));
4903 MesPrint(
"&No extra text allowed as part of an else statement");
4906 if ( AC.IfLevel <= 0 ) { MesPrint(
"&else statement without if");
return(1); }
4907 if ( AC.IfSumCheck[AC.IfLevel-1] != NestingChecksum() - 1 ) {
4911 Add3Com(TYPEELSE,AC.IfLevel)
4912 C->Buffer[AC.IfStack[-1]] = C->numlhs;
4913 AC.IfStack[-1] = C->Pointer - C->Buffer - 1;
4922int CoElseIf(UBYTE *inp)
4924 CBUF *C = cbuf+AC.cbufnum;
4925 if ( AC.IfLevel <= 0 ) { MesPrint(
"&elseif statement without if");
return(1); }
4926 Add3Com(TYPEELSE,-AC.IfLevel)
4928 C->Buffer[*--AC.IfStack] = C->numlhs;
4949int CoEndIf(UBYTE *inp)
4951 CBUF *C = cbuf+AC.cbufnum;
4952 WORD i = C->numlhs, to, k = -AC.IfLevel;
4954 while ( *inp ==
',' ) inp++;
4957 MesPrint(
"&No extra text allowed as part of an endif/elseif statement");
4959 if ( AC.IfLevel <= 0 ) {
4960 MesPrint(
"&Endif statement without corresponding if");
return(1);
4963 C->
Buffer[*--AC.IfStack] = i+1;
4964 if ( AC.IfSumCheck[AC.IfLevel] != NestingChecksum() ) {
4968 Add3Com(TYPEENDIF,i+1)
4974 if ( C->
lhs[i][0] == TYPEELSE && C->
lhs[i][2] == to ) to = i;
4975 if ( C->
lhs[i][0] == TYPEIF ) {
4976 if ( C->
lhs[i][2] == to ) {
4978 if ( i <= 0 || C->lhs[i][0] != TYPEELSE
4979 || C->
lhs[i][2] != k )
break;
4980 C->
lhs[i][2] = C->numlhs;
4994int CoWhile(UBYTE *inp)
4996 CBUF *C = cbuf+AC.cbufnum;
4997 WORD startnum = C->numlhs + 1;
5001 if ( C->numlhs > startnum && C->
lhs[startnum][2] == C->numlhs
5002 && C->
lhs[C->numlhs][0] == TYPEENDIF ) {
5003 C->
lhs[C->numlhs][2] = startnum-1;
5006 else C->
lhs[startnum][2] = startnum;
5015int CoEndWhile(UBYTE *inp)
5019 CBUF *C = cbuf+AC.cbufnum;
5020 if ( AC.WhileLevel <= 0 ) {
5021 MesPrint(
"&EndWhile statement without corresponding While");
return(1);
5024 i = C->
Buffer[AC.IfStack[-1]];
5025 error = CoEndIf(inp);
5026 C->
lhs[C->numlhs][2] = i - 1;
5037static char *messfind[] = {
5038 "Findloop(function,arguments=#,loopsize(=#|<#)[,include=index])"
5039 ,
"Replaceloop,function,arguments=#,loopsize(=#|<#),outfun=function[,include=index]"
5041static WORD comfindloop[7] = { TYPEFINDLOOP,7,0,0,0,0,0 };
5043int DoFindLoop(UBYTE *inp,
int mode)
5046 WORD funnum, nargs = 0, nloop = 0, indexnum = 0, outfun = 0;
5047 int type, aflag, lflag, indflag, outflag, error = 0, sym;
5048 while ( *inp ==
',' ) inp++;
5051 MesPrint(
"&Proper syntax is:");
5052 MesPrint(
"%s",messfind[mode]);
5056 if ( ( ( type = GetName(AC.varnames,inp,&funnum,WITHAUTO) ) == NAMENOTFOUND )
5057 || type != CFUNCTION || ( ( sym = (functions[funnum].symmetric) & ~REVERSEORDER )
5058 != SYMMETRIC && sym != ANTISYMMETRIC ) ) {
5059 MesPrint(
"&%s should be a (anti)symmetric function or tensor",inp);
5064 aflag = lflag = indflag = outflag = 0;
5065 while ( *inp ==
',' ) {
5066 while ( *inp ==
',' ) inp++;
5068 if ( ( s =
SkipAName(inp) ) == 0 )
goto syntax;
5070 if ( StrICont(inp,(UBYTE *)
"arguments") == 0 ) {
5071 if ( c !=
'=' )
goto syntax;
5073 NeedNumber(nargs,s,syntax)
5077 else if ( StrICont(inp,(UBYTE *)
"loopsize") == 0 ) {
5078 if ( c !=
'=' && c !=
'<' )
goto syntax;
5080 if ( FG.cTable[*s] == 1 ) {
5081 NeedNumber(nloop,s,syntax)
5083 MesPrint(
"&loopsize should be at least 2");
5086 if ( c ==
'<' ) nloop = -nloop;
5088 else if ( tolower(*s) ==
'a' && tolower(s[1]) ==
'l'
5089 && tolower(s[2]) ==
'l' && FG.cTable[s[3]] > 1 ) {
5091 if ( c !=
'=' )
goto syntax;
5096 else if ( StrICont(inp,(UBYTE *)
"include") == 0 ) {
5097 if ( c !=
'=' )
goto syntax;
5099 if ( ( inp =
SkipAName(s) ) == 0 )
goto syntax;
5101 if ( ( type = GetName(AC.varnames,s,&indexnum,WITHAUTO) ) != CINDEX ) {
5102 MesPrint(
"&%s is not a proper index",s);
5105 else if ( indexnum < WILDOFFSET
5106 && indices[indexnum].dimension == 0 ) {
5107 MesPrint(
"&%s should be a summable index",s);
5110 indexnum += AM.OffsetIndex;
5114 else if ( StrICont(inp,(UBYTE *)
"outfun") == 0 ) {
5115 if ( c !=
'=' )
goto syntax;
5117 if ( ( inp =
SkipAName(s) ) == 0 )
goto syntax;
5119 if ( ( type = GetName(AC.varnames,s,&outfun,WITHAUTO) ) != CFUNCTION ) {
5120 MesPrint(
"&%s is not a proper function or tensor",s);
5128 MesPrint(
"&Unrecognized option in FindLoop or ReplaceLoop: %s",inp);
5131 while ( *inp && *inp !=
',' ) inp++;
5134 if ( *inp != 0 && mode == REPLACELOOP )
goto syntax;
5135 if ( mode == FINDLOOP && outflag > 0 ) {
5136 MesPrint(
"&outflag option is illegal in FindLoop");
5139 if ( mode == REPLACELOOP && outflag == 0 )
goto syntax;
5140 if ( aflag == 0 || lflag == 0 )
goto syntax;
5141 comfindloop[3] = funnum;
5142 comfindloop[4] = nloop;
5143 comfindloop[5] = nargs;
5144 comfindloop[6] = outfun;
5147 if ( mode == 0 ) comfindloop[2] = indexnum + 5;
5148 else comfindloop[2] = -indexnum - 5;
5150 else comfindloop[2] = mode;
5151 AddNtoL(comfindloop[1],comfindloop);
5160int CoFindLoop(UBYTE *inp)
5161{
return(DoFindLoop(inp,FINDLOOP)); }
5168int CoReplaceLoop(UBYTE *inp)
5170 int error = DoFindLoop(inp,REPLACELOOP);
5182static UBYTE *FunPowOptions[] = {
5183 (UBYTE *)
"nofunpowers"
5184 ,(UBYTE *)
"commutingonly"
5185 ,(UBYTE *)
"allfunpowers"
5188int CoFunPowers(UBYTE *inp)
5191 int i, maxoptions =
sizeof(FunPowOptions)/
sizeof(UBYTE *);
5192 while ( *inp ==
',' ) inp++;
5194 inp =
SkipAName(inp); c = *inp; *inp = 0;
5195 for ( i = 0; i < maxoptions; i++ ) {
5196 if ( StrICont(option,FunPowOptions[i]) == 0 ) {
5199 MesPrint(
"&Illegal FunPowers statement");
5206 MesPrint(
"&Illegal option in FunPowers statement: %s",option);
5215int CoUnitTrace(UBYTE *s)
5218 if ( FG.cTable[*s] == 1 ) {
5221nogood: MesPrint(
"&Value of UnitTrace should be a (positive) number or a symbol");
5224 AC.lUniTrace[0] = SNUMBER;
5225 AC.lUniTrace[2] = num;
5228 if ( GetName(AC.varnames,s,&num,WITHAUTO) == CSYMBOL ) {
5229 AC.lUniTrace[0] = SYMBOL;
5230 AC.lUniTrace[2] = num;
5235 if ( *s )
goto nogood;
5237 AC.lUnitTrace = num;
5253 WORD *w = AT.WorkPointer;
5255 while ( *s ==
',' ) s++;
5257 MesPrint(
"&Illegal syntax for Term statement");
5260 if ( AC.termlevel+1 >= AC.maxtermlevel ) {
5261 if ( AC.maxtermlevel <= 0 ) {
5262 AC.maxtermlevel = 20;
5263 AC.termstack = (LONG *)Malloc1(AC.maxtermlevel*
sizeof(LONG),
"termstack");
5264 AC.termsortstack = (LONG *)Malloc1(AC.maxtermlevel*
sizeof(LONG),
"termsortstack");
5265 AC.termsumcheck = (WORD *)Malloc1(AC.maxtermlevel*
sizeof(WORD),
"termsumcheck");
5268 DoubleBuffer((
void **)AC.termstack,(
void **)AC.termstack+AC.maxtermlevel,
5269 sizeof(LONG),
"doubling termstack");
5270 DoubleBuffer((
void **)AC.termsortstack,
5271 (
void **)AC.termsortstack+AC.maxtermlevel,
5272 sizeof(LONG),
"doubling termsortstack");
5273 DoubleBuffer((
void **)AC.termsumcheck,
5274 (
void **)AC.termsumcheck+AC.maxtermlevel,
5275 sizeof(LONG),
"doubling termsumcheck");
5276 AC.maxtermlevel *= 2;
5279 AC.termsumcheck[AC.termlevel] = NestingChecksum();
5280 AC.termstack[AC.termlevel] = cbuf[AC.cbufnum].Pointer
5281 - cbuf[AC.cbufnum].Buffer + 2;
5282 AC.termsortstack[AC.termlevel] = AC.termstack[AC.termlevel] + 1;
5286 *w++ = cbuf[AC.cbufnum].numlhs;
5287 *w++ = cbuf[AC.cbufnum].numlhs;
5288 AT.WorkPointer[1] = w - AT.WorkPointer;
5289 AddNtoL(AT.WorkPointer[1],AT.WorkPointer);
5298int CoEndTerm(UBYTE *s)
5300 CBUF *C = cbuf+AC.cbufnum;
5301 while ( *s ==
',' ) s++;
5303 MesPrint(
"&Illegal syntax for EndTerm statement");
5306 if ( AC.termlevel <= 0 ) {
5307 MesPrint(
"&EndTerm without corresponding Argument statement");
5311 cbuf[AC.cbufnum].Buffer[AC.termstack[AC.termlevel]] = C->numlhs;
5312 cbuf[AC.cbufnum].Buffer[AC.termsortstack[AC.termlevel]] = C->numlhs;
5313 if ( AC.termsumcheck[AC.termlevel] != NestingChecksum() ) {
5328 WORD *w = AT.WorkPointer;
5330 while ( *s ==
',' ) s++;
5332 MesPrint(
"&Illegal syntax for Sort statement");
5335 if ( AC.termlevel <= 0 ) {
5336 MesPrint(
"&The Sort statement can only be used inside a term environment");
5339 if ( error )
return(error);
5343 cbuf[AC.cbufnum].Buffer[AC.termsortstack[AC.termlevel-1]] =
5344 *w = cbuf[AC.cbufnum].numlhs+1;
5346 AC.termsortstack[AC.termlevel-1] = cbuf[AC.cbufnum].Pointer
5347 - cbuf[AC.cbufnum].Buffer + 3;
5348 if ( AC.termsumcheck[AC.termlevel-1] != NestingChecksum() - 1 ) {
5352 AT.WorkPointer[1] = w - AT.WorkPointer;
5353 AddNtoL(AT.WorkPointer[1],AT.WorkPointer);
5364int CoPolyFun(UBYTE *s)
5368 int type, error = 0;
5370 AR.PolyFun = AC.lPolyFun = 0;
5371 AR.PolyFunInv = AC.lPolyFunInv = 0;
5372 AR.PolyFunType = AC.lPolyFunType = 0;
5373 AR.PolyFunExp = AC.lPolyFunExp = 0;
5374 AR.PolyFunVar = AC.lPolyFunVar = 0;
5375 AR.PolyFunPow = AC.lPolyFunPow = 0;
5376 if ( *s == 0 ) {
return(0); }
5378 if ( t == 0 || *t != 0 ) {
5379 MesPrint(
"&PolyFun statement needs a single commuting function for its argument");
5382 if ( ( ( type = GetName(AC.varnames,s,&numfun,WITHAUTO) ) != CFUNCTION )
5383 || ( functions[numfun].spec != 0 ) || ( functions[numfun].commute != 0 ) ) {
5384 MesPrint(
"&%s should be a regular commuting function",s);
5386 if ( GetName(AC.exprnames,s,&numfun,NOAUTO) == NAMENOTFOUND )
5387 AddFunction(s,0,0,0,0,0,-1,-1);
5392 AR.PolyFun = AC.lPolyFun = numfun+FUNCTION;
5393 AR.PolyFunType = AC.lPolyFunType = 1;
5396 if ( mpfaux_ != 0 ) {
5397 MesPrint(
"&Simultaneous use of PolyFun and float_ is not allowed.");
5411int CoPolyRatFun(UBYTE *s)
5415 int type, error = 0;
5417 AR.PolyFun = AC.lPolyFun = 0;
5418 AR.PolyFunInv = AC.lPolyFunInv = 0;
5419 AR.PolyFunType = AC.lPolyFunType = 0;
5420 AR.PolyFunExp = AC.lPolyFunExp = 0;
5421 AR.PolyFunVar = AC.lPolyFunVar = 0;
5422 AR.PolyFunPow = AC.lPolyFunPow = 0;
5423 if ( *s == 0 )
return(error);
5425 if ( t == 0 )
goto NumErr;
5428 if ( mpfaux_ != 0 ) {
5429 MesPrint(
"&Simultaneous use of PolyFun and float_ is not allowed.");
5433 if ( ( ( type = GetName(AC.varnames,s,&numfun,WITHAUTO) ) != CFUNCTION )
5434 || ( functions[numfun].spec != 0 ) || ( functions[numfun].commute != 0 ) ) {
5435 MesPrint(
"&%s should be a regular commuting function",s);
5437 if ( GetName(AC.exprnames,s,&numfun,NOAUTO) == NAMENOTFOUND )
5438 AddFunction(s,0,0,0,0,0,-1,-1);
5442 AR.PolyFun = AC.lPolyFun = numfun+FUNCTION;
5443 AR.PolyFunInv = AC.lPolyFunInv = 0;
5444 AR.PolyFunType = AC.lPolyFunType = 2;
5445 AC.PolyRatFunChanged = 1;
5446 if ( c == 0 )
return(error);
5448 if ( *t ==
'-' ) { AC.PolyRatFunChanged = 0; t++; }
5449 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5450 if ( *t == 0 )
return(error);
5454 if ( t == 0 )
goto NumErr;
5456 if ( ( ( type = GetName(AC.varnames,s,&numfun,WITHAUTO) ) != CFUNCTION )
5457 || ( functions[numfun].spec != 0 ) || ( functions[numfun].commute != 0 ) ) {
5458 MesPrint(
"&%s should be a regular commuting function",s);
5460 if ( GetName(AC.exprnames,s,&numfun,NOAUTO) == NAMENOTFOUND )
5461 AddFunction(s,0,0,0,0,0,-1,-1);
5465 AR.PolyFunInv = AC.lPolyFunInv = numfun+FUNCTION;
5466 if ( c == 0 )
return(error);
5468 if ( *t ==
'-' ) { AC.PolyRatFunChanged = 0; t++; }
5469 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5470 if ( *t == 0 )
return(error);
5474 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5482 if ( t == 0 )
goto NumErr;
5484 if ( ( StrICmp(s,(UBYTE *)
"divergence") == 0 )
5485 || ( StrICmp(s,(UBYTE *)
"finddivergence") == 0 ) ) {
5487 MesPrint(
"&Illegal option field in PolyRatFun statement.");
5491 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5494 if ( t == 0 )
goto NumErr;
5496 if ( ( type = GetName(AC.varnames,s,&AC.lPolyFunVar,WITHAUTO) ) != CSYMBOL ) {
5497 MesPrint(
"&Illegal symbol %s in option field in PolyRatFun statement.",s);
5501 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5503 MesPrint(
"&Illegal termination of option in PolyRatFun statement.");
5506 AR.PolyFunExp = AC.lPolyFunExp = 1;
5507 AR.PolyFunVar = AC.lPolyFunVar;
5508 symbols[AC.lPolyFunVar].minpower = -MAXPOWER;
5509 symbols[AC.lPolyFunVar].maxpower = MAXPOWER;
5511 else if ( StrICmp(s,(UBYTE *)
"expand") == 0 ) {
5512 WORD x = 0, etype = 2;
5514 MesPrint(
"&Illegal option field in PolyRatFun statement.");
5518 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5521 if ( t == 0 )
goto NumErr;
5523 if ( ( type = GetName(AC.varnames,s,&AC.lPolyFunVar,WITHAUTO) ) != CSYMBOL ) {
5524 MesPrint(
"&Illegal symbol %s in option field in PolyRatFun statement.",s);
5528 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5529 if ( *t >
'9' || *t <
'0' ) {
5530 MesPrint(
"&Illegal option field in PolyRatFun statement.");
5533 while ( *t <=
'9' && *t >=
'0' ) x = 10*x + *t++ -
'0';
5534 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5538 if ( t == 0 )
goto ParErr;
5540 if ( StrICmp(s,(UBYTE *)
"fixed") == 0 ) {
5543 else if ( StrICmp(s,(UBYTE *)
"relative") == 0 ) {
5547 MesPrint(
"&Illegal termination of option in PolyRatFun statement.");
5551 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5553 MesPrint(
"&Illegal termination of option in PolyRatFun statement.");
5557 AR.PolyFunExp = AC.lPolyFunExp = etype;
5558 AR.PolyFunVar = AC.lPolyFunVar;
5559 AR.PolyFunPow = AC.lPolyFunPow = x;
5560 symbols[AC.lPolyFunVar].minpower = -MAXPOWER;
5561 symbols[AC.lPolyFunVar].maxpower = MAXPOWER;
5564ParErr: MesPrint(
"&Illegal option %s in PolyRatFun statement.",s);
5568 while ( *t ==
',' || *t ==
' ' || *t ==
'\t' ) t++;
5569 if ( *t == 0 )
return(error);
5572 MesPrint(
"&PolyRatFun statement needs one or two commuting function(s) for its argument(s)");
5581int CoMerge(UBYTE *inp)
5585 WORD numfunc, option = 0;
5586 if ( tolower(s[0]) ==
'o' && tolower(s[1]) ==
'n' && tolower(s[2]) ==
'c' &&
5587 tolower(s[3]) ==
'e' && tolower(s[4]) ==
',' ) {
5590 else if ( tolower(s[0]) ==
'a' && tolower(s[1]) ==
'l' && tolower(s[2]) ==
'l' &&
5591 tolower(s[3]) ==
',' ) {
5595 if ( ( type = GetName(AC.dollarnames,s+1,&numfunc,NOAUTO) ) == CDOLLAR )
5598 MesPrint(
"&%s is undefined",s);
5599 numfunc = AddDollar(s+1,DOLINDEX,&one,1);
5604 MesPrint(
"&Merge/shuffle should have a single function or $variable for its argument");
5608 else if ( ( type = GetName(AC.varnames,s,&numfunc,WITHAUTO) ) == CFUNCTION ) {
5609 numfunc += FUNCTION;
5612 else if ( type != -1 ) {
5613 if ( type != CDUBIOUS ) {
5614 NameConflict(type,s);
5615 type = MakeDubious(AC.varnames,s,&numfunc);
5620 MesPrint(
"&%s is not a function",s);
5621 numfunc = AddFunction(s,0,0,0,0,0,-1,-1) + FUNCTION;
5624 Add4Com(TYPEMERGE,numfunc,option);
5637int CoStuffle(UBYTE *inp)
5639 UBYTE *s = inp, *ss, c;
5641 WORD numfunc, option = 0;
5642 if ( tolower(s[0]) ==
'o' && tolower(s[1]) ==
'n' && tolower(s[2]) ==
'c' &&
5643 tolower(s[3]) ==
'e' && tolower(s[4]) ==
',' ) {
5646 else if ( tolower(s[0]) ==
'a' && tolower(s[1]) ==
'l' && tolower(s[2]) ==
'l' &&
5647 tolower(s[3]) ==
',' ) {
5653 if ( ( type = GetName(AC.dollarnames,s+1,&numfunc,NOAUTO) ) == CDOLLAR )
5656 MesPrint(
"&%s is undefined",s);
5657 numfunc = AddDollar(s+1,DOLINDEX,&one,1);
5661 if ( *ss !=
'+' && *ss !=
'-' && ss[1] != 0 ) {
5662 MesPrint(
"&Stuffle should have a single function or $variable for its argument, followed by either + or -");
5665 if ( *ss ==
'-' ) option += 2;
5667 else if ( ( type = GetName(AC.varnames,s,&numfunc,WITHAUTO) ) == CFUNCTION ) {
5668 numfunc += FUNCTION;
5671 else if ( type != -1 ) {
5672 if ( type != CDUBIOUS ) {
5673 NameConflict(type,s);
5674 type = MakeDubious(AC.varnames,s,&numfunc);
5679 MesPrint(
"&%s is not a function",s);
5680 numfunc = AddFunction(s,0,0,0,0,0,-1,-1) + FUNCTION;
5683 Add4Com(TYPESTUFFLE,numfunc,option);
5692int CoProcessBucket(UBYTE *s)
5695 while ( *s ==
',' || *s ==
'=' ) s++;
5697 if ( *s && *s !=
' ' && *s !=
'\t' ) {
5698 MesPrint(
"&Numerical value expected for ProcessBucketSize");
5701 AC.ProcessBucketSize = x;
5710int CoThreadBucket(UBYTE *s)
5713 while ( *s ==
',' || *s ==
'=' ) s++;
5715 if ( *s && *s !=
' ' && *s !=
'\t' ) {
5716 MesPrint(
"&Numerical value expected for ThreadBucketSize");
5720 Warning(
"Negative of zero value not allowed for ThreadBucketSize. Adjusted to 1.");
5723 AC.ThreadBucketSize = x;
5725 if ( AS.MultiThreaded ) MakeThreadBuckets(-1,1);
5740int DoArgPlode(UBYTE *s,
int par)
5743 WORD numfunc, type, error = 0, *w, n;
5749 while ( *s ==
',' ) s++;
5752 MesPrint(
"&We don't do dollar variables yet in ArgImplode/ArgExplode");
5756 if ( ( s =
SkipAName(s) ) == 0 )
return(1);
5758 if ( ( type = GetName(AC.varnames,t,&numfunc,WITHAUTO) ) == CFUNCTION ) {
5759 numfunc += FUNCTION;
5761 else if ( type != -1 ) {
5762 if ( type != CDUBIOUS ) {
5763 NameConflict(type,t);
5764 type = MakeDubious(AC.varnames,t,&numfunc);
5769 MesPrint(
"&%s is not a function",t);
5770 numfunc = AddFunction(s,0,0,0,0,0,-1,-1) + FUNCTION;
5777 for ( i = 2; i < FUNHEAD; i++ ) *w++ = 0;
5779 if ( *s && *s !=
',' ) {
5780 MesPrint(
"&Illegal character in ArgImplode/ArgExplode statement: %s",s);
5783 while ( *s ==
',' ) s++;
5785 n = w - AT.WorkPointer;
5786 AT.WorkPointer[1] = n;
5796int CoArgExplode(UBYTE *s) {
return(DoArgPlode(s,TYPEARGEXPLODE)); }
5803int CoArgImplode(UBYTE *s) {
return(DoArgPlode(s,TYPEARGIMPLODE)); }
5810int CoClearTable(UBYTE *s)
5813 int j, type, error = 0;
5817 MesPrint(
"&The ClearTable statement needs at least one (table) argument.");
5824 if ( ( ( type = GetName(AC.varnames,t,&numfun,WITHAUTO) ) != CFUNCTION )
5825 && type != CDUBIOUS ) {
5826nofunc: MesPrint(
"&%s is not a table",t);
5828 if ( type < 0 ) numfun = AddFunction(t,0,0,0,0,0,-1,-1);
5830 if ( *s ==
',' ) s++;
5837 else if ( ( T = functions[numfun].tabl ) == 0 )
goto nofunc;
5840 if ( *s ==
',' ) s++;
5876 if ( TT->
mm ) M_free(TT->
mm,
"tableminmax");
5877 if ( TT->
flags ) M_free(TT->
flags,
"tableflags");
5892int CoDenominators(UBYTE *s)
5897 if ( t == 0 )
goto syntaxerror;
5898 t1 = t;
while ( *t1 ==
',' || *t1 ==
' ' || *t1 ==
'\t' ) t1++;
5899 if ( *t1 )
goto syntaxerror;
5901 if ( ( ( type = GetName(AC.varnames,s,&numfun,WITHAUTO) ) != CFUNCTION )
5902 || ( functions[numfun].spec != 0 ) ) {
5904 if ( GetName(AC.exprnames,s,&numfun,NOAUTO) == NAMENOTFOUND )
5905 AddFunction(s,0,0,0,0,0,-1,-1);
5909 Add3Com(TYPEDENOMINATORS,numfun+FUNCTION);
5912 MesPrint(
"&Denominators statement needs one regular function for its argument");
5921int CoDropCoefficient(UBYTE *s)
5924 Add2Com(TYPEDROPCOEFFICIENT)
5927 MesPrint(
"&Illegal argument in DropCoefficient statement: '%s'",s);
5935int CoDropSymbols(UBYTE *s)
5938 Add2Com(TYPEDROPSYMBOLS)
5941 MesPrint(
"&Illegal argument in DropSymbols statement: '%s'",s);
5958int CoToPolynomial(UBYTE *inp)
5961 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
5962 if ( ( AC.topolynomialflag & ~TOPOLYNOMIALFLAG ) != 0 ) {
5963 MesPrint(
"&ToPolynomial statement and FactArg statement are not allowed in the same module");
5966 if ( AO.OptimizeResult.code != NULL ) {
5967 MesPrint(
"&Using ToPolynomial statement when there are still optimization results active.");
5968 MesPrint(
"&Please use #ClearOptimize instruction first.");
5969 MesPrint(
"&This will loose the optimized expression.");
5973 Add3Com(TYPETOPOLYNOMIAL,DOALL)
5977 WORD *funnums = 0, type, num;
5980 if ( s == 0 )
return(1);
5982 if ( StrICmp(inp,(UBYTE *)
"onlyfunctions") ) {
5983 MesPrint(
"&Illegal option %s in ToPolynomial statement",inp);
5989 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
5995 funnums = (WORD *)Malloc1(((LONG)(s-inp)+3)*
sizeof(WORD),
"ToPlynomial");
5998 if ( s == 0 )
return(1);
6000 type = GetName(AC.varnames,inp,&num,WITHAUTO);
6001 if ( type != CFUNCTION ) {
6002 MesPrint(
"&%s is not a function in ToPolynomial statement",inp);
6005 funnums[3+numargs++] = num+FUNCTION;
6008 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
6010 funnums[0] = TYPETOPOLYNOMIAL;
6011 funnums[1] = numargs+3;
6012 funnums[2] = ONLYFUNCTIONS;
6015 if ( funnums ) M_free(funnums,
"ToPolynomial");
6017 AC.topolynomialflag |= TOPOLYNOMIALFLAG;
6020 AC.mparallelflag |= NOPARALLEL_CONVPOLY;
6033int CoFromPolynomial(UBYTE *inp)
6035 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
6037 if ( AO.OptimizeResult.code != NULL ) {
6038 MesPrint(
"&Using FromPolynomial statement when there are still optimization results active.");
6039 MesPrint(
"&Please use #ClearOptimize instruction first.");
6040 MesPrint(
"&This will loose the optimized expression.");
6043 Add2Com(TYPEFROMPOLYNOMIAL)
6046 MesPrint(
"&Illegal argument in FromPolynomial statement: '%s'",inp);
6059int CoArgToExtraSymbol(UBYTE *s)
6061 CBUF *C = cbuf + AC.cbufnum;
6065 if ( ( AC.topolynomialflag & ~TOPOLYNOMIALFLAG ) != 0 ) {
6066 MesPrint(
"&ArgToExtraSymbol statement and FactArg statement are not allowed in the same module");
6069 if ( AO.OptimizeResult.code != NULL ) {
6070 MesPrint(
"&Using ArgToExtraSymbol statement when there are still optimization results active.");
6071 MesPrint(
"&Please use #ClearOptimize instruction first.");
6072 MesPrint(
"&This will loose the optimized expression.");
6077 int tonumber = ConsumeOption(&s,
"tonumber");
6079 int ret = DoArgument(s,TYPEARGTOEXTRASYMBOL);
6080 if ( ret )
return(ret);
6086 lhs = C->
lhs[C->numlhs];
6087 if ( lhs[4] != 1 ) {
6088 Warning(
"scale parameter (^n) is ignored in ArgToExtraSymbol");
6092 AC.topolynomialflag |= TOPOLYNOMIALFLAG;
6098 AC.mparallelflag |= NOPARALLEL_CONVPOLY;
6109int CoExtraSymbols(UBYTE *inp)
6111 UBYTE *arg1, *arg2, c, *s;
6112 WORD i, j, type, number;
6113 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
6114 if ( FG.cTable[*inp] != 0 ) {
6115 MesPrint(
"&Illegal argument in ExtraSymbols statement: '%s'",inp);
6119 while ( FG.cTable[*inp] == 0 ) inp++;
6121 if ( ( StrICmp(arg1,(UBYTE *)
"array") == 0 )
6122 || ( StrICmp(arg1,(UBYTE *)
"vector") == 0 ) ) {
6123 AC.extrasymbols = 1;
6125 else if ( StrICmp(arg1,(UBYTE *)
"underscore") == 0 ) {
6126 AC.extrasymbols = 0;
6134 MesPrint(
"&Illegal keyword in ExtraSymbols statement: '%s'",arg1);
6138 while ( *inp ==
' ' || *inp ==
',' || *inp ==
'\t' ) inp++;
6139 if ( FG.cTable[*inp] != 0 ) {
6140 MesPrint(
"&Illegal argument in ExtraSymbols statement: '%s'",inp);
6144 while ( FG.cTable[*inp] <= 1 ) inp++;
6146 MesPrint(
"&Illegal end of ExtraSymbols statement: '%s'",inp);
6153 if ( AC.extrasymbols == 1 ) {
6154 type = GetName(AC.varnames,arg2,&number,NOAUTO);
6155 if ( type != NAMENOTFOUND ) {
6156 MesPrint(
"&ExtraSymbols statement: '%s' has already been declared before",arg2);
6160 else if ( AC.extrasymbols == 0 ) {
6161 if ( *arg2 ==
'N' ) {
6163 while ( FG.cTable[*s] == 1 ) s++;
6165 MesPrint(
"&ExtraSymbols statement: '%s' creates conflicts with summed indices",arg2);
6170 if ( AC.extrasym ) { M_free(AC.extrasym,
"extrasym"); AC.extrasym = 0; }
6172 AC.extrasym = (UBYTE *)Malloc1(i*
sizeof(UBYTE),
"extrasym");
6173 for ( j = 0; j < i; j++ ) AC.extrasym[j] = arg2[j];
6182WORD *GetIfDollarFactor(UBYTE **inp, WORD *w)
6188 if ( FG.cTable[*s] == 1 ) {
6190 while ( FG.cTable[*s] == 1 ) {
6191 x = 10*x + *s++ -
'0';
6192 if ( x >= MAXPOSITIVE ) {
6193 MesPrint(
"&Value in dollar factor too large");
6194 while ( FG.cTable[*s] == 1 ) s++;
6199 *w++ = IFDOLLAREXTRA;
6206 MesPrint(
"&Factor indicator for $-variable should be a number or a $-variable.");
6210 while ( FG.cTable[*s] < 2 ) s++;
6212 if ( GetName(AC.dollarnames,name,&number,NOAUTO) == NAMENOTFOUND ) {
6213 MesPrint(
"&dollar in if statement should have been defined previously");
6217 *w++ = IFDOLLAREXTRA;
6223 if ( ( w = GetIfDollarFactor(inp,w) ) == 0 )
return(0);
6226 MesPrint(
"&unmatched [] in $ in if statement");
6240UBYTE *GetDoParam(UBYTE *inp, WORD **wp,
int par)
6245 if ( FG.cTable[*inp] == 1 ) {
6247 while ( *inp >=
'0' && *inp <=
'9' ) {
6248 x = 10*x + *inp++ -
'0';
6249 if ( x > MAXPOSITIVE ) {
6251 MesPrint(
"&Value in dollar factor too large");
6254 MesPrint(
"&Value in do loop boundaries too large");
6256 while ( FG.cTable[*inp] == 1 ) inp++;
6265 *(*wp)++ = DOLLAREXPR2;
6266 *(*wp)++ = -((WORD)x)-1;
6270 if ( *inp !=
'$' ) {
6274 while ( FG.cTable[*inp] < 2 ) inp++;
6276 if ( GetName(AC.dollarnames,name,&number,NOAUTO) == NAMENOTFOUND ) {
6278 MesPrint(
"&dollar in print statement should have been defined previously");
6281 MesPrint(
"&dollar in do loop boundaries should have been defined previously");
6287 *(*wp)++ = DOLLAREXPRESSION;
6291 *(*wp)++ = DOLLAREXPR2;
6296 inp = GetDoParam(inp,wp,0);
6297 if ( inp == 0 )
return(0);
6298 if ( *inp !=
']' ) {
6300 MesPrint(
"&unmatched [] in $ in print statement");
6303 MesPrint(
"&unmatched [] in do loop boundaries");
6320 CBUF *C = cbuf+AC.cbufnum;
6324 if ( AC.doloopstack == 0 ) {
6325 AC.doloopstacksize = 20;
6326 AC.doloopstack = (WORD *)Malloc1(AC.doloopstacksize*2*
sizeof(WORD),
"doloop stack");
6327 AC.doloopnest = AC.doloopstack + AC.doloopstacksize;
6329 if ( AC.dolooplevel >= AC.doloopstacksize ) {
6330 WORD *newstack, *newnest, newsize;
6331 newsize = AC.doloopstacksize * 2;
6332 newstack = (WORD *)Malloc1(newsize*2*
sizeof(WORD),
"doloop stack");
6333 newnest = newstack + newsize;
6334 for ( i = 0; i < newsize; i++ ) {
6335 newstack[i] = AC.doloopstack[i];
6336 newnest[i] = AC.doloopnest[i];
6338 M_free(AC.doloopstack,
"doloop stack");
6339 AC.doloopstack = newstack;
6340 AC.doloopnest = newnest;
6341 AC.doloopstacksize = newsize;
6343 AC.doloopnest[AC.dolooplevel] = NestingChecksum();
6351 while ( *inp ==
',' ) inp++;
6352 if ( *inp !=
'$' ) {
6354 MesPrint(
"&do loop parameter should be a dollar variable");
6359 if ( FG.cTable[*inp] != 0 ) {
6361 MesPrint(
"&illegal name for do loop parameter");
6363 while ( FG.cTable[*inp] < 2 ) inp++;
6365 if ( GetName(AC.dollarnames,name,&numparam,NOAUTO) == NAMENOTFOUND ) {
6366 numparam = AddDollar(name,DOLUNDEFINED,0,0);
6373 while ( *inp ==
',' ) inp++;
6374 if ( *inp !=
'=' )
goto IllSyntax;
6376 while ( *inp ==
',' ) inp++;
6380 inp = GetDoParam(inp,&w,1);
6381 if ( inp == 0 || *inp !=
',' )
goto IllSyntax;
6382 while ( *inp ==
',' ) inp++;
6386 inp = GetDoParam(inp,&w,1);
6387 if ( inp == 0 || ( *inp != 0 && *inp !=
',' ) )
goto IllSyntax;
6391 if ( *inp !=
',' ) {
6392 if ( *inp == 0 ) { *w++ = SNUMBER; *w++ = 1; }
6393 else goto IllSyntax;
6396 while ( *inp ==
',' ) inp++;
6397 inp = GetDoParam(inp,&w,1);
6399 if ( inp == 0 || *inp != 0 )
goto IllSyntax;
6401 AT.WorkPointer[1] = w - AT.WorkPointer;
6405 AddNtoL(AT.WorkPointer[1],AT.WorkPointer);
6406 AC.doloopstack[AC.dolooplevel++] = C->numlhs;
6411 MesPrint(
"&Illegal syntax for do statement");
6420int CoEndDo(UBYTE *inp)
6422 CBUF *C = cbuf+AC.cbufnum;
6424 while ( *inp ==
',' ) inp++;
6426 MesPrint(
"&Illegal syntax for EndDo statement");
6429 if ( AC.dolooplevel <= 0 ) {
6430 MesPrint(
"&EndDo without corresponding Do statement");
6434 scratch[0] = TYPEENDDOLOOP;
6436 scratch[2] = AC.doloopstack[AC.dolooplevel];
6438 cbuf[AC.cbufnum].lhs[AC.doloopstack[AC.dolooplevel]][3] = C->numlhs;
6439 if ( AC.doloopnest[AC.dolooplevel] != NestingChecksum() ) {
6451int CoFactDollar(UBYTE *inp)
6454 if ( *inp ==
'$' ) {
6455 if ( GetName(AC.dollarnames,inp+1,&numdollar,NOAUTO) != CDOLLAR ) {
6456 MesPrint(
"&%s is undefined",inp);
6457 numdollar = AddDollar(inp+1,DOLINDEX,&one,1);
6462 MesPrint(
"&FactDollar should have a single $variable for its argument");
6468 MesPrint(
"&%s is not a $-variable",inp);
6471 Add3Com(TYPEFACTOR,numdollar);
6480int CoFactorize(UBYTE *s) {
return(DoFactorize(s,1)); }
6487int CoNFactorize(UBYTE *s) {
return(DoFactorize(s,0)); }
6494int CoUnFactorize(UBYTE *s) {
return(DoFactorize(s,3)); }
6501int CoNUnFactorize(UBYTE *s) {
return(DoFactorize(s,2)); }
6508int DoFactorize(UBYTE *s,
int par)
6514 int error = 0, keepzeroflag = 0;
6517 while ( *s !=
')' && *s ) {
6518 if ( FG.cTable[*s] == 0 ) {
6519 t = s;
while ( FG.cTable[*s] == 0 ) s++;
6521 if ( StrICmp((UBYTE *)
"keepzero",t) == 0 ) {
6525 MesPrint(
"&Illegal option in [N][Un]Factorize statement: %s",t);
6530 while ( *s ==
',' ) s++;
6531 if ( *s && *s !=
')' && FG.cTable[*s] != 0 ) {
6532 MesPrint(
"&Illegal character in option field of [N][Un]Factorize statement");
6538 while ( *s ==
',' || *s ==
' ' ) s++;
6541 for ( i = NumExpressions-1; i >= 0; i-- ) {
6543 if ( e->replace >= 0 ) {
6544 e = Expressions + e->replace;
6546 if ( e->status == LOCALEXPRESSION || e->status == GLOBALEXPRESSION
6547 || e->status == UNHIDELEXPRESSION || e->status == UNHIDEGEXPRESSION
6548 || e->status == INTOHIDELEXPRESSION || e->status == INTOHIDEGEXPRESSION
6552 e->vflags &= ~TOBEFACTORED;
6555 e->vflags |= TOBEFACTORED;
6556 e->vflags &= ~TOBEUNFACTORED;
6559 e->vflags &= ~TOBEUNFACTORED;
6562 e->vflags |= TOBEUNFACTORED;
6563 e->vflags &= ~TOBEFACTORED;
6567 if ( ( e->vflags & TOBEFACTORED ) != 0 ) {
6568 if ( keepzeroflag ) e->vflags |= KEEPZERO;
6569 else e->vflags &= ~KEEPZERO;
6571 else e->vflags &= ~KEEPZERO;
6576 while ( *s ==
',' ) s++;
6577 if ( *s == 0 )
break;
6578 if ( *s ==
'[' || FG.cTable[*s] == 0 ) {
6581 MesPrint(
"&Improper name for an expression: '%s'",t);
6585 if ( GetName(AC.exprnames,t,&number,NOAUTO) == CEXPRESSION ) {
6586 e = Expressions+number;
6587 if ( e->replace >= 0 ) {
6588 e = Expressions + e->replace;
6590 if ( e->status == LOCALEXPRESSION || e->status == GLOBALEXPRESSION
6591 || e->status == UNHIDELEXPRESSION || e->status == UNHIDEGEXPRESSION
6592 || e->status == INTOHIDELEXPRESSION || e->status == INTOHIDEGEXPRESSION
6596 e->vflags &= ~TOBEFACTORED;
6599 e->vflags |= TOBEFACTORED;
6600 e->vflags &= ~TOBEUNFACTORED;
6603 e->vflags &= ~TOBEUNFACTORED;
6606 e->vflags |= TOBEUNFACTORED;
6607 e->vflags &= ~TOBEFACTORED;
6611 if ( ( e->vflags & TOBEFACTORED ) != 0 ) {
6612 if ( keepzeroflag ) e->vflags |= KEEPZERO;
6613 else e->vflags &= ~KEEPZERO;
6615 else e->vflags &= ~KEEPZERO;
6617 else if ( GetName(AC.varnames,t,&number,NOAUTO) != NAMENOTFOUND ) {
6618 MesPrint(
"&%s is not an expression",t);
6624 MesPrint(
"&Illegal object in (N)Factorize statement");
6626 while ( *s && *s !=
',' ) s++;
6627 if ( *s == 0 )
break;
6641int CoOptimizeOption(UBYTE *s)
6643 UBYTE *name, *t1, *t2, c1, c2, *value, *u;
6646 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
6648 name = s;
while ( FG.cTable[*s] == 0 ) s++;
6650 while ( *s ==
' ' || *s ==
'\t' ) s++;
6653 MesPrint(
"&Correct use in Format,Optimize statement is Optionname=value");
6655 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' || *s ==
'=' ) s++;
6661 while ( *s ==
' ' || *s ==
'\t' ) s++;
6662 if ( *s == 0 )
goto correctuse;
6664 while ( FG.cTable[*s] <= 1 || *s==
'.' || *s==
'*' || *s ==
'(' || *s ==
')' ) {
6665 if ( *s ==
'(' ) { SKIPBRA4(s) }
6669 while ( *s ==
' ' || *s ==
'\t' ) s++;
6670 if ( *s && *s !=
',' )
goto correctuse;
6673 while ( *s ==
' ' || *s ==
'\t' ) s++;
6679 if ( StrICmp(name,(UBYTE *)
"horner") == 0 ) {
6680 if ( StrICmp(value,(UBYTE *)
"occurrence") == 0 ) {
6681 AO.Optimize.horner = O_OCCURRENCE;
6683 else if ( StrICmp(value,(UBYTE *)
"mcts") == 0 ) {
6684 AO.Optimize.horner = O_MCTS;
6686 else if ( StrICmp(value,(UBYTE *)
"sa") == 0 ) {
6687 AO.Optimize.horner = O_SIMULATED_ANNEALING;
6690 AO.Optimize.horner = -1;
6691 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6695 else if ( StrICmp(name,(UBYTE *)
"hornerdirection") == 0 ) {
6696 if ( StrICmp(value,(UBYTE *)
"forward") == 0 ) {
6697 AO.Optimize.hornerdirection = O_FORWARD;
6699 else if ( StrICmp(value,(UBYTE *)
"backward") == 0 ) {
6700 AO.Optimize.hornerdirection = O_BACKWARD;
6702 else if ( StrICmp(value,(UBYTE *)
"forwardorbackward") == 0 ) {
6703 AO.Optimize.hornerdirection = O_FORWARDORBACKWARD;
6705 else if ( StrICmp(value,(UBYTE *)
"forwardandbackward") == 0 ) {
6706 AO.Optimize.hornerdirection = O_FORWARDANDBACKWARD;
6709 AO.Optimize.method = -1;
6710 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6714 else if ( StrICmp(name,(UBYTE *)
"method") == 0 ) {
6715 if ( StrICmp(value,(UBYTE *)
"none") == 0 ) {
6716 AO.Optimize.method = O_NONE;
6718 else if ( StrICmp(value,(UBYTE *)
"cse") == 0 ) {
6719 AO.Optimize.method = O_CSE;
6721 else if ( StrICmp(value,(UBYTE *)
"csegreedy") == 0 ) {
6722 AO.Optimize.method = O_CSEGREEDY;
6724 else if ( StrICmp(value,(UBYTE *)
"greedy") == 0 ) {
6725 AO.Optimize.method = O_GREEDY;
6728 AO.Optimize.method = -1;
6729 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6733 else if ( StrICmp(name,(UBYTE *)
"timelimit") == 0 ) {
6735 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6737 MesPrint(
"&Option TimeLimit in Format,Optimize statement should be a positive number: %s",value);
6738 AO.Optimize.mctstimelimit = 0;
6739 AO.Optimize.greedytimelimit = 0;
6743 AO.Optimize.mctstimelimit = x/2;
6744 AO.Optimize.greedytimelimit = x/2;
6747 else if ( StrICmp(name,(UBYTE *)
"mctstimelimit") == 0 ) {
6749 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6751 MesPrint(
"&Option MCTSTimeLimit in Format,Optimize statement should be a positive number: %s",value);
6752 AO.Optimize.mctstimelimit = 0;
6756 AO.Optimize.mctstimelimit = x;
6759 else if ( StrICmp(name,(UBYTE *)
"mctsnumexpand") == 0 ) {
6762 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6763 if ( *u ==
'*' || *u ==
'x' || *u ==
'X' ) {
6766 while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6770 MesPrint(
"&Option MCTSNumExpand in Format,Optimize statement should be a positive number: %s",value);
6771 AO.Optimize.mctsnumexpand= 0;
6772 AO.Optimize.mctsnumrepeat= 1;
6776 AO.Optimize.mctsnumexpand= x;
6777 AO.Optimize.mctsnumrepeat= y;
6780 else if ( StrICmp(name,(UBYTE *)
"mctsnumrepeat") == 0 ) {
6782 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6784 MesPrint(
"&Option MCTSNumExpand in Format,Optimize statement should be a positive number: %s",value);
6785 AO.Optimize.mctsnumrepeat= 1;
6789 AO.Optimize.mctsnumrepeat= x;
6792 else if ( StrICmp(name,(UBYTE *)
"mctsnumkeep") == 0 ) {
6794 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6796 MesPrint(
"&Option MCTSNumKeep in Format,Optimize statement should be a positive number: %s",value);
6797 AO.Optimize.mctsnumkeep= 0;
6801 AO.Optimize.mctsnumkeep= x;
6804 else if ( StrICmp(name,(UBYTE *)
"mctsconstant") == 0 ) {
6806 if ( sscanf ((
char*)value,
"%lf", &d) != 1 ) {
6807 MesPrint(
"&Option MCTSConstant in Format,Optimize statement should be a positive number: %s",value);
6808 AO.Optimize.mctsconstant.fval = 0;
6812 AO.Optimize.mctsconstant.fval = d;
6815 else if ( StrICmp(name,(UBYTE *)
"greedytimelimit") == 0 ) {
6817 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6819 MesPrint(
"&Option GreedyTimeLimit in Format,Optimize statement should be a positive number: %s",value);
6820 AO.Optimize.greedytimelimit = 0;
6824 AO.Optimize.greedytimelimit = x;
6827 else if ( StrICmp(name,(UBYTE *)
"greedyminnum") == 0 ) {
6829 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6831 MesPrint(
"&Option GreedyMinNum in Format,Optimize statement should be a positive number: %s",value);
6832 AO.Optimize.greedyminnum= 0;
6836 AO.Optimize.greedyminnum= x;
6839 else if ( StrICmp(name,(UBYTE *)
"greedymaxperc") == 0 ) {
6841 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6843 MesPrint(
"&Option GreedyMaxPerc in Format,Optimize statement should be a positive number: %s",value);
6844 AO.Optimize.greedymaxperc= 0;
6848 AO.Optimize.greedymaxperc= x;
6851 else if ( StrICmp(name,(UBYTE *)
"stats") == 0 ) {
6852 if ( StrICmp(value,(UBYTE *)
"on") == 0 ) {
6853 AO.Optimize.printstats = 1;
6855 else if ( StrICmp(value,(UBYTE *)
"off") == 0 ) {
6856 AO.Optimize.printstats = 0;
6859 AO.Optimize.printstats = 0;
6860 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6864 else if ( StrICmp(name,(UBYTE *)
"printscheme") == 0 ) {
6865 if ( StrICmp(value,(UBYTE *)
"on") == 0 ) {
6866 AO.Optimize.schemeflags |= 1;
6868 else if ( StrICmp(value,(UBYTE *)
"off") == 0 ) {
6869 AO.Optimize.schemeflags &= ~1;
6872 AO.Optimize.schemeflags &= ~1;
6873 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6877 else if ( StrICmp(name,(UBYTE *)
"debugflag") == 0 ) {
6885 if ( FG.cTable[*u] == 1 ) {
6886 while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
6888 MesPrint(
"&Numerical value for DebugFlag in Format,Optimize statement should be a nonnegative number: %s",value);
6889 AO.Optimize.debugflags = 0;
6893 AO.Optimize.debugflags = x;
6896 else if ( StrICmp(value,(UBYTE *)
"on") == 0 ) {
6897 AO.Optimize.debugflags = 1;
6899 else if ( StrICmp(value,(UBYTE *)
"off") == 0 ) {
6900 AO.Optimize.debugflags = 0;
6903 AO.Optimize.debugflags = 0;
6904 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
6908 else if ( StrICmp(name,(UBYTE *)
"scheme") == 0 ) {
6915 MesPrint(
"&Option Scheme in Format,Optimize statement should be an array of names or integers between (): %s",value);
6920 while ( *ss ==
' ' || *ss ==
'\t' || *ss ==
',' ) ss++;
6921 if ( FG.cTable[*ss] == 0 || *ss ==
'$' || *ss ==
'[' ) {
6922 s1 = u; SKIPBRA3(s1)
6923 if ( *s1 !=
')' )
goto noscheme;
6924 while ( ss < s1 ) {
if ( *ss++ ==
',' ) AO.schemenum++; }
6925 *ss++ = 0;
while ( *ss ==
' ' ) ss++;
6926 if ( *ss != 0 )
goto noscheme;
6928 if ( AO.schemenum < 1 ) {
6929 MesPrint(
"&Option Scheme in Format,Optimize statement should have at least one name or number between ()");
6933 if ( AO.inscheme ) M_free(AO.inscheme,
"Horner input scheme");
6934 AO.inscheme = (WORD *)Malloc1((AO.schemenum+1)*
sizeof(WORD),
"Horner input scheme");
6935 while ( *ss ==
' ' || *ss ==
'\t' || *ss ==
',' ) ss++;
6938 if ( *ss == 0 )
break;
6939 s1 = ss; ss =
SkipAName(s1); c = *ss; *ss = 0;
6941 if ( ss[-1] ==
'_' ) {
6946 u1 = s1; u2 = AC.extrasym;
6947 while ( *u1 == *u2 ) { u1++; u2++; }
6950 while ( *u1 >=
'0' && *u1 <=
'9' ) numsym = 10*numsym + *u1++ -
'0';
6951 if ( u1 != ss-1 || numsym == 0 || AC.extrasymbols != 0 ) {
6952 MesPrint(
"&Improper use of extra symbol in scheme format option");
6955 numsym = MAXVARIABLES-numsym;
6960 else if ( *s1 ==
'$' ) {
6963 if ( ( numdollar = GetDollar(s1+1) ) < 0 ) {
6964 MesPrint(
"&Undefined variable %s",s1);
6967 else if ( ( numsym = DolToSymbol(BHEAD numdollar) ) < 0 ) {
6968 MesPrint(
"&$%s does not evaluate to a symbol",s1);
6974 else if ( c ==
'(' ) {
6975 if ( StrCmp(s1,AC.extrasym) == 0 ) {
6976 if ( (AC.extrasymbols&1) != 1 ) {
6977 MesPrint(
"&Improper use of extra symbol in scheme format option");
6982 while ( *ss >=
'0' && *ss <=
'9' ) numsym = 10*numsym + *ss++ -
'0';
6984 MesPrint(
"&Extra symbol should have a number for its argument.");
6987 numsym = MAXVARIABLES-numsym;
6992 type = GetName(AC.varnames,s1,&numsym,WITHAUTO);
6993 if ( ( type != CSYMBOL ) && type != CDUBIOUS ) {
6994 MesPrint(
"&%s is not a symbol",s1);
6996 if ( type < 0 ) numsym = AddSymbol(s1,-MAXPOWER,MAXPOWER,0,0);
7000 AO.inscheme[AO.schemenum++] = numsym;
7001 while ( *ss ==
' ' || *ss ==
'\t' || *ss ==
',' ) ss++;
7005 else if ( StrICmp(name,(UBYTE *)
"mctsdecaymode") == 0 ) {
7008 if ( FG.cTable[*u] == 1 ) {
7009 while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
7011 MesPrint(
"&Option MCTSDecayMode in Format,Optimize statement should be a nonnegative integer: %s",value);
7012 AO.Optimize.mctsdecaymode = 0;
7016 AO.Optimize.mctsdecaymode = x;
7020 AO.Optimize.mctsdecaymode = 0;
7021 MesPrint(
"&Unrecognized option value in Format,Optimize statement: %s=%s",name,value);
7025 else if ( StrICmp(name,(UBYTE *)
"saiter") == 0 ) {
7027 u = value;
while ( *u >=
'0' && *u <=
'9' ) x = 10*x + *u++ -
'0';
7029 MesPrint(
"&Option SAIter in Format,Optimize statement should be a positive integer: %s",value);
7030 AO.Optimize.saIter = 0;
7034 AO.Optimize.saIter= x;
7037 else if ( StrICmp(name,(UBYTE *)
"samaxt") == 0 ) {
7039 if ( sscanf ((
char*)value,
"%lf", &d) != 1 ) {
7040 MesPrint(
"&Option SAMaxT in Format,Optimize statement should be a positive number: %s",value);
7041 AO.Optimize.saMaxT.fval = 0;
7045 AO.Optimize.saMaxT.fval = d;
7048 else if ( StrICmp(name,(UBYTE *)
"samint") == 0 ) {
7050 if ( sscanf ((
char*)value,
"%lf", &d) != 1 ) {
7051 MesPrint(
"&Option SAMinT in Format,Optimize statement should be a positive number: %s",value);
7052 AO.Optimize.saMinT.fval = 0;
7056 AO.Optimize.saMinT.fval = d;
7060 MesPrint(
"&Unrecognized option name in Format,Optimize statement: %s",name);
7077int CoPutInside(UBYTE *inp) {
return(DoPutInside(inp,1)); }
7078int CoAntiPutInside(UBYTE *inp) {
return(DoPutInside(inp,-1)); }
7080int DoPutInside(UBYTE *inp,
int par)
7084 WORD *to, type, c1,c2,funnum, *WorkSave;
7086 while ( *inp ==
' ' || *inp ==
'\t' || *inp ==
',' ) inp++;
7091 if ( p == 0 )
return(1);
7093 type = GetName(AC.varnames,inp,&funnum,WITHAUTO);
7094 if ( type != CFUNCTION || functions[funnum].tabl != 0 || functions[funnum].spec ) {
7095 MesPrint(
"&PutInside/AntiPutInside expects a regular function for its first argument");
7096 MesPrint(
"&Argument is %s",inp);
7102 while ( *inp ==
' ' || *inp ==
'\t' || *inp ==
',' ) inp++;
7106 tocompiler[0] = TYPEPUTINSIDE;
7109 tocompiler[3] = funnum;
7113 MesPrint(
"&AntiPutInside needs inside information.");
7118 WorkSave = to = AT.WorkPointer;
7119 *to++ = TYPEPUTINSIDE;
7125 while ( *inp ==
' ' || *inp ==
'\t' || *inp ==
',' ) inp++;
7126 if ( *inp == 0 )
break;
7128 if ( p == 0 ) { error = 1;
break; }
7130 type = GetName(AC.varnames,inp,&c1,WITHAUTO);
7132 if ( type == CVECTOR || type == CDUBIOUS ) {
7136 if ( p == 0 )
return(1);
7138 type = GetName(AC.varnames,inp,&c2,WITHAUTO);
7139 if ( type != CVECTOR && type != CDUBIOUS ) {
7140 MesPrint(
"&Not a vector in dotproduct in PutInside/AntiPutInside statement: %s",inp);
7143 else type = CDOTPRODUCT;
7146 MesPrint(
"&Illegal use of . after %s in PutInside/AntiPutInside statement",inp);
7154 *to++ = SYMBOL; *to++ = 4; *to++ = c1; *to++ = 1;
break;
7156 *to++ = INDEX; *to++ = 3; *to++ = AM.OffsetVector + c1;
break;
7158 *to++ = c1+FUNCTION; *to++ = FUNHEAD; *to++ = 0;
7162 *to++ = DOTPRODUCT; *to++ = 5; *to++ = c1 + AM.OffsetVector;
7163 *to++ = c2 + AM.OffsetVector; *to++ = 1;
break;
7165 *to++ = DELTA; *to++ = 4; *to++ = EMPTYINDEX; *to++ = EMPTYINDEX;
break;
7167 MesPrint(
"&Illegal variable request for %s in PutInside/AntiPutInside statement",inp);
7173 *to++ = 1; *to++ = 1; *to++ = 3;
7174 AT.WorkPointer[1] = to - AT.WorkPointer;
7175 AT.WorkPointer[4] = AT.WorkPointer[1]-4;
7176 AT.WorkPointer = to;
7177 AC.BracketNormalize = 1;
7178 if ( Normalize(BHEAD WorkSave+4) ) { error = 1; }
7180 WorkSave[1] = WorkSave[4]+4;
7181 to = WorkSave + WorkSave[1] - 1;
7185 AddNtoL(WorkSave[1],WorkSave);
7187 AC.BracketNormalize = 0;
7188 AT.WorkPointer = WorkSave;
7200int CoSwitch(UBYTE *s)
7205 if ( GetName(AC.dollarnames,s+1,&numdollar,NOAUTO) != CDOLLAR ) {
7206 MesPrint(
"&%s is undefined in switch statement",s);
7207 numdollar = AddDollar(s+1,DOLINDEX,&one,1);
7212 MesPrint(
"&Switch should have a single $variable for its argument");
7218 MesPrint(
"&%s is not a $-variable in switch statement",s);
7227 if ( AC.SwitchInArray >= AC.MaxSwitch ) DoubleSwitchBuffers();
7228 AC.SwitchHeap[AC.SwitchLevel] = AC.SwitchInArray;
7229 sw = AC.SwitchArray + AC.SwitchInArray;
7231 sw->iflevel = AC.IfLevel;
7232 sw->whilelevel = AC.WhileLevel;
7233 sw->nestingsum = NestingChecksum();
7235 Add4Com(TYPESWITCH,numdollar,AC.SwitchInArray);
7248 SWITCH *sw = AC.SwitchArray + AC.SwitchHeap[AC.SwitchLevel];
7249 WORD x = 0, sign = 1;
7250 while ( *s ==
',' ) s++;
7252 while ( *s ==
'-' || *s ==
'+' ) {
7253 if ( *s ==
'-' ) sign = -sign;
7256 while ( FG.cTable[*s] == 1 ) { x = 10*x + *s++ -
'0'; }
7259 if ( sw->iflevel != AC.IfLevel || sw->whilelevel != AC.WhileLevel
7260 || sw->nestingsum != NestingChecksum() ) {
7261 MesPrint(
"&Illegal nesting of switch/case/default with if/while/repeat/loop/argument/term/...");
7267 if ( sw->numcases >= sw->tablesize ) {
7271 if ( sw->tablesize == 0 ) newsize = 10;
7272 else newsize = 2*sw->tablesize;
7275 for ( i = 0; i < sw->tablesize; i++ ) newtable[i] = sw->table[i];
7276 M_free(sw->table,
"Switch table");
7278 sw->table = newtable;
7279 sw->tablesize = newsize;
7281 if ( sw->numcases == 0 ) { sw->mincase = sw->maxcase = x; }
7282 else if ( x > sw->maxcase ) sw->maxcase = x;
7283 else if ( x < sw->mincase ) sw->mincase = x;
7284 sw->table[sw->numcases].ncase = x;
7285 sw->table[sw->numcases].value = cbuf[AC.cbufnum].numlhs;
7286 sw->table[sw->numcases].compbuffer = AC.cbufnum;
7296int CoBreak(UBYTE *s)
7303 SWITCH *sw = AC.SwitchArray + AC.SwitchHeap[AC.SwitchLevel];
7304 if ( sw->iflevel != AC.IfLevel || sw->whilelevel != AC.WhileLevel
7305 || sw->nestingsum != NestingChecksum() ) {
7306 MesPrint(
"&Illegal nesting of switch/case/default with if/while/repeat/loop/argument/term/...");
7310 MesPrint(
"&No parameters allowed in Break statement");
7313 Add3Com(TYPEENDSWITCH,AC.SwitchHeap[AC.SwitchLevel]);
7322int CoDefault(UBYTE *s)
7328 SWITCH *sw = AC.SwitchArray + AC.SwitchHeap[AC.SwitchLevel];
7329 if ( sw->iflevel != AC.IfLevel || sw->whilelevel != AC.WhileLevel
7330 || sw->nestingsum != NestingChecksum() ) {
7331 MesPrint(
"&Illegal nesting of switch/case/default with if/while/repeat/loop/argument/term/...");
7335 MesPrint(
"&No parameters allowed in Default statement");
7338 sw->defaultcase.ncase = 0;
7339 sw->defaultcase.value = cbuf[AC.cbufnum].numlhs;
7340 sw->defaultcase.compbuffer = AC.cbufnum;
7349int CoEndSwitch(UBYTE *s)
7358 SWITCH *sw = AC.SwitchArray + AC.SwitchHeap[AC.SwitchLevel];
7360 WORD totcases = sw->maxcase-sw->mincase+1;
7361 while ( *s ==
',' ) s++;
7364 MesPrint(
"&No parameters allowed in EndSwitch statement");
7367 if ( sw->iflevel != AC.IfLevel || sw->whilelevel != AC.WhileLevel
7368 || sw->nestingsum != NestingChecksum() ) {
7369 MesPrint(
"&Illegal nesting of switch/case/default with if/while/repeat/loop/argument/term/...");
7372 if ( sw->defaultcase.value == 0 ) CoDefault(s);
7373 if ( totcases > sw->numcases*AM.jumpratio ) {
7375 sw->typetable = SPARSETABLE;
7379 SwitchSplitMerge(sw->table,sw->numcases);
7383 sw->caseoffset = sw->mincase;
7384 sw->typetable = DENSETABLE;
7386 for ( i = 0; i < totcases; i++ ) {
7387 ntable[i].ncase = i+sw->caseoffset;
7388 ntable[i].value = sw->defaultcase.value;
7389 ntable[i].compbuffer = sw->defaultcase.compbuffer;
7391 for ( i = 0; i < sw->numcases; i++ ) {
7392 ntable[sw->table[i].ncase-sw->caseoffset] = sw->table[i];
7394 M_free(sw->table,
"Switch table");
7396 sw->numcases = totcases;
7398 sw->endswitch.ncase = 0;
7399 sw->endswitch.value = cbuf[AC.cbufnum].numlhs;
7400 sw->endswitch.compbuffer = AC.cbufnum;
7401 if ( sw->defaultcase.value == 0 ) {
7402 sw->defaultcase = sw->endswitch;
7404 Add3Com(TYPEENDSWITCH,AC.SwitchHeap[AC.SwitchLevel]);
7417int CoSetUserFlag(UBYTE *s)
7420 while ( *s && ( *s ==
',' || *s ==
' ' || *s ==
'\t' ) ) s++;
7421 while ( *s && ( FG.cTable[*s] == 1 ) ) {
7423 while ( *s && ( FG.cTable[*s] == 1 ) ) x = 10*x+(*s++ -
'0');
7424 if ( x < 1 || x > BITSINWORD ) {
7425 MesPrint(
"&Flag number %d outside the permitted range 1-%d.",BITSINWORD);
7429 Add3Com(TYPESETUSERFLAG,x-1);
7431 while ( *s && ( *s ==
',' || *s ==
' ' || *s ==
'\t' ) ) s++;
7434 MesPrint(
"&Illegal character in SetUserFlag statement: %s",s);
7445int CoClearUserFlag(UBYTE *s)
7448 while ( *s && ( *s ==
',' || *s ==
' ' || *s ==
'\t' ) ) s++;
7449 while ( *s && ( FG.cTable[*s] == 1 ) ) {
7451 while ( *s && ( FG.cTable[*s] == 1 ) ) x = 10*x+(*s++ -
'0');
7452 if ( x < 1 || x > BITSINWORD ) {
7453 MesPrint(
"&Flag number %d outside the permitted range 1-%d.",BITSINWORD);
7457 Add3Com(TYPECLEARUSERFLAG,x);
7459 while ( *s && ( *s ==
',' || *s ==
' ' || *s ==
'\t' ) ) s++;
7462 MesPrint(
"&Illegal character in SetUserFlag statement: %s",s);
7482int CoCreateAllLoops(UBYTE *s)
7485 UBYTE *inname, *outname, *stype, c;
7486 WORD infun, outfun, x, type, tensorflag, typenum;
7487 WORD *WorkSave, *to;
7488 while ( *s ==
',' || *s ==
' ' ) s++;
7491 if ( ( ( type = GetName(AC.varnames,inname,&infun,WITHAUTO) ) != CFUNCTION )
7492 || ( ( functions[infun].spec != 0 ) && ( functions[infun].spec != TENSORFUNCTION ) ) ) {
7493 MesPrint(
"&%s should be a regular function or a tensor.",inname);
7495 if ( GetName(AC.exprnames,s,&infun,NOAUTO) == NAMENOTFOUND )
7496 AddFunction(s,0,0,0,0,0,-1,-1);
7502 while ( *s ==
',' || *s ==
' ' ) s++;
7505 if ( ( ( type = GetName(AC.varnames,outname,&outfun,WITHAUTO) ) != CFUNCTION )
7506 || ( ( functions[outfun].spec != 0 ) && ( functions[outfun].spec != TENSORFUNCTION ) ) ) {
7507 MesPrint(
"&%s should be a regular function or a tensor.",outname);
7509 if ( GetName(AC.exprnames,s,&outfun,NOAUTO) == NAMENOTFOUND )
7510 AddFunction(s,0,0,0,0,0,-1,-1);
7516 if ( functions[infun].spec == TENSORFUNCTION ||
7517 functions[outfun].spec == TENSORFUNCTION ) tensorflag = 1;
7518 else tensorflag = 0;
7522 while ( *s ==
',' || *s ==
' ' ) s++;
7524 while ( FG.cTable[*s] == 0 ) s++;
7526 if ( StrICmp(stype,(UBYTE *)
"type") != 0 || c !=
'=' ) {
7527 MesPrint(
"&In CreateAllLoops statement: expected type=vartype.");
7532 while ( FG.cTable[*s] == 0 ) s++;
7534 if ( StrICmp(stype,(UBYTE *)
"vector") == 0 ) {
7537 else if ( StrICmp(stype,(UBYTE *)
"index") == 0 ) {
7540 else if ( StrICmp(stype,(UBYTE *)
"symbol") == 0 ) {
7541 if ( tensorflag )
goto notintensor;
7544 else if ( StrICmp(stype,(UBYTE *)
"snumber") == 0 ) {
7545 if ( tensorflag )
goto notintensor;
7549 MesPrint(
"&Unknown/not allowed variable type in CreateAllLoops: %s",stype);
7553 while ( *s ==
',' || *s ==
' ' ) s++;
7556 while ( FG.cTable[*s] == 0 ) s++;
7558 if ( StrICmp(stype,(UBYTE *)
"ifnoloop") != 0 || c !=
'=' ) {
7559 MesPrint(
"&Unrecognised option in CreateAllLoops statement: %s",stype);
7564 if ( FG.cTable[*s] == 1 ) {
7566 do { x = 10*x + (*s++-
'0'); }
while (FG.cTable[*s] == 1);
7568 if ( x != 0 && x != 1 ) {
7569 MesPrint(
"&Only options allowed for ifnoloop are 0 or 1.");
7572 WorkSave = to = AT.WorkPointer;
7573 *to++ = TYPEALLLOOPS;
7580 AddNtoL(WorkSave[1],WorkSave);
7584 MesPrint(
"&Variable type not allowed in tensors: %s",stype);
7602int CoCreateAllPaths(UBYTE *s)
7605 UBYTE *endname,*inname, *outname, *stype, c;
7606 WORD endfun, infun, outfun, x, type, tensorflag, typenum;
7607 WORD *WorkSave, *to;
7608 while ( *s ==
',' || *s ==
' ' ) s++;
7611 if ( ( ( type = GetName(AC.varnames,endname,&endfun,WITHAUTO) ) != CFUNCTION )
7612 || ( ( functions[endfun].spec != 0 ) && ( functions[endfun].spec != TENSORFUNCTION ) ) ) {
7613 MesPrint(
"&%s should be a regular function or a tensor.",endname);
7615 if ( GetName(AC.exprnames,s,&endfun,NOAUTO) == NAMENOTFOUND )
7616 AddFunction(s,0,0,0,0,0,-1,-1);
7622 while ( *s ==
',' || *s ==
' ' ) s++;
7625 if ( ( ( type = GetName(AC.varnames,inname,&infun,WITHAUTO) ) != CFUNCTION )
7626 || ( ( functions[infun].spec != 0 ) && ( functions[infun].spec != TENSORFUNCTION ) ) ) {
7627 MesPrint(
"&%s should be a regular function or a tensor.",inname);
7629 if ( GetName(AC.exprnames,s,&infun,NOAUTO) == NAMENOTFOUND )
7630 AddFunction(s,0,0,0,0,0,-1,-1);
7636 while ( *s ==
',' || *s ==
' ' ) s++;
7639 if ( ( ( type = GetName(AC.varnames,outname,&outfun,WITHAUTO) ) != CFUNCTION )
7640 || ( ( functions[outfun].spec != 0 ) && ( functions[outfun].spec != TENSORFUNCTION ) ) ) {
7641 MesPrint(
"&%s should be a regular function or a tensor.",outname);
7643 if ( GetName(AC.exprnames,s,&outfun,NOAUTO) == NAMENOTFOUND )
7644 AddFunction(s,0,0,0,0,0,-1,-1);
7650 if ( functions[infun].spec == TENSORFUNCTION ||
7651 functions[outfun].spec == TENSORFUNCTION ) tensorflag = 1;
7652 else tensorflag = 0;
7656 while ( *s ==
',' || *s ==
' ' ) s++;
7658 while ( FG.cTable[*s] == 0 ) s++;
7660 if ( StrICmp(stype,(UBYTE *)
"type") != 0 || c !=
'=' ) {
7661 MesPrint(
"&In CreateAllPaths statement: expected type=vartype.");
7666 while ( FG.cTable[*s] == 0 ) s++;
7668 if ( StrICmp(stype,(UBYTE *)
"vector") == 0 ) {
7671 else if ( StrICmp(stype,(UBYTE *)
"index") == 0 ) {
7674 else if ( StrICmp(stype,(UBYTE *)
"symbol") == 0 ) {
7675 if ( tensorflag )
goto notintensor;
7678 else if ( StrICmp(stype,(UBYTE *)
"snumber") == 0 ) {
7679 if ( tensorflag )
goto notintensor;
7683 MesPrint(
"&Unknown/not allowed variable type in CreateAllPaths: %s",stype);
7687 while ( *s ==
',' || *s ==
' ' ) s++;
7690 while ( FG.cTable[*s] == 0 ) s++;
7692 if ( StrICmp(stype,(UBYTE *)
"ifnopath") != 0 || c !=
'=' ) {
7693 MesPrint(
"&Unrecognised option in CreateAllPaths statement: %s",stype);
7698 if ( FG.cTable[*s] == 1 ) {
7700 do { x = 10*x + (*s++-
'0'); }
while (FG.cTable[*s] == 1);
7702 if ( x != 0 && x != 1 ) {
7703 MesPrint(
"&Only options allowed for ifnopath are 0 or 1.");
7706 WorkSave = to = AT.WorkPointer;
7707 *to++ = TYPEALLPATHS;
7715 AddNtoL(WorkSave[1],WorkSave);
7719 MesPrint(
"&CreateAllPaths: Variable type not allowed in tensors: %s",stype);
7730int CoCreateAll(UBYTE *s)
7733 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
7735 while ( FG.cTable[*s] == 0 ) s++;
7736 if ( *s !=
' ' && *s !=
',' && *s !=
'\t' ) {
7737 MesPrint(
"&Illegal subkey in CoCreate statement.");
7741 while ( *s ==
' ' || *s ==
',' || *s ==
'\t' ) s++;
7742 if ( StrICmp(subkey,(UBYTE *)
"loops") == 0 ) {
7743 return(CoCreateAllLoops(s));
7745 else if ( StrICmp(subkey,(UBYTE *)
"paths") == 0 ) {
7746 return(CoCreateAllPaths(s));
7757 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)