My Project  debian-1:4.1.1-p2+ds-4build4
Data Structures | Macros | Functions | Variables
gentable.cc File Reference
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <unistd.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 RING_MASK   4
 
#define ZERODIVISOR_MASK   8
 
#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 57 of file gentable.cc.

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

◆ sValCmd2

struct sValCmd2

Definition at line 67 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 76 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 84 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 94 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 102 of file gentable.cc.

Data Fields
short arg
int p
proc1 p
short res

◆ sValAssign

struct sValAssign

Definition at line 109 of file gentable.cc.

Data Fields
short arg
int p
proci p
short res

◆ sConvertTypes

struct sConvertTypes

Definition at line 116 of file gentable.cc.

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

Macro Definition Documentation

◆ ALLOW_PLURAL

#define ALLOW_PLURAL   1

Definition at line 36 of file gentable.cc.

◆ ALLOW_RING

#define ALLOW_RING   4

Definition at line 41 of file gentable.cc.

◆ ALLOW_ZERODIVISOR

#define ALLOW_ZERODIVISOR   0

Definition at line 46 of file gentable.cc.

◆ ALLOW_ZZ

#define ALLOW_ZZ   (ALLOW_RING|NO_ZERODIVISOR)

Definition at line 49 of file gentable.cc.

◆ COMM_PLURAL

#define COMM_PLURAL   2

Definition at line 37 of file gentable.cc.

◆ D

#define D (   A)    2

Definition at line 129 of file gentable.cc.

◆ GENTABLE

#define GENTABLE

Definition at line 132 of file gentable.cc.

◆ IPARITH

#define IPARITH

Definition at line 131 of file gentable.cc.

◆ IPASSIGN

#define IPASSIGN

Definition at line 134 of file gentable.cc.

◆ IPCONV

#define IPCONV

Definition at line 133 of file gentable.cc.

◆ jjWRONG

#define jjWRONG   1

Definition at line 125 of file gentable.cc.

◆ jjWRONG2

#define jjWRONG2   1

Definition at line 126 of file gentable.cc.

◆ jjWRONG3

#define jjWRONG3   1

Definition at line 127 of file gentable.cc.

◆ NO_CONVERSION

#define NO_CONVERSION   32

Definition at line 54 of file gentable.cc.

◆ NO_PLURAL

#define NO_PLURAL   0

Definition at line 35 of file gentable.cc.

◆ NO_RING

#define NO_RING   0

Definition at line 42 of file gentable.cc.

◆ NO_ZERODIVISOR

#define NO_ZERODIVISOR   8

Definition at line 45 of file gentable.cc.

◆ NULL_VAL

#define NULL_VAL   0

Definition at line 130 of file gentable.cc.

◆ PLURAL_MASK

#define PLURAL_MASK   3

Definition at line 38 of file gentable.cc.

◆ RING_MASK

#define RING_MASK   4

Definition at line 22 of file gentable.cc.

◆ WARN_RING

#define WARN_RING   16

Definition at line 52 of file gentable.cc.

◆ ZERODIVISOR_MASK [1/2]

#define ZERODIVISOR_MASK   8

Definition at line 47 of file gentable.cc.

◆ ZERODIVISOR_MASK [2/2]

#define ZERODIVISOR_MASK   8

Definition at line 47 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 192 of file gentable.cc.

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

◆ _texi_sort_cmds()

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

Definition at line 221 of file gentable.cc.

