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 WARN_RING   16
 
#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 **argv)
 

Variables

int produce_convert_table =0
 
char * iparith_inc
 

Data Structure Documentation

§ _scmdnames

struct _scmdnames

Definition at line 47 of file gentable.cc.

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

§ sValCmd2

struct sValCmd2

Definition at line 57 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 66 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 74 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 84 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 92 of file gentable.cc.

Data Fields
short arg
int p
proc1 p
short res

§ sValAssign

struct sValAssign

Definition at line 99 of file gentable.cc.

Data Fields
short arg
int p
proci p
short res

§ sConvertTypes

struct sConvertTypes

Definition at line 106 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.

§ COMM_PLURAL

#define COMM_PLURAL   2

Definition at line 31 of file gentable.cc.

§ D

#define D (   A)    2

Definition at line 119 of file gentable.cc.

§ GENTABLE

#define GENTABLE

Definition at line 122 of file gentable.cc.

§ IPARITH

#define IPARITH

Definition at line 121 of file gentable.cc.

§ IPASSIGN

#define IPASSIGN

Definition at line 124 of file gentable.cc.

§ IPCONV

#define IPCONV

Definition at line 123 of file gentable.cc.

§ jjWRONG

#define jjWRONG   1

Definition at line 115 of file gentable.cc.

§ jjWRONG2

#define jjWRONG2   1

Definition at line 116 of file gentable.cc.

§ jjWRONG3

#define jjWRONG3   1

Definition at line 117 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 120 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 44 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 185 of file gentable.cc.

186 {
187  cmdnames *pCmdL = (cmdnames*)a;
188  cmdnames *pCmdR = (cmdnames*)b;
189 
190  if(a==NULL || b==NULL) return 0;
191 
192  /* empty entries goes to the end of the list for later reuse */
193  if(pCmdL->name==NULL) return 1;
194  if(pCmdR->name==NULL) return -1;
195 
196  /* $INVALID$ must come first */
197  if(strcmp(pCmdL->name, "$INVALID$")==0) return -1;
198  if(strcmp(pCmdR->name, "$INVALID$")==0) return 1;
199 
200  /* tokval=-1 are reserved names at the end */
201  if (pCmdL->tokval==-1)
202  {
203  if (pCmdR->tokval==-1)
204  return strcmp(pCmdL->name, pCmdR->name);
205  /* pCmdL->tokval==-1, pCmdL goes at the end */
206  return 1;
207  }
208  /* pCmdR->tokval==-1, pCmdR goes at the end */
209  if(pCmdR->tokval==-1) return -1;
210 
211  return strcmp(pCmdL->name, pCmdR->name);
212 }
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 214 of file gentable.cc.

215 {
216  cmdnames *pCmdL = (cmdnames*)a;
217  cmdnames *pCmdR = (cmdnames*)b;
218 
219  if(a==NULL || b==NULL) return 0;
220 
221  /* empty entries goes to the end of the list for later reuse */
222  if(pCmdL->name==NULL) return 1;
223  if(pCmdR->name==NULL) return -1;
224 
225  /* $INVALID$ must come first */
226  if(strcmp(pCmdL->name, "$INVALID$")==0) return -1;
227  if(strcmp(pCmdR->name, "$INVALID$")==0) return 1;
228  char *ls=strdup(pCmdL->name);
229  char *rs=strdup(pCmdR->name);
230  char *s=ls;
231  while (*s) { *s=tolower(*s); s++; }
232  s=rs;
233  while (*s) { *s=tolower(*s); s++; }
234 
235  /* tokval=-1 are reserved names at the end */
236  if (pCmdL->tokval==-1)
237  {
238  if (pCmdR->tokval==-1)
239  { int r=strcmp(ls,rs); free(ls); free(rs); return r; }
240  /* pCmdL->tokval==-1, pCmdL goes at the end */
241  free(ls);free(rs);
242  return 1;
243  }
244  /* pCmdR->tokval==-1, pCmdR goes at the end */
245  if(pCmdR->tokval==-1)
246  { free(ls);free(rs);return -1;}
247 
248  { int r=strcmp(ls,rs); free(ls); free(rs); return r; }
249 }
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 292 of file gentable.cc.

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

§ iiTwoOps()

const char* iiTwoOps ( int  t)

Definition at line 252 of file gentable.cc.

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

§ is_ref_cmd()

int is_ref_cmd ( cmdnames *  c)

Definition at line 609 of file gentable.cc.

610 {
611  if( c->tokval==0) return 0;
612  if (c->alias > 0) return 0;
613  if ((c->toktype==CMD_1)
614  || (c->toktype==CMD_2)
615  || (c->toktype==CMD_3)
616  || (c->toktype==CMD_M)
617  || (c->toktype==CMD_12)
618  || (c->toktype==CMD_13)
619  || (c->toktype==CMD_23)
620  || (c->toktype==CMD_123)) return 1;
621  return 0;
622 }

§ main()

int main ( int  argc,
char **  argv 
)

Definition at line 934 of file gentable.cc.

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

§ 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 128 of file gentable.cc.

129 {
130  if (tok < 0)
131  {
132  return cmds[0].name;
133  }
134  if (tok==COMMAND) return "command";
135  if (tok==ANY_TYPE) return "any_type";
136  if (tok==NONE) return "nothing";
137  //if (tok==IFBREAK) return "if_break";
138  //if (tok==VECTOR_FROM_POLYS) return "vector_from_polys";
139  //if (tok==ORDER_VECTOR) return "ordering";
140  //if (tok==REF_VAR) return "ref";
141  //if (tok==OBJECT) return "object";
142  //if (tok==PRINT_EXPR) return "print_expr";
143  if (tok==IDHDL) return "identifier";
144  #ifdef SINGULAR_4_1
145  //if (tok==CRING_CMD) return "Ring";
146  #endif
147  // we do not blackbox objects during table generation:
148  //if (tok>MAX_TOK) return getBlackboxName(tok);
149  int i = 0;
150  while (cmds[i].tokval!=0)
151  {
152  if ((cmds[i].tokval == tok)&&(cmds[i].alias==0))
153  {
154  return cmds[i].name;
155  }
156  i++;
157  }
158  i=0;// try again for old/alias names:
159  while (cmds[i].tokval!=0)
160  {
161  if (cmds[i].tokval == tok)
162  {
163  return cmds[i].name;
164  }
165  i++;
166  }
167  #if 0
168  char *s=(char*)malloc(10);
169  sprintf(s,"(%d)",tok);
170  return s;
171  #else
172  return cmds[0].name;
173  #endif
174 }
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:894
#define NONE
Definition: tok.h:216
#define COMMAND
Definition: tok.h:29

§ ttGen1()

void ttGen1 ( )

Definition at line 321 of file gentable.cc.

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

§ ttGen2b()

void ttGen2b ( )

generate cmds initialisation

Definition at line 527 of file gentable.cc.

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

§ ttGen2c()

void ttGen2c ( )

Definition at line 623 of file gentable.cc.

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

§ ttGen4()

void ttGen4 ( )

Definition at line 799 of file gentable.cc.

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

Variable Documentation

§ iparith_inc

char* iparith_inc

Definition at line 320 of file gentable.cc.

§ produce_convert_table

int produce_convert_table =0

Definition at line 26 of file gentable.cc.