Data Structures | Macros | Functions | Variables
gentable.cc File Reference
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "kernel/mod2.h"
#include "grammar.h"
#include "tok.h"
#include "table.h"

Go to the source code of this file.

Data Structures

struct  cmdnames
 
struct  sValCmd2
 
struct  sValCmd1
 
struct  sValCmd3
 
struct  sValCmdM
 
struct  sValAssign_sys
 
struct  sValAssign
 
struct  sConvertTypes
 

Macros

#define NO_PLURAL   0
 
#define ALLOW_PLURAL   1
 
#define COMM_PLURAL   2
 
#define PLURAL_MASK   3
 
#define ALLOW_RING   4
 
#define NO_RING   0
 
#define NO_ZERODIVISOR   8
 
#define ALLOW_ZERODIVISOR   0
 
#define ZERODIVISOR_MASK   8
 
#define ALLOW_ZZ   (ALLOW_RING|NO_ZERODIVISOR)
 
#define WARN_RING   16
 
#define NO_CONVERSION   32
 
#define jjWRONG   1
 
#define jjWRONG2   1
 
#define jjWRONG3   1
 
#define D(A)   2
 
#define NULL_VAL   0
 
#define IPARITH
 
#define GENTABLE
 
#define IPCONV
 
#define IPASSIGN
 

Functions

int RingDependend (int t)
 
const char * Tok2Cmdname (int tok)
 
static int _gentable_sort_cmds (const void *a, const void *b)
 compares to entry of cmdsname-list More...
 
static int _texi_sort_cmds (const void *a, const void *b)
 
const char * iiTwoOps (int t)
 
int iiTestConvert (int inputType, int outputType)
 
void ttGen1 ()
 
void ttGen2b ()
 generate cmds initialisation More...
 
int is_ref_cmd (cmdnames *c)
 
void ttGen2c ()
 
void ttGen4 ()
 
int main (int argc, char **)
 

Variables

int produce_convert_table =0
 
char * iparith_inc
 

Data Structure Documentation

◆ _scmdnames

struct _scmdnames

Definition at line 51 of file gentable.cc.

Data Fields
short alias
const char * name
char * name
short toktype
short tokval

◆ sValCmd2

struct sValCmd2

Definition at line 61 of file gentable.cc.

Data Fields
short arg1
short arg2
short cmd
int p
proc2 p
short res
short valid_for

◆ sValCmd1

struct sValCmd1

Definition at line 70 of file gentable.cc.

Data Fields
short arg
short cmd
int p
proc1 p
short res
short valid_for

◆ sValCmd3

struct sValCmd3

Definition at line 78 of file gentable.cc.

Data Fields
short arg1
short arg2
short arg3
short cmd
int p
proc3 p
short res
short valid_for

◆ sValCmdM

struct sValCmdM

Definition at line 88 of file gentable.cc.

Data Fields
short cmd
short number_of_args
int p
proc1 p
short res
short valid_for

◆ sValAssign_sys

struct sValAssign_sys

Definition at line 96 of file gentable.cc.

Data Fields
short arg
int p
proc1 p
short res

◆ sValAssign

struct sValAssign

Definition at line 103 of file gentable.cc.

Data Fields
short arg
int p
proci p
short res

◆ sConvertTypes

struct sConvertTypes

Definition at line 110 of file gentable.cc.

Data Fields
int i_typ
int o_typ
iiConvertProc p
int p
iiConvertProcL pl
int pl

Macro Definition Documentation

◆ ALLOW_PLURAL

#define ALLOW_PLURAL   1

Definition at line 30 of file gentable.cc.

◆ ALLOW_RING

#define ALLOW_RING   4

Definition at line 35 of file gentable.cc.

◆ ALLOW_ZERODIVISOR

#define ALLOW_ZERODIVISOR   0

Definition at line 40 of file gentable.cc.

◆ ALLOW_ZZ

#define ALLOW_ZZ   (ALLOW_RING|NO_ZERODIVISOR)

Definition at line 43 of file gentable.cc.

◆ COMM_PLURAL

#define COMM_PLURAL   2

Definition at line 31 of file gentable.cc.

◆ D

#define D (   A)    2

Definition at line 123 of file gentable.cc.

◆ GENTABLE

#define GENTABLE

Definition at line 126 of file gentable.cc.

◆ IPARITH

#define IPARITH

Definition at line 125 of file gentable.cc.

◆ IPASSIGN

#define IPASSIGN

Definition at line 128 of file gentable.cc.

◆ IPCONV

#define IPCONV

Definition at line 127 of file gentable.cc.

◆ jjWRONG

#define jjWRONG   1

Definition at line 119 of file gentable.cc.

◆ jjWRONG2

#define jjWRONG2   1

Definition at line 120 of file gentable.cc.

◆ jjWRONG3

#define jjWRONG3   1

Definition at line 121 of file gentable.cc.

◆ NO_CONVERSION

#define NO_CONVERSION   32

Definition at line 48 of file gentable.cc.

◆ NO_PLURAL

#define NO_PLURAL   0

