#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <unistd.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 57 of file gentable.cc.
Data Fields |
short |
alias |
|
const char * |
name |
|
char * |
name |
|
short |
toktype |
|
short |
tokval |
|
◆ sValCmd2
Definition at line 67 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 76 of file gentable.cc.
Data Fields |
short |
arg |
|
short |
cmd |
|
int |
p |
|
proc1 |
p |
|
short |
res |
|
short |
valid_for |
|
◆ sValCmd3
Definition at line 84 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 94 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
◆ 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 192 of file gentable.cc.
194 cmdnames *pCmdL = (cmdnames*)a;
195 cmdnames *pCmdR = (cmdnames*)
b;
200 if(pCmdL->name==
NULL)
return 1;
201 if(pCmdR->name==
NULL)
return -1;
204 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
205 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
208 if (pCmdL->tokval==-1)
210 if (pCmdR->tokval==-1)
211 return strcmp(pCmdL->name, pCmdR->name);
216 if(pCmdR->tokval==-1)
return -1;
218 return strcmp(pCmdL->name, pCmdR->name);
◆ _texi_sort_cmds()
static int _texi_sort_cmds |
( |
const void * |
a, |
|
|
const void * |
b |
|
) |
| |
|
static |
Definition at line 221 of file gentable.cc.
223 cmdnames *pCmdL = (cmdnames*)a;
224 cmdnames *pCmdR = (cmdnames*)
b;
229 if(pCmdL->name==
NULL)
return 1;
230 if(pCmdR->name==
NULL)
return -1;
233 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
234 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
235 char *ls=
strdup(pCmdL->name);
236 char *rs=
strdup(pCmdR->name);
238 while (*
s) { *
s=tolower(*
s);
s++; }
240 while (*
s) { *
s=tolower(*
s);
s++; }
243 if (pCmdL->tokval==-1)
245 if (pCmdR->tokval==-1)
246 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
252 if(pCmdR->tokval==-1)
255 {
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 299 of file gentable.cc.
301 if ((inputType==outputType)
303 || (outputType==
IDHDL)
308 if (inputType==
UNKNOWN)
return 0;
const struct sConvertTypes dConvertTypes[]
◆ iiTwoOps()
const char* iiTwoOps |
( |
int |
t | ) |
|
Definition at line 259 of file gentable.cc.
285 case LE:
return "<=";
286 case GE:
return ">=";
const char * Tok2Cmdname(int tok)
◆ is_ref_cmd()
int is_ref_cmd |
( |
cmdnames * |
c | ) |
|
Definition at line 650 of file gentable.cc.
652 if( c->tokval==0)
return 0;
653 if (c->alias > 0)
return 0;
654 if ((c->toktype==
CMD_1)
655 || (c->toktype==
CMD_2)
656 || (c->toktype==
CMD_3)
657 || (c->toktype==
CMD_M)
661 || (c->toktype==
CMD_123))
return 1;
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
|
|
) |
| |
Definition at line 975 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 138 of file gentable.cc.
144 if (tok==
COMMAND)
return "command";
145 if (tok==
ANY_TYPE)
return "any_type";
146 if (tok==
NONE)
return "nothing";
153 if (tok==
IDHDL)
return "identifier";
157 while (
cmds[
i].tokval!=0)
159 if ((
cmds[
i].tokval == tok)&&(
cmds[
i].alias==0))
166 while (
cmds[
i].tokval!=0)
168 if (
cmds[
i].tokval == tok)
176 sprintf(
s,
"(%d)",tok);
void * malloc(size_t size)
◆ ttGen1()
Definition at line 328 of file gentable.cc.
341 "/****************************************\n"
342 "* Computer Algebra System SINGULAR *\n"
343 "****************************************/\n\n");
345 fprintf(outfile,
"// syntax table for Singular\n//\n");
346 fprintf(outfile,
"// - search for an exact match of the argument types\n");
347 fprintf(outfile,
"// - otherwise search for the first possibility\n");
348 fprintf(outfile,
"// with converted types of the arguments\n");
349 fprintf(outfile,
"// - otherwise report an error\n//\n");
356 fprintf(outfile,
"// DUMMY ");
358 fprintf(outfile,
"// operation: %s (%s) -> %s",
363 fprintf(outfile,
" requires currRing");
365 fprintf(outfile,
", commutative subalgebra");
367 fprintf(outfile,
", only commutative rings");
369 fprintf(outfile,
", field coeffs");
371 fprintf(outfile,
", domain coeffs");
373 fprintf(outfile,
", QQ coeffs");
375 fprintf(outfile,
"\n");
378 fprintf(outfile,
"/*---------------------------------------------*/\n");
383 fprintf(outfile,
"// DUMMY ");
385 fprintf(outfile,
"// operation: %s (%s, %s) -> %s",
394 fprintf(outfile,
" requires currRing");
397 fprintf(outfile,
", commutative subalgebra");
399 fprintf(outfile,
", only commutative rings");
401 fprintf(outfile,
", field coeffs");
403 fprintf(outfile,
", domain coeffs");
405 fprintf(outfile,
", QQ coeffs");
407 fprintf(outfile,
"\n");
410 fprintf(outfile,
"/*---------------------------------------------*/\n");
416 fprintf(outfile,
"// DUMMY ");
417 fprintf(outfile,
"// operation: %s (%s, %s, %s) -> %s",
428 fprintf(outfile,
" requires currRing");
431 fprintf(outfile,
", commutative subalgebra");
433 fprintf(outfile,
", only commutative rings");
435 fprintf(outfile,
", field coeffs");
437 fprintf(outfile,
", domain coeffs");
439 fprintf(outfile,
", QQ coeffs");
441 fprintf(outfile,
"\n");
444 fprintf(outfile,
"/*---------------------------------------------*/\n");
449 fprintf(outfile,
"// operation: %s (...) -> %s",
455 fprintf(outfile,
" ( number of arguments >0 )\n");
458 fprintf(outfile,
" ( any number of arguments )\n");
461 fprintf(outfile,
" ( %d arguments )\n",
dArithM[
i].number_of_args);
466 fprintf(outfile,
"/*---------------------------------------------*/\n");
470 fprintf(outfile,
"// assign: %s = %s\n",
476 fprintf(outfile,
"/*---------------------------------------------*/\n");
480 doctable=fopen(
"convert_table.texi",
"w");
481 fprintf(doctable,
"@multitable @columnfractions .05 .18 .81\n");
491 fprintf(outfile,
"// convert %s -> %s\n",
496 "@item\n@ %d. @tab @code{%s} @tab @expansion{} @code{%s}\n",
506 fprintf(doctable,
"@end multitable\n");
509 fprintf(outfile,
"/*---------------------------------------------*/\n");
510 char ops[]=
"=><+*/[.^,%(;";
511 for(
i=0;ops[
i]!=
'\0';
i++)
512 fprintf(outfile,
"// token %d : %c\n", (
int)ops[
i], ops[
i]);
518 fprintf(outfile,
"// token %d : %s\n",
i,
s);
522 fprintf(outfile,
"/*--max. token: %d, gr: %d --*/\n",
MAX_TOK,
UMINUS);
524 fprintf(outfile,
"/*---------------------------------------------*/\n");
526 "const struct sValCmdTab dArithTab1[]=\n"
534 fprintf(outfile,
" { %d,%d },\n",
j,
i);
540 fprintf(outfile,
" { 10000,0 }\n};\n");
541 fprintf(outfile,
"#define JJTAB1LEN %d\n",l1);
544 "const struct sValCmdTab dArithTab2[]=\n"
552 fprintf(outfile,
" { %d,%d },\n",
j,
i);
558 fprintf(outfile,
" { 10000,0 }\n};\n");
559 fprintf(outfile,
"#define JJTAB2LEN %d\n",l2);
int iiTestConvert(int inputType, int outputType)
const char * iiTwoOps(int t)
const struct sValCmd1 dArith1[]
const struct sValCmd2 dArith2[]
const struct sValCmdM dArithM[]
const struct sValCmd3 dArith3[]
const struct sValAssign dAssign[]
◆ ttGen2b()
generate cmds initialisation
Definition at line 568 of file gentable.cc.
570 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
574 "/****************************************\n"
575 "* Computer Algebra System SINGULAR *\n"
576 "****************************************/\n\n");
578 fprintf(outfile,
"// identifier table for Singular\n//\n");
582 "#ifdef MODULE_GENERATOR\n"
583 "#define omAlloc0(A) malloc(A)\n"
585 "void iiInitCmdName()\n{\n"
586 " sArithBase.nCmdUsed = 0;\n"
587 " sArithBase.nCmdAllocated = %d;\n"
588 " sArithBase.sCmds = (cmdnames*)omAlloc0(sArithBase.nCmdAllocated*sizeof(cmdnames));\n"
590 " // name-string alias tokval toktype index\n",
597 for(
m=0;
m<cmd_size;
m++)
599 if(
cmds[
m].tokval>0) id_nr++;
600 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, %3d, ",
cmds[
m].
name,
604 switch(
cmds[
m].toktype)
606 case CMD_1: fprintf(outfile,
"CMD_1");
break;
607 case CMD_2: fprintf(outfile,
"CMD_2");
break;
608 case CMD_3: fprintf(outfile,
"CMD_3");
break;
609 case CMD_12: fprintf(outfile,
"CMD_12");
break;
610 case CMD_123 : fprintf(outfile,
"CMD_123");
break;
611 case CMD_23: fprintf(outfile,
"CMD_23");
break;
612 case CMD_M: fprintf(outfile,
"CMD_M");
break;
613 case SYSVAR: fprintf(outfile,
"SYSVAR");
break;
614 case ROOT_DECL: fprintf(outfile,
"ROOT_DECL");
break;
616 case RING_DECL: fprintf(outfile,
"RING_DECL");
break;
617 case NONE: fprintf(outfile,
"NONE");
break;
619 if((
cmds[
m].toktype>
' ') &&(
cmds[
m].toktype<127))
621 fprintf(outfile,
"'%c'",
cmds[
m].toktype);
625 fprintf(outfile,
"%d",
cmds[
m].toktype);
629 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, -1, 0 );\n",
636 fprintf(outfile,
", %d);\n",
m);
638 fprintf(outfile,
"/* end of list marker */\n");
640 " sArithBase.nLastIdentifier = %d;\n",
646 "#define LAST_IDENTIFIER %d\n"
char name(const Variable &v)
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
◆ ttGen2c()
Definition at line 664 of file gentable.cc.
666 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
668 FILE *outfile = fopen(
"reference_table.texi",
"w");
669 fprintf(outfile,
"@menu\n");
674 for(
m=0;
m<cmd_size;
m++)
679 fprintf(outfile,
"* %s::\n",
cmds[
m].
name);
682 fprintf(outfile,
"@end menu\n@c ---------------------------\n");
683 for(
m=0;
m<cmd_size;
m++)
688 fprintf(outfile,
"@node %s,",
cmds[
m].
name);
693 fprintf(outfile,
"%s,",
cmds[mm].
name);
695 fprintf(outfile,
",");
702 fprintf(outfile,
",");
704 fprintf(outfile,
"Functions\n"
707 fprintf(outfile,
"@include %s.part\n",
cmds[
m].
name);
709 sprintf(partName,
"%s.part",
cmds[
m].
name);
711 if (lstat(partName,&
buf)!=0)
714 int only_field=0,only_comm=0,no_zerodiv=0;
715 FILE *part=fopen(partName,
"w");
716 fprintf(part,
"@table @code\n@item @strong{Syntax:}\n");
777 fprintf(part,
"@code{%s (} %s, %s, %s @code{)}\n",
cmds[
m].
name,
801 fprintf(part,
"@code{%s (} ... @code{)}\n",
cmds[
m].
name);
814 fprintf(part,
"@item @strong{Remark:}\n"
815 "only for commutive polynomial rings\n");
817 fprintf(part,
"@item @strong{Remark:}\n"
818 "only for polynomial rings over fields\n");
820 fprintf(part,
"@item @strong{Remark:}\n"
821 "only for polynomial rings over domains\n");
822 fprintf(part,
"@item @strong{Purpose:}\n"
823 "@item @strong{Example:}\n"
827 "@end smallexample\n"
int is_ref_cmd(cmdnames *c)
static int _texi_sort_cmds(const void *a, const void *b)
int status int void * buf
◆ ttGen4()
Definition at line 840 of file gentable.cc.
842 FILE *outfile = fopen(
"plural_cmd.xx",
"w");
844 const char *old_s=
"";
846 "@c *****************************************\n"
847 "@c * Computer Algebra System SINGULAR *\n"
848 "@c *****************************************\n\n");
850 fprintf(outfile,
"@multicolumn .45 .45\n");
858 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
865 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
868 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
871 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
881 fprintf(outfile,
"@c ---------------------------------------------\n");
888 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
895 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
898 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
901 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
911 fprintf(outfile,
"@c ---------------------------------------------\n");
918 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
925 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
928 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
931 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
941 fprintf(outfile,
"@c ---------------------------------------------\n");
946 if ((
s!=
NULL) && (isalpha(
s[0])) && (strcmp(
s,old_s)!=0))
953 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",
s);
956 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",
s,
s);
959 fprintf(outfile,
"@item @ref{%s} @tab %s\n",
s,
s);
968 fprintf(outfile,
"@c ---------------------------------------------\n");
969 fprintf(outfile,
"@end table\n");
971 rename(
"plural_cmd.xx",
"plural_cmd.inc");
◆ iparith_inc
◆ produce_convert_table
int produce_convert_table =0 |