#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 49 of file gentable.cc.
Data Fields |
short |
alias |
|
const char * |
name |
|
char * |
name |
|
short |
toktype |
|
short |
tokval |
|
§ sValCmd2
Definition at line 59 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 68 of file gentable.cc.
Data Fields |
short |
arg |
|
short |
cmd |
|
int |
p |
|
proc1 |
p |
|
short |
res |
|
short |
valid_for |
|
§ sValCmd3
Definition at line 76 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 86 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 |
§ 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 187 of file gentable.cc.
189 cmdnames *pCmdL = (cmdnames*)
a;
190 cmdnames *pCmdR = (cmdnames*)
b;
195 if(pCmdL->name==
NULL)
return 1;
196 if(pCmdR->name==
NULL)
return -1;
199 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
200 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
203 if (pCmdL->tokval==-1)
205 if (pCmdR->tokval==-1)
206 return strcmp(pCmdL->name, pCmdR->name);
211 if(pCmdR->tokval==-1)
return -1;
213 return strcmp(pCmdL->name, pCmdR->name);
§ _texi_sort_cmds()
static int _texi_sort_cmds |
( |
const void * |
a, |
|
|
const void * |
b |
|
) |
| |
|
static |
Definition at line 216 of file gentable.cc.
218 cmdnames *pCmdL = (cmdnames*)
a;
219 cmdnames *pCmdR = (cmdnames*)
b;
224 if(pCmdL->name==
NULL)
return 1;
225 if(pCmdR->name==
NULL)
return -1;
228 if(strcmp(pCmdL->name,
"$INVALID$")==0)
return -1;
229 if(strcmp(pCmdR->name,
"$INVALID$")==0)
return 1;
230 char *ls=
strdup(pCmdL->name);
231 char *rs=
strdup(pCmdR->name);
233 while (*s) { *s=tolower(*s); s++; }
235 while (*s) { *s=tolower(*s); s++; }
238 if (pCmdL->tokval==-1)
240 if (pCmdR->tokval==-1)
241 {
int r=strcmp(ls,rs);
free(ls);
free(rs);
return r; }
247 if(pCmdR->tokval==-1)
250 {
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 294 of file gentable.cc.
296 if ((inputType==outputType)
298 || (outputType==
IDHDL)
303 if (inputType==
UNKNOWN)
return 0;
const struct sConvertTypes dConvertTypes[]
§ iiTwoOps()
const char* iiTwoOps |
( |
int |
t | ) |
|
Definition at line 254 of file gentable.cc.
280 case LE:
return "<=";
281 case GE:
return ">=";
const char * Tok2Cmdname(int tok)
§ is_ref_cmd()
int is_ref_cmd |
( |
cmdnames * |
c | ) |
|
Definition at line 611 of file gentable.cc.
613 if( c->tokval==0)
return 0;
614 if (c->alias > 0)
return 0;
615 if ((c->toktype==
CMD_1)
616 || (c->toktype==
CMD_2)
617 || (c->toktype==
CMD_3)
618 || (c->toktype==
CMD_M)
622 || (c->toktype==
CMD_123))
return 1;
§ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 936 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 130 of file gentable.cc.
136 if (tok==
COMMAND)
return "command";
137 if (tok==
ANY_TYPE)
return "any_type";
138 if (tok==
NONE)
return "nothing";
145 if (tok==
IDHDL)
return "identifier";
152 while (
cmds[i].tokval!=0)
154 if ((
cmds[i].tokval == tok)&&(
cmds[i].alias==0))
161 while (
cmds[i].tokval!=0)
163 if (
cmds[i].tokval == tok)
171 sprintf(s,
"(%d)",tok);
const CanonicalForm int s
void * malloc(size_t size)
§ ttGen1()
Definition at line 323 of file gentable.cc.
336 "/****************************************\n" 337 "* Computer Algebra System SINGULAR *\n" 338 "****************************************/\n\n");
340 fprintf(outfile,
"// syntax table for Singular\n//\n");
341 fprintf(outfile,
"// - search for an exact match of the argument types\n");
342 fprintf(outfile,
"// - otherwise search for the first possibility\n");
343 fprintf(outfile,
"// with converted types of the arguments\n");
344 fprintf(outfile,
"// - otherwise report an error\n//\n");
351 fprintf(outfile,
"// DUMMY ");
353 fprintf(outfile,
"// operation: %s (%s) -> %s\n",
359 fprintf(outfile,
"// WARNING: %s requires currRing\n",s);
363 fprintf(outfile,
"/*---------------------------------------------*/\n");
368 fprintf(outfile,
"// DUMMY ");
370 fprintf(outfile,
"// operation: %s (%s, %s) -> %s\n",
379 fprintf(outfile,
"// WARNING: %s requires currRing\n",s);
383 fprintf(outfile,
"/*---------------------------------------------*/\n");
389 fprintf(outfile,
"// DUMMY ");
390 fprintf(outfile,
"// operation: %s (%s, %s, %s) -> %s\n",
401 fprintf(outfile,
"// WARNING: %s requires currRing\n",s);
405 fprintf(outfile,
"/*---------------------------------------------*/\n");
410 fprintf(outfile,
"// operation: %s (...) -> %s",
413 switch(
dArithM[i].number_of_args)
416 fprintf(outfile,
" ( number of arguments >0 )\n");
419 fprintf(outfile,
" ( any number of arguments )\n");
422 fprintf(outfile,
" ( %d arguments )\n",
dArithM[i].number_of_args);
427 fprintf(outfile,
"/*---------------------------------------------*/\n");
431 fprintf(outfile,
"// assign: %s = %s\n",
437 fprintf(outfile,
"/*---------------------------------------------*/\n");
441 doctable=fopen(
"convert_table.texi",
"w");
442 fprintf(doctable,
"@multitable @columnfractions .05 .18 .81\n");
452 fprintf(outfile,
"// convert %s -> %s\n",
457 "@item\n@ %d. @tab @code{%s} @tab @expansion{} @code{%s}\n",
467 fprintf(doctable,
"@end multitable\n");
470 fprintf(outfile,
"/*---------------------------------------------*/\n");
471 char ops[]=
"=><+*/[.^,%(;";
472 for(i=0;ops[
i]!=
'\0';i++)
473 fprintf(outfile,
"// token %d : %c\n", (
int)ops[i], ops[i]);
479 fprintf(outfile,
"// token %d : %s\n", i, s);
483 fprintf(outfile,
"/*--max. token: %d, gr: %d --*/\n",
MAX_TOK,
UMINUS);
485 fprintf(outfile,
"/*---------------------------------------------*/\n");
487 "const struct sValCmdTab dArithTab1[]=\n" 495 fprintf(outfile,
" { %d,%d },\n",j,i);
501 fprintf(outfile,
" { 10000,0 }\n};\n");
502 fprintf(outfile,
"#define JJTAB1LEN %d\n",l1);
505 "const struct sValCmdTab dArithTab2[]=\n" 513 fprintf(outfile,
" { %d,%d },\n",j,i);
519 fprintf(outfile,
" { 10000,0 }\n};\n");
520 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)
§ ttGen2b()
generate cmds initialisation
Definition at line 529 of file gentable.cc.
531 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
535 "/****************************************\n" 536 "* Computer Algebra System SINGULAR *\n" 537 "****************************************/\n\n");
539 fprintf(outfile,
"// identifier table for Singular\n//\n");
543 "#ifdef MODULE_GENERATOR\n" 544 "#define omAlloc0(A) malloc(A)\n" 546 "void iiInitCmdName()\n{\n" 547 " sArithBase.nCmdUsed = 0;\n" 548 " sArithBase.nCmdAllocated = %d;\n" 549 " sArithBase.sCmds = (cmdnames*)omAlloc0(sArithBase.nCmdAllocated*sizeof(cmdnames));\n" 551 " // name-string alias tokval toktype index\n",
558 for(m=0; m<cmd_size; m++)
560 if(
cmds[m].tokval>0) id_nr++;
561 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, %3d, ",
cmds[m].
name,
562 (
int)(20-strlen(
cmds[m].name)),
565 switch(
cmds[m].toktype)
567 case CMD_1: fprintf(outfile,
"CMD_1");
break;
568 case CMD_2: fprintf(outfile,
"CMD_2");
break;
569 case CMD_3: fprintf(outfile,
"CMD_3");
break;
570 case CMD_12: fprintf(outfile,
"CMD_12");
break;
571 case CMD_123 : fprintf(outfile,
"CMD_123");
break;
572 case CMD_23: fprintf(outfile,
"CMD_23");
break;
573 case CMD_M: fprintf(outfile,
"CMD_M");
break;
574 case SYSVAR: fprintf(outfile,
"SYSVAR");
break;
575 case ROOT_DECL: fprintf(outfile,
"ROOT_DECL");
break;
577 case RING_DECL: fprintf(outfile,
"RING_DECL");
break;
578 case NONE: fprintf(outfile,
"NONE");
break;
580 if((
cmds[m].toktype>
' ') &&(
cmds[m].toktype<127))
582 fprintf(outfile,
"'%c'",
cmds[m].toktype);
586 fprintf(outfile,
"%d",
cmds[m].toktype);
590 fprintf(outfile,
" iiArithAddCmd(\"%s\", %*d, -1, 0 );\n",
591 cmds[m].name, 20-strlen(
cmds[m].name),
597 fprintf(outfile,
", %d);\n", m);
599 fprintf(outfile,
"/* end of list marker */\n");
601 " sArithBase.nLastIdentifier = %d;\n",
607 "#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 625 of file gentable.cc.
627 int cmd_size = (
sizeof(
cmds)/
sizeof(cmdnames))-1;
629 FILE *outfile = fopen(
"reference_table.texi",
"w");
630 fprintf(outfile,
"@menu\n");
635 for(m=0; m<cmd_size; m++)
640 fprintf(outfile,
"* %s::\n",
cmds[m].
name);
643 fprintf(outfile,
"@end menu\n@c ---------------------------\n");
644 for(m=0; m<cmd_size; m++)
649 fprintf(outfile,
"@node %s,",
cmds[m].
name);
654 fprintf(outfile,
"%s,",
cmds[mm].
name);
656 fprintf(outfile,
",");
661 fprintf(outfile,
"%s,",
cmds[m-1].
name);
663 fprintf(outfile,
",");
665 fprintf(outfile,
"Functions\n" 668 fprintf(outfile,
"@include %s.part\n",
cmds[m].
name);
670 sprintf(partName,
"%s.part",
cmds[m].
name);
672 if (lstat(partName,&
buf)!=0)
675 int only_field=0,only_comm=0,no_zerodiv=0;
676 FILE *part=fopen(partName,
"w");
677 fprintf(part,
"@table @code\n@item @strong{Syntax:}\n");
716 if ((
dArith2[i].valid_for & ALLOW_PLURAL)==0)
738 fprintf(part,
"@code{%s (} %s, %s, %s @code{)}\n",
cmds[m].name,
743 if ((
dArith3[i].valid_for & ALLOW_PLURAL)==0)
762 fprintf(part,
"@code{%s (} ... @code{)}\n",
cmds[m].name);
764 if ((
dArithM[i].valid_for & ALLOW_PLURAL)==0)
775 fprintf(part,
"@item @strong{Remark:}\n" 776 "only for commutive polynomial rings\n");
778 fprintf(part,
"@item @strong{Remark:}\n" 779 "only for polynomial rings over fields\n");
781 fprintf(part,
"@item @strong{Remark:}\n" 782 "only for polynomial rings over domains\n");
783 fprintf(part,
"@item @strong{Purpose:}\n" 784 "@item @strong{Example:}\n" 788 "@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)
§ ttGen4()
Definition at line 801 of file gentable.cc.
803 FILE *outfile = fopen(
"plural_cmd.xx",
"w");
805 const char *old_s=
"";
807 "@c *****************************************\n" 808 "@c * Computer Algebra System SINGULAR *\n" 809 "@c *****************************************\n\n");
811 fprintf(outfile,
"@multicolumn .45 .45\n");
819 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
826 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
829 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
832 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
842 fprintf(outfile,
"@c ---------------------------------------------\n");
849 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
856 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
859 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
862 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
872 fprintf(outfile,
"@c ---------------------------------------------\n");
879 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
886 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
889 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
892 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
902 fprintf(outfile,
"@c ---------------------------------------------\n");
907 if ((s!=
NULL) && (isalpha(s[0])) && (strcmp(s,old_s)!=0))
914 fprintf(outfile,
"@item @ref{%s} @tab @code{---}\n",s);
917 fprintf(outfile,
"@item @ref{%s} @tab @ref{%s (plural)}\n",s,s);
920 fprintf(outfile,
"@item @ref{%s} @tab %s\n",s,s);
929 fprintf(outfile,
"@c ---------------------------------------------\n");
930 fprintf(outfile,
"@end table\n");
932 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[]
§ iparith_inc
§ produce_convert_table
int produce_convert_table =0 |