Definition at line 29 of file gentable.cc.

◆ NO_RING

#define NO_RING   0

Definition at line 36 of file gentable.cc.

◆ NO_ZERODIVISOR

#define NO_ZERODIVISOR   8

Definition at line 39 of file gentable.cc.

◆ NULL_VAL

#define NULL_VAL   0

Definition at line 124 of file gentable.cc.

◆ PLURAL_MASK

#define PLURAL_MASK   3

Definition at line 32 of file gentable.cc.

◆ WARN_RING

#define WARN_RING   16

Definition at line 46 of file gentable.cc.

◆ ZERODIVISOR_MASK

#define ZERODIVISOR_MASK   8

Definition at line 41 of file gentable.cc.

Function Documentation

◆ _gentable_sort_cmds()

static int _gentable_sort_cmds ( const void *  a,
const void *  b 
)
static

compares to entry of cmdsname-list

Parameters
[in]a
[in]b
Returns
<ReturnValue>

Definition at line 186 of file gentable.cc.

187 {
188  cmdnames *pCmdL = (cmdnames*)a;
189  cmdnames *pCmdR = (cmdnames*)b;
190 
191  if(a==NULL || b==NULL) return 0;
192 
193  /* empty entries goes to the end of the list for later reuse */
194  if(pCmdL->name==NULL) return 1;
195  if(pCmdR->name==NULL) return -1;
196 
197  /* $INVALID$ must come first */
198  if(strcmp(pCmdL->name, "$INVALID$")==0) return -1;
199  if(strcmp(pCmdR->name, "$INVALID$")==0) return 1;
200 
201  /* tokval=-1 are reserved names at the end */
202  if (pCmdL->tokval==-1)
203  {
204  if (pCmdR->tokval==-1)
205  return strcmp(pCmdL->name, pCmdR->name);
206  /* pCmdL->tokval==-1, pCmdL goes at the end */
207  return 1;
208  }
209  /* pCmdR->tokval==-1, pCmdR goes at the end */
210  if(pCmdR->tokval==-1) return -1;
211 
212  return strcmp(pCmdL->name, pCmdR->name);
213 }
const poly a
Definition: syzextra.cc:212
#define NULL
Definition: omList.c:10
const poly b
Definition: syzextra.cc:213

◆ _texi_sort_cmds()

static int _texi_sort_cmds ( const void *  a,
const void *  b 
)
static

Definition at line 215 of file gentable.cc.

216 {
217  cmdnames *pCmdL = (cmdnames*)a;
218  cmdnames *pCmdR = (cmdnames*)b;
219 
220  if(a==NULL || b==NULL) return 0;
221 
222  /* empty entries goes to the end of the list for later reuse */
223  if(pCmdL->name==NULL) return 1;
224  if(pCmdR->name==NULL) return -1;
225 
226  /* $INVALID$ must come first */
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);
231  char *s=ls;
232  while (*s) { *s=tolower(*s); s++; }
233  s=rs;
234  while (*s) { *s=tolower(*s); s++; }
235 
236  /* tokval=-1 are reserved names at the end */
237  if (pCmdL->tokval==-1)
238  {
239  if (pCmdR->tokval==-1)
240  { int r=strcmp(ls,rs); free(ls); free(rs); return r; }
241  /* pCmdL->tokval==-1, pCmdL goes at the end */
242  free(ls);free(rs);
243  return 1;
244  }
245  /* pCmdR->tokval==-1, pCmdR goes at the end */
246  if(pCmdR->tokval==-1)
247  { free(ls);free(rs);return -1;}
248 
249  { int r=strcmp(ls,rs); free(ls); free(rs); return r; }
250 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
const poly a
Definition: syzextra.cc:212
const ring r
Definition: syzextra.cc:208
#define free
Definition: omAllocFunc.c:12
#define strdup
Definition: omAllocFunc.c:17
#define NULL
Definition: omList.c:10
const poly b
Definition: syzextra.cc:213

◆ iiTestConvert()

int iiTestConvert ( int  inputType,
int  outputType 
)

Definition at line 293 of file gentable.cc.

294 {
295  if ((inputType==outputType)
296  || (outputType==DEF_CMD)
297  || (outputType==IDHDL)
298  || (outputType==ANY_TYPE))
299  {
300  return -1;
301  }
302  if (inputType==UNKNOWN) return 0;
303 
304  // search the list
305  int i=0;
306  while (dConvertTypes[i].i_typ!=0)
307  {
308  if((dConvertTypes[i].i_typ==inputType)
309  &&(dConvertTypes[i].o_typ==outputType))
310  {
311  //Print("test convert %d to %d (%s -> %s):%d\n",inputType,outputType,
312  //Tok2Cmdname(inputType), Tok2Cmdname(outputType),i+1);
313  return i+1;
314  }
315  i++;
316  }
317  //Print("test convert %d to %d (%s -> %s):0\n",inputType,outputType,
318  // Tok2Cmdname(inputType), Tok2Cmdname(outputType));
319  return 0;
320 }
#define ANY_TYPE
Definition: tok.h:30
const struct sConvertTypes dConvertTypes[]
Definition: table.h:1186
#define UNKNOWN
Definition: tok.h:217
#define IDHDL
Definition: tok.h:31
Definition: tok.h:58
int i
Definition: cfEzgcd.cc:123

