#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.
◆ _scmdnames
Definition at line 51 of file gentable.cc.
Data Fields |
short |
alias |
|
const char * |
name |
|
char * |
name |
|
short |
toktype |
|
short |
tokval |
|
◆ sValCmd2
Definition at line 61 of file gentable.cc.
Data Fields |
short |
arg1 |
|
short |
arg2 |
|
short |
cmd |
|
int |
p |
|
proc2 |
p |
|
short |
res |
|
short |
valid_for |
|
◆ sValCmd1
Definition at line 70 of file gentable.cc.
Data Fields |
short |
arg |
|
short |
cmd |
|
int |
p |
|
proc1 |
p |
|
short |
res |
|
short |
valid_for |
|
◆ sValCmd3
Definition at line 78 of file gentable.cc.
Data Fields |
short |
arg1 |
|
short |
arg2 |
|
short |
arg3 |
|
short |
cmd |
|
int |
p |
|
proc3 |
p |
|
short |
res |
|
short |
valid_for |
|
◆ sValCmdM
Definition at line 88 of file gentable.cc.
Data Fields |
short |
cmd |
|
short |
number_of_args |
|
int |
p |
|
proc1 |
p |
|
short |
res |
|
short |
valid_for |
|
◆ sValAssign_sys
◆ sValAssign
◆ sConvertTypes
◆ ALLOW_PLURAL
◆ ALLOW_RING
◆ ALLOW_ZERODIVISOR
#define ALLOW_ZERODIVISOR 0 |
◆ ALLOW_ZZ
◆ COMM_PLURAL
◆ GENTABLE
◆ IPARITH
◆ IPASSIGN
◆ IPCONV
◆ jjWRONG
◆ jjWRONG2
◆ jjWRONG3
◆ NO_CONVERSION
◆ NO_PLURAL
◆ NO_RING
◆ NO_ZERODIVISOR
◆ NULL_VAL
◆ PLURAL_MASK
◆ WARN_RING
◆ ZERODIVISOR_MASK
#define ZERODIVISOR_MASK 8 |
◆ _gentable_sort_cmds()
static int _gentable_sort_cmds |
( |
const void * |
a, |
|
|
const void * |
b |
|
) |
| |
|
static |
compares to entry of cmdsname-list
- Parameters
-
- Returns
- <ReturnValue>
Definition at line 186 of file gentable.cc.
188 cmdnames *pCmdL = (cmdnames*)
a;
189 cmdnames *pCmdR = (cmdnames*)
b;
194 if(pCmdL->name==
NULL)
return 1;
195 if(pCmdR->name==
NULL)
return -1;
198 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
199 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
202 if (pCmdL->tokval==-1)
204 if (pCmdR->tokval==-1)
205 return strcmp(pCmdL->name, pCmdR->name);
210 if(pCmdR->tokval==-1)
return -1;
212 return strcmp(pCmdL->name, pCmdR->name);
◆ _texi_sort_cmds()
static int _texi_sort_cmds |
( |
const void * |
a, |
|
|
const void * |
b |
|
) |
| |
|
static |
Definition at line 215 of file gentable.cc.
217 cmdnames *pCmdL = (cmdnames*)
a;
218 cmdnames *pCmdR = (cmdnames*)
b;
223 if(pCmdL->name==
NULL)
return 1;
224 if(pCmdR->name==
NULL)
return -1;
227 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
228 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
229 char *ls=
strdup(pCmdL->name);
230 char *rs=
strdup(pCmdR->name);
232 while (*
s) { *
s=tolower(*
s);
s++; }
234 while (*
s) { *
s=tolower(*
s);
s++; }
237 if (pCmdL->tokval==-1)
239 if (pCmdR->tokval==-1)
240 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
246 if(pCmdR->tokval==-1)
249 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
const CanonicalForm int s
◆ iiTestConvert()
int iiTestConvert |
( |
int |
inputType, |
|
|
int |
outputType |
|
) |
| |
Definition at line 293 of file gentable.cc.
295 if ((inputType==outputType)
297 || (outputType==
IDHDL)
302 if (inputType==
UNKNOWN)
return 0;
const struct sConvertTypes dConvertTypes[]
◆ iiTwoOps()
const char* iiTwoOps |
( |
int |
t | ) |
|
Definition at line 253 of file gentable.cc.
279 case LE:
return "<=";
280 case GE:
return ">=";
const char * Tok2Cmdname(int tok)
◆ is_ref_cmd()
int is_ref_cmd |
( |
cmdnames * |
c | ) |
|
Definition at line 610 of file gentable.cc.
612 if( c->tokval==0)
return 0;
613 if (c->alias > 0)
return 0;
614 if ((c->toktype==
CMD_1)
615 || (c->toktype==
CMD_2)
616 || (c->toktype==
CMD_3)
617 || (c->toktype==
CMD_M)
621 || (c->toktype==
CMD_123))
return 1;
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
|
|
) |
| |
Definition at line 935 of file gentable.cc.
int produce_convert_table
void ttGen2b()
generate cmds initialisation
◆ RingDependend()
int RingDependend |
( |
int |
t | ) |
|
|
inline |
◆ Tok2Cmdname()
const char* Tok2Cmdname |
( |
int |
tok | ) |
|
Definition at line 132 of file gentable.cc.
138 if (tok==
COMMAND)
return "command";
139 if (tok==
ANY_TYPE)
return "any_type";
140 if (tok==
NONE)
return "nothing";
147 if (tok==
IDHDL)
return "identifier";
151 while (
cmds[
i].tokval!=0)
153 if ((
cmds[
i].tokval == tok)&&(
cmds[
i].alias==0))
160 while (
cmds[
i].tokval!=0)
162 if (
cmds[
i].tokval == tok)
170 sprintf(
s,
"(%d)",tok);
const CanonicalForm int s
void * malloc(size_t size)
◆ ttGen1()
Definition at line 322 of file gentable.cc.
335 "/****************************************\n" 336 "* Computer Algebra System SINGULAR *\n" 337 "****************************************/\n\n");
339 fprintf(outfile,
"// syntax table for Singular\n//\n");
340 fprintf(outfile,
"// - search for an exact match of the argument types\n");
341 fprintf(outfile,
"// - otherwise search for the first possibility\n");
342 fprintf(outfile,
"// with converted types of the arguments\n");
343 fprintf(outfile,
"// - otherwise report an error\n//\n");
350 fprintf(outfile,
"// DUMMY ");
352 fprintf(outfile,
"// operation: %s (%s) -> %s\n",
358 fprintf(outfile,
"// WARNING: %s requires currRing\n",
s);
362 fprintf(outfile,
"/*---------------------------------------------*/\n");
367 fprintf(outfile,
"// DUMMY ");
369 fprintf(outfile,
"// operation: %s (%s, %s) -> %s\n",
378 fprintf(outfile,
"// WARNING: %s requires currRing\n",
s);
382 fprintf(outfile,
"/*---------------------------------------------*/\n");
388 fprintf(outfile,
"// DUMMY ");
389 fprintf(outfile,
"// operation: %s (%s, %s, %s) -> %s\n",
400 fprintf(outfile,
"// WARNING: %s requires currRing\n",
s);
404 fprintf(outfile,
"/*---------------------------------------------*/\n");
409 fprintf(outfile,
"// operation: %s (...) -> %s",
415 fprintf(outfile,
" ( number of arguments >0 )\n");
418 fprintf(outfile,
" ( any number of arguments )\n");
421 fprintf(outfile,
" ( %d arguments )\n",
dArithM[
i].number_of_args);
426 fprintf(outfile,
"/*---------------------------------------------*/\n");
430 fprintf(outfile,
"// assign: %s = %s\n",
436 fprintf(outfile,
"/*---------------------------------------------*/\n");
440 doctable=fopen(
"convert_table.texi",
"w");
441 fprintf(doctable,
"@multitable @columnfractions .05 .18 .81\n");
451 fprintf(outfile,
"// convert %s -> %s\n",
456 "@item\n@ %d. @tab @code{%s} @tab @expansion{} @code{%s}\n",
466 fprintf(doctable,
"@end multitable\n");
469 fprintf(outfile,
"/*---------------------------------------------*/\n");
470 char ops[]=
"=><+*/[.^,%(;";
471 for(
i=0;ops[
i]!=
'\0';
i++)
472 fprintf(outfile,
"// token %d : %c\n", (
int)ops[
i], ops[
i]);
478 fprintf(outfile,
"// token %d : %s\n",
i,
s);
482 fprintf(outfile,
"/*--max. token: %d, gr: %d --*/\n",
MAX_TOK,
UMINUS);
484 fprintf(outfile,
"/*---------------------------------------------*/\n");
486 "const struct sValCmdTab dArithTab1[]=\n" 494 fprintf(outfile,
" { %d,%d },\n",
j,
i);
500 fprintf(outfile,
" { 10000,0 }\n};\n");
501 fprintf(outfile,
"#define JJTAB1LEN %d\n",l1);
504 "const struct sValCmdTab dArithTab2[]=\n" 512 fprintf(outfile,
" { %d,%d },\n",
j,
i);
518 fprintf(outfile,
" { 10000,0 }\n};\n");
519 fprintf(outfile,
"#define JJTAB2LEN %d\n",l2);
const CanonicalForm int s
int iiTestConvert(int inputType, int outputType)
const struct sValCmd2 dArith2[]
const struct sValCmdM dArithM[]
const struct sValCmd3 dArith3[]
int produce_convert_table
const char * iiTwoOps(int t)
const struct sValAssign dAssign[]
const char * Tok2Cmdname(int tok)
const struct sValCmd1 dArith1[]
◆ ttGen2b()
generate cmds initialisation
Definition at line 528 of file gentable.cc.
530 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
534 "/****************************************\n" 535 "* Computer Algebra System SINGULAR *\n" 536 "****************************************/\n\n");
538 fprintf(outfile,
"// identifier table for Singular\n//\n");
542 "#ifdef MODULE_GENERATOR\n" 543 "#define omAlloc0(A) malloc(A)\n" 545 "void iiInitCmdName()\n{\n" 546 " sArithBase.nCmdUsed = 0;\n" 547 " sArithBase.nCmdAllocated = %d;\n" 548 " sArithBase.sCmds = (cmdnames*)omAlloc0(sArithBase.nCmdAllocated*sizeof(cmdnames));\n" 550 " // name-string alias tokval toktype index\n",
557 for(
m=0;
m<cmd_size;
m++)
559 if(
cmds[
m].tokval>0) id_nr++;
560 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, %3d, ",
cmds[
m].
name,
564 switch(
cmds[
m].toktype)
566 case CMD_1: fprintf(outfile,
"CMD_1");
break;
567 case CMD_2: fprintf(outfile,
"CMD_2");
break;
568 case CMD_3: fprintf(outfile,
"CMD_3");
break;
569 case CMD_12: fprintf(outfile,
"CMD_12");
break;
570 case CMD_123 : fprintf(outfile,
"CMD_123");
break;
571 case CMD_23: fprintf(outfile,
"CMD_23");
break;
572 case CMD_M: fprintf(outfile,
"CMD_M");
break;
573 case SYSVAR: fprintf(outfile,
"SYSVAR");
break;
574 case ROOT_DECL: fprintf(outfile,
"ROOT_DECL");
break;
576 case RING_DECL: fprintf(outfile,
"RING_DECL");
break;
577 case NONE: fprintf(outfile,
"NONE");
break;
579 if((
cmds[
m].toktype>
' ') &&(
cmds[
m].toktype<127))
581 fprintf(outfile,
"'%c'",
cmds[
m].toktype);
585 fprintf(outfile,
"%d",
cmds[
m].toktype);
589 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, -1, 0 );\n",
596 fprintf(outfile,
", %d);\n",
m);
598 fprintf(outfile,
"/* end of list marker */\n");
600 " sArithBase.nLastIdentifier = %d;\n",
606 "#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)
◆ ttGen2c()
Definition at line 624 of file gentable.cc.
626 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
628 FILE *outfile = fopen(
"reference_table.texi",
"w");
629 fprintf(outfile,
"@menu\n");
634 for(
m=0;
m<cmd_size;
m++)
639 fprintf(outfile,
"* %s::\n",
cmds[
m].
name);
642 fprintf(outfile,
"@end menu\n@c ---------------------------\n");
643 for(
m=0;
m<cmd_size;
m++)
648 fprintf(outfile,
"@node %s,",
cmds[
m].
name);
653 fprintf(outfile,
"%s,",
cmds[mm].
name);
655 fprintf(outfile,
",");
662 fprintf(outfile,
",");
664 fprintf(outfile,
"Functions\n" 667 fprintf(outfile,
"@include %s.part\n",
cmds[
m].
name);
669 sprintf(partName,
"%s.part",
cmds[
m].
name);
671 if (lstat(partName,&
buf)!=0)
674 int only_field=0,only_comm=0,no_zerodiv=0;
675 FILE *part=fopen(partName,
"w");
676 fprintf(part,
"@table @code\n@item @strong{Syntax:}\n");
737 fprintf(part,
"@code{%s (} %s, %s, %s @code{)}\n",
cmds[
m].
name,
761 fprintf(part,
"@code{%s (} ... @code{)}\n",
cmds[
m].
name);
774 fprintf(part,
"@item @strong{Remark:}\n" 775 "only for commutive polynomial rings\n");
777 fprintf(part,
"@item @strong{Remark:}\n" 778 "only for polynomial rings over fields\n");
780 fprintf(part,
"@item @strong{Remark:}\n" 781 "only for polynomial rings over domains\n");
782 fprintf(part,
"@item @strong{Purpose:}\n" 783 "@item @strong{Example:}\n" 787 "@end smallexample\n"
const struct sValCmd2 dArith2[]
const struct sValCmdM dArithM[]
const struct sValCmd3 dArith3[]
int status int void * buf
static int _texi_sort_cmds(const void *a, const void *b)
char name(const Variable &v)
const char * Tok2Cmdname(int tok)
const struct sValCmd1 dArith1[]
int is_ref_cmd(cmdnames *c)
◆ ttGen4()
Definition at line 800 of file gentable.cc.
802 FILE *outfile = fopen(
"plural_cmd.xx",
"w");
804 const char *old_s=
"";
806 "@c *****************************************\n" 807 "@c * Computer Algebra System SINGULAR *\n" 808 "@c *****************************************\n\n");
810 fprintf(outfile,
"@multicolumn .45 .45\n");
818 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
825 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
828 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
831 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
841 fprintf(outfile,
"@c ---------------------------------------------\n");
848 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
855 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
858 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
861 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
871 fprintf(outfile,
"@c ---------------------------------------------\n");
878 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
885 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
888 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
891 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
901 fprintf(outfile,
"@c ---------------------------------------------\n");
906 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
913 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
916 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
919 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
928 fprintf(outfile,
"@c ---------------------------------------------\n");
929 fprintf(outfile,
"@end table\n");
931 rename(
"plural_cmd.xx",
"plural_cmd.inc");
const CanonicalForm int s
const struct sValCmd2 dArith2[]
const struct sValCmdM dArithM[]
const struct sValCmd3 dArith3[]
const char * iiTwoOps(int t)
const struct sValCmd1 dArith1[]
◆ iparith_inc
◆ produce_convert_table
int produce_convert_table =0 |