21#define ZERODIVISOR_MASK 8
35#define ALLOW_NC ALLOW_LP|ALLOW_PLURAL
42#define NO_ZERODIVISOR 8
43#define ALLOW_ZERODIVISOR 0
44#define ZERODIVISOR_MASK 8
46#define ALLOW_ZZ (ALLOW_RING|NO_ZERODIVISOR)
51#define NO_CONVERSION 32
143 if (tok==
COMMAND)
return "command";
144 if (tok==
ANY_TYPE)
return "any_type";
145 if (tok==
NONE)
return "nothing";
152 if (tok==
IDHDL)
return "identifier";
156 while (
cmds[
i].tokval!=0)
158 if ((
cmds[
i].tokval == tok)&&(
cmds[
i].alias==0))
165 while (
cmds[
i].tokval!=0)
167 if (
cmds[
i].tokval == tok)
175 snprintf(
s,10,
"(%d)",tok);
193 cmdnames *pCmdL = (cmdnames*)a;
194 cmdnames *pCmdR = (cmdnames*)
b;
199 if(pCmdL->name==
NULL)
return 1;
200 if(pCmdR->name==
NULL)
return -1;
203 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
204 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
207 if (pCmdL->tokval==-1)
209 if (pCmdR->tokval==-1)
210 return strcmp(pCmdL->name, pCmdR->name);
215 if(pCmdR->tokval==-1)
return -1;
217 return strcmp(pCmdL->name, pCmdR->name);
222 cmdnames *pCmdL = (cmdnames*)a;
223 cmdnames *pCmdR = (cmdnames*)
b;
228 if(pCmdL->name==
NULL)
return 1;
229 if(pCmdR->name==
NULL)
return -1;
232 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
233 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
234 char *ls=
strdup(pCmdL->name);
235 char *rs=
strdup(pCmdR->name);
237 while (*
s) { *
s=tolower(*
s);
s++; }
239 while (*
s) { *
s=tolower(*
s);
s++; }
242 if (pCmdL->tokval==-1)
244 if (pCmdR->tokval==-1)
245 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
251 if(pCmdR->tokval==-1)
254 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
284 case LE:
return "<=";
285 case GE:
return ">=";
300 if ((inputType==outputType)
302 || (outputType==
IDHDL)
307 if (inputType==
UNKNOWN)
return 0;
340 "/****************************************\n"
341 "* Computer Algebra System SINGULAR *\n"
342 "****************************************/\n\n");
344 fprintf(outfile,
"// syntax table for Singular\n//\n");
345 fprintf(outfile,
"// - search for an exact match of the argument types\n");
346 fprintf(outfile,
"// - otherwise search for the first possibility\n");
347 fprintf(outfile,
"// with converted types of the arguments\n");
348 fprintf(outfile,
"// - otherwise report an error\n//\n");
349 fprintf(outfile,
"// --------------------------------------------------\n");
350 fprintf(outfile,
"// depends on Singular/table.h and kernel/mod2.h\n\n");
357 fprintf(outfile,
"// DUMMY ");
359 fprintf(outfile,
"// operation: %s (%s) -> %s",
364 fprintf(outfile,
" requires currRing");
366 fprintf(outfile,
", commutative subalgebra");
368 fprintf(outfile,
", letterplace rings");
370 fprintf(outfile,
", only commutative rings");
372 fprintf(outfile,
", field coeffs");
374 fprintf(outfile,
", domain coeffs");
376 fprintf(outfile,
", QQ coeffs");
378 fprintf(outfile,
", field coeffs for non-global orderings");
380 fprintf(outfile,
"\n");
383 fprintf(outfile,
"/*---------------------------------------------*/\n");
388 fprintf(outfile,
"// DUMMY ");
390 fprintf(outfile,
"// operation: %s (%s, %s) -> %s",
399 fprintf(outfile,
" requires currRing");
402 fprintf(outfile,
", commutative subalgebra");
404 fprintf(outfile,
", only commutative rings");
406 fprintf(outfile,
", field coeffs");
408 fprintf(outfile,
", domain coeffs");
410 fprintf(outfile,
", QQ coeffs");
412 fprintf(outfile,
"\n");
415 fprintf(outfile,
"/*---------------------------------------------*/\n");
421 fprintf(outfile,
"// DUMMY ");
422 fprintf(outfile,
"// operation: %s (%s, %s, %s) -> %s",
433 fprintf(outfile,
" requires currRing");
436 fprintf(outfile,
", commutative subalgebra");
438 fprintf(outfile,
", only commutative rings");
440 fprintf(outfile,
", field coeffs");
442 fprintf(outfile,
", domain coeffs");
444 fprintf(outfile,
", QQ coeffs");
446 fprintf(outfile,
"\n");
449 fprintf(outfile,
"/*---------------------------------------------*/\n");
454 fprintf(outfile,
"// operation: %s (...) -> %s",
460 fprintf(outfile,
" ( number of arguments >0 )\n");
463 fprintf(outfile,
" ( any number of arguments )\n");
466 fprintf(outfile,
" ( %d arguments )\n",
dArithM[
i].number_of_args);
471 fprintf(outfile,
"/*---------------------------------------------*/\n");
475 fprintf(outfile,
"// assign: %s = %s\n",
481 fprintf(outfile,
"/*---------------------------------------------*/\n");
485 doctable=fopen(
"convert_table.texi",
"w");
486 fprintf(doctable,
"@multitable @columnfractions .05 .18 .81\n");
496 fprintf(outfile,
"// convert %s -> %s\n",
501 "@item\n@ %d. @tab @code{%s} @tab @expansion{} @code{%s}\n",
511 fprintf(doctable,
"@end multitable\n");
514 fprintf(outfile,
"/*---------------------------------------------*/\n");
515 char ops[]=
"=><+*/[.^,%(;";
516 for(
i=0;ops[
i]!=
'\0';
i++)
517 fprintf(outfile,
"// token %d : %c\n", (
int)ops[
i], ops[
i]);
523 fprintf(outfile,
"// token %d : %s\n",
i,
s);
527 fprintf(outfile,
"/*--max. token: %d, gr: %d --*/\n",
MAX_TOK,
UMINUS);
529 fprintf(outfile,
"/*---------------------------------------------*/\n");
531 "const struct sValCmdTab dArithTab1[]=\n"
539 fprintf(outfile,
" { %d,%d }, /* %s */\n",
j,
i,
iiTwoOps(
j));
545 fprintf(outfile,
" { 10000,0 }\n};\n");
546 fprintf(outfile,
"#define JJTAB1LEN %d\n",l1);
549 "const struct sValCmdTab dArithTab2[]=\n"
557 fprintf(outfile,
" { %d,%d }, /* %s */\n",
j,
i,
iiTwoOps(
j));
563 fprintf(outfile,
" { 10000,0 }\n};\n");
564 fprintf(outfile,
"#define JJTAB2LEN %d\n",l2);
575 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
579 "/****************************************\n"
580 "* Computer Algebra System SINGULAR *\n"
581 "****************************************/\n\n");
583 fprintf(outfile,
"// identifier table for Singular\n//\n");
587 "void iiInitCmdName()\n{\n"
588 " sArithBase.nCmdUsed = 0;\n"
589 " sArithBase.nCmdAllocated = %d;\n"
590 " sArithBase.sCmds = (cmdnames*)omAlloc0(%d/*sArithBase.nCmdAllocated*/ *sizeof(cmdnames));\n"
592 " // name-string alias tokval toktype index\n",
599 for(
m=0;
m<cmd_size;
m++)
601 if(
cmds[
m].tokval>0) id_nr++;
602 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, %3d, ",
cmds[
m].
name,
606 switch(
cmds[
m].toktype)
608 case CMD_1: fprintf(outfile,
"CMD_1");
break;
609 case CMD_2: fprintf(outfile,
"CMD_2");
break;
610 case CMD_3: fprintf(outfile,
"CMD_3");
break;
611 case CMD_12: fprintf(outfile,
"CMD_12");
break;
612 case CMD_123 : fprintf(outfile,
"CMD_123");
break;
613 case CMD_13 : fprintf(outfile,
"CMD_13");
break;
614 case CMD_23: fprintf(outfile,
"CMD_23");
break;
615 case CMD_M: fprintf(outfile,
"CMD_M");
break;
616 case SYSVAR: fprintf(outfile,
"SYSVAR");
break;
617 case ROOT_DECL: fprintf(outfile,
"ROOT_DECL");
break;
619 case RING_DECL: fprintf(outfile,
"RING_DECL");
break;
620 case NONE: fprintf(outfile,
"NONE");
break;
622 if((
cmds[
m].toktype>
' ') &&(
cmds[
m].toktype<127))
624 fprintf(outfile,
"'%c'",
cmds[
m].toktype);
628 fprintf(outfile,
"%d",
cmds[
m].toktype);
632 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, -1, 0 );\n",
639 fprintf(outfile,
", %d);\n",
m);
641 fprintf(outfile,
"/* end of list marker */\n");
643 " sArithBase.nLastIdentifier = %d;\n",
649"#define LAST_IDENTIFIER %d\n"
655 if( c->tokval==0)
return 0;
656 if (c->alias > 0)
return 0;
657 if ((c->toktype==
CMD_1)
658 || (c->toktype==
CMD_2)
659 || (c->toktype==
CMD_3)
660 || (c->toktype==
CMD_M)
664 || (c->toktype==
CMD_123))
return 1;
669 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
671 FILE *outfile = fopen(
"reference_table.texi",
"w");
672 fprintf(outfile,
"@menu\n");
677 for(
m=0;
m<cmd_size;
m++)
682 fprintf(outfile,
"* %s::\n",
cmds[
m].
name);
685 fprintf(outfile,
"@end menu\n@c ---------------------------\n");
686 for(
m=0;
m<cmd_size;
m++)
691 fprintf(outfile,
"@node %s,",
cmds[
m].
name);
696 fprintf(outfile,
"%s,",
cmds[mm].
name);
698 fprintf(outfile,
",");
705 fprintf(outfile,
",");
707 fprintf(outfile,
"Functions\n"
710 fprintf(outfile,
"@include %s.part\n",
cmds[
m].
name);
712 snprintf(partName,50,
"%s.part",
cmds[
m].
name);
714 if (lstat(partName,&
buf)!=0)
717 int only_field=0,only_comm=0,no_zerodiv=0;
718 FILE *part=fopen(partName,
"w");
719 fprintf(part,
"@table @code\n@item @strong{Syntax:}\n");
780 fprintf(part,
"@code{%s (} %s, %s, %s @code{)}\n",
cmds[
m].
name,
804 fprintf(part,
"@code{%s (} ... @code{)}\n",
cmds[
m].
name);
817 fprintf(part,
"@item @strong{Remark:}\n"
818 "only for commutive polynomial rings\n");
820 fprintf(part,
"@item @strong{Remark:}\n"
821 "only for polynomial rings over fields\n");
823 fprintf(part,
"@item @strong{Remark:}\n"
824 "only for polynomial rings over domains\n");
825 fprintf(part,
"@item @strong{Purpose:}\n"
826 "@item @strong{Example:}\n"
830 "@end smallexample\n"
845 FILE *outfile = fopen(
"plural_cmd.xx",
"w");
847 const char *old_s=
"";
849 "@c *****************************************\n"
850 "@c * Computer Algebra System SINGULAR *\n"
851 "@c *****************************************\n\n");
853 fprintf(outfile,
"@multicolumn .45 .45\n");
861 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
868 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
871 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
874 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
882 fprintf(outfile,
"@c ---------------------------------------------\n");
889 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
896 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
899 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
902 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
910 fprintf(outfile,
"@c ---------------------------------------------\n");
917 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
924 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
927 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
930 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
938 fprintf(outfile,
"@c ---------------------------------------------\n");
943 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
950 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
953 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
956 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
963 fprintf(outfile,
"@c ---------------------------------------------\n");
964 fprintf(outfile,
"@end table\n");
966 rename(
"plural_cmd.xx",
"plural_cmd.inc");
const CanonicalForm int s
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
int is_ref_cmd(cmdnames *c)
int iiTestConvert(int inputType, int outputType)
const char * iiTwoOps(int t)
void ttGen2b()
generate cmds initialisation
static int _texi_sort_cmds(const void *a, const void *b)
VAR int produce_convert_table
const char * Tok2Cmdname(int tok)
static int RingDependend(int t)
const struct sConvertTypes dConvertTypes[]
const struct sValCmd1 dArith1[]
const struct sValCmd2 dArith2[]
const struct sValCmdM dArithM[]
const struct sValCmd3 dArith3[]
int status int void * buf
const struct sValAssign dAssign[]
int name
New type name for int.