◆ iiTwoOps()

const char* iiTwoOps ( int  t)

Definition at line 253 of file gentable.cc.

254 {
255  if (t<127)
256  {
257  static char ch[2];
258  switch (t)
259  {
260  case '&':
261  return "and";
262  case '|':
263  return "or";
264  default:
265  ch[0]=t;
266  ch[1]='\0';
267  return ch;
268  }
269  }
270  switch (t)
271  {
272  case COLONCOLON: return "::";
273  case DOTDOT: return "..";
274  //case PLUSEQUAL: return "+=";
275  //case MINUSEQUAL: return "-=";
276  case MINUSMINUS: return "--";
277  case PLUSPLUS: return "++";
278  case EQUAL_EQUAL: return "==";
279  case LE: return "<=";
280  case GE: return ">=";
281  case NOTEQUAL: return "<>";
282  default: return Tok2Cmdname(t);
283  }
284 }
Definition: grammar.cc:270
Definition: grammar.cc:269
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:132

◆ is_ref_cmd()

int is_ref_cmd ( cmdnames *  c)

Definition at line 610 of file gentable.cc.

611 {
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)
618  || (c->toktype==CMD_12)
619  || (c->toktype==CMD_13)
620  || (c->toktype==CMD_23)
621  || (c->toktype==CMD_123)) return 1;
622  return 0;
623 }

◆ main()

int main ( int  argc,
char **   
)

Definition at line 935 of file gentable.cc.

936 {
937  if (argc>1)
938  {
939  produce_convert_table=1; /* for ttGen1 */
940  ttGen1();
941  unlink(iparith_inc);
942  ttGen4();
943  ttGen2c();
944  }
945  else
946  {
947  ttGen1();
948  ttGen2b();
949  rename(iparith_inc,"iparith.inc");
950  }
951  return 0;
952 }
int produce_convert_table
Definition: gentable.cc:26
void ttGen1()
Definition: gentable.cc:322
char * iparith_inc
Definition: gentable.cc:321
void ttGen2b()
generate cmds initialisation
Definition: gentable.cc:528
void ttGen4()
Definition: gentable.cc:800
void ttGen2c()
Definition: gentable.cc:624

◆ RingDependend()

int RingDependend ( int  t)
inline

Definition at line 23 of file gentable.cc.

23 { return (BEGIN_RING<t)&&(t<END_RING); }

◆ Tok2Cmdname()

const char* Tok2Cmdname ( int  tok)

Definition at line 132 of file gentable.cc.

