My Project
Loading...
Searching...
No Matches
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 "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 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

static int RingDependend (int t)
 
const charTok2Cmdname (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 chariiTwoOps (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 chariparith_inc
 

Data Structure Documentation

◆ _scmdnames

struct _scmdnames

Definition at line 54 of file gentable.cc.

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

◆ sValCmd2

struct sValCmd2

Definition at line 64 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 73 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 81 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 91 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 99 of file gentable.cc.

Data Fields
short arg
int p
proc1 p
short res

◆ sValAssign

struct sValAssign

Definition at line 106 of file gentable.cc.

Data Fields
short arg
int p
proci p
short res

◆ sConvertTypes

struct sConvertTypes

Definition at line 113 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)    2

Definition at line 126 of file gentable.cc.

◆ GENTABLE

#define GENTABLE

Definition at line 129 of file gentable.cc.

◆ IPARITH

#define IPARITH

Definition at line 128 of file gentable.cc.

◆ IPASSIGN

#define IPASSIGN

Definition at line 131 of file gentable.cc.

◆ IPCONV

#define IPCONV

Definition at line 130 of file gentable.cc.

◆ jjWRONG

#define jjWRONG   1

Definition at line 122 of file gentable.cc.

◆ jjWRONG2

#define jjWRONG2   1

Definition at line 123 of file gentable.cc.

◆ jjWRONG3

#define jjWRONG3   1

Definition at line 124 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_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 127 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 189 of file gentable.cc.

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

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

297{
298 if ((inputType==outputType)
299 || (outputType==DEF_CMD)
300 || (outputType==IDHDL)
301 || (outputType==ANY_TYPE))
302 {
303 return -1;
304 }
305 if (inputType==UNKNOWN) return 0;
306
307 // search the list
308 int i=0;
309 while (dConvertTypes[i].i_typ!=0)
310 {
311 if((dConvertTypes[i].i_typ==inputType)
312 &&(dConvertTypes[i].o_typ==outputType))
313 {
314 //Print("test convert %d to %d (%s -> %s):%d\n",inputType,outputType,
315 //Tok2Cmdname(inputType), Tok2Cmdname(outputType),i+1);
316 return i+1;
317 }
318 i++;
319 }
320 //Print("test convert %d to %d (%s -> %s):0\n",inputType,outputType,
321 // Tok2Cmdname(inputType), Tok2Cmdname(outputType));
322 return 0;
323}
int i
Definition cfEzgcd.cc:132
const struct sConvertTypes dConvertTypes[]
Definition table.h:1320
#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 256 of file gentable.cc.

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

650{
651 if( c->tokval==0) return 0;
652 if (c->alias > 0) return 0;
653 if ((c->toktype==CMD_1)
654 || (c->toktype==CMD_2)
655 || (c->toktype==CMD_3)
656 || (c->toktype==CMD_M)
657 || (c->toktype==CMD_12)
658 || (c->toktype==CMD_13)
659 || (c->toktype==CMD_23)
660 || (c->toktype==CMD_123)) return 1;
661 return 0;
662}
@ 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 966 of file gentable.cc.

967{
968 if (argc>1)
969 {
970 produce_convert_table=1; /* for ttGen1 */
971 ttGen1();
973 ttGen4();
974 ttGen2c();
975 }
976 else
977 {
978 ttGen1();
979 ttGen2b();
980 rename(iparith_inc,"iparith.inc");
981 }
982 return 0;
983}
void ttGen2c()
Definition gentable.cc:663
void ttGen4()
Definition gentable.cc:839
void ttGen2b()
generate cmds initialisation
Definition gentable.cc:569
VAR int produce_convert_table
Definition gentable.cc:26
void ttGen1()
Definition gentable.cc:325
VAR char * iparith_inc
Definition gentable.cc:324

◆ 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 135 of file gentable.cc.

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

◆ ttGen1()

void ttGen1 ( )

Definition at line 325 of file gentable.cc.

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

◆ ttGen2b()

void ttGen2b ( )

generate cmds initialisation

Definition at line 569 of file gentable.cc.

570{
571 int cmd_size = (sizeof(cmds)/sizeof(cmdnames))-1;
572
575 "/****************************************\n"
576 "* Computer Algebra System SINGULAR *\n"
577 "****************************************/\n\n");
578/*-------------------------------------------------------------------*/
579 fprintf(outfile,"// identifier table for Singular\n//\n");
580
581 fprintf(
582 outfile,
583 "void iiInitCmdName()\n{\n"
584 " sArithBase.nCmdUsed = 0;\n"
585 " sArithBase.nCmdAllocated = %d;\n"
586 " sArithBase.sCmds = (cmdnames*)omAlloc0(%d/*sArithBase.nCmdAllocated*/ *sizeof(cmdnames));\n"
587 "\n"
588 " // name-string alias tokval toktype index\n",
590 int m=0;
591 int id_nr=0;
592
594
595 for(m=0; m<cmd_size; m++)
596 {
597 if(cmds[m].tokval>0) id_nr++;
598 fprintf(outfile," iiArithAddCmd(\"%s\", %*d, %3d, ",cmds[m].name,
599 (int)(20-strlen(cmds[m].name)),
600 cmds[m].alias,
601 cmds[m].tokval);
602 switch(cmds[m].toktype)
603 {
604 case CMD_1: fprintf(outfile,"CMD_1"); break;
605 case CMD_2: fprintf(outfile,"CMD_2"); break;
606 case CMD_3: fprintf(outfile,"CMD_3"); break;
607 case CMD_12: fprintf(outfile,"CMD_12"); break;
608 case CMD_123 : fprintf(outfile,"CMD_123"); break;
609 case CMD_13 : fprintf(outfile,"CMD_13"); break;
610 case CMD_23: fprintf(outfile,"CMD_23"); break;
611 case CMD_M: fprintf(outfile,"CMD_M"); break;
612 case SYSVAR: fprintf(outfile,"SYSVAR"); break;
613 case ROOT_DECL: fprintf(outfile,"ROOT_DECL"); break;
614 case ROOT_DECL_LIST: fprintf(outfile,"ROOT_DECL_LIST"); break;
615 case RING_DECL: fprintf(outfile,"RING_DECL"); break;
616 case NONE: fprintf(outfile,"NONE"); break;
617 default:
618 if((cmds[m].toktype>' ') &&(cmds[m].toktype<127))
619 {
620 fprintf(outfile,"'%c'",cmds[m].toktype);
621 }
622 else
623 {
624 fprintf(outfile,"%d",cmds[m].toktype);
625 }
626 break;
627#if 0
628 fprintf(outfile," iiArithAddCmd(\"%s\", %*d, -1, 0 );\n",
629 cmds[m].name, 20-strlen(cmds[m].name),
630 0/*cmds[m].alias*/
631 /*-1 cmds[m].tokval*/
632 /*0 cmds[m].toktype*/);
633#endif
634 }
635 fprintf(outfile,", %d);\n", m);
636 }
637 fprintf(outfile, "/* end of list marker */\n");
639 " sArithBase.nLastIdentifier = %d;\n",
640 id_nr);
641
642
644"}\n"
645"#define LAST_IDENTIFIER %d\n"
646 ,id_nr);
648}
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:189
@ 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 663 of file gentable.cc.

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

◆ ttGen4()

void ttGen4 ( )

Definition at line 839 of file gentable.cc.

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

Variable Documentation

◆ iparith_inc

VAR char* iparith_inc

Definition at line 324 of file gentable.cc.

◆ produce_convert_table

VAR int produce_convert_table =0

Definition at line 26 of file gentable.cc.