#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "kernel/mod2.h"
#include "grammar.h"
#include "tok.h"
#include "table.h"
Go to the source code of this file.
Definition at line 47 of file gentable.cc.
Data Fields |
short |
alias |
|
const char * |
name |
|
char * |
name |
|
short |
toktype |
|
short |
tokval |
|
Definition at line 57 of file gentable.cc.
Data Fields |
short |
arg1 |
|
short |
arg2 |
|
short |
cmd |
|
int |
p |
|
proc2 |
p |
|
short |
res |
|
short |
valid_for |
|
Definition at line 66 of file gentable.cc.
Data Fields |
short |
arg |
|
short |
cmd |
|
int |
p |
|
proc1 |
p |
|
short |
res |
|
short |
valid_for |
|
Definition at line 74 of file gentable.cc.
Data Fields |
short |
arg1 |
|
short |
arg2 |
|
short |
arg3 |
|
short |
cmd |
|
int |
p |
|
proc3 |
p |
|
short |
res |
|
short |
valid_for |
|
Definition at line 84 of file gentable.cc.
Data Fields |
short |
cmd |
|
short |
number_of_args |
|
int |
p |
|
proc1 |
p |
|
short |
res |
|
short |
valid_for |
|
#define ALLOW_ZERODIVISOR 0 |
#define ZERODIVISOR_MASK 8 |
static int _gentable_sort_cmds |
( |
const void * |
a, |
|
|
const void * |
b |
|
) |
| |
|
static |
compares to entry of cmdsname-list
- Parameters
-
- Returns
- <ReturnValue>
Definition at line 185 of file gentable.cc.
187 cmdnames *pCmdL = (cmdnames*)
a;
188 cmdnames *pCmdR = (cmdnames*)
b;
193 if(pCmdL->name==
NULL)
return 1;
194 if(pCmdR->name==
NULL)
return -1;
197 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
198 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
201 if (pCmdL->tokval==-1)
203 if (pCmdR->tokval==-1)
204 return strcmp(pCmdL->name, pCmdR->name);
209 if(pCmdR->tokval==-1)
return -1;
211 return strcmp(pCmdL->name, pCmdR->name);
static int _texi_sort_cmds |
( |
const void * |
a, |
|
|
const void * |
b |
|
) |
| |
|
static |
Definition at line 214 of file gentable.cc.
216 cmdnames *pCmdL = (cmdnames*)
a;
217 cmdnames *pCmdR = (cmdnames*)
b;
222 if(pCmdL->name==
NULL)
return 1;
223 if(pCmdR->name==
NULL)
return -1;
226 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
227 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
228 char *ls=
strdup(pCmdL->name);
229 char *rs=
strdup(pCmdR->name);
231 while (*s) { *s=tolower(*s); s++; }
233 while (*s) { *s=tolower(*s); s++; }
236 if (pCmdL->tokval==-1)
238 if (pCmdR->tokval==-1)
239 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
245 if(pCmdR->tokval==-1)
248 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
const CanonicalForm int s
int iiTestConvert |
( |
int |
inputType, |
|
|
int |
outputType |
|
) |
| |
Definition at line 292 of file gentable.cc.
294 if ((inputType==outputType)
296 || (outputType==
IDHDL)
301 if (inputType==
UNKNOWN)
return 0;
const struct sConvertTypes dConvertTypes[]
const char* iiTwoOps |
( |
int |
t | ) |
|
Definition at line 252 of file gentable.cc.
278 case LE:
return "<=";
279 case GE:
return ">=";
const char * Tok2Cmdname(int tok)
int is_ref_cmd |
( |
cmdnames * |
c | ) |
|
Definition at line 609 of file gentable.cc.
611 if( c->tokval==0)
return 0;
612 if (c->alias > 0)
return 0;
613 if ((c->toktype==
CMD_1)
614 || (c->toktype==
CMD_2)
615 || (c->toktype==
CMD_3)
616 || (c->toktype==
CMD_M)
620 || (c->toktype==
CMD_123))
return 1;
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 934 of file gentable.cc.
int produce_convert_table
void ttGen2b()
generate cmds initialisation
int RingDependend |
( |
int |
t | ) |
|
|
inline |
const char* Tok2Cmdname |
( |
int |
tok | ) |
|
Definition at line 128 of file gentable.cc.
134 if (tok==
COMMAND)
return "command";
135 if (tok==
ANY_TYPE)
return "any_type";
136 if (tok==
NONE)
return "nothing";
143 if (tok==
IDHDL)
return "identifier";
150 while (
cmds[i].tokval!=0)
152 if ((
cmds[i].tokval == tok)&&(
cmds[i].alias==0))
159 while (
cmds[i].tokval!=0)
161 if (
cmds[i].tokval == tok)
169 sprintf(s,
"(%d)",tok);
const CanonicalForm int s
void * malloc(size_t size)
Definition at line 321 of file gentable.cc.
334 "/****************************************\n" 335 "* Computer Algebra System SINGULAR *\n" 336 "****************************************/\n\n");
338 fprintf(outfile,
"// syntax table for Singular\n//\n");
339 fprintf(outfile,
"// - search for an exact match of the argument types\n");
340 fprintf(outfile,
"// - otherwise search for the first possibility\n");
341 fprintf(outfile,
"// with converted types of the arguments\n");
342 fprintf(outfile,
"// - otherwise report an error\n//\n");
349 fprintf(outfile,
"// DUMMY ");
351 fprintf(outfile,
"// operation: %s (%s) -> %s\n",
357 fprintf(outfile,
"// WARNING: %s requires currRing\n",s);
361 fprintf(outfile,
"/*---------------------------------------------*/\n");
366 fprintf(outfile,
"// DUMMY ");
368 fprintf(outfile,
"// operation: %s (%s, %s) -> %s\n",
377 fprintf(outfile,
"// WARNING: %s requires currRing\n",s);
381 fprintf(outfile,
"/*---------------------------------------------*/\n");
387 fprintf(outfile,
"// DUMMY ");
388 fprintf(outfile,
"// operation: %s (%s, %s, %s) -> %s\n",
399 fprintf(outfile,
"// WARNING: %s requires currRing\n",s);
403 fprintf(outfile,
"/*---------------------------------------------*/\n");
408 fprintf(outfile,
"// operation: %s (...) -> %s",
411 switch(
dArithM[i].number_of_args)
414 fprintf(outfile,
" ( number of arguments >0 )\n");
417 fprintf(outfile,
" ( any number of arguments )\n");
420 fprintf(outfile,
" ( %d arguments )\n",
dArithM[i].number_of_args);
425 fprintf(outfile,
"/*---------------------------------------------*/\n");
429 fprintf(outfile,
"// assign: %s = %s\n",
435 fprintf(outfile,
"/*---------------------------------------------*/\n");
439 doctable=fopen(
"convert_table.texi",
"w");
440 fprintf(doctable,
"@multitable @columnfractions .05 .18 .81\n");
450 fprintf(outfile,
"// convert %s -> %s\n",
455 "@item\n@ %d. @tab @code{%s} @tab @expansion{} @code{%s}\n",
465 fprintf(doctable,
"@end multitable\n");
468 fprintf(outfile,
"/*---------------------------------------------*/\n");
469 char ops[]=
"=><+*/[.^,%(;";
470 for(i=0;ops[
i]!=
'\0';i++)
471 fprintf(outfile,
"// token %d : %c\n", (
int)ops[i], ops[i]);
477 fprintf(outfile,
"// token %d : %s\n", i, s);
481 fprintf(outfile,
"/*--max. token: %d, gr: %d --*/\n",
MAX_TOK,
UMINUS);
483 fprintf(outfile,
"/*---------------------------------------------*/\n");
485 "const struct sValCmdTab dArithTab1[]=\n" 493 fprintf(outfile,
" { %d,%d },\n",j,i);
499 fprintf(outfile,
" { 10000,0 }\n};\n");
500 fprintf(outfile,
"#define JJTAB1LEN %d\n",l1);
503 "const struct sValCmdTab dArithTab2[]=\n" 511 fprintf(outfile,
" { %d,%d },\n",j,i);
517 fprintf(outfile,
" { 10000,0 }\n};\n");
518 fprintf(outfile,
"#define JJTAB2LEN %d\n",l2);
const CanonicalForm int s
int iiTestConvert(int inputType, int outputType)
struct sValCmd1 dArith1[]
int produce_convert_table
const char * iiTwoOps(int t)
const struct sValAssign dAssign[]
struct sValCmd3 dArith3[]
struct sValCmd2 dArith2[]
struct sValCmdM dArithM[]
const char * Tok2Cmdname(int tok)
generate cmds initialisation
Definition at line 527 of file gentable.cc.
529 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
533 "/****************************************\n" 534 "* Computer Algebra System SINGULAR *\n" 535 "****************************************/\n\n");
537 fprintf(outfile,
"// identifier table for Singular\n//\n");
541 "#ifdef MODULE_GENERATOR\n" 542 "#define omAlloc0(A) malloc(A)\n" 544 "void iiInitCmdName()\n{\n" 545 " sArithBase.nCmdUsed = 0;\n" 546 " sArithBase.nCmdAllocated = %d;\n" 547 " sArithBase.sCmds = (cmdnames*)omAlloc0(sArithBase.nCmdAllocated*sizeof(cmdnames));\n" 549 " // name-string alias tokval toktype index\n",
556 for(m=0; m<cmd_size; m++)
558 if(
cmds[m].tokval>0) id_nr++;
559 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, %3d, ",
cmds[m].
name,
560 (
int)(20-strlen(
cmds[m].name)),
563 switch(
cmds[m].toktype)
565 case CMD_1: fprintf(outfile,
"CMD_1");
break;
566 case CMD_2: fprintf(outfile,
"CMD_2");
break;
567 case CMD_3: fprintf(outfile,
"CMD_3");
break;
568 case CMD_12: fprintf(outfile,
"CMD_12");
break;
569 case CMD_123 : fprintf(outfile,
"CMD_123");
break;
570 case CMD_23: fprintf(outfile,
"CMD_23");
break;
571 case CMD_M: fprintf(outfile,
"CMD_M");
break;
572 case SYSVAR: fprintf(outfile,
"SYSVAR");
break;
573 case ROOT_DECL: fprintf(outfile,
"ROOT_DECL");
break;
575 case RING_DECL: fprintf(outfile,
"RING_DECL");
break;
576 case NONE: fprintf(outfile,
"NONE");
break;
578 if((
cmds[m].toktype>
' ') &&(
cmds[m].toktype<127))
580 fprintf(outfile,
"'%c'",
cmds[m].toktype);
584 fprintf(outfile,
"%d",
cmds[m].toktype);
588 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, -1, 0 );\n",
589 cmds[m].name, 20-strlen(
cmds[m].name),
595 fprintf(outfile,
", %d);\n", m);
597 fprintf(outfile,
"/* end of list marker */\n");
599 " sArithBase.nLastIdentifier = %d;\n",
605 "#define LAST_IDENTIFIER %d\n"
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
char name(const Variable &v)
Definition at line 623 of file gentable.cc.
625 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
627 FILE *outfile = fopen(
"reference_table.texi",
"w");
628 fprintf(outfile,
"@menu\n");
633 for(m=0; m<cmd_size; m++)
638 fprintf(outfile,
"* %s::\n",
cmds[m].
name);
641 fprintf(outfile,
"@end menu\n@c ---------------------------\n");
642 for(m=0; m<cmd_size; m++)
647 fprintf(outfile,
"@node %s,",
cmds[m].
name);
652 fprintf(outfile,
"%s,",
cmds[mm].
name);
654 fprintf(outfile,
",");
659 fprintf(outfile,
"%s,",
cmds[m-1].
name);
661 fprintf(outfile,
",");
663 fprintf(outfile,
"Functions\n" 666 fprintf(outfile,
"@include %s.part\n",
cmds[m].
name);
668 sprintf(partName,
"%s.part",
cmds[m].
name);
670 if (lstat(partName,&
buf)!=0)
673 int only_field=0,only_comm=0,no_zerodiv=0;
674 FILE *part=fopen(partName,
"w");
675 fprintf(part,
"@table @code\n@item @strong{Syntax:}\n");
714 if ((
dArith2[i].valid_for & ALLOW_PLURAL)==0)
736 fprintf(part,
"@code{%s (} %s, %s, %s @code{)}\n",
cmds[m].name,
741 if ((
dArith3[i].valid_for & ALLOW_PLURAL)==0)
760 fprintf(part,
"@code{%s (} ... @code{)}\n",
cmds[m].name);
762 if ((
dArithM[i].valid_for & ALLOW_PLURAL)==0)
773 fprintf(part,
"@item @strong{Remark:}\n" 774 "only for commutive polynomial rings\n");
776 fprintf(part,
"@item @strong{Remark:}\n" 777 "only for polynomial rings over fields\n");
779 fprintf(part,
"@item @strong{Remark:}\n" 780 "only for polynomial rings over domains\n");
781 fprintf(part,
"@item @strong{Purpose:}\n" 782 "@item @strong{Example:}\n" 786 "@end smallexample\n"
struct sValCmd1 dArith1[]
int status int void * buf
static int _texi_sort_cmds(const void *a, const void *b)
struct sValCmd3 dArith3[]
char name(const Variable &v)
struct sValCmd2 dArith2[]
struct sValCmdM dArithM[]
const char * Tok2Cmdname(int tok)
int is_ref_cmd(cmdnames *c)
Definition at line 799 of file gentable.cc.
801 FILE *outfile = fopen(
"plural_cmd.xx",
"w");
803 const char *old_s=
"";
805 "@c *****************************************\n" 806 "@c * Computer Algebra System SINGULAR *\n" 807 "@c *****************************************\n\n");
809 fprintf(outfile,
"@multicolumn .45 .45\n");
817 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
824 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
827 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
830 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
840 fprintf(outfile,
"@c ---------------------------------------------\n");
847 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
854 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
857 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
860 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
870 fprintf(outfile,
"@c ---------------------------------------------\n");
877 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
884 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
887 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
890 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
900 fprintf(outfile,
"@c ---------------------------------------------\n");
905 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
912 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
915 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
918 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
927 fprintf(outfile,
"@c ---------------------------------------------\n");
928 fprintf(outfile,
"@end table\n");
930 rename(
"plural_cmd.xx",
"plural_cmd.inc");
const CanonicalForm int s
struct sValCmd1 dArith1[]
const char * iiTwoOps(int t)
struct sValCmd3 dArith3[]
struct sValCmd2 dArith2[]
struct sValCmdM dArithM[]
int produce_convert_table =0 |