23 #define ZERODIVISOR_MASK 8 26 #define ZERODIVISOR_MASK 0 36 #define ALLOW_PLURAL 1 45 #define NO_ZERODIVISOR 8 46 #define ALLOW_ZERODIVISOR 0 47 #define ZERODIVISOR_MASK 8 49 #define ALLOW_ZZ (ALLOW_RING|NO_ZERODIVISOR) 54 #define NO_CONVERSION 32 144 if (tok==
COMMAND)
return "command";
145 if (tok==
ANY_TYPE)
return "any_type";
146 if (tok==
NONE)
return "nothing";
153 if (tok==
IDHDL)
return "identifier";
176 sprintf(s,
"(%d)",tok);
194 cmdnames *pCmdL = (cmdnames*)a;
195 cmdnames *pCmdR = (cmdnames*)b;
200 if(pCmdL->name==
NULL)
return 1;
201 if(pCmdR->name==
NULL)
return -1;
204 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
205 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
208 if (pCmdL->tokval==-1)
210 if (pCmdR->tokval==-1)
211 return strcmp(pCmdL->name, pCmdR->name);
216 if(pCmdR->tokval==-1)
return -1;
218 return strcmp(pCmdL->name, pCmdR->name);
223 cmdnames *pCmdL = (cmdnames*)a;
224 cmdnames *pCmdR = (cmdnames*)b;
229 if(pCmdL->name==
NULL)
return 1;
230 if(pCmdR->name==
NULL)
return -1;
233 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
234 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
235 char *ls=
strdup(pCmdL->name);
236 char *rs=
strdup(pCmdR->name);
238 while (*s) { *s=tolower(*s); s++; }
240 while (*s) { *s=tolower(*s); s++; }
243 if (pCmdL->tokval==-1)
245 if (pCmdR->tokval==-1)
246 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
252 if(pCmdR->tokval==-1)
255 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
285 case LE:
return "<=";
286 case GE:
return ">=";
301 if ((inputType==outputType)
303 || (outputType==
IDHDL)
308 if (inputType==
UNKNOWN)
return 0;
341 "/****************************************\n" 342 "* Computer Algebra System SINGULAR *\n" 343 "****************************************/\n\n");
345 fprintf(outfile,
"// syntax table for Singular\n//\n");
346 fprintf(outfile,
"// - search for an exact match of the argument types\n");
347 fprintf(outfile,
"// - otherwise search for the first possibility\n");
348 fprintf(outfile,
"// with converted types of the arguments\n");
349 fprintf(outfile,
"// - otherwise report an error\n//\n");
356 fprintf(outfile,
"// DUMMY ");
358 fprintf(outfile,
"// operation: %s (%s) -> %s",
363 fprintf(outfile,
" requires currRing");
365 fprintf(outfile,
", commutative subalgebra");
366 else if ((
dArith1[i].valid_for & PLURAL_MASK)==0)
367 fprintf(outfile,
", only commutative rings");
369 fprintf(outfile,
", field coeffs");
371 fprintf(outfile,
", domain coeffs");
373 fprintf(outfile,
", QQ coeffs");
375 fprintf(outfile,
"\n");
378 fprintf(outfile,
"/*---------------------------------------------*/\n");
383 fprintf(outfile,
"// DUMMY ");
385 fprintf(outfile,
"// operation: %s (%s, %s) -> %s",
394 fprintf(outfile,
" requires currRing");
397 fprintf(outfile,
", commutative subalgebra");
398 else if ((
dArith2[i].valid_for & PLURAL_MASK)==0)
399 fprintf(outfile,
", only commutative rings");
401 fprintf(outfile,
", field coeffs");
403 fprintf(outfile,
", domain coeffs");
405 fprintf(outfile,
", QQ coeffs");
407 fprintf(outfile,
"\n");
410 fprintf(outfile,
"/*---------------------------------------------*/\n");
416 fprintf(outfile,
"// DUMMY ");
417 fprintf(outfile,
"// operation: %s (%s, %s, %s) -> %s",
428 fprintf(outfile,
" requires currRing");
431 fprintf(outfile,
", commutative subalgebra");
432 else if ((
dArith3[i].valid_for & PLURAL_MASK)==0)
433 fprintf(outfile,
", only commutative rings");
435 fprintf(outfile,
", field coeffs");
437 fprintf(outfile,
", domain coeffs");
439 fprintf(outfile,
", QQ coeffs");
441 fprintf(outfile,
"\n");
444 fprintf(outfile,
"/*---------------------------------------------*/\n");
449 fprintf(outfile,
"// operation: %s (...) -> %s",
452 switch(
dArithM[i].number_of_args)
455 fprintf(outfile,
" ( number of arguments >0 )\n");
458 fprintf(outfile,
" ( any number of arguments )\n");
461 fprintf(outfile,
" ( %d arguments )\n",
dArithM[i].number_of_args);
466 fprintf(outfile,
"/*---------------------------------------------*/\n");
470 fprintf(outfile,
"// assign: %s = %s\n",
476 fprintf(outfile,
"/*---------------------------------------------*/\n");
480 doctable=fopen(
"convert_table.texi",
"w");
481 fprintf(doctable,
"@multitable @columnfractions .05 .18 .81\n");
491 fprintf(outfile,
"// convert %s -> %s\n",
496 "@item\n@ %d. @tab @code{%s} @tab @expansion{} @code{%s}\n",
506 fprintf(doctable,
"@end multitable\n");
509 fprintf(outfile,
"/*---------------------------------------------*/\n");
510 char ops[]=
"=><+*/[.^,%(;";
511 for(i=0;ops[
i]!=
'\0';i++)
512 fprintf(outfile,
"// token %d : %c\n", (
int)ops[i], ops[i]);
518 fprintf(outfile,
"// token %d : %s\n", i, s);
522 fprintf(outfile,
"/*--max. token: %d, gr: %d --*/\n",
MAX_TOK,
UMINUS);
524 fprintf(outfile,
"/*---------------------------------------------*/\n");
526 "const struct sValCmdTab dArithTab1[]=\n" 534 fprintf(outfile,
" { %d,%d },\n",j,i);
540 fprintf(outfile,
" { 10000,0 }\n};\n");
541 fprintf(outfile,
"#define JJTAB1LEN %d\n",l1);
544 "const struct sValCmdTab dArithTab2[]=\n" 552 fprintf(outfile,
" { %d,%d },\n",j,i);
558 fprintf(outfile,
" { 10000,0 }\n};\n");
559 fprintf(outfile,
"#define JJTAB2LEN %d\n",l2);
570 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
574 "/****************************************\n" 575 "* Computer Algebra System SINGULAR *\n" 576 "****************************************/\n\n");
578 fprintf(outfile,
"// identifier table for Singular\n//\n");
582 "#ifdef MODULE_GENERATOR\n" 583 "#define omAlloc0(A) malloc(A)\n" 585 "void iiInitCmdName()\n{\n" 586 " sArithBase.nCmdUsed = 0;\n" 587 " sArithBase.nCmdAllocated = %d;\n" 588 " sArithBase.sCmds = (cmdnames*)omAlloc0(sArithBase.nCmdAllocated*sizeof(cmdnames));\n" 590 " // name-string alias tokval toktype index\n",
597 for(m=0; m<cmd_size; m++)
600 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, %3d, ",
cmds[m].
name,
601 (
int)(20-strlen(
cmds[m].name)),
606 case CMD_1: fprintf(outfile,
"CMD_1");
break;
607 case CMD_2: fprintf(outfile,
"CMD_2");
break;
608 case CMD_3: fprintf(outfile,
"CMD_3");
break;
609 case CMD_12: fprintf(outfile,
"CMD_12");
break;
610 case CMD_123 : fprintf(outfile,
"CMD_123");
break;
611 case CMD_23: fprintf(outfile,
"CMD_23");
break;
612 case CMD_M: fprintf(outfile,
"CMD_M");
break;
613 case SYSVAR: fprintf(outfile,
"SYSVAR");
break;
614 case ROOT_DECL: fprintf(outfile,
"ROOT_DECL");
break;
616 case RING_DECL: fprintf(outfile,
"RING_DECL");
break;
617 case NONE: fprintf(outfile,
"NONE");
break;
619 if((
cmds[m].toktype>
' ') &&(
cmds[m].toktype<127))
621 fprintf(outfile,
"'%c'",
cmds[m].toktype);
625 fprintf(outfile,
"%d",
cmds[m].toktype);
629 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, -1, 0 );\n",
630 cmds[m].name, 20-strlen(
cmds[m].name),
636 fprintf(outfile,
", %d);\n", m);
638 fprintf(outfile,
"/* end of list marker */\n");
640 " sArithBase.nLastIdentifier = %d;\n",
646 "#define LAST_IDENTIFIER %d\n" 652 if( c->tokval==0)
return 0;
653 if (c->alias > 0)
return 0;
654 if ((c->toktype==
CMD_1)
655 || (c->toktype==
CMD_2)
656 || (c->toktype==
CMD_3)
657 || (c->toktype==
CMD_M)
661 || (c->toktype==
CMD_123))
return 1;
666 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
668 FILE *outfile = fopen(
"reference_table.texi",
"w");
669 fprintf(outfile,
"@menu\n");
674 for(m=0; m<cmd_size; m++)
679 fprintf(outfile,
"* %s::\n",
cmds[m].
name);
682 fprintf(outfile,
"@end menu\n@c ---------------------------\n");
683 for(m=0; m<cmd_size; m++)
688 fprintf(outfile,
"@node %s,",
cmds[m].
name);
693 fprintf(outfile,
"%s,",
cmds[mm].name);
695 fprintf(outfile,
",");
700 fprintf(outfile,
"%s,",
cmds[m-1].name);
702 fprintf(outfile,
",");
704 fprintf(outfile,
"Functions\n" 706 "@cindex %s\n",
cmds[m].name,
cmds[m].name);
707 fprintf(outfile,
"@include %s.part\n",
cmds[m].name);
709 sprintf(partName,
"%s.part",
cmds[m].name);
711 if (lstat(partName,&buf)!=0)
714 int only_field=0,only_comm=0,no_zerodiv=0;
715 FILE *part=fopen(partName,
"w");
716 fprintf(part,
"@table @code\n@item @strong{Syntax:}\n");
777 fprintf(part,
"@code{%s (} %s, %s, %s @code{)}\n",
cmds[m].name,
801 fprintf(part,
"@code{%s (} ... @code{)}\n",
cmds[m].name);
814 fprintf(part,
"@item @strong{Remark:}\n" 815 "only for commutive polynomial rings\n");
817 fprintf(part,
"@item @strong{Remark:}\n" 818 "only for polynomial rings over fields\n");
820 fprintf(part,
"@item @strong{Remark:}\n" 821 "only for polynomial rings over domains\n");
822 fprintf(part,
"@item @strong{Purpose:}\n" 823 "@item @strong{Example:}\n" 827 "@end smallexample\n" 842 FILE *outfile = fopen(
"plural_cmd.xx",
"w");
844 const char *old_s=
"";
846 "@c *****************************************\n" 847 "@c * Computer Algebra System SINGULAR *\n" 848 "@c *****************************************\n\n");
850 fprintf(outfile,
"@multicolumn .45 .45\n");
858 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
865 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
868 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
871 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
881 fprintf(outfile,
"@c ---------------------------------------------\n");
888 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
895 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
898 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
901 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
911 fprintf(outfile,
"@c ---------------------------------------------\n");
918 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
925 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
928 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
931 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
941 fprintf(outfile,
"@c ---------------------------------------------\n");
946 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
953 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
956 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
959 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
968 fprintf(outfile,
"@c ---------------------------------------------\n");
969 fprintf(outfile,
"@end table\n");
971 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
const struct sValCmd2 dArith2[]
const struct sValCmdM dArithM[]
const struct sValCmd3 dArith3[]
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)
void ttGen2b()
generate cmds initialisation
const char * Tok2Cmdname(int tok)
const struct sValCmd1 dArith1[]
int is_ref_cmd(cmdnames *c)