#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.
◆ _scmdnames
Definition at line 58 of file gentable.cc.
Data Fields |
short |
alias |
|
const char * |
name |
|
char * |
name |
|
short |
toktype |
|
short |
tokval |
|
◆ sValCmd2
Definition at line 68 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 77 of file gentable.cc.
Data Fields |
short |
arg |
|
short |
cmd |
|
int |
p |
|
proc1 |
p |
|
short |
res |
|
short |
valid_for |
|
◆ sValCmd3
Definition at line 85 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 95 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_LP
◆ ALLOW_NC
◆ ALLOW_PLURAL
◆ ALLOW_RING
◆ ALLOW_ZERODIVISOR
#define ALLOW_ZERODIVISOR 0 |
◆ ALLOW_ZZ
◆ COMM_PLURAL
◆ GENTABLE
◆ IPARITH
◆ IPASSIGN
◆ IPCONV
◆ jjWRONG
◆ jjWRONG2
◆ jjWRONG3
◆ NC_MASK
◆ NO_CONVERSION
◆ NO_NC
◆ NO_RING
◆ NO_ZERODIVISOR
◆ NULL_VAL
◆ RING_MASK
◆ WARN_RING
◆ ZERODIVISOR_MASK [1/2]
#define ZERODIVISOR_MASK 8 |
◆ ZERODIVISOR_MASK [2/2]
#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 193 of file gentable.cc.
196 cmdnames *pCmdL = (cmdnames*)a;
197 cmdnames *pCmdR = (cmdnames*)
b;
202 if(pCmdL->name==
NULL)
return 1;
203 if(pCmdR->name==
NULL)
return -1;
206 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
207 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
210 if (pCmdL->tokval==-1)
212 if (pCmdR->tokval==-1)
213 return strcmp(pCmdL->name, pCmdR->name);
218 if(pCmdR->tokval==-1)
return -1;
220 return strcmp(pCmdL->name, pCmdR->name);
◆ _texi_sort_cmds()
static int _texi_sort_cmds |
( |
const void * |
a, |
|
|
const void * |
b |
|
) |
| |
|
static |
Definition at line 222 of file gentable.cc.
225 cmdnames *pCmdL = (cmdnames*)a;
226 cmdnames *pCmdR = (cmdnames*)
b;
231 if(pCmdL->name==
NULL)
return 1;
232 if(pCmdR->name==
NULL)
return -1;
235 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
236 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
237 char *ls=
strdup(pCmdL->name);
238 char *rs=
strdup(pCmdR->name);
240 while (*
s) { *
s=tolower(*
s);
s++; }
242 while (*
s) { *
s=tolower(*
s);
s++; }
245 if (pCmdL->tokval==-1)
247 if (pCmdR->tokval==-1)
248 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
254 if(pCmdR->tokval==-1)
257 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
◆ iiTestConvert()
int iiTestConvert |
( |
int |
inputType, |
|
|
int |
outputType |
|
) |
| |
Definition at line 300 of file gentable.cc.
303 if ((inputType==outputType)
305 || (outputType==
IDHDL)
310 if (inputType==
UNKNOWN)
return 0;
◆ iiTwoOps()
const char* iiTwoOps |
( |
int |
t | ) |
|
Definition at line 260 of file gentable.cc.
287 case LE:
return "<=";
288 case GE:
return ">=";
◆ is_ref_cmd()
int is_ref_cmd |
( |
cmdnames * |
c | ) |
|
Definition at line 653 of file gentable.cc.
656 if( c->tokval==0)
return 0;
657 if (c->alias > 0)
return 0;
658 if ((c->toktype==
CMD_1)
659 || (c->toktype==
CMD_2)
660 || (c->toktype==
CMD_3)
661 || (c->toktype==
CMD_M)
665 || (c->toktype==
CMD_123))
return 1;
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
|
|
) |
| |
◆ RingDependend()
int RingDependend |
( |
int |
t | ) |
|
|
inline |
◆ Tok2Cmdname()
const char* Tok2Cmdname |
( |
int |
tok | ) |
|
Definition at line 139 of file gentable.cc.
146 if (tok==
COMMAND)
return "command";
147 if (tok==
ANY_TYPE)
return "any_type";
148 if (tok==
NONE)
return "nothing";
155 if (tok==
IDHDL)
return "identifier";
159 while (
cmds[
i].tokval!=0)
161 if ((
cmds[
i].tokval == tok)&&(
cmds[
i].alias==0))
168 while (
cmds[
i].tokval!=0)
170 if (
cmds[
i].tokval == tok)
178 sprintf(
s,
"(%d)",tok);
◆ ttGen1()
Definition at line 329 of file gentable.cc.
343 "/****************************************\n"
344 "* Computer Algebra System SINGULAR *\n"
345 "****************************************/\n\n");
347 fprintf(outfile,
"// syntax table for Singular\n//\n");
348 fprintf(outfile,
"// - search for an exact match of the argument types\n");
349 fprintf(outfile,
"// - otherwise search for the first possibility\n");
350 fprintf(outfile,
"// with converted types of the arguments\n");
351 fprintf(outfile,
"// - otherwise report an error\n//\n");
358 fprintf(outfile,
"// DUMMY ");
360 fprintf(outfile,
"// operation: %s (%s) -> %s",
365 fprintf(outfile,
" requires currRing");
367 fprintf(outfile,
", commutative subalgebra");
369 fprintf(outfile,
", letterplace rings");
371 fprintf(outfile,
", only commutative rings");
373 fprintf(outfile,
", field coeffs");
375 fprintf(outfile,
", domain coeffs");
377 fprintf(outfile,
", QQ coeffs");
379 fprintf(outfile,
"\n");
382 fprintf(outfile,
"/*---------------------------------------------*/\n");
387 fprintf(outfile,
"// DUMMY ");
389 fprintf(outfile,
"// operation: %s (%s, %s) -> %s",
398 fprintf(outfile,
" requires currRing");
401 fprintf(outfile,
", commutative subalgebra");
403 fprintf(outfile,
", only commutative rings");
405 fprintf(outfile,
", field coeffs");
407 fprintf(outfile,
", domain coeffs");
409 fprintf(outfile,
", QQ coeffs");
411 fprintf(outfile,
"\n");
414 fprintf(outfile,
"/*---------------------------------------------*/\n");
420 fprintf(outfile,
"// DUMMY ");
421 fprintf(outfile,
"// operation: %s (%s, %s, %s) -> %s",
432 fprintf(outfile,
" requires currRing");
435 fprintf(outfile,
", commutative subalgebra");
437 fprintf(outfile,
", only commutative rings");
439 fprintf(outfile,
", field coeffs");
441 fprintf(outfile,
", domain coeffs");
443 fprintf(outfile,
", QQ coeffs");
445 fprintf(outfile,
"\n");
448 fprintf(outfile,
"/*---------------------------------------------*/\n");
453 fprintf(outfile,
"// operation: %s (...) -> %s",
459 fprintf(outfile,
" ( number of arguments >0 )\n");
462 fprintf(outfile,
" ( any number of arguments )\n");
465 fprintf(outfile,
" ( %d arguments )\n",
dArithM[
i].number_of_args);
470 fprintf(outfile,
"/*---------------------------------------------*/\n");
474 fprintf(outfile,
"// assign: %s = %s\n",
480 fprintf(outfile,
"/*---------------------------------------------*/\n");
484 doctable=fopen(
"convert_table.texi",
"w");
485 fprintf(doctable,
"@multitable @columnfractions .05 .18 .81\n");
495 fprintf(outfile,
"// convert %s -> %s\n",
500 "@item\n@ %d. @tab @code{%s} @tab @expansion{} @code{%s}\n",
510 fprintf(doctable,
"@end multitable\n");
513 fprintf(outfile,
"/*---------------------------------------------*/\n");
514 char ops[]=
"=><+*/[.^,%(;";
515 for(
i=0;ops[
i]!=
'\0';
i++)
516 fprintf(outfile,
"// token %d : %c\n", (
int)ops[
i], ops[
i]);
522 fprintf(outfile,
"// token %d : %s\n",
i,
s);
526 fprintf(outfile,
"/*--max. token: %d, gr: %d --*/\n",
MAX_TOK,
UMINUS);
528 fprintf(outfile,
"/*---------------------------------------------*/\n");
530 "const struct sValCmdTab dArithTab1[]=\n"
538 fprintf(outfile,
" { %d,%d },\n",
j,
i);
544 fprintf(outfile,
" { 10000,0 }\n};\n");
545 fprintf(outfile,
"#define JJTAB1LEN %d\n",l1);
548 "const struct sValCmdTab dArithTab2[]=\n"
556 fprintf(outfile,
" { %d,%d },\n",
j,
i);
562 fprintf(outfile,
" { 10000,0 }\n};\n");
563 fprintf(outfile,
"#define JJTAB2LEN %d\n",l2);
◆ ttGen2b()
generate cmds initialisation
Definition at line 571 of file gentable.cc.
574 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
578 "/****************************************\n"
579 "* Computer Algebra System SINGULAR *\n"
580 "****************************************/\n\n");
582 fprintf(outfile,
"// identifier table for Singular\n//\n");
586 "#ifdef MODULE_GENERATOR\n"
587 "#define omAlloc0(A) malloc(A)\n"
589 "void iiInitCmdName()\n{\n"
590 " sArithBase.nCmdUsed = 0;\n"
591 " sArithBase.nCmdAllocated = %d;\n"
592 " sArithBase.sCmds = (cmdnames*)omAlloc0(sArithBase.nCmdAllocated*sizeof(cmdnames));\n"
594 " // name-string alias tokval toktype index\n",
601 for(
m=0;
m<cmd_size;
m++)
603 if(
cmds[
m].tokval>0) id_nr++;
604 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, %3d, ",
cmds[
m].
name,
608 switch(
cmds[
m].toktype)
610 case CMD_1: fprintf(outfile,
"CMD_1");
break;
611 case CMD_2: fprintf(outfile,
"CMD_2");
break;
612 case CMD_3: fprintf(outfile,
"CMD_3");
break;
613 case CMD_12: fprintf(outfile,
"CMD_12");
break;
614 case CMD_123 : fprintf(outfile,
"CMD_123");
break;
615 case CMD_23: fprintf(outfile,
"CMD_23");
break;
616 case CMD_M: fprintf(outfile,
"CMD_M");
break;
617 case SYSVAR: fprintf(outfile,
"SYSVAR");
break;
618 case ROOT_DECL: fprintf(outfile,
"ROOT_DECL");
break;
620 case RING_DECL: fprintf(outfile,
"RING_DECL");
break;
621 case NONE: fprintf(outfile,
"NONE");
break;
623 if((
cmds[
m].toktype>
' ') &&(
cmds[
m].toktype<127))
625 fprintf(outfile,
"'%c'",
cmds[
m].toktype);
629 fprintf(outfile,
"%d",
cmds[
m].toktype);
633 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, -1, 0 );\n",
640 fprintf(outfile,
", %d);\n",
m);
642 fprintf(outfile,
"/* end of list marker */\n");
644 " sArithBase.nLastIdentifier = %d;\n",
650 "#define LAST_IDENTIFIER %d\n"
◆ ttGen2c()
Definition at line 667 of file gentable.cc.
670 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
672 FILE *outfile = fopen(
"reference_table.texi",
"w");
673 fprintf(outfile,
"@menu\n");
678 for(
m=0;
m<cmd_size;
m++)
683 fprintf(outfile,
"* %s::\n",
cmds[
m].
name);
686 fprintf(outfile,
"@end menu\n@c ---------------------------\n");
687 for(
m=0;
m<cmd_size;
m++)
692 fprintf(outfile,
"@node %s,",
cmds[
m].
name);
697 fprintf(outfile,
"%s,",
cmds[mm].
name);
699 fprintf(outfile,
",");
706 fprintf(outfile,
",");
708 fprintf(outfile,
"Functions\n"
711 fprintf(outfile,
"@include %s.part\n",
cmds[
m].
name);
713 sprintf(partName,
"%s.part",
cmds[
m].
name);
715 if (lstat(partName,&
buf)!=0)
718 int only_field=0,only_comm=0,no_zerodiv=0;
719 FILE *part=fopen(partName,
"w");
720 fprintf(part,
"@table @code\n@item @strong{Syntax:}\n");
781 fprintf(part,
"@code{%s (} %s, %s, %s @code{)}\n",
cmds[
m].
name,
805 fprintf(part,
"@code{%s (} ... @code{)}\n",
cmds[
m].
name);
818 fprintf(part,
"@item @strong{Remark:}\n"
819 "only for commutive polynomial rings\n");
821 fprintf(part,
"@item @strong{Remark:}\n"
822 "only for polynomial rings over fields\n");
824 fprintf(part,
"@item @strong{Remark:}\n"
825 "only for polynomial rings over domains\n");
826 fprintf(part,
"@item @strong{Purpose:}\n"
827 "@item @strong{Example:}\n"
831 "@end smallexample\n"
◆ ttGen4()
Definition at line 843 of file gentable.cc.
846 FILE *outfile = fopen(
"plural_cmd.xx",
"w");
848 const char *old_s=
"";
850 "@c *****************************************\n"
851 "@c * Computer Algebra System SINGULAR *\n"
852 "@c *****************************************\n\n");
854 fprintf(outfile,
"@multicolumn .45 .45\n");
862 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
869 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
872 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
875 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
885 fprintf(outfile,
"@c ---------------------------------------------\n");
892 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
899 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
902 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
905 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
915 fprintf(outfile,
"@c ---------------------------------------------\n");
922 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
929 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
932 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
935 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
945 fprintf(outfile,
"@c ---------------------------------------------\n");
950 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
957 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
960 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
963 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
972 fprintf(outfile,
"@c ---------------------------------------------\n");
973 fprintf(outfile,
"@end table\n");
975 rename(
"plural_cmd.xx",
"plural_cmd.inc");
◆ iparith_inc
◆ produce_convert_table
int produce_convert_table =0 |