222 {
223  cmdnames *pCmdL = (cmdnames*)a;
224  cmdnames *pCmdR = (cmdnames*)b;
225 
226  if(a==NULL || b==NULL) return 0;
227 
228  /* empty entries goes to the end of the list for later reuse */
229  if(pCmdL->name==NULL) return 1;
230  if(pCmdR->name==NULL) return -1;
231 
232  /* $INVALID$ must come first */
233  if(strcmp(pCmdL->name, "$INVALID$")==0) return -1;
234  if(strcmp(pCmdR->name, "$INVALID$")==0) return 1;
235  char *ls=strdup(pCmdL->name);
236  char *rs=strdup(pCmdR->name);
237  char *s=ls;
238  while (*s) { *s=tolower(*s); s++; }
239  s=rs;
240  while (*s) { *s=tolower(*s); s++; }
241 
242  /* tokval=-1 are reserved names at the end */
243  if (pCmdL->tokval==-1)
244  {
245  if (pCmdR->tokval==-1)
246  { int r=strcmp(ls,rs); free(ls); free(rs); return r; }
247  /* pCmdL->tokval==-1, pCmdL goes at the end */
248  free(ls);free(rs);
249  return 1;
250  }
251  /* pCmdR->tokval==-1, pCmdR goes at the end */
252  if(pCmdR->tokval==-1)
253  { free(ls);free(rs);return -1;}
254 
255  { int r=strcmp(ls,rs); free(ls); free(rs); return r; }
256 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define free
Definition: omAllocFunc.c:12
#define strdup
Definition: omAllocFunc.c:17

◆ iiTestConvert()

int iiTestConvert ( int  inputType,
int  outputType 
)

Definition at line 299 of file gentable.cc.

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

◆ iiTwoOps()

const char* iiTwoOps ( int  t)

Definition at line 259 of file gentable.cc.

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

◆ is_ref_cmd()

int is_ref_cmd ( cmdnames *  c)

Definition at line 650 of file gentable.cc.

651 {
652  if( c->tokval==0) return 0;
653  if (c->alias > 0) return 0;
654  if ((c->toktype==CMD_1)
655  || (c->toktype==CMD_2)
656  || (c->toktype==CMD_3)
657  || (c->toktype==CMD_M)
658  || (c->toktype==CMD_12)
659  || (c->toktype==CMD_13)
660  || (c->toktype==CMD_23)
661  || (c->toktype==CMD_123)) return 1;
662  return 0;
663 }
@ CMD_1
Definition: grammar.cc:309
@ CMD_23
Definition: grammar.cc:314
@ CMD_2
Definition: grammar.cc:310
@ CMD_3
Definition: grammar.cc:311
@ CMD_123
Definition: grammar.cc:315
@ CMD_12
Definition: grammar.cc:312
@ CMD_13
Definition: grammar.cc:313
@ CMD_M
Definition: grammar.cc:316

◆ main()

int main ( int  argc,
char **   
)

Definition at line 975 of file gentable.cc.

976 {
977  if (argc>1)
978  {
979  produce_convert_table=1; /* for ttGen1 */
980  ttGen1();
981  unlink(iparith_inc);
982  ttGen4();
983  ttGen2c();
984  }
985  else
986  {
987  ttGen1();
988  ttGen2b();
989  rename(iparith_inc,"iparith.inc");
990  }
991  return 0;
992 }
char * iparith_inc
Definition: gentable.cc:327
int produce_convert_table
Definition: gentable.cc:32
void ttGen2c()
Definition: gentable.cc:664
void ttGen4()
Definition: gentable.cc:840
void ttGen2b()
generate cmds initialisation
Definition: gentable.cc:568
void ttGen1()
Definition: gentable.cc:328

◆ RingDependend()

int RingDependend ( int  t)
inline

Definition at line 29 of file gentable.cc.

29 { return (BEGIN_RING<t)&&(t<END_RING); }
@ END_RING
Definition: grammar.cc:308
@ BEGIN_RING
Definition: grammar.cc:282

◆ Tok2Cmdname()

const char* Tok2Cmdname ( int  tok)

Definition at line 138 of file gentable.cc.

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

◆ ttGen1()

void ttGen1 ( )

Definition at line 328 of file gentable.cc.

329 {
330  iparith_inc=strdup("iparith.xxxxxx");
331  int pid=getpid();
332  iparith_inc[8]=(pid %10)+'0'; pid/=10;
333  iparith_inc[9]=(pid %10)+'0'; pid/=10;
334  iparith_inc[10]=(pid %10)+'0'; pid/=10;
335  iparith_inc[11]=(pid %10)+'0'; pid/=10;
336  iparith_inc[12]=(pid %10)+'0'; pid/=10;
337  iparith_inc[13]=(pid %10)+'0';
338  FILE *outfile = fopen(iparith_inc,"w");
339  int i,j,l1=0,l2=0;
340  fprintf(outfile,
341  "/****************************************\n"
342  "* Computer Algebra System SINGULAR *\n"
343  "****************************************/\n\n");
344 /*-------------------------------------------------------------------*/
345  fprintf(outfile,"// syntax table for Singular\n//\n");
346  fprintf(outfile,"// - search for an exact match of the argument types\n");
347  fprintf(outfile,"// - otherwise search for the first possibility\n");
348  fprintf(outfile,"// with converted types of the arguments\n");
349  fprintf(outfile,"// - otherwise report an error\n//\n");
350 
351  int op;
352  i=0;
353  while ((op=dArith1[i].cmd)!=0)
354  {
355  if (dArith1[i].p==jjWRONG)
356  fprintf(outfile,"// DUMMY ");
357  const char *s = iiTwoOps(op);
358  fprintf(outfile,"// operation: %s (%s) -> %s",
359  s,
360  Tok2Cmdname(dArith1[i].arg),
362  if (RingDependend(dArith1[i].res) && (!RingDependend(dArith1[i].arg)))
363  fprintf(outfile," requires currRing");
364  if ((dArith1[i].valid_for & PLURAL_MASK)==2)
365  fprintf(outfile,", commutative subalgebra");
366  else if ((dArith1[i].valid_for & PLURAL_MASK)==0)
367  fprintf(outfile,", only commutative rings");
368  if ((dArith1[i].valid_for & RING_MASK)==0)
369  fprintf(outfile,", field coeffs");
370  else if ((dArith1[i].valid_for & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
371  fprintf(outfile,", domain coeffs");
372  else if ((dArith1[i].valid_for & WARN_RING)==WARN_RING)
373  fprintf(outfile,", QQ coeffs");
374 
375  fprintf(outfile,"\n");
376  i++;
377  }
378  fprintf(outfile,"/*---------------------------------------------*/\n");
379  i=0;
380  while ((op=dArith2[i].cmd)!=0)
381  {
382  if (dArith2[i].p==jjWRONG2)
383  fprintf(outfile,"// DUMMY ");
384  const char *s = iiTwoOps(op);
385  fprintf(outfile,"// operation: %s (%s, %s) -> %s",
386  s,
387  Tok2Cmdname(dArith2[i].arg1),
388  Tok2Cmdname(dArith2[i].arg2),
390  if (RingDependend(dArith2[i].res)
391  && (!RingDependend(dArith2[i].arg1))
392  && (!RingDependend(dArith2[i].arg2)))
393  {
394  fprintf(outfile," requires currRing");
395  }
396  if ((dArith2[i].valid_for & PLURAL_MASK)==2)
397  fprintf(outfile,", commutative subalgebra");
398  else if ((dArith2[i].valid_for & PLURAL_MASK)==0)
399  fprintf(outfile,", only commutative rings");
400  if ((dArith2[i].valid_for & RING_MASK)==0)
401  fprintf(outfile,", field coeffs");
402  else if ((dArith2[i].valid_for & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
403  fprintf(outfile,", domain coeffs");
404  else if ((dArith2[i].valid_for & WARN_RING)==WARN_RING)
405  fprintf(outfile,", QQ coeffs");
406 
407  fprintf(outfile,"\n");
408  i++;
409  }
410  fprintf(outfile,"/*---------------------------------------------*/\n");
411  i=0;
412  while ((op=dArith3[i].cmd)!=0)
413  {
414  const char *s = iiTwoOps(op);
415  if (dArith3[i].p==jjWRONG3)
416  fprintf(outfile,"// DUMMY ");
417  fprintf(outfile,"// operation: %s (%s, %s, %s) -> %s",
418  s,
419  Tok2Cmdname(dArith3[i].arg1),
420  Tok2Cmdname(dArith3[i].arg2),
421  Tok2Cmdname(dArith3[i].arg3),
423  if (RingDependend(dArith3[i].res)
424  && (!RingDependend(dArith3[i].arg1))
425  && (!RingDependend(dArith3[i].arg2))
426  && (!RingDependend(dArith3[i].arg3)))
427  {
428  fprintf(outfile," requires currRing");
429  }
430  if ((dArith3[i].valid_for & PLURAL_MASK)==2)
431  fprintf(outfile,", commutative subalgebra");
432  else if ((dArith3[i].valid_for & PLURAL_MASK)==0)
433  fprintf(outfile,", only commutative rings");
434  if ((dArith3[i].valid_for & RING_MASK)==0)
435  fprintf(outfile,", field coeffs");
436  else if ((dArith3[i].valid_for & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
437  fprintf(outfile,", domain coeffs");
438  else if ((dArith3[i].valid_for & WARN_RING)==WARN_RING)
439  fprintf(outfile,", QQ coeffs");
440 
441  fprintf(outfile,"\n");
442  i++;
443  }
444  fprintf(outfile,"/*---------------------------------------------*/\n");
445  i=0;
446  while ((op=dArithM[i].cmd)!=0)
447  {
448  const char *s = iiTwoOps(op);
449  fprintf(outfile,"// operation: %s (...) -> %s",
450  s,
452  switch(dArithM[i].number_of_args)
453  {
454  case -2:
455  fprintf(outfile," ( number of arguments >0 )\n");
456  break;
457  case -1:
458  fprintf(outfile," ( any number of arguments )\n");
459  break;
460  default:
461  fprintf(outfile," ( %d arguments )\n",dArithM[i].number_of_args);
462  break;
463  }
464  i++;
465  }
466  fprintf(outfile,"/*---------------------------------------------*/\n");
467  i=0;
468  while ((op=dAssign[i].res)!=0)
469  {
470  fprintf(outfile,"// assign: %s = %s\n",
471  Tok2Cmdname(op/*dAssign[i].res*/),
472  Tok2Cmdname(dAssign[i].arg));
473  i++;
474  }
475 /*-------------------------------------------------------------------*/
476  fprintf(outfile,"/*---------------------------------------------*/\n");
477  FILE *doctable=NULL; /*to silence "may be used uninitialized"*/
479  {
480  doctable=fopen("convert_table.texi","w");
481  fprintf(doctable,"@multitable @columnfractions .05 .18 .81\n");
482  }
483  int doc_nr=1;
484  for (j=257;j<=MAX_TOK+1;j++)
485  {
486  for(i=257;i<=MAX_TOK+1;i++)
487  {
488  if ((i!=j) && (j!=IDHDL) && (j!=DEF_CMD) && (j!=ANY_TYPE)
489  && iiTestConvert(i,j))
490  {
491  fprintf(outfile,"// convert %s -> %s\n",
494  {
495  fprintf(doctable,
496  "@item\n@ %d. @tab @code{%s} @tab @expansion{} @code{%s}\n",
497  doc_nr,Tok2Cmdname(i),Tok2Cmdname(j));
498  doc_nr++;
499  }
500  if (j==ANY_TYPE) break;
501  }
502  }
503  }
505  {
506  fprintf(doctable,"@end multitable\n");
507  fclose(doctable);
508  }
509  fprintf(outfile,"/*---------------------------------------------*/\n");
510  char ops[]="=><+*/[.^,%(;";
511  for(i=0;ops[i]!='\0';i++)
512  fprintf(outfile,"// token %d : %c\n", (int)ops[i], ops[i]);
513  for (i=257;i<=MAX_TOK;i++)
514  {
515  const char *s=iiTwoOps(i);
516  if (s[0]!='$')
517  {
518  fprintf(outfile,"// token %d : %s\n", i, s);
519  }
520  }
521 /*-------------------------------------------------------------------*/
522  fprintf(outfile,"/*--max. token: %d, gr: %d --*/\n",MAX_TOK,UMINUS);
523 /*-------------------------------------------------------------------*/
524  fprintf(outfile,"/*---------------------------------------------*/\n");
525  fprintf(outfile,
526  "const struct sValCmdTab dArithTab1[]=\n"
527  "{\n");
528  for (j=1;j<=MAX_TOK+1;j++)
529  {
530  for(i=0;dArith1[i].cmd!=0;i++)
531  {
532  if (dArith1[i].cmd==j)
533  {
534  fprintf(outfile," { %d,%d },\n",j,i);
535  l1++;
536  break;
537  }
538  }
539  }
540  fprintf(outfile," { 10000,0 }\n};\n");
541  fprintf(outfile,"#define JJTAB1LEN %d\n",l1);
542 /*-------------------------------------------------------------------*/
543  fprintf(outfile,
544  "const struct sValCmdTab dArithTab2[]=\n"
545  "{\n");
546  for (j=1;j<=MAX_TOK+1;j++)
547  {
548  for(i=0;dArith2[i].cmd!=0;i++)
549  {
550  if (dArith2[i].cmd==j)
551  {
552  fprintf(outfile," { %d,%d },\n",j,i);
553  l2++;
554  break;
555  }
556  }
557  }
558  fprintf(outfile," { 10000,0 }\n};\n");
559  fprintf(outfile,"#define JJTAB2LEN %d\n",l2);
560  fclose(outfile);
561 }
int p
Definition: cfModGcd.cc:4019
CanonicalForm res
Definition: facAbsFact.cc:64
int j
Definition: facHensel.cc:105
#define jjWRONG3
Definition: gentable.cc:127
#define NO_ZERODIVISOR
Definition: gentable.cc:45
#define PLURAL_MASK
Definition: gentable.cc:38
int iiTestConvert(int inputType, int outputType)
Definition: gentable.cc:299
#define RING_MASK
Definition: gentable.cc:22
#define WARN_RING
Definition: gentable.cc:52
int RingDependend(int t)
Definition: gentable.cc:29
#define jjWRONG2
Definition: gentable.cc:126
const char * iiTwoOps(int t)
Definition: gentable.cc:259
#define jjWRONG
Definition: gentable.cc:125
#define ZERODIVISOR_MASK
Definition: gentable.cc:47
@ UMINUS
Definition: grammar.cc:349
const struct sValCmd1 dArith1[]
Definition: table.h:19
const struct sValCmd2 dArith2[]
Definition: table.h:293
short cmd
Definition: gentable.cc:70
short cmd
Definition: gentable.cc:79
const struct sValCmdM dArithM[]
Definition: table.h:844
const struct sValCmd3 dArith3[]
Definition: table.h:726
const struct sValAssign dAssign[]
Definition: table.h:1288
@ MAX_TOK
Definition: tok.h:215

◆ ttGen2b()

void ttGen2b ( )

generate cmds initialisation

Definition at line 568 of file gentable.cc.

569 {
570  int cmd_size = (sizeof(cmds)/sizeof(cmdnames))-1;
571 
572  FILE *outfile = fopen(iparith_inc,"a");
573  fprintf(outfile,
574  "/****************************************\n"
575  "* Computer Algebra System SINGULAR *\n"
576  "****************************************/\n\n");
577 /*-------------------------------------------------------------------*/
578  fprintf(outfile,"// identifier table for Singular\n//\n");
579 
580  fprintf(
581  outfile,
582  "#ifdef MODULE_GENERATOR\n"
583  "#define omAlloc0(A) malloc(A)\n"
584  "#endif\n"
585  "void iiInitCmdName()\n{\n"
586  " sArithBase.nCmdUsed = 0;\n"
587  " sArithBase.nCmdAllocated = %d;\n"
588  " sArithBase.sCmds = (cmdnames*)omAlloc0(sArithBase.nCmdAllocated*sizeof(cmdnames));\n"
589  "\n"
590  " // name-string alias tokval toktype index\n",
591  cmd_size);
592  int m=0;
593  int id_nr=0;
594 
595  qsort(&cmds, cmd_size, sizeof(cmdnames), (&_gentable_sort_cmds));
596 
597  for(m=0; m<cmd_size; m++)
598  {
599  if(cmds[m].tokval>0) id_nr++;
600  fprintf(outfile," iiArithAddCmd(\"%s\", %*d, %3d, ",cmds[m].name,
601  (int)(20-strlen(cmds[m].name)),
602  cmds[m].alias,
603  cmds[m].tokval);
604  switch(cmds[m].toktype)
605  {
606  case CMD_1: fprintf(outfile,"CMD_1"); break;
607  case CMD_2: fprintf(outfile,"CMD_2"); break;
608  case CMD_3: fprintf(outfile,"CMD_3"); break;
609  case CMD_12: fprintf(outfile,"CMD_12"); break;
610  case CMD_123 : fprintf(outfile,"CMD_123"); break;
611  case CMD_23: fprintf(outfile,"CMD_23"); break;
612  case CMD_M: fprintf(outfile,"CMD_M"); break;
613  case SYSVAR: fprintf(outfile,"SYSVAR"); break;
614  case ROOT_DECL: fprintf(outfile,"ROOT_DECL"); break;
615  case ROOT_DECL_LIST: fprintf(outfile,"ROOT_DECL_LIST"); break;
616  case RING_DECL: fprintf(outfile,"RING_DECL"); break;
617  case NONE: fprintf(outfile,"NONE"); break;
618  default:
619  if((cmds[m].toktype>' ') &&(cmds[m].toktype<127))
620  {
621  fprintf(outfile,"'%c'",cmds[m].toktype);
622  }
623  else
624  {
625  fprintf(outfile,"%d",cmds[m].toktype);
626  }
627  break;
628 #if 0
629  fprintf(outfile," iiArithAddCmd(\"%s\", %*d, -1, 0 );\n",
630  cmds[m].name, 20-strlen(cmds[m].name),
631  0/*cmds[m].alias*/
632  /*-1 cmds[m].tokval*/
633  /*0 cmds[m].toktype*/);
634 #endif
635  }
636  fprintf(outfile,", %d);\n", m);
637  }
638  fprintf(outfile, "/* end of list marker */\n");
639  fprintf(outfile,
640  " sArithBase.nLastIdentifier = %d;\n",
641  id_nr);
642 
643 
644  fprintf(outfile,
645 "}\n"
646 "#define LAST_IDENTIFIER %d\n"
647  ,id_nr);
648  fclose(outfile);
649 }
int m
Definition: cfEzgcd.cc:121
char name(const Variable &v)
Definition: factory.h:180
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
Definition: gentable.cc:192
@ RING_DECL
Definition: grammar.cc:319
@ SYSVAR
Definition: grammar.cc:348
@ ROOT_DECL
Definition: grammar.cc:317
@ ROOT_DECL_LIST
Definition: grammar.cc:318

◆ ttGen2c()

void ttGen2c ( )

Definition at line 664 of file gentable.cc.

665 {
666  int cmd_size = (sizeof(cmds)/sizeof(cmdnames))-1;
667 
668  FILE *outfile = fopen("reference_table.texi","w");
669  fprintf(outfile, "@menu\n");
670 /*-------------------------------------------------------------------*/
671  qsort(&cmds, cmd_size, sizeof(cmdnames), (&_texi_sort_cmds));
672 
673  int m;
674  for(m=0; m<cmd_size; m++)
675  {
676  // assume that cmds[0].tokval== -1 and all others with tokval -1 at the end
677  if(is_ref_cmd(&(cmds[m])))
678  {
679  fprintf(outfile,"* %s::\n",cmds[m].name);
680  }
681  }
682  fprintf(outfile, "@end menu\n@c ---------------------------\n");
683  for(m=0; m<cmd_size; m++)
684  {
685  // assume that cmds[0].tokval== -1 and all others with tokval -1 at the end
686  if(is_ref_cmd(&(cmds[m])))
687  {
688  fprintf(outfile,"@node %s,",cmds[m].name);
689  // next:
690  int mm=m-1;
691  while((mm>0)&& (is_ref_cmd(&cmds[mm]))) mm--;
692  if((mm>0)&& (is_ref_cmd(&cmds[mm])))
693  fprintf(outfile,"%s,",cmds[mm].name);
694  else
695  fprintf(outfile,",");
696  // prev:
697  mm=m+1;
698  while((mm>0)&& (is_ref_cmd(&cmds[mm]))) mm++;
699  if((mm>0)&& (is_ref_cmd(&cmds[mm])))
700  fprintf(outfile,"%s,",cmds[m-1].name);
701  else
702  fprintf(outfile,",");
703  // up:, and header
704  fprintf(outfile,"Functions\n"
705  "@subsection %s\n"
706  "@cindex %s\n",cmds[m].name,cmds[m].name);
707  fprintf(outfile,"@include %s.part\n",cmds[m].name);
708  char partName[50];
709  sprintf(partName,"%s.part",cmds[m].name);
710  struct stat buf;
711  if (lstat(partName,&buf)!=0)
712  {
713  int op,i;
714  int only_field=0,only_comm=0,no_zerodiv=0;
715  FILE *part=fopen(partName,"w");
716  fprintf(part,"@table @code\n@item @strong{Syntax:}\n");
717  if ((cmds[m].toktype==CMD_1)
718  || (cmds[m].toktype==CMD_12)
719  || (cmds[m].toktype==CMD_13)
720  || (cmds[m].toktype==CMD_123))
721  {
722  op= cmds[m].tokval;
723  i=0;
724  while ((dArith1[i].cmd!=op) && (dArith1[i].cmd!=0)) i++;
725  while (dArith1[i].cmd==op)
726  {
727  if (dArith1[i].p!=jjWRONG)
728  {
729  fprintf(part,"@code{%s (} %s @code{)}\n",cmds[m].name,Tok2Cmdname(dArith1[i].arg));
730  fprintf(part,"@item @strong{Type:}\n%s\n",Tok2Cmdname(dArith1[i].res));
731  if ((dArith1[i].valid_for & ALLOW_PLURAL)==0)
732  only_comm=1;
733  if ((dArith1[i].valid_for & ALLOW_RING)==0)
734  only_field=1;
735  if ((dArith1[i].valid_for & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
736  no_zerodiv=1;
737  }
738  i++;
739  }
740  }
741  if ((cmds[m].toktype==CMD_23)
742  || (cmds[m].toktype==CMD_12)
743  || (cmds[m].toktype==CMD_2)
744  || (cmds[m].toktype==CMD_123))
745  {
746  op= cmds[m].tokval;
747  i=0;
748  while ((dArith2[i].cmd!=op) && (dArith2[i].cmd!=0)) i++;
749  while (dArith2[i].cmd==op)
750  {
751  if (dArith2[i].p!=jjWRONG)
752  {
753  fprintf(part,"@code{%s (} %s, %s @code{)}\n",cmds[m].name,Tok2Cmdname(dArith2[i].arg1),Tok2Cmdname(dArith2[i].arg2));
754  fprintf(part,"@item @strong{Type:}\n%s\n",Tok2Cmdname(dArith2[i].res));
755  if ((dArith2[i].valid_for & ALLOW_PLURAL)==0)
756  only_comm=1;
757  if ((dArith2[i].valid_for & ALLOW_RING)==0)
758  only_field=1;
759  if ((dArith2[i].valid_for & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
760  no_zerodiv=1;
761  }
762  i++;
763  }
764  }
765  if ((cmds[m].toktype==CMD_23)
766  || (cmds[m].toktype==CMD_13)
767  || (cmds[m].toktype==CMD_3)
768  || (cmds[m].toktype==CMD_123))
769  {
770  op= cmds[m].tokval;
771  i=0;
772  while ((dArith3[i].cmd!=op) && (dArith3[i].cmd!=0)) i++;
773  while (dArith3[i].cmd==op)
774  {
775  if (dArith3[i].p!=jjWRONG)
776  {
777  fprintf(part,"@code{%s (} %s, %s, %s @code{)}\n",cmds[m].name,
778  Tok2Cmdname(dArith3[i].arg1),
779  Tok2Cmdname(dArith3[i].arg2),
780  Tok2Cmdname(dArith3[i].arg3));
781  fprintf(part,"@item @strong{Type:}\n%s\n",Tok2Cmdname(dArith3[i].res));
782  if ((dArith3[i].valid_for & ALLOW_PLURAL)==0)
783  only_comm=1;
784  if ((dArith3[i].valid_for & ALLOW_RING)==0)
785  only_field=1;
786  if ((dArith3[i].valid_for & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
787  no_zerodiv=1;
788  }
789  i++;
790  }
791  }
792  if (cmds[m].toktype==CMD_M)
793  {
794  op= cmds[m].tokval;
795  i=0;
796  while ((dArithM[i].cmd!=op) && (dArithM[i].cmd!=0)) i++;
797  while (dArithM[i].cmd==op)
798  {
799  if (dArithM[i].p!=jjWRONG)
800  {
801  fprintf(part,"@code{%s (} ... @code{)}\n",cmds[m].name);
802  fprintf(part,"@item @strong{Type:}\n%s\n",Tok2Cmdname(dArithM[i].res));
803  if ((dArithM[i].valid_for & ALLOW_PLURAL)==0)
804  only_comm=1;
805  if ((dArithM[i].valid_for & ALLOW_RING)==0)
806  only_field=1;
807  if ((dArithM[i].valid_for & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
808  no_zerodiv=1;
809  }
810  i++;
811  }
812  }
813  if (only_comm)
814  fprintf(part,"@item @strong{Remark:}\n"
815  "only for commutive polynomial rings\n");
816  if (only_field)
817  fprintf(part,"@item @strong{Remark:}\n"
818  "only for polynomial rings over fields\n");
819  if (no_zerodiv)
820  fprintf(part,"@item @strong{Remark:}\n"
821  "only for polynomial rings over domains\n");
822  fprintf(part,"@item @strong{Purpose:}\n"
823  "@item @strong{Example:}\n"
824  "@smallexample\n"
825  "@c example\n"
826  "@c example\n"
827  "@end smallexample\n"
828  "@c ref\n"
829  "@c See\n"
830  "@c ref{....};\n"
831  "@c ref{....}.\n"
832  "@c ref\n");
833  fclose(part);
834  }
835  }
836  }
837  fclose(outfile);
838 }
#define ALLOW_RING
Definition: gentable.cc:41
int is_ref_cmd(cmdnames *c)
Definition: gentable.cc:650
static int _texi_sort_cmds(const void *a, const void *b)
Definition: gentable.cc:221
#define ALLOW_PLURAL
Definition: gentable.cc:36
int status int void * buf
Definition: si_signals.h:59

◆ ttGen4()

void ttGen4 ( )

Definition at line 840 of file gentable.cc.

841 {
842  FILE *outfile = fopen("plural_cmd.xx","w");
843  int i;
844  const char *old_s="";
845  fprintf(outfile,
846  "@c *****************************************\n"
847  "@c * Computer Algebra System SINGULAR *\n"
848  "@c *****************************************\n\n");
849 /*-------------------------------------------------------------------*/
850  fprintf(outfile,"@multicolumn .45 .45\n");
851  int op;
852  i=0;
853  while ((op=dArith1[i].cmd)!=0)
854  {
855  if (dArith1[i].p!=jjWRONG)
856  {
857  const char *s = iiTwoOps(op);
858  if ((s!=NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
859  {
860  old_s=s;
861  #ifdef HAVE_PLURAL
862  switch (dArith1[i].valid_for & PLURAL_MASK)
863  {
864  case NO_PLURAL:
865  fprintf(outfile,"@item @ref{%s} @tab @code{---}\n",s);
866  break;
867  case ALLOW_PLURAL:
868  fprintf(outfile,"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
869  break;
870  case COMM_PLURAL:
871  fprintf(outfile,"@item @ref{%s} @tab %s\n",s,s);
872  break;
873  }
874  #endif
875  #ifdef HAVE_RINGS
876  #endif
877  }
878  }
879  i++;
880  }
881  fprintf(outfile,"@c ---------------------------------------------\n");
882  i=0;
883  while ((op=dArith2[i].cmd)!=0)
884  {
885  if (dArith2[i].p!=jjWRONG2)
886  {
887  const char *s = iiTwoOps(op);
888  if ((s!=NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
889  {
890  old_s=s;
891  #ifdef HAVE_PLURAL
892  switch (dArith2[i].valid_for & PLURAL_MASK)
893  {
894  case NO_PLURAL:
895  fprintf(outfile,"@item @ref{%s} @tab @code{---}\n",s);
896  break;
897  case ALLOW_PLURAL:
898  fprintf(outfile,"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
899  break;
900  case COMM_PLURAL:
901  fprintf(outfile,"@item @ref{%s} @tab %s\n",s,s);
902  break;
903  }
904  #endif
905  #ifdef HAVE_RINGS
906  #endif
907  }
908  }
909  i++;
910  }
911  fprintf(outfile,"@c ---------------------------------------------\n");
912  i=0;
913  while ((op=dArith3[i].cmd)!=0)
914  {
915  const char *s = iiTwoOps(op);
916  if (dArith3[i].p!=jjWRONG3)
917  {
918  if ((s!=NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
919  {
920  old_s=s;
921  #ifdef HAVE_PLURAL
922  switch (dArith3[i].valid_for & PLURAL_MASK)
923  {
924  case NO_PLURAL:
925  fprintf(outfile,"@item @ref{%s} @tab @code{---}\n",s);
926  break;
927  case ALLOW_PLURAL:
928  fprintf(outfile,"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
929  break;
930  case COMM_PLURAL:
931  fprintf(outfile,"@item @ref{%s} @tab %s\n",s,s);
932  break;
933  }
934  #endif
935  #ifdef HAVE_RINGS
936  #endif
937  }
938  }
939  i++;
940  }
941  fprintf(outfile,"@c ---------------------------------------------\n");
942  i=0;
943  while ((op=dArithM[i].cmd)!=0)
944  {
945  const char *s = iiTwoOps(op);
946  if ((s!=NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
947  {
948  old_s=s;
949  #ifdef HAVE_PLURAL
950  switch (dArithM[i].valid_for & PLURAL_MASK)
951  {
952  case NO_PLURAL:
953  fprintf(outfile,"@item @ref{%s} @tab @code{---}\n",s);
954  break;
955  case ALLOW_PLURAL:
956  fprintf(outfile,"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
957  break;
958  case COMM_PLURAL:
959  fprintf(outfile,"@item @ref{%s} @tab %s\n",s,s);
960  break;
961  }
962  #endif
963  #ifdef HAVE_RINGS
964  #endif
965  }
966  i++;
967  }
968  fprintf(outfile,"@c ---------------------------------------------\n");
969  fprintf(outfile,"@end table\n");
970  fclose(outfile);
971  rename("plural_cmd.xx","plural_cmd.inc");
972 }
#define COMM_PLURAL
Definition: gentable.cc:37
#define NO_PLURAL
Definition: gentable.cc:35

Variable Documentation

◆ iparith_inc

char* iparith_inc

Definition at line 327 of file gentable.cc.

◆ produce_convert_table

int produce_convert_table =0

Definition at line 32 of file gentable.cc.