14 #include <sys/types.h> 30 #define ALLOW_PLURAL 1 39 #define NO_ZERODIVISOR 8 40 #define ALLOW_ZERODIVISOR 0 41 #define ZERODIVISOR_MASK 8 134 if (tok==
COMMAND)
return "command";
135 if (tok==
ANY_TYPE)
return "any_type";
136 if (tok==
NONE)
return "nothing";
143 if (tok==
IDHDL)
return "identifier";
169 sprintf(s,
"(%d)",tok);
187 cmdnames *pCmdL = (cmdnames*)a;
188 cmdnames *pCmdR = (cmdnames*)b;
193 if(pCmdL->name==
NULL)
return 1;
194 if(pCmdR->name==
NULL)
return -1;
197 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
198 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
201 if (pCmdL->tokval==-1)
203 if (pCmdR->tokval==-1)
204 return strcmp(pCmdL->name, pCmdR->name);
209 if(pCmdR->tokval==-1)
return -1;
211 return strcmp(pCmdL->name, pCmdR->name);
216 cmdnames *pCmdL = (cmdnames*)a;
217 cmdnames *pCmdR = (cmdnames*)b;
222 if(pCmdL->name==
NULL)
return 1;
223 if(pCmdR->name==
NULL)
return -1;
226 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
227 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
228 char *ls=
strdup(pCmdL->name);
229 char *rs=
strdup(pCmdR->name);
231 while (*s) { *s=tolower(*s); s++; }
233 while (*s) { *s=tolower(*s); s++; }
236 if (pCmdL->tokval==-1)
238 if (pCmdR->tokval==-1)
239 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
245 if(pCmdR->tokval==-1)
248 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
278 case LE:
return "<=";
279 case GE:
return ">=";
294 if ((inputType==outputType)
296 || (outputType==
IDHDL)
333 "/****************************************\n" 334 "* Computer Algebra System SINGULAR *\n" 335 "****************************************/\n\n");
337 fprintf(outfile,
"// syntax table for Singular\n//\n");
338 fprintf(outfile,
"// - search for an exact match of the argument types\n");
339 fprintf(outfile,
"// - otherwise search for the first possibility\n");
340 fprintf(outfile,
"// with converted types of the arguments\n");
341 fprintf(outfile,
"// - otherwise report an error\n//\n");
348 fprintf(outfile,
"// DUMMY ");
350 fprintf(outfile,
"// operation: %s (%s) -> %s\n",
356 fprintf(outfile,
"// WARNING: %s requires currRing\n",s);
360 fprintf(outfile,
"/*---------------------------------------------*/\n");
365 fprintf(outfile,
"// DUMMY ");
367 fprintf(outfile,
"// operation: %s (%s, %s) -> %s\n",
376 fprintf(outfile,
"// WARNING: %s requires currRing\n",s);
380 fprintf(outfile,
"/*---------------------------------------------*/\n");
386 fprintf(outfile,
"// DUMMY ");
387 fprintf(outfile,
"// operation: %s (%s, %s, %s) -> %s\n",
398 fprintf(outfile,
"// WARNING: %s requires currRing\n",s);
402 fprintf(outfile,
"/*---------------------------------------------*/\n");
407 fprintf(outfile,
"// operation: %s (...) -> %s",
410 switch(
dArithM[i].number_of_args)
413 fprintf(outfile,
" ( number of arguments >0 )\n");
416 fprintf(outfile,
" ( any number of arguments )\n");
419 fprintf(outfile,
" ( %d arguments )\n",
dArithM[i].number_of_args);
424 fprintf(outfile,
"/*---------------------------------------------*/\n");
428 fprintf(outfile,
"// assign: %s = %s\n",
434 fprintf(outfile,
"/*---------------------------------------------*/\n");
438 doctable=fopen(
"convert_table.texi",
"w");
439 fprintf(doctable,
"@multitable @columnfractions .05 .18 .81\n");
449 fprintf(outfile,
"// convert %s -> %s\n",
454 "@item\n@ %d. @tab @code{%s} @tab @expansion{} @code{%s}\n",
464 fprintf(doctable,
"@end multitable\n");
467 fprintf(outfile,
"/*---------------------------------------------*/\n");
468 char ops[]=
"=><+*/[.^,%(;";
469 for(i=0;ops[
i]!=
'\0';i++)
470 fprintf(outfile,
"// token %d : %c\n", (
int)ops[i], ops[i]);
476 fprintf(outfile,
"// token %d : %s\n", i, s);
480 fprintf(outfile,
"/*--max. token: %d, gr: %d --*/\n",
MAX_TOK,
UMINUS);
482 fprintf(outfile,
"/*---------------------------------------------*/\n");
484 "struct sValCmdTab dArithTab1[]=\n" 492 fprintf(outfile,
" { %d,%d },\n",j,i);
498 fprintf(outfile,
" { 10000,0 }\n};\n");
499 fprintf(outfile,
"#define JJTAB1LEN %d\n",l1);
502 "struct sValCmdTab dArithTab2[]=\n" 510 fprintf(outfile,
" { %d,%d },\n",j,i);
516 fprintf(outfile,
" { 10000,0 }\n};\n");
517 fprintf(outfile,
"#define JJTAB2LEN %d\n",l2);
528 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
532 "/****************************************\n" 533 "* Computer Algebra System SINGULAR *\n" 534 "****************************************/\n\n");
536 fprintf(outfile,
"// identifier table for Singular\n//\n");
540 "#ifdef MODULE_GENERATOR\n" 541 "#define omAlloc0(A) malloc(A)\n" 543 "void iiInitCmdName()\n{\n" 544 " sArithBase.nCmdUsed = 0;\n" 545 " sArithBase.nCmdAllocated = %d;\n" 546 " sArithBase.sCmds = (cmdnames*)omAlloc0(sArithBase.nCmdAllocated*sizeof(cmdnames));\n" 548 " // name-string alias tokval toktype index\n",
555 for(m=0; m<cmd_size; m++)
558 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, %3d, ",
cmds[m].
name,
559 (
int)(20-strlen(
cmds[m].name)),
564 case CMD_1: fprintf(outfile,
"CMD_1");
break;
565 case CMD_2: fprintf(outfile,
"CMD_2");
break;
566 case CMD_3: fprintf(outfile,
"CMD_3");
break;
567 case CMD_12: fprintf(outfile,
"CMD_12");
break;
568 case CMD_123 : fprintf(outfile,
"CMD_123");
break;
569 case CMD_23: fprintf(outfile,
"CMD_23");
break;
570 case CMD_M: fprintf(outfile,
"CMD_M");
break;
571 case SYSVAR: fprintf(outfile,
"SYSVAR");
break;
572 case ROOT_DECL: fprintf(outfile,
"ROOT_DECL");
break;
574 case RING_DECL: fprintf(outfile,
"RING_DECL");
break;
575 case NONE: fprintf(outfile,
"NONE");
break;
577 if((
cmds[m].toktype>
' ') &&(
cmds[m].toktype<127))
579 fprintf(outfile,
"'%c'",
cmds[m].toktype);
583 fprintf(outfile,
"%d",
cmds[m].toktype);
587 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, -1, 0 );\n",
588 cmds[m].name, 20-strlen(
cmds[m].name),
594 fprintf(outfile,
", %d);\n", m);
596 fprintf(outfile,
"/* end of list marker */\n");
598 " sArithBase.nLastIdentifier = %d;\n",
604 "#define LAST_IDENTIFIER %d\n" 610 if( c->tokval==0)
return 0;
611 if (c->alias > 0)
return 0;
612 if ((c->toktype==
CMD_1)
613 || (c->toktype==
CMD_2)
614 || (c->toktype==
CMD_3)
615 || (c->toktype==
CMD_M)
619 || (c->toktype==
CMD_123))
return 1;
624 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
626 FILE *outfile = fopen(
"reference_table.texi",
"w");
627 fprintf(outfile,
"@menu\n");
632 for(m=0; m<cmd_size; m++)
637 fprintf(outfile,
"* %s::\n",
cmds[m].
name);
640 fprintf(outfile,
"@end menu\n@c ---------------------------\n");
641 for(m=0; m<cmd_size; m++)
646 fprintf(outfile,
"@node %s,",
cmds[m].
name);
651 fprintf(outfile,
"%s,",
cmds[mm].name);
653 fprintf(outfile,
",");
658 fprintf(outfile,
"%s,",
cmds[m-1].name);
660 fprintf(outfile,
",");
662 fprintf(outfile,
"Functions\n" 664 "@cindex %s\n",
cmds[m].name,
cmds[m].name);
665 fprintf(outfile,
"@include %s.part\n",
cmds[m].name);
667 sprintf(partName,
"%s.part",
cmds[m].name);
669 if (lstat(partName,&buf)!=0)
672 int only_field=0,only_comm=0,no_zerodiv=0;
673 FILE *part=fopen(partName,
"w");
674 fprintf(part,
"@table @code\n@item @strong{Syntax:}\n");
735 fprintf(part,
"@code{%s (} %s, %s, %s @code{)}\n",
cmds[m].name,
759 fprintf(part,
"@code{%s (} ... @code{)}\n",
cmds[m].name);
772 fprintf(part,
"@item @strong{Remark:}\n" 773 "only for commutive polynomial rings\n");
775 fprintf(part,
"@item @strong{Remark:}\n" 776 "only for polynomial rings over fields\n");
778 fprintf(part,
"@item @strong{Remark:}\n" 779 "only for polynomial rings over domains\n");
780 fprintf(part,
"@item @strong{Purpose:}\n" 781 "@item @strong{Example:}\n" 785 "@end smallexample\n" 800 FILE *outfile = fopen(
"plural_cmd.xx",
"w");
802 const char *old_s=
"";
804 "@c *****************************************\n" 805 "@c * Computer Algebra System SINGULAR *\n" 806 "@c *****************************************\n\n");
808 fprintf(outfile,
"@multicolumn .45 .45\n");
816 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
823 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
826 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
829 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
839 fprintf(outfile,
"@c ---------------------------------------------\n");
846 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
853 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
856 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
859 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
869 fprintf(outfile,
"@c ---------------------------------------------\n");
876 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
883 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
886 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
889 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
899 fprintf(outfile,
"@c ---------------------------------------------\n");
904 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
911 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
914 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
917 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
926 fprintf(outfile,
"@c ---------------------------------------------\n");
927 fprintf(outfile,
"@end table\n");
929 rename(
"plural_cmd.xx",
"plural_cmd.inc");
933 int main(
int argc,
char** argv)
int main(int argc, char **argv)
const CanonicalForm int s
int iiTestConvert(int inputType, int outputType)
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
struct sValCmd1 dArith1[]
int produce_convert_table
const char * iiTwoOps(int t)
void * malloc(size_t size)
static int _texi_sort_cmds(const void *a, const void *b)
struct sValCmd3 dArith3[]
struct sValAssign dAssign[]
struct sValCmd2 dArith2[]
struct sValCmdM dArithM[]
struct sConvertTypes dConvertTypes[]
void ttGen2b()
generate cmds initialisation
const char * Tok2Cmdname(int tok)
int is_ref_cmd(cmdnames *c)