22  #define ZERODIVISOR_MASK 8 
   25  #define ZERODIVISOR_MASK 0 
   40#define ALLOW_NC         ALLOW_LP|ALLOW_PLURAL 
   47#define NO_ZERODIVISOR   8 
   48#define ALLOW_ZERODIVISOR  0 
   49#define ZERODIVISOR_MASK 8 
   51#define ALLOW_ZZ (ALLOW_RING|NO_ZERODIVISOR) 
   56#define NO_CONVERSION    32 
  146  if (tok==
COMMAND) 
return "command";
 
  147  if (tok==
ANY_TYPE) 
return "any_type";
 
  148  if (tok==
NONE) 
return "nothing";
 
  155  if (tok==
IDHDL) 
return "identifier";
 
  159  while (
cmds[
i].tokval!=0)
 
  161    if ((
cmds[
i].tokval == tok)&&(
cmds[
i].alias==0))
 
  168  while (
cmds[
i].tokval!=0)
 
  170    if (
cmds[
i].tokval == tok)
 
  178  sprintf(
s,
"(%d)",tok);
 
  196  cmdnames *pCmdL = (cmdnames*)a;
 
  197  cmdnames *pCmdR = (cmdnames*)
b;
 
  202  if(pCmdL->name==
NULL) 
return 1;
 
  203  if(pCmdR->name==
NULL) 
return -1;
 
  206  if(strcmp(pCmdL->name, 
"$INVALID$")==0) 
return -1;
 
  207  if(strcmp(pCmdR->name, 
"$INVALID$")==0) 
return  1;
 
  210  if (pCmdL->tokval==-1)
 
  212    if (pCmdR->tokval==-1)
 
  213       return strcmp(pCmdL->name, pCmdR->name);
 
  218  if(pCmdR->tokval==-1) 
return -1;
 
  220  return strcmp(pCmdL->name, pCmdR->name);
 
  225  cmdnames *pCmdL = (cmdnames*)a;
 
  226  cmdnames *pCmdR = (cmdnames*)
b;
 
  231  if(pCmdL->name==
NULL) 
return 1;
 
  232  if(pCmdR->name==
NULL) 
return -1;
 
  235  if(strcmp(pCmdL->name, 
"$INVALID$")==0) 
return -1;
 
  236  if(strcmp(pCmdR->name, 
"$INVALID$")==0) 
return  1;
 
  237  char *ls=
strdup(pCmdL->name);
 
  238  char *rs=
strdup(pCmdR->name);
 
  240  while (*
s) { *
s=tolower(*
s); 
s++; }
 
  242  while (*
s) { *
s=tolower(*
s); 
s++; }
 
  245  if (pCmdL->tokval==-1)
 
  247    if (pCmdR->tokval==-1)
 
  248       { 
int r=strcmp(ls,rs); 
free(ls); 
free(rs); 
return r; }
 
  254  if(pCmdR->tokval==-1)
 
  257  { 
int r=strcmp(ls,rs); 
free(ls); 
free(rs); 
return r; }
 
  287    case LE:          
return "<=";
 
  288    case GE:          
