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
141 if (tok==
COMMAND)
return "command";
142 if (tok==
ANY_TYPE)
return "any_type";
143 if (tok==
NONE)
return "nothing";
150 if (tok==
IDHDL)
return "identifier";
154 while (
cmds[
i].tokval!=0)
156 if ((
cmds[
i].tokval == tok)&&(
cmds[
i].alias==0))
163 while (
cmds[
i].tokval!=0)
165 if (
cmds[
i].tokval == tok)
173 snprintf(
s,10,
"(%d)",tok);
191 cmdnames *pCmdL = (cmdnames*)a;
192 cmdnames *pCmdR = (cmdnames*)
b;
197 if(pCmdL->name==
NULL)
return 1;
198 if(pCmdR->name==
NULL)
return -1;
201 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
202 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
205 if (pCmdL->tokval==-1)
207 if (pCmdR->tokval==-1)
208 return strcmp(pCmdL->name, pCmdR->name);
213 if(pCmdR->tokval==-1)
return -1;
215 return strcmp(pCmdL->name, pCmdR->name);
220 cmdnames *pCmdL = (cmdnames*)a;
221 cmdnames *pCmdR = (cmdnames*)
b;
226 if(pCmdL->name==
NULL)
return 1;
227 if(pCmdR->name==
NULL)
return -1;
230 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
231 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
232 char *ls=
strdup(pCmdL->name);
233 char *rs=
strdup(pCmdR->name);
235 while (*
s) { *
s=tolower(*
s);
s++; }
237 while (*
s) { *
s=tolower(*
s);
s++; }
240 if (pCmdL->tokval==-1)
242 if (pCmdR->tokval==-1)
243 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
249 if(pCmdR->tokval==-1)
252 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
282 case LE:
return "<=";
283 case GE:
return ">=";
298 if ((inputType==outputType)
300 || (outputType==
IDHDL)
305 if (inputType==
UNKNOWN)
return 0;
338 "/****************************************\n"
339 "* Computer Algebra System SINGULAR *\n"
340 "****************************************/\n\n");
342 fprintf(outfile,
"// syntax table for Singular\n//\n");
343 fprintf(outfile,
"// - search for an exact match of the argument types\n");
344 fprintf(outfile,
"// - otherwise search for the first possibility\n");
345 fprintf(outfile,
"// with converted types of the arguments\n");
346 fprintf(outfile,
"// - otherwise report an error\n//\n");
347 fprintf(outfile,
"// --------------------------------------------------\n");
348 fprintf(outfile,
"// depends on Singular/table.h and kernel/mod2.h\n\n");
355 fprintf(outfile,
"// DUMMY ");
357 fprintf(outfile,
"// operation: %s (%s) -> %s",
362 fprintf(outfile,
" requires currRing");
364 fprintf(outfile,
", commutative subalgebra");
366 fprintf(outfile,
", letterplace rings");
368 fprintf(outfile,
", only commutative rings");
370 fprintf(outfile,
", field coeffs");
372 fprintf(outfile,
", domain coeffs");
374 fprintf(outfile,
", QQ coeffs");
376 fprintf(outfile,
"\n");
379 fprintf(outfile,
"/*---------------------------------------------*/\n");
384 fprintf(outfile,
"// DUMMY ");
386 fprintf(outfile,
"// operation: %s (%s, %s) -> %s",
395 fprintf(outfile,
" requires currRing");
398 fprintf(outfile,
", commutative subalgebra");
400 fprintf(outfile,
", only commutative rings");
402 fprintf(outfile,
", field coeffs");
404 fprintf(outfile,
", domain coeffs");
406 fprintf(outfile,
", QQ coeffs");
408 fprintf(outfile,
"\n");
411 fprintf(outfile,
"/*---------------------------------------------*/\n");
417 fprintf(outfile,
"// DUMMY ");
418 fprintf(outfile,
"// operation: %s (%s, %s, %s) -> %s",
429 fprintf(outfile,
" requires currRing");
432 fprintf(outfile,
", commutative subalgebra");
434 fprintf(outfile,
", only commutative rings");
436 fprintf(outfile,
", field coeffs");
438 fprintf(outfile,
", domain coeffs");
440 fprintf(outfile,
", QQ coeffs");
442 fprintf(outfile,
"\n");
445 fprintf(outfile,
"/*---------------------------------------------*/\n");
450 fprintf(outfile,
"// operation: %s (...) -> %s",
456 fprintf(outfile,
" ( number of arguments >0 )\n");
459 fprintf(outfile,
" ( any number of arguments )\n");
462 fprintf(outfile,
" ( %d arguments )\n",
dArithM[
i].number_of_args);
467 fprintf(outfile,
"/*---------------------------------------------*/\n");
471 fprintf(outfile,
"// assign: %s = %s\n",
477 fprintf(outfile,
"/*---------------------------------------------*/\n");
481 doctable=fopen(
"convert_table.texi",
"w");
482 fprintf(doctable,
"@multitable @columnfractions .05 .18 .81\n");
492 fprintf(outfile,
"// convert %s -> %s\n",
497 "@item\n@ %d. @tab @code{%s} @tab @expansion{} @code{%s}\n",
507 fprintf(doctable,
"@end multitable\n");
510 fprintf(outfile,
"/*---------------------------------------------*/\n");
511 char ops[]=
"=><+*/[.^,%(;";
512 for(
i=0;ops[
i]!=
'\0';
i++)
513 fprintf(outfile,
"// token %d : %c\n", (
int)ops[
i], ops[
i]);
519 fprintf(outfile,
"// token %d : %s\n",
i,
s);
523 fprintf(outfile,
"/*--max. token: %d, gr: %d --*/\n",
MAX_TOK,
UMINUS);
525 fprintf(outfile,
"/*---------------------------------------------*/\n");
527 "const struct sValCmdTab dArithTab1[]=\n"
535 fprintf(outfile,
" { %d,%d }, /* %s */\n",
j,
i,
iiTwoOps(
j));
541 fprintf(outfile,
" { 10000,0 }\n};\n");
542 fprintf(outfile,
"#define JJTAB1LEN %d\n",l1);
545 "const struct sValCmdTab dArithTab2[]=\n"
553 fprintf(outfile,
" { %d,%d }, /* %s */\n",
j,
i,
iiTwoOps(
j));
559 fprintf(outfile,
" { 10000,0 }\n};\n");
560 fprintf(outfile,
"#define JJTAB2LEN %d\n",l2);
571 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
575 "/****************************************\n"
576 "* Computer Algebra System SINGULAR *\n"
577 "****************************************/\n\n");
579 fprintf(outfile,
"// identifier table for Singular\n//\n");
583 "void iiInitCmdName()\n{\n"
584 " sArithBase.nCmdUsed = 0;\n"
585 " sArithBase.nCmdAllocated = %d;\n"
586 " sArithBase.sCmds = (cmdnames*)omAlloc0(%d/*sArithBase.nCmdAllocated*/ *sizeof(cmdnames));\n"
588 " // name-string alias tokval toktype index\n",
595 for(
m=0;
m<cmd_size;
m++)
597 if(
cmds[
m].tokval>0) id_nr++;
598 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, %3d, ",
cmds[
m].
name,
602 switch(
cmds[
m].toktype)
604 case CMD_1: fprintf(outfile,
"CMD_1");
break;
605 case CMD_2: fprintf(outfile,
"CMD_2");
break;
606 case CMD_3: fprintf(outfile,
"CMD_3");
break;
607 case CMD_12: fprintf(outfile,
"CMD_12");
break;
608 case CMD_123 : fprintf(outfile,
"CMD_123");
break;
609 case CMD_13 : fprintf(outfile,
"CMD_13");
break;
610 case CMD_23: fprintf(outfile,
"CMD_23");
break;
611 case CMD_M: fprintf(outfile,
"CMD_M");
break;
612 case SYSVAR: fprintf(outfile,
"SYSVAR");
break;
613 case ROOT_DECL: fprintf(outfile,
"ROOT_DECL");
break;
615 case RING_DECL: fprintf(outfile,
"RING_DECL");
break;
616 case NONE: fprintf(outfile,
"NONE");
break;
618 if((
cmds[
m].toktype>
' ') &&(
cmds[
m].toktype<127))
620 fprintf(outfile,
"'%c'",
cmds[
m].toktype);
624 fprintf(outfile,
"%d",
cmds[
m].toktype);
628 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, -1, 0 );\n",
635 fprintf(outfile,
", %d);\n",
m);
637 fprintf(outfile,
"/* end of list marker */\n");
639 " sArithBase.nLastIdentifier = %d;\n",
645"#define LAST_IDENTIFIER %d\n"
651 if( c->tokval==0)
return 0;
652 if (c->alias > 0)
return 0;
653 if ((c->toktype==
CMD_1)
654 || (c->toktype==
CMD_2)
655 || (c->toktype==
CMD_3)
656 || (c->toktype==
CMD_M)
660 || (c->toktype==
CMD_123))
return 1;
665 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
667 FILE *outfile = fopen(
"reference_table.texi",
"w");
668 fprintf(outfile,
"@menu\n");
673 for(
m=0;
m<cmd_size;
m++)
678 fprintf(outfile,
"* %s::\n",
cmds[
m].
name);
681 fprintf(outfile,
"@end menu\n@c ---------------------------\n");
682 for(
m=0;
m<cmd_size;
m++)
687 fprintf(outfile,
"@node %s,",
cmds[
m].
name);
692 fprintf(outfile,
"%s,",
cmds[mm].
name);
694 fprintf(outfile,
",");
701 fprintf(outfile,
",");
703 fprintf(outfile,
"Functions\n"
706 fprintf(outfile,
"@include %s.part\n",
cmds[
m].
name);
708 snprintf(partName,50,
"%s.part",
cmds[
m].
name);
710 if (lstat(partName,&
buf)!=0)
713 int only_field=0,only_comm=0,no_zerodiv=0;
714 FILE *part=fopen(partName,
"w");
715 fprintf(part,
"@table @code\n@item @strong{Syntax:}\n");
776 fprintf(part,
"@code{%s (} %s, %s, %s @code{)}\n",
cmds[
m].
name,
800 fprintf(part,
"@code{%s (} ... @code{)}\n",
cmds[
m].
name);
813 fprintf(part,
"@item @strong{Remark:}\n"
814 "only for commutive polynomial rings\n");
816 fprintf(part,
"@item @strong{Remark:}\n"
817 "only for polynomial rings over fields\n");
819 fprintf(part,
"@item @strong{Remark:}\n"
820 "only for polynomial rings over domains\n");
821 fprintf(part,
"@item @strong{Purpose:}\n"
822 "@item @strong{Example:}\n"
826 "@end smallexample\n"
841 FILE *outfile = fopen(
"plural_cmd.xx",
"w");
843 const char *old_s=
"";
845 "@c *****************************************\n"
846 "@c * Computer Algebra System SINGULAR *\n"
847 "@c *****************************************\n\n");
849 fprintf(outfile,
"@multicolumn .45 .45\n");
857 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
864 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
867 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
870 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
878 fprintf(outfile,
"@c ---------------------------------------------\n");
885 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
892 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
895 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
898 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
906 fprintf(outfile,
"@c ---------------------------------------------\n");
913 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
920 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
923 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
926 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
934 fprintf(outfile,
"@c ---------------------------------------------\n");
939 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
946 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
949 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
952 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
959 fprintf(outfile,
"@c ---------------------------------------------\n");
960 fprintf(outfile,
"@end table\n");
962 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.