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

struct _scmdnames

Definition at line 47 of file gentable.cc.

Data Fields
short alias
const char * name
char * name
short toktype
short tokval
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
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
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
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
struct sValAssign_sys

Definition at line 92 of file gentable.cc.

Data Fields
short arg
int p
proc1 p
short res
struct sValAssign

Definition at line 99 of file gentable.cc.

Data Fields
short arg
int p
proci p
short res
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

#define ALLOW_PLURAL   1

Definition at line 30 of file gentable.cc.

#define ALLOW_RING   4

Definition at line 35 of file gentable.cc.

#define ALLOW_ZERODIVISOR   0

Definition at line 40 of file gentable.cc.

#define COMM_PLURAL   2

Definition at line 31 of file gentable.cc.

#define D (   A)    2

Definition at line 119 of file gentable.cc.

#define GENTABLE

Definition at line 122 of file gentable.cc.

#define IPARITH

Definition at line 121 of file gentable.cc.

#define IPASSIGN

Definition at line 124 of file gentable.cc.

#define IPCONV

Definition at line 123 of file gentable.cc.

#define jjWRONG   1

Definition at line 115 of file gentable.cc.

#define jjWRONG2   1

Definition at line 116 of file gentable.cc.

#define jjWRONG3   1

Definition at line 117 of file gentable.cc.

#define NO_PLURAL   0

Definition at line 29 of file gentable.cc.

#define NO_RING   0

Definition at line 36 of file gentable.cc.

#define NO_ZERODIVISOR   8

Definition at line 39 of file gentable.cc.

#define NULL_VAL   0

Definition at line 120 of file gentable.cc.

#define PLURAL_MASK   3

Definition at line 32 of file gentable.cc.

#define WARN_RING   16

Definition at line 44 of file gentable.cc.

#define ZERODIVISOR_MASK   8

Definition at line 41 of file gentable.cc.

Function Documentation

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
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
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 
302  // search the list
303  int i=0;
304  while (dConvertTypes[i].i_typ!=0)
305  {
306  if((dConvertTypes[i].i_typ==inputType)
307  &&(dConvertTypes[i].o_typ==outputType))
308  {
309  //Print("test convert %d to %d (%s -> %s):%d\n",inputType,outputType,
310  //Tok2Cmdname(inputType), Tok2Cmdname(outputType),i+1);
311  return i+1;
312  }
313  i++;
314  }
315  //Print("test convert %d to %d (%s -> %s):0\n",inputType,outputType,
316  // Tok2Cmdname(inputType), Tok2Cmdname(outputType));
317  return 0;
318 }
#define ANY_TYPE
Definition: tok.h:34
#define IDHDL
Definition: tok.h:35
Definition: tok.h:58
int i
Definition: cfEzgcd.cc:123
struct sConvertTypes dConvertTypes[]
Definition: table.h:1170
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:271
Definition: grammar.cc:270
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:128
int is_ref_cmd ( cmdnames *  c)

Definition at line 608 of file gentable.cc.

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

Definition at line 933 of file gentable.cc.

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

Definition at line 23 of file gentable.cc.

23 { return (BEGIN_RING<t)&&(t<END_RING); }
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 "(c)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:34
#define IDHDL
Definition: tok.h:35
Definition: tok.h:56
void * malloc(size_t size)
Definition: omalloc.c:92
int i
Definition: cfEzgcd.cc:123
cmdnames cmds[]
Definition: table.h:886
#define NONE
Definition: tok.h:173
#define COMMAND
Definition: tok.h:33
void ttGen1 ( )

Definition at line 320 of file gentable.cc.

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

generate cmds initialisation

Definition at line 526 of file gentable.cc.

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

Definition at line 622 of file gentable.cc.

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

Definition at line 798 of file gentable.cc.

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

char* iparith_inc

Definition at line 319 of file gentable.cc.

int produce_convert_table =0

Definition at line 26 of file gentable.cc.