return ">=";
 
  303  if ((inputType==outputType)
 
  305  || (outputType==
IDHDL)
 
  310  if (inputType==
UNKNOWN) 
return 0;
 
  343  "/****************************************\n" 
  344  "*  Computer Algebra System SINGULAR     *\n" 
  345  "****************************************/\n\n");
 
  347  fprintf(outfile,
"// syntax table for Singular\n//\n");
 
  348  fprintf(outfile,
"// - search for an exact match of the argument types\n");
 
  349  fprintf(outfile,
"// - otherwise search for the first possibility\n");
 
  350  fprintf(outfile,
"//   with converted types of the arguments\n");
 
  351  fprintf(outfile,
"// - otherwise report an error\n//\n");
 
  352  fprintf(outfile,
"// --------------------------------------------------\n");
 
  353  fprintf(outfile,
"// depends on Singular/table.h and kernel/mod2.h\n\n");
 
  360      fprintf(outfile,
"// DUMMY ");
 
  362    fprintf(outfile,
"// operation: %s (%s)  ->  %s",
 
  367      fprintf(outfile,
" requires currRing");
 
  369      fprintf(outfile,
", commutative subalgebra");
 
  371      fprintf(outfile,
", letterplace rings");
 
  373      fprintf(outfile,
", only commutative rings");
 
  375      fprintf(outfile,
", field coeffs");
 
  377      fprintf(outfile,
", domain coeffs");
 
  379      fprintf(outfile,
", QQ coeffs");
 
  381    fprintf(outfile,
"\n");
 
  384  fprintf(outfile,
"/*---------------------------------------------*/\n");
 
  389      fprintf(outfile,
"// DUMMY ");
 
  391    fprintf(outfile,
"// operation: %s (%s, %s)  ->  %s",
 
  400      fprintf(outfile,
" requires currRing");
 
  403      fprintf(outfile,
", commutative subalgebra");
 
  405      fprintf(outfile,
", only commutative rings");
 
  407      fprintf(outfile,
", field coeffs");
 
  409      fprintf(outfile,
", domain coeffs");
 
  411      fprintf(outfile,
", QQ coeffs");
 
  413    fprintf(outfile,
"\n");
 
  416  fprintf(outfile,
"/*---------------------------------------------*/\n");
 
  422      fprintf(outfile,
"// DUMMY ");
 
  423    fprintf(outfile,
"// operation: %s (%s, %s, %s)  ->  %s",
 
  434      fprintf(outfile,
" requires currRing");
 
  437      fprintf(outfile,
", commutative subalgebra");
 
  439      fprintf(outfile,
", only commutative rings");
 
  441      fprintf(outfile,
", field coeffs");
 
  443      fprintf(outfile,
", domain coeffs");
 
  445      fprintf(outfile,
", QQ coeffs");
 
  447    fprintf(outfile,
"\n");
 
  450  fprintf(outfile,
"/*---------------------------------------------*/\n");
 
  455    fprintf(outfile,
"// operation: %s (...)  ->  %s",
 
  461         fprintf(outfile,
" ( number of arguments >0 )\n");
 
  464         fprintf(outfile,
" ( any number of arguments )\n");
 
  467         fprintf(outfile,
" ( %d arguments )\n",
dArithM[
i].number_of_args);
 
  472  fprintf(outfile,
"/*---------------------------------------------*/\n");
 
  476    fprintf(outfile,
"// assign: %s =  %s\n",
 
  482  fprintf(outfile,
"/*---------------------------------------------*/\n");
 
  486    doctable=fopen(
"convert_table.texi",
"w");
 
  487    fprintf(doctable,
"@multitable @columnfractions .05 .18 .81\n");
 
  497        fprintf(outfile,
"// convert %s -> %s\n",
 
  502          "@item\n@   %d. @tab @code{%s}  @tab @expansion{} @code{%s}\n",
 
  512    fprintf(doctable,
"@end multitable\n");
 
  515  fprintf(outfile,
"/*---------------------------------------------*/\n");
 
  516  char ops[]=
"=><+*/[.^,%(;";
 
  517  for(
i=0;ops[
i]!=
'\0';
i++)
 
  518    fprintf(outfile,
"// token %d : %c\n", (
int)ops[
i], ops[
i]);
 
  524      fprintf(outfile,
"// token %d : %s\n", 
i, 
s);
 
  528  fprintf(outfile,
"/*--max. token: %d, gr: %d --*/\n",
MAX_TOK,
UMINUS);
 
  530  fprintf(outfile,
"/*---------------------------------------------*/\n");
 
  532  "const struct sValCmdTab dArithTab1[]=\n" 
  540        fprintf(outfile,
" { %d,%d }, /* %s */\n",
j,
i,
iiTwoOps(
j));
 
  546  fprintf(outfile,
" { 10000,0 }\n};\n");
 
  547  fprintf(outfile,
"#define JJTAB1LEN %d\n",l1);
 
  550  "const struct sValCmdTab dArithTab2[]=\n" 
  558        fprintf(outfile,
" { %d,%d }, /* %s */\n",
j,
i,
iiTwoOps(
j));
 
  564  fprintf(outfile,
" { 10000,0 }\n};\n");
 
  565  fprintf(outfile,
"#define JJTAB2LEN %d\n",l2);
 
  576  int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
 
  580  "/****************************************\n" 
  581  "*  Computer Algebra System SINGULAR     *\n" 
  582  "****************************************/\n\n");
 
  584  fprintf(outfile,
"// identifier table for Singular\n//\n");
 
  588    "void iiInitCmdName()\n{\n" 
  589    "  sArithBase.nCmdUsed      = 0;\n" 
  590    "  sArithBase.nCmdAllocated = %d;\n" 
  591    "  sArithBase.sCmds = (cmdnames*)omAlloc0(%d/*sArithBase.nCmdAllocated*/ *sizeof(cmdnames));\n" 
  593    "  // name-string                   alias  tokval toktype index\n",
 
  600  for(
m=0; 
m<cmd_size; 
m++)
 
  602    if(
cmds[
m].tokval>0) id_nr++;
 
  603    fprintf(outfile,
"  iiArithAddCmd(\"%s\", %*d, %3d, ",
cmds[
m].
name,
 
  607    switch(
cmds[
m].toktype)
 
  609        case CMD_1:            fprintf(outfile,
"CMD_1"); 
break;
 
  610        case CMD_2:            fprintf(outfile,
"CMD_2"); 
break;
 
  611        case CMD_3:            fprintf(outfile,
"CMD_3"); 
break;
 
  612        case CMD_12:           fprintf(outfile,
"CMD_12"); 
break;
 
  613        case CMD_123 :         fprintf(outfile,
"CMD_123"); 
break;
 
  614        case CMD_13 :          fprintf(outfile,
"CMD_13"); 
break;
 
  615        case CMD_23:           fprintf(outfile,
"CMD_23"); 
break;
 
  616        case CMD_M:            fprintf(outfile,
"CMD_M"); 
break;
 
  617        case SYSVAR:           fprintf(outfile,
"SYSVAR"); 
break;
 
  618        case ROOT_DECL:        fprintf(outfile,
"ROOT_DECL"); 
break;
 
  620        case RING_DECL:        fprintf(outfile,
"RING_DECL"); 
break;
 
  621        case NONE:             fprintf(outfile,
"NONE"); 
break;
 
  623          if((
cmds[
m].toktype>
' ') &&(
cmds[
m].toktype<127))
 
  625            fprintf(outfile,
"'%c'",
cmds[
m].toktype);
 
  629            fprintf(outfile,
"%d",
cmds[
m].toktype);
 
  633          fprintf(outfile,
"  iiArithAddCmd(\"%s\", %*d,  -1, 0 );\n",
 
  640    fprintf(outfile,
", %d);\n", 
m);
 
  642  fprintf(outfile, 
"/* end of list marker */\n");
 
  644          "  sArithBase.nLastIdentifier = %d;\n",
 
  650"#define LAST_IDENTIFIER %d\n" 
  656  if( c->tokval==0) 
return 0;
 
  657  if (c->alias > 0) 
return 0;
 
  658  if  ((c->toktype==
CMD_1)
 
  659        || (c->toktype==
CMD_2)
 
  660        || (c->toktype==
CMD_3)
 
  661        || (c->toktype==
CMD_M)
 
  665        || (c->toktype==
CMD_123)) 
return 1;
 
  670  int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
 
  672  FILE *outfile = fopen(
"reference_table.texi",
"w");
 
  673  fprintf(outfile, 
"@menu\n");
 
  678  for(
m=0; 
m<cmd_size; 
m++)
 
  683      fprintf(outfile,
"* %s::\n",
cmds[
m].
name);
 
  686  fprintf(outfile, 
"@end menu\n@c ---------------------------\n");
 
  687  for(
m=0; 
m<cmd_size; 
m++)
 
  692      fprintf(outfile,
"@node %s,",
cmds[
m].
name);
 
  697        fprintf(outfile,
"%s,",
cmds[mm].
name);
 
  699        fprintf(outfile,
",");
 
  706        fprintf(outfile,
",");
 
  708      fprintf(outfile,
"Functions\n" 
  711      fprintf(outfile,
"@include %s.part\n",
cmds[
m].
name);
 
  713      sprintf(partName,
"%s.part",
cmds[
m].
name);
 
  715      if (lstat(partName,&
buf)!=0)
 
  718        int only_field=0,only_comm=0,no_zerodiv=0;
 
  719        FILE *part=fopen(partName,
"w");
 
  720        fprintf(part,
"@table @code\n@item @strong{Syntax:}\n");
 
  781              fprintf(part,
"@code{%s (} %s, %s, %s @code{)}\n",
cmds[
m].
name,
 
  805              fprintf(part,
"@code{%s (} ... @code{)}\n",
cmds[
m].
name);
 
  818              fprintf(part,
"@item @strong{Remark:}\n" 
  819                           "only for commutive polynomial rings\n");
 
  821              fprintf(part,
"@item @strong{Remark:}\n" 
  822                           "only for polynomial rings over fields\n");
 
  824              fprintf(part,
"@item @strong{Remark:}\n" 
  825                           "only for polynomial rings over domains\n");
 
  826        fprintf(part,
"@item @strong{Purpose:}\n" 
  827                     "@item @strong{Example:}\n" 
  831                     "@end smallexample\n" 
  846  FILE *outfile = fopen(
"plural_cmd.xx",
"w");
 
  848  const char *old_s=
"";
 
  850  "@c *****************************************\n" 
  851  "@c *  Computer Algebra System SINGULAR     *\n" 
  852  "@c *****************************************\n\n");
 
  854  fprintf(outfile,
"@multicolumn .45 .45\n");
 
  862      if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
 
  869            fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
 
  872            fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
 
  875            fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
 
  885  fprintf(outfile,
"@c ---------------------------------------------\n");
 
  892      if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
 
  899            fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
 
  902            fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
 
  905            fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
 
  915  fprintf(outfile,
"@c ---------------------------------------------\n");
 
  922      if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
 
  929            fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
 
  932            fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
 
  935            fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
 
  945  fprintf(outfile,
"@c ---------------------------------------------\n");
 
  950    if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
 
  957            fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
 
  960            fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
 
  963            fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
 
  972  fprintf(outfile,
"@c ---------------------------------------------\n");
 
  973  fprintf(outfile,
"@end table\n");
 
  975  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.