My Project
Loading...
Searching...
No Matches
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 "Singular/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_NC   0
 
#define ALLOW_PLURAL   1
 
#define COMM_PLURAL   2
 
#define ALLOW_LP   64
 
#define NC_MASK   (3+64)
 
#define ALLOW_NC   ALLOW_LP|ALLOW_PLURAL
 
#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 NO_LRING   128
 
#define jjWRONG   1
 
#define jjWRONG2   1
 
#define jjWRONG3   1
 
#define D(A)
 
#define NULL_VAL   0
 
#define IPARITH
 
#define GENTABLE
 
#define IPCONV
 
#define IPASSIGN
 

Functions

static 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
 
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
 
int is_ref_cmd (cmdnames *c)
 
void ttGen2c ()
 
void ttGen4 ()
 
int main (int argc, char **argv)
 

Variables

VAR int produce_convert_table =0
 
VAR char * iparith_inc
 

Data Structure Documentation

◆ _scmdnames

struct _scmdnames

Definition at line 56 of file gentable.cc.

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

◆ sValCmd2

struct sValCmd2

Definition at line 66 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 75 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 83 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 93 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 101 of file gentable.cc.

Data Fields
short arg
int p
proc1 p
short res

◆ sValAssign

struct sValAssign

Definition at line 108 of file gentable.cc.

Data Fields
short arg
int p
proci p
short res

◆ sConvertTypes

struct sConvertTypes

Definition at line 115 of file gentable.cc.

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

Macro Definition Documentation

◆ ALLOW_LP

#define ALLOW_LP   64

Definition at line 33 of file gentable.cc.

◆ ALLOW_NC

#define ALLOW_NC   ALLOW_LP|ALLOW_PLURAL

Definition at line 35 of file gentable.cc.

◆ ALLOW_PLURAL

#define ALLOW_PLURAL   1

Definition at line 30 of file gentable.cc.

◆ ALLOW_RING

#define ALLOW_RING   4

Definition at line 38 of file gentable.cc.

◆ ALLOW_ZERODIVISOR

#define ALLOW_ZERODIVISOR   0

Definition at line 43 of file gentable.cc.

◆ ALLOW_ZZ

#define ALLOW_ZZ   (ALLOW_RING|NO_ZERODIVISOR)

Definition at line 46 of file gentable.cc.

◆ COMM_PLURAL

#define COMM_PLURAL   2

Definition at line 31 of file gentable.cc.

◆ D

#define D ( A)
Value:
2

Definition at line 128 of file gentable.cc.

◆ GENTABLE

#define GENTABLE

Definition at line 131 of file gentable.cc.

◆ IPARITH

#define IPARITH

Definition at line 130 of file gentable.cc.

◆ IPASSIGN

#define IPASSIGN

Definition at line 133 of file gentable.cc.

◆ IPCONV

#define IPCONV

Definition at line 132 of file gentable.cc.

◆ jjWRONG

#define jjWRONG   1

Definition at line 124 of file gentable.cc.

◆ jjWRONG2

#define jjWRONG2   1

Definition at line 125 of file gentable.cc.

◆ jjWRONG3

#define jjWRONG3   1

Definition at line 126 of file gentable.cc.

◆ NC_MASK

#define NC_MASK   (3+64)

Definition at line 34 of file gentable.cc.

◆ NO_CONVERSION

#define NO_CONVERSION   32

Definition at line 51 of file gentable.cc.

◆ NO_LRING

#define NO_LRING   128

Definition at line 54 of file gentable.cc.

◆ NO_NC

#define NO_NC   0

Definition at line 29 of file gentable.cc.

◆ NO_RING

#define NO_RING   0

Definition at line 39 of file gentable.cc.

◆ NO_ZERODIVISOR

#define NO_ZERODIVISOR   8

Definition at line 42 of file gentable.cc.

◆ NULL_VAL

#define NULL_VAL   0

Definition at line 129 of file gentable.cc.

◆ RING_MASK

#define RING_MASK   4

Definition at line 20 of file gentable.cc.

◆ WARN_RING

#define WARN_RING   16

Definition at line 49 of file gentable.cc.

◆ ZERODIVISOR_MASK [1/2]

#define ZERODIVISOR_MASK   8

Definition at line 21 of file gentable.cc.

◆ ZERODIVISOR_MASK [2/2]

#define ZERODIVISOR_MASK   8

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

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

◆ _texi_sort_cmds()

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

Definition at line 220 of file gentable.cc.

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

◆ iiTestConvert()

int iiTestConvert ( int inputType,
int outputType )

Definition at line 298 of file gentable.cc.

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

◆ iiTwoOps()

const char * iiTwoOps ( int t)

Definition at line 258 of file gentable.cc.

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

654{
655 if( c->tokval==0) return 0;
656 if (c->alias > 0) return 0;
657 if ((c->toktype==CMD_1)
658 || (c->toktype==CMD_2)
659 || (c->toktype==CMD_3)
660 || (c->toktype==CMD_M)
661 || (c->toktype==CMD_12)
662 || (c->toktype==CMD_13)
663 || (c->toktype==CMD_23)
664 || (c->toktype==CMD_123)) return 1;
665 return 0;
666}
@ CMD_1
Definition grammar.cc:312
@ CMD_23
Definition grammar.cc:317
@ CMD_2
Definition grammar.cc:313
@ CMD_3
Definition grammar.cc:314
@ CMD_123
Definition grammar.cc:318
@ CMD_12
Definition grammar.cc:315
@ CMD_13
Definition grammar.cc:316
@ CMD_M
Definition grammar.cc:319

◆ main()

int main ( int argc,
char ** argv )

Definition at line 970 of file gentable.cc.

971{
972 if (argc>1)
973 {
974 produce_convert_table=1; /* for ttGen1 */
975 ttGen1();
976 unlink(iparith_inc);
977 ttGen4();
978 ttGen2c();
979 }
980 else
981 {
982 ttGen1();
983 ttGen2b();
984 rename(iparith_inc,"iparith.inc");
985 }
986 return 0;
987}
void ttGen2c()
Definition gentable.cc:667
void ttGen4()
Definition gentable.cc:843
void ttGen2b()
generate cmds initialisation
Definition gentable.cc:573
VAR int produce_convert_table
Definition gentable.cc:26
void ttGen1()
Definition gentable.cc:327
VAR char * iparith_inc
Definition gentable.cc:326

◆ RingDependend()

static int RingDependend ( int t)
inlinestatic

Definition at line 23 of file gentable.cc.

23{ return (BEGIN_RING<t)&&(t<END_RING); }
@ END_RING
Definition grammar.cc:311
@ BEGIN_RING
Definition grammar.cc:283

◆ Tok2Cmdname()

const char * Tok2Cmdname ( int tok)

Definition at line 137 of file gentable.cc.

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

◆ ttGen1()

void ttGen1 ( )

Definition at line 327 of file gentable.cc.

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

◆ ttGen2b()

void ttGen2b ( )

generate cmds initialisation

Definition at line 573 of file gentable.cc.

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

◆ ttGen2c()

void ttGen2c ( )

Definition at line 667 of file gentable.cc.

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

◆ ttGen4()

void ttGen4 ( )

Definition at line 843 of file gentable.cc.

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

Variable Documentation

◆ iparith_inc

VAR char* iparith_inc

Definition at line 326 of file gentable.cc.

◆ produce_convert_table

VAR int produce_convert_table =0

Definition at line 26 of file gentable.cc.