133 {
134  if (tok < 0)
135  {
136  return cmds[0].name;
137  }
138  if (tok==COMMAND) return "command";
139  if (tok==ANY_TYPE) return "any_type";
140  if (tok==NONE) return "nothing";
141  //if (tok==IFBREAK) return "if_break";
142  //if (tok==VECTOR_FROM_POLYS) return "vector_from_polys";
143  //if (tok==ORDER_VECTOR) return "ordering";
144  //if (tok==REF_VAR) return "ref";
145  //if (tok==OBJECT) return "object";
146  //if (tok==PRINT_EXPR) return "print_expr";
147  if (tok==IDHDL) return "identifier";
148  // we do not blackbox objects during table generation:
149  //if (tok>MAX_TOK) return getBlackboxName(tok);
150  int i = 0;
151  while (cmds[i].tokval!=0)
152  {
153  if ((cmds[i].tokval == tok)&&(cmds[i].alias==0))
154  {
155  return cmds[i].name;
156  }
157  i++;
158  }
159  i=0;// try again for old/alias names:
160  while (cmds[i].tokval!=0)
161  {
162  if (cmds[i].tokval == tok)
163  {
164  return cmds[i].name;
165  }
166  i++;
167  }
168  #if 0
169  char *s=(char*)malloc(10);
170  sprintf(s,"(%d)",tok);
171  return s;
172  #else
173  return cmds[0].name;
174  #endif
175 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define ANY_TYPE
Definition: tok.h:30
#define IDHDL
Definition: tok.h:31
void * malloc(size_t size)
Definition: omalloc.c:92
int i
Definition: cfEzgcd.cc:123
cmdnames cmds[]
Definition: table.h:904
#define NONE
Definition: tok.h:216
#define COMMAND
Definition: tok.h:29

◆ ttGen1()

void ttGen1 ( )

Definition at line 322 of file gentable.cc.

323 {
324  iparith_inc=strdup("iparith.xxxxxx");
325  int pid=getpid();
326  iparith_inc[8]=(pid %10)+'0'; pid/=10;
327  iparith_inc[9]=(pid %10)+'0'; pid/=10;
328  iparith_inc[10]=(pid %10)+'0'; pid/=10;
329  iparith_inc[11]=(pid %10)+'0'; pid/=10;
330  iparith_inc[12]=(pid %10)+'0'; pid/=10;
331  iparith_inc[13]=(pid %10)+'0';
332  FILE *outfile = fopen(iparith_inc,"w");
333  int i,j,l1=0,l2=0;
334  fprintf(outfile,
335  "/****************************************\n"
336  "* Computer Algebra System SINGULAR *\n"
337  "****************************************/\n\n");
338 /*-------------------------------------------------------------------*/
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");
344 
345  int op;
346  i=0;
347  while ((op=dArith1[i].cmd)!=0)
348  {
349  if (dArith1[i].p==jjWRONG)
350  fprintf(outfile,"// DUMMY ");
351  const char *s = iiTwoOps(op);
352  fprintf(outfile,"// operation: %s (%s) -> %s\n",
353  s,
354  Tok2Cmdname(dArith1[i].arg),
355  Tok2Cmdname(dArith1[i].res));
356  if (RingDependend(dArith1[i].res) && (!RingDependend(dArith1[i].arg)))
357  {
358  fprintf(outfile,"// WARNING: %s requires currRing\n",s);
359  }
360  i++;
361  }
362  fprintf(outfile,"/*---------------------------------------------*/\n");
363  i=0;
364  while ((op=dArith2[i].cmd)!=0)
365  {
366  if (dArith2[i].p==jjWRONG2)
367  fprintf(outfile,"// DUMMY ");
368  const char *s = iiTwoOps(op);
369  fprintf(outfile,"// operation: %s (%s, %s) -> %s\n",
370  s,
371  Tok2Cmdname(dArith2[i].arg1),
372  Tok2Cmdname(dArith2[i].arg2),
373  Tok2Cmdname(dArith2[i].res));
374  if (RingDependend(dArith2[i].res)
375  && (!RingDependend(dArith2[i].arg1))
376  && (!RingDependend(dArith2[i].arg2)))
377  {
378  fprintf(outfile,"// WARNING: %s requires currRing\n",s);
379  }
380  i++;
381  }
382  fprintf(outfile,"/*---------------------------------------------*/\n");
383  i=0;
384  while ((op=dArith3[i].cmd)!=0)
385  {
386  const char *s = iiTwoOps(op);
387  if (dArith3[i].p==jjWRONG3)
388  fprintf(outfile,"// DUMMY ");
389  fprintf(outfile,"// operation: %s (%s, %s, %s) -> %s\n",
390  s,
391  Tok2Cmdname(dArith3[i].arg1),
392  Tok2Cmdname(dArith3[i].arg2),
393  Tok2Cmdname(dArith3[i].arg3),
394  Tok2Cmdname(dArith3[i].res));
395  if (RingDependend(dArith3[i].res)
396  && (!RingDependend(dArith3[i].arg1))
397  && (!RingDependend(dArith3[i].arg2))
398  && (!RingDependend(dArith3[i].arg3)))
399  {
400  fprintf(outfile,"// WARNING: %s requires currRing\n",s);
401  }
402  i++;
403  }
404  fprintf(outfile,"/*---------------------------------------------*/\n");
405  i=0;
406  while ((op=dArithM[i].cmd)!=0)
407  {
408  const char *s = iiTwoOps(op);
409  fprintf(outfile,"// operation: %s (...) -> %s",
410  s,
411  Tok2Cmdname(dArithM[i].res));
412  switch(dArithM[i].number_of_args)
413  {
414  case -2:
415  fprintf(outfile," ( number of arguments >0 )\n");
416  break;
417  case -1:
418  fprintf(outfile," ( any number of arguments )\n");
419  break;
420  default:
421  fprintf(outfile," ( %d arguments )\n",dArithM[i].number_of_args);
422  break;
423  }
424  i++;
425  }
426  fprintf(outfile,"/*---------------------------------------------*/\n");
427  i=0;
428  while ((op=dAssign[i].res)!=0)
429  {
430  fprintf(outfile,"// assign: %s = %s\n",
431  Tok2Cmdname(op/*dAssign[i].res*/),
432  Tok2Cmdname(dAssign[i].arg));
433  i++;
434  }
435 /*-------------------------------------------------------------------*/
436  fprintf(outfile,"/*---------------------------------------------*/\n");
437  FILE *doctable;
439  {
440  doctable=fopen("convert_table.texi","w");
441  fprintf(doctable,"@multitable @columnfractions .05 .18 .81\n");
442  }
443  int doc_nr=1;
444  for (j=257;j<=MAX_TOK+1;j++)
445  {
446  for(i=257;i<=MAX_TOK+1;i++)
447  {
448  if ((i!=j) && (j!=IDHDL) && (j!=DEF_CMD) && (j!=ANY_TYPE)
449  && iiTestConvert(i,j))
450  {
451  fprintf(outfile,"// convert %s -> %s\n",
452  Tok2Cmdname(i), Tok2Cmdname(j));
454  {
455  fprintf(doctable,
456  "@item\n@ %d. @tab @code{%s} @tab @expansion{} @code{%s}\n",
457  doc_nr,Tok2Cmdname(i),Tok2Cmdname(j));
458  doc_nr++;
459  }
460  if (j==ANY_TYPE) break;
461  }
462  }
463  }
465  {
466  fprintf(doctable,"@end multitable\n");
467  fclose(doctable);
468  }
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]);
473  for (i=257;i<=MAX_TOK;i++)
474  {
475  const char *s=iiTwoOps(i);
476  if (s[0]!='$')
477  {
478  fprintf(outfile,"// token %d : %s\n", i, s);
479  }
480  }
481 /*-------------------------------------------------------------------*/
482  fprintf(outfile,"/*--max. token: %d, gr: %d --*/\n",MAX_TOK,UMINUS);
483 /*-------------------------------------------------------------------*/
484  fprintf(outfile,"/*---------------------------------------------*/\n");
485  fprintf(outfile,
486  "const struct sValCmdTab dArithTab1[]=\n"
487  "{\n");
488  for (j=1;j<=MAX_TOK+1;j++)
489  {
490  for(i=0;dArith1[i].cmd!=0;i++)
491  {
492  if (dArith1[i].cmd==j)
493  {
494  fprintf(outfile," { %d,%d },\n",j,i);
495  l1++;
496  break;
497  }
498  }
499  }
500  fprintf(outfile," { 10000,0 }\n};\n");
501  fprintf(outfile,"#define JJTAB1LEN %d\n",l1);
502 /*-------------------------------------------------------------------*/
503  fprintf(outfile,
504  "const struct sValCmdTab dArithTab2[]=\n"
505  "{\n");
506  for (j=1;j<=MAX_TOK+1;j++)
507  {
508  for(i=0;dArith2[i].cmd!=0;i++)
509  {
510  if (dArith2[i].cmd==j)
511  {
512  fprintf(outfile," { %d,%d },\n",j,i);
513  l2++;
514  break;
515  }
516  }
517  }
518  fprintf(outfile," { 10000,0 }\n};\n");
519  fprintf(outfile,"#define JJTAB2LEN %d\n",l2);
520  fclose(outfile);
521 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
int iiTestConvert(int inputType, int outputType)
Definition: gentable.cc:293
#define ANY_TYPE
Definition: tok.h:30
return P p
Definition: myNF.cc:203
Definition: tok.h:213
const struct sValCmd2 dArith2[]
Definition: table.h:291
const struct sValCmdM dArithM[]
Definition: table.h:826
short cmd
Definition: gentable.cc:64
#define IDHDL
Definition: tok.h:31
poly res
Definition: myNF.cc:322
const struct sValCmd3 dArith3[]
Definition: table.h:716
int RingDependend(int t)
Definition: gentable.cc:23
int produce_convert_table
Definition: gentable.cc:26
short cmd
Definition: gentable.cc:73
const char * iiTwoOps(int t)
Definition: gentable.cc:253
int j
Definition: myNF.cc:70
Definition: tok.h:58
const struct sValAssign dAssign[]
Definition: table.h:1267
int i
Definition: cfEzgcd.cc:123
#define strdup
Definition: omAllocFunc.c:17
#define jjWRONG3
Definition: gentable.cc:121
char * iparith_inc
Definition: gentable.cc:321
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:132
#define jjWRONG2
Definition: gentable.cc:120
#define jjWRONG
Definition: gentable.cc:119
const struct sValCmd1 dArith1[]
Definition: table.h:19

◆ ttGen2b()

void ttGen2b ( )

generate cmds initialisation

Definition at line 528 of file gentable.cc.

529 {
530  int cmd_size = (sizeof(cmds)/sizeof(cmdnames))-1;
531 
532  FILE *outfile = fopen(iparith_inc,"a");
533  fprintf(outfile,
534  "/****************************************\n"
535  "* Computer Algebra System SINGULAR *\n"
536  "****************************************/\n\n");
537 /*-------------------------------------------------------------------*/
538  fprintf(outfile,"// identifier table for Singular\n//\n");
539 
540  fprintf(
541  outfile,
542  "#ifdef MODULE_GENERATOR\n"
543  "#define omAlloc0(A) malloc(A)\n"
544  "#endif\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"
549  "\n"
550  " // name-string alias tokval toktype index\n",
551  cmd_size);
552  int m=0;
553  int id_nr=0;
554 
555  qsort(&cmds, cmd_size, sizeof(cmdnames), (&_gentable_sort_cmds));
556 
557  for(m=0; m<cmd_size; m++)
558  {
559  if(cmds[m].tokval>0) id_nr++;
560  fprintf(outfile," iiArithAddCmd(\"%s\", %*d, %3d, ",cmds[m].name,
561  (int)(20-strlen(cmds[m].name)),
562  cmds[m].alias,
563  cmds[m].tokval);
564  switch(cmds[m].toktype)
565  {
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;
575  case ROOT_DECL_LIST: fprintf(outfile,"ROOT_DECL_LIST"); break;
576  case RING_DECL: fprintf(outfile,"RING_DECL"); break;
577  case NONE: fprintf(outfile,"NONE"); break;
578  default:
579  if((cmds[m].toktype>' ') &&(cmds[m].toktype<127))
580  {
581  fprintf(outfile,"'%c'",cmds[m].toktype);
582  }
583  else
584  {
585  fprintf(outfile,"%d",cmds[m].toktype);
586  }
587  break;
588 #if 0
589  fprintf(outfile," iiArithAddCmd(\"%s\", %*d, -1, 0 );\n",
590  cmds[m].name, 20-strlen(cmds[m].name),
591  0/*cmds[m].alias*/
592  /*-1 cmds[m].tokval*/
593  /*0 cmds[m].toktype*/);
594 #endif
595  }
596  fprintf(outfile,", %d);\n", m);
597  }
598  fprintf(outfile, "/* end of list marker */\n");
599  fprintf(outfile,
600  " sArithBase.nLastIdentifier = %d;\n",
601  id_nr);
602 
603 
604  fprintf(outfile,
605 "}\n"
606 "#define LAST_IDENTIFIER %d\n"
607  ,id_nr);
608  fclose(outfile);
609 }
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
Definition: gentable.cc:186
int m
Definition: cfEzgcd.cc:119
char name(const Variable &v)
Definition: factory.h:178
cmdnames cmds[]
Definition: table.h:904
char * iparith_inc
Definition: gentable.cc:321
#define NONE
Definition: tok.h:216

◆ ttGen2c()

void ttGen2c ( )

Definition at line 624 of file gentable.cc.

625 {
626  int cmd_size = (sizeof(cmds)/sizeof(cmdnames))-1;
627 
628  FILE *outfile = fopen("reference_table.texi","w");
629  fprintf(outfile, "@menu\n");
630 /*-------------------------------------------------------------------*/
631  qsort(&cmds, cmd_size, sizeof(cmdnames), (&_texi_sort_cmds));
632 
633  int m;
634  for(m=0; m<cmd_size; m++)
635  {
636  // assume that cmds[0].tokval== -1 and all others with tokval -1 at the end
637  if(is_ref_cmd(&(cmds[m])))
638  {
639  fprintf(outfile,"* %s::\n",cmds[m].name);
640  }
641  }
642  fprintf(outfile, "@end menu\n@c ---------------------------\n");
643  for(m=0; m<cmd_size; m++)
644  {
645  // assume that cmds[0].tokval== -1 and all others with tokval -1 at the end
646  if(is_ref_cmd(&(cmds[m])))
647  {
648  fprintf(outfile,"@node %s,",cmds[m].name);
649  // next:
650  int mm=m-1;
651  while((mm>0)&& (is_ref_cmd(&cmds[mm]))) mm--;
652  if((mm>0)&& (is_ref_cmd(&cmds[mm])))
653  fprintf(outfile,"%s,",cmds[mm].name);
654  else
655  fprintf(outfile,",");
656  // prev:
657  mm=m+1;
658  while((mm>0)&& (is_ref_cmd(&cmds[mm]))) mm++;
659  if((mm>0)&& (is_ref_cmd(&cmds[mm])))
660  fprintf(outfile,"%s,",cmds[m-1].name);
661  else
662  fprintf(outfile,",");
663  // up:, and header
664  fprintf(outfile,"Functions\n"
665  "@subsection %s\n"
666  "@cindex %s\n",cmds[m].name,cmds[m].name);
667  fprintf(outfile,"@include %s.part\n",cmds[m].name);
668  char partName[50];
669  sprintf(partName,"%s.part",cmds[m].name);
670  struct stat buf;
671  if (lstat(partName,&buf)!=0)
672  {
673  int op,i;
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");
677  if ((cmds[m].toktype==CMD_1)
678  || (cmds[m].toktype==CMD_12)
679  || (cmds[m].toktype==CMD_13)
680  || (cmds[m].toktype==CMD_123))
681  {
682  op= cmds[m].tokval;
683  i=0;
684  while ((dArith1[i].cmd!=op) && (dArith1[i].cmd!=0)) i++;
685  while (dArith1[i].cmd==op)
686  {
687  if (dArith1[i].p!=jjWRONG)
688  {
689  fprintf(part,"@code{%s (} %s @code{)}\n",cmds[m].name,Tok2Cmdname(dArith1[i].arg));
690  fprintf(part,"@item @strong{Type:}\n%s\n",Tok2Cmdname(dArith1[i].res));
691  if ((dArith1[i].valid_for & ALLOW_PLURAL)==0)
692  only_comm=1;
693  if ((dArith1[i].valid_for & ALLOW_RING)==0)
694  only_field=1;
695  if ((dArith1[i].valid_for & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
696  no_zerodiv=1;
697  }
698  i++;
699  }
700  }
701  if ((cmds[m].toktype==CMD_23)
702  || (cmds[m].toktype==CMD_12)
703  || (cmds[m].toktype==CMD_2)
704  || (cmds[m].toktype==CMD_123))
705  {
706  op= cmds[m].tokval;
707  i=0;
708  while ((dArith2[i].cmd!=op) && (dArith2[i].cmd!=0)) i++;
709  while (dArith2[i].cmd==op)
710  {
711  if (dArith2[i].p!=jjWRONG)
712  {
713  fprintf(part,"@code{%s (} %s, %s @code{)}\n",cmds[m].name,Tok2Cmdname(dArith2[i].arg1),Tok2Cmdname(dArith2[i].arg2));
714  fprintf(part,"@item @strong{Type:}\n%s\n",Tok2Cmdname(dArith2[i].res));
715  if ((dArith2[i].valid_for & ALLOW_PLURAL)==0)
716  only_comm=1;
717  if ((dArith2[i].valid_for & ALLOW_RING)==0)
718  only_field=1;
719  if ((dArith2[i].valid_for & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
720  no_zerodiv=1;
721  }
722  i++;
723  }
724  }
725  if ((cmds[m].toktype==CMD_23)
726  || (cmds[m].toktype==CMD_13)
727  || (cmds[m].toktype==CMD_3)
728  || (cmds[m].toktype==CMD_123))
729  {
730  op= cmds[m].tokval;
731  i=0;
732  while ((dArith3[i].cmd!=op) && (dArith3[i].cmd!=0)) i++;
733  while (dArith3[i].cmd==op)
734  {
735  if (dArith3[i].p!=jjWRONG)
736  {
737  fprintf(part,"@code{%s (} %s, %s, %s @code{)}\n",cmds[m].name,
738  Tok2Cmdname(dArith3[i].arg1),
739  Tok2Cmdname(dArith3[i].arg2),
740  Tok2Cmdname(dArith3[i].arg3));
741  fprintf(part,"@item @strong{Type:}\n%s\n",Tok2Cmdname(dArith3[i].res));
742  if ((dArith3[i].valid_for & ALLOW_PLURAL)==0)
743  only_comm=1;
744  if ((dArith3[i].valid_for & ALLOW_RING)==0)
745  only_field=1;
746  if ((dArith3[i].valid_for & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
747  no_zerodiv=1;
748  }
749  i++;
750  }
751  }
752  if (cmds[m].toktype==CMD_M)
753  {
754  op= cmds[m].tokval;
755  i=0;
756  while ((dArithM[i].cmd!=op) && (dArithM[i].cmd!=0)) i++;
757  while (dArithM[i].cmd==op)
758  {
759  if (dArithM[i].p!=jjWRONG)
760  {
761  fprintf(part,"@code{%s (} ... @code{)}\n",cmds[m].name);
762  fprintf(part,"@item @strong{Type:}\n%s\n",Tok2Cmdname(dArithM[i].res));
763  if ((dArithM[i].valid_for & ALLOW_PLURAL)==0)
764  only_comm=1;
765  if ((dArithM[i].valid_for & ALLOW_RING)==0)
766  only_field=1;
767  if ((dArithM[i].valid_for & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
768  no_zerodiv=1;
769  }
770  i++;
771  }
772  }
773  if (only_comm)
774  fprintf(part,"@item @strong{Remark:}\n"
775  "only for commutive polynomial rings\n");
776  if (only_field)
777  fprintf(part,"@item @strong{Remark:}\n"
778  "only for polynomial rings over fields\n");
779  if (no_zerodiv)
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"
784  "@smallexample\n"
785  "@c example\n"
786  "@c example\n"
787  "@end smallexample\n"
788  "@c ref\n"
789  "@c See\n"
790  "@c ref{....};\n"
791  "@c ref{....}.\n"
792  "@c ref\n");
793  fclose(part);
794  }
795  }
796  }
797  fclose(outfile);
798 }
#define ALLOW_PLURAL
Definition: gentable.cc:30
return P p
Definition: myNF.cc:203
#define ZERODIVISOR_MASK
Definition: gentable.cc:41
#define NO_ZERODIVISOR
Definition: gentable.cc:39
const struct sValCmd2 dArith2[]
Definition: table.h:291
const struct sValCmdM dArithM[]
Definition: table.h:826
poly res
Definition: myNF.cc:322
const struct sValCmd3 dArith3[]
Definition: table.h:716
int status int void * buf
Definition: si_signals.h:59
static int _texi_sort_cmds(const void *a, const void *b)
Definition: gentable.cc:215
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
char name(const Variable &v)
Definition: factory.h:178
cmdnames cmds[]
Definition: table.h:904
#define ALLOW_RING
Definition: gentable.cc:35
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:132
#define jjWRONG
Definition: gentable.cc:119
const struct sValCmd1 dArith1[]
Definition: table.h:19
int is_ref_cmd(cmdnames *c)
Definition: gentable.cc:610

◆ ttGen4()

void ttGen4 ( )

Definition at line 800 of file gentable.cc.

801 {
802  FILE *outfile = fopen("plural_cmd.xx","w");
803  int i;
804  const char *old_s="";
805  fprintf(outfile,
806  "@c *****************************************\n"
807  "@c * Computer Algebra System SINGULAR *\n"
808  "@c *****************************************\n\n");
809 /*-------------------------------------------------------------------*/
810  fprintf(outfile,"@multicolumn .45 .45\n");
811  int op;
812  i=0;
813  while ((op=dArith1[i].cmd)!=0)
814  {
815  if (dArith1[i].p!=jjWRONG)
816  {
817  const char *s = iiTwoOps(op);
818  if ((s!=NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
819  {
820  old_s=s;
821  #ifdef HAVE_PLURAL
822  switch (dArith1[i].valid_for & PLURAL_MASK)
823  {
824  case NO_PLURAL:
825  fprintf(outfile,"@item @ref{%s} @tab @code{---}\n",s);
826  break;
827  case ALLOW_PLURAL:
828  fprintf(outfile,"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
829  break;
830  case COMM_PLURAL:
831  fprintf(outfile,"@item @ref{%s} @tab %s\n",s,s);
832  break;
833  }
834  #endif
835  #ifdef HAVE_RINGS
836  #endif
837  }
838  }
839  i++;
840  }
841  fprintf(outfile,"@c ---------------------------------------------\n");
842  i=0;
843  while ((op=dArith2[i].cmd)!=0)
844  {
845  if (dArith2[i].p!=jjWRONG2)
846  {
847  const char *s = iiTwoOps(op);
848  if ((s!=NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
849  {
850  old_s=s;
851  #ifdef HAVE_PLURAL
852  switch (dArith2[i].valid_for & PLURAL_MASK)
853  {
854  case NO_PLURAL:
855  fprintf(outfile,"@item @ref{%s} @tab @code{---}\n",s);
856  break;
857  case ALLOW_PLURAL:
858  fprintf(outfile,"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
859  break;
860  case COMM_PLURAL:
861  fprintf(outfile,"@item @ref{%s} @tab %s\n",s,s);
862  break;
863  }
864  #endif
865  #ifdef HAVE_RINGS
866  #endif
867  }
868  }
869  i++;
870  }
871  fprintf(outfile,"@c ---------------------------------------------\n");
872  i=0;
873  while ((op=dArith3[i].cmd)!=0)
874  {
875  const char *s = iiTwoOps(op);
876  if (dArith3[i].p!=jjWRONG3)
877  {
878  if ((s!=NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
879  {
880  old_s=s;
881  #ifdef HAVE_PLURAL
882  switch (dArith3[i].valid_for & PLURAL_MASK)
883  {
884  case NO_PLURAL:
885  fprintf(outfile,"@item @ref{%s} @tab @code{---}\n",s);
886  break;
887  case ALLOW_PLURAL:
888  fprintf(outfile,"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
889  break;
890  case COMM_PLURAL:
891  fprintf(outfile,"@item @ref{%s} @tab %s\n",s,s);
892  break;
893  }
894  #endif
895  #ifdef HAVE_RINGS
896  #endif
897  }
898  }
899  i++;
900  }
901  fprintf(outfile,"@c ---------------------------------------------\n");
902  i=0;
903  while ((op=dArithM[i].cmd)!=0)
904  {
905  const char *s = iiTwoOps(op);
906  if ((s!=NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
907  {
908  old_s=s;
909  #ifdef HAVE_PLURAL
910  switch (dArithM[i].valid_for & PLURAL_MASK)
911  {
912  case NO_PLURAL:
913  fprintf(outfile,"@item @ref{%s} @tab @code{---}\n",s);
914  break;
915  case ALLOW_PLURAL:
916  fprintf(outfile,"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
917  break;
918  case COMM_PLURAL:
919  fprintf(outfile,"@item @ref{%s} @tab %s\n",s,s);
920  break;
921  }
922  #endif
923  #ifdef HAVE_RINGS
924  #endif
925  }
926  i++;
927  }
928  fprintf(outfile,"@c ---------------------------------------------\n");
929  fprintf(outfile,"@end table\n");
930  fclose(outfile);
931  rename("plural_cmd.xx","plural_cmd.inc");
932 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define ALLOW_PLURAL
Definition: gentable.cc:30
return P p
Definition: myNF.cc:203
const struct sValCmd2 dArith2[]
Definition: table.h:291
const struct sValCmdM dArithM[]
Definition: table.h:826
const struct sValCmd3 dArith3[]
Definition: table.h:716
const char * iiTwoOps(int t)
Definition: gentable.cc:253
#define COMM_PLURAL
Definition: gentable.cc:31
int i
Definition: cfEzgcd.cc:123
#define jjWRONG3
Definition: gentable.cc:121
#define PLURAL_MASK
Definition: gentable.cc:32
#define NULL
Definition: omList.c:10
#define jjWRONG2
Definition: gentable.cc:120
#define jjWRONG
Definition: gentable.cc:119
const struct sValCmd1 dArith1[]
Definition: table.h:19
#define NO_PLURAL
Definition: gentable.cc:29

Variable Documentation

◆ iparith_inc

char* iparith_inc

Definition at line 321 of file gentable.cc.

◆ produce_convert_table

int produce_convert_table =0

Definition at line 26 of file gentable.cc.