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 43 #define ALLOW_ZZ (ALLOW_RING|NO_ZERODIVISOR) 48 #define NO_CONVERSION 32 138 if (tok==
COMMAND)
return "command";
139 if (tok==
ANY_TYPE)
return "any_type";
140 if (tok==
NONE)
return "nothing";
147 if (tok==
IDHDL)
return "identifier";
170 sprintf(s,
"(%d)",tok);
188 cmdnames *pCmdL = (cmdnames*)a;
189 cmdnames *pCmdR = (cmdnames*)b;
194 if(pCmdL->name==
NULL)
return 1;
195 if(pCmdR->name==
NULL)
return -1;
198 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
199 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
202 if (pCmdL->tokval==-1)
204 if (pCmdR->tokval==-1)
205 return strcmp(pCmdL->name, pCmdR->name);
210 if(pCmdR->tokval==-1)
return -1;
212 return strcmp(pCmdL->name, pCmdR->name);
217 cmdnames *pCmdL = (cmdnames*)a;
218 cmdnames *pCmdR = (cmdnames*)b;
223 if(pCmdL->name==
NULL)
return 1;
224 if(pCmdR->name==
NULL)
return -1;
227 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
228 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
229 char *ls=
strdup(pCmdL->name);
230 char *rs=
strdup(pCmdR->name);
232 while (*s) { *s=tolower(*s); s++; }
234 while (*s) { *s=tolower(*s); s++; }
237 if (pCmdL->tokval==-1)
239 if (pCmdR->tokval==-1)
240 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
246 if(pCmdR->tokval==-1)
249 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
279 case LE:
return "<=";
280 case GE:
return ">=";
295 if ((inputType==outputType)
297 || (outputType==
IDHDL)
302 if (inputType==
UNKNOWN)
return 0;
335 "/****************************************\n" 336 "* Computer Algebra System SINGULAR *\n" 337 "****************************************/\n\n");
339 fprintf(outfile,
"// syntax table for Singular\n//\n");
340 fprintf(outfile,
"// - search for an exact match of the argument types\n");
341 fprintf(outfile,
"// - otherwise search for the first possibility\n");
342 fprintf(outfile,
"// with converted types of the arguments\n");
343 fprintf(outfile,
"// - otherwise report an error\n//\n");
350 fprintf(outfile,
"// DUMMY ");
352 fprintf(outfile,
"// operation: %s (%s) -> %s\n",
358 fprintf(outfile,
"// WARNING: %s requires currRing\n",s);
362 fprintf(outfile,
"/*---------------------------------------------*/\n");
367 fprintf(outfile,
"// DUMMY ");
369 fprintf(outfile,
"// operation: %s (%s, %s) -> %s\n",
378 fprintf(outfile,
"// WARNING: %s requires currRing\n",s);
382 fprintf(outfile,
"/*---------------------------------------------*/\n");
388 fprintf(outfile,
"// DUMMY ");
389 fprintf(outfile,
"// operation: %s (%s, %s, %s) -> %s\n",
400 fprintf(outfile,
"// WARNING: %s requires currRing\n",s);
404 fprintf(outfile,
"/*---------------------------------------------*/\n");
409 fprintf(outfile,
"// operation: %s (...) -> %s",
412 switch(
dArithM[i].number_of_args)
415 fprintf(outfile,
" ( number of arguments >0 )\n");
418 fprintf(outfile,
" ( any number of arguments )\n");
421 fprintf(outfile,
" ( %d arguments )\n",
dArithM[i].number_of_args);
426 fprintf(outfile,
"/*---------------------------------------------*/\n");
430 fprintf(outfile,
"// assign: %s = %s\n",
436 fprintf(outfile,
"/*---------------------------------------------*/\n");
440 doctable=fopen(
"convert_table.texi",
"w");
441 fprintf(doctable,
"@multitable @columnfractions .05 .18 .81\n");
451 fprintf(outfile,
"// convert %s -> %s\n",
456 "@item\n@ %d. @tab @code{%s} @tab @expansion{} @code{%s}\n",
466 fprintf(doctable,
"@end multitable\n");
469 fprintf(outfile,
"/*---------------------------------------------*/\n");
470 char ops[]=
"=><+*/[.^,%(;";
471 for(i=0;ops[
i]!=
'\0';i++)
472 fprintf(outfile,
"// token %d : %c\n", (
int)ops[i], ops[i]);
478 fprintf(outfile,
"// token %d : %s\n", i, s);
482 fprintf(outfile,
"/*--max. token: %d, gr: %d --*/\n",
MAX_TOK,
UMINUS);
484 fprintf(outfile,
"/*---------------------------------------------*/\n");
486 "const struct sValCmdTab dArithTab1[]=\n" 494 fprintf(outfile,
" { %d,%d },\n",j,i);
500 fprintf(outfile,
" { 10000,0 }\n};\n");
501 fprintf(outfile,
"#define JJTAB1LEN %d\n",l1);
504 "const struct sValCmdTab dArithTab2[]=\n" 512 fprintf(outfile,
" { %d,%d },\n",j,i);
518 fprintf(outfile,
" { 10000,0 }\n};\n");
519 fprintf(outfile,
"#define JJTAB2LEN %d\n",l2);
530 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
534 "/****************************************\n" 535 "* Computer Algebra System SINGULAR *\n" 536 "****************************************/\n\n");
538 fprintf(outfile,
"// identifier table for Singular\n//\n");
542 "#ifdef MODULE_GENERATOR\n" 543 "#define omAlloc0(A) malloc(A)\n" 545 "void iiInitCmdName()\n{\n" 546 " sArithBase.nCmdUsed = 0;\n" 547 " sArithBase.nCmdAllocated = %d;\n" 548 " sArithBase.sCmds = (cmdnames*)omAlloc0(sArithBase.nCmdAllocated*sizeof(cmdnames));\n" 550 " // name-string alias tokval toktype index\n",
557 for(m=0; m<cmd_size; m++)
560 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, %3d, ",
cmds[m].
name,
561 (
int)(20-strlen(
cmds[m].name)),
566 case CMD_1: fprintf(outfile,
"CMD_1");
break;
567 case CMD_2: fprintf(outfile,
"CMD_2");
break;
568 case CMD_3: fprintf(outfile,
"CMD_3");
break;
569 case CMD_12: fprintf(outfile,
"CMD_12");
break;
570 case CMD_123 : fprintf(outfile,
"CMD_123");
break;
571 case CMD_23: fprintf(outfile,
"CMD_23");
break;
572 case CMD_M: fprintf(outfile,
"CMD_M");
break;
573 case SYSVAR: fprintf(outfile,
"SYSVAR");
break;
574 case ROOT_DECL: fprintf(outfile,
"ROOT_DECL");
break;
576 case RING_DECL: fprintf(outfile,
"RING_DECL");
break;
577 case NONE: fprintf(outfile,
"NONE");
break;
579 if((
cmds[m].toktype>
' ') &&(
cmds[m].toktype<127))
581 fprintf(outfile,
"'%c'",
cmds[m].toktype);
585 fprintf(outfile,
"%d",
cmds[m].toktype);
589 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, -1, 0 );\n",
590 cmds[m].name, 20-strlen(
cmds[m].name),
596 fprintf(outfile,
", %d);\n", m);
598 fprintf(outfile,
"/* end of list marker */\n");
600 " sArithBase.nLastIdentifier = %d;\n",
606 "#define LAST_IDENTIFIER %d\n" 612 if( c->tokval==0)
return 0;
613 if (c->alias > 0)
return 0;
614 if ((c->toktype==
CMD_1)
615 || (c->toktype==
CMD_2)
616 || (c->toktype==
CMD_3)
617 || (c->toktype==
CMD_M)
621 || (c->toktype==
CMD_123))
return 1;
626 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
628 FILE *outfile = fopen(
"reference_table.texi",
"w");
629 fprintf(outfile,
"@menu\n");
634 for(m=0; m<cmd_size; m++)
639 fprintf(outfile,
"* %s::\n",
cmds[m].
name);
642 fprintf(outfile,
"@end menu\n@c ---------------------------\n");
643 for(m=0; m<cmd_size; m++)
648 fprintf(outfile,
"@node %s,",
cmds[m].
name);
653 fprintf(outfile,
"%s,",
cmds[mm].name);
655 fprintf(outfile,
",");
660 fprintf(outfile,
"%s,",
cmds[m-1].name);
662 fprintf(outfile,
",");
664 fprintf(outfile,
"Functions\n" 666 "@cindex %s\n",
cmds[m].name,
cmds[m].name);
667 fprintf(outfile,
"@include %s.part\n",
cmds[m].name);
669 sprintf(partName,
"%s.part",
cmds[m].name);
671 if (lstat(partName,&buf)!=0)
674 int only_field=0,only_comm=0,no_zerodiv=0;
675 FILE *part=fopen(partName,
"w");
676 fprintf(part,
"@table @code\n@item @strong{Syntax:}\n");
737 fprintf(part,
"@code{%s (} %s, %s, %s @code{)}\n",
cmds[m].name,
761 fprintf(part,
"@code{%s (} ... @code{)}\n",
cmds[m].name);
774 fprintf(part,
"@item @strong{Remark:}\n" 775 "only for commutive polynomial rings\n");
777 fprintf(part,
"@item @strong{Remark:}\n" 778 "only for polynomial rings over fields\n");
780 fprintf(part,
"@item @strong{Remark:}\n" 781 "only for polynomial rings over domains\n");
782 fprintf(part,
"@item @strong{Purpose:}\n" 783 "@item @strong{Example:}\n" 787 "@end smallexample\n" 802 FILE *outfile = fopen(
"plural_cmd.xx",
"w");
804 const char *old_s=
"";
806 "@c *****************************************\n" 807 "@c * Computer Algebra System SINGULAR *\n" 808 "@c *****************************************\n\n");
810 fprintf(outfile,
"@multicolumn .45 .45\n");
818 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
825 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
828 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
831 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
841 fprintf(outfile,
"@c ---------------------------------------------\n");
848 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
855 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
858 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
861 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
871 fprintf(outfile,
"@c ---------------------------------------------\n");
878 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
885 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
888 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
891 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
901 fprintf(outfile,
"@c ---------------------------------------------\n");
906 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
913 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
916 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
919 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
928 fprintf(outfile,
"@c ---------------------------------------------\n");
929 fprintf(outfile,
"@end table\n");
931 rename(
"plural_cmd.xx",
"plural_cmd.inc");
const CanonicalForm int s
int iiTestConvert(int inputType, int outputType)
int main(int argc, char **)
const struct sConvertTypes dConvertTypes[]
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)
const struct sValAssign dAssign[]
void * malloc(size_t size)
static int _texi_sort_cmds(const void *a, const void *b)
struct sValCmd3 dArith3[]
struct sValCmd2 dArith2[]
struct sValCmdM dArithM[]
void ttGen2b()
generate cmds initialisation
const char * Tok2Cmdname(int tok)
int is_ref_cmd(cmdnames *c)