| version 1.3, 2001/05/04 01:06:24 |
version 1.13, 2020/10/06 11:33:46 |
|
|
| /* $OpenXM: OpenXM/src/kan96xx/Kan/parser.c,v 1.2 2000/01/16 07:55:40 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/parser.c,v 1.12 2015/10/08 11:49:37 takayama Exp $ */ |
| /* |
/* |
| parser.c parser for poly.c |
parser.c parser for poly.c |
| */ |
*/ |
| |
|
| #include <stdio.h> |
#include <stdio.h> |
| |
#include <string.h> |
| #include "datatype.h" |
#include "datatype.h" |
| #include "setjmp.h" |
#include "setjmp.h" |
| #include "stackm.h" |
#include "stackm.h" |
| #include "extern.h" |
#include "extern.h" |
| #include "extern2.h" |
#include "extern2.h" |
| |
|
| |
|
| #define NUM 1 /* NUM means struct Bignum */ |
#define NUM 1 /* NUM means struct Bignum */ |
| #define POL 0 |
#define POL 0 |
| |
|
| Line 22 union valObject { |
|
| Line 24 union valObject { |
|
| POLY p; |
POLY p; |
| }; |
}; |
| |
|
| |
#if defined(__CYGWIN__) |
| |
static sigjmp_buf EnvOfParser; |
| |
#else |
| static jmp_buf EnvOfParser; |
static jmp_buf EnvOfParser; |
| |
#endif |
| |
|
| static char *String; |
static char *String; |
| static int StrPtr = 0; /* String and StrPtr are used in getcharFromStr() */ |
static int StrPtr = 0; /* String and StrPtr are used in getcharFromStr() */ |
| Line 35 static int Spv = 0; /* stack pointer */ |
|
| Line 40 static int Spv = 0; /* stack pointer */ |
|
| #define SSIZE 20000 |
#define SSIZE 20000 |
| static int TagStack[SSIZE]; |
static int TagStack[SSIZE]; |
| static union valObject ValStack[SSIZE]; |
static union valObject ValStack[SSIZE]; |
| #define NAME_MAX 2000 |
#define MY_NAME_MAX 2000 |
| static char Name[NAME_MAX]; |
static char Name[MY_NAME_MAX]; |
| |
|
| static union valObject ValTmp; |
static union valObject ValTmp; |
| |
|
| Line 119 POLY stringToPOLY(s,ringp) |
|
| Line 124 POLY stringToPOLY(s,ringp) |
|
| Ring0 = *ringp; |
Ring0 = *ringp; |
| Ring0.p = 0; |
Ring0.p = 0; |
| Ring0.next = (struct ring *)NULL; |
Ring0.next = (struct ring *)NULL; |
| |
#if defined(__CYGWIN__) |
| if (setjmp(EnvOfParser)) { |
if (MYSIGSETJMP(EnvOfParser,1)) { |
| |
#else |
| |
if (MYSETJMP(EnvOfParser)) { |
| |
#endif |
| fprintf(stderr,"\nERROR: You have syntax errors in the expression: %s\n",s); |
fprintf(stderr,"\nERROR: You have syntax errors in the expression: %s\n",s); |
| errorKan1("%s\n"," parser.c : Syntax error in the input polynomial."); |
errorKan1("%s\n"," parser.c : Syntax error in the input polynomial."); |
| return( POLYNULL ); /* error */ |
return( POLYNULL ); /* error */ |
| Line 214 static int getoken() { |
|
| Line 222 static int getoken() { |
|
| i = 0; |
i = 0; |
| do { |
do { |
| Name[i] = Ch; Name[i+1] = '\0'; i++; |
Name[i] = Ch; Name[i+1] = '\0'; i++; |
| if (i+2 >= NAME_MAX) { |
if (i+2 >= MY_NAME_MAX) { |
| errorParser("Too long name begining with @."); |
errorParser("Too long name begining with @."); |
| } |
} |
| Ch = getcharFromStr(); |
Ch = getcharFromStr(); |
| Line 404 static void term() { |
|
| Line 412 static void term() { |
|
| |
|
| }else { |
}else { |
| if (ftype == NUM && gtype == NUM) { |
if (ftype == NUM && gtype == NUM) { |
| |
errorParser("num/num is not supported yet.\n"); |
| mpz_div(f,f,g); |
mpz_div(f,f,g); |
| utmp.ival = f; |
utmp.ival = f; |
| push(NUM,utmp); |
push(NUM,utmp); |
| Line 479 static void factor() { |
|
| Line 488 static void factor() { |
|
| |
|
| static void monom() { |
static void monom() { |
| union valObject utmp; |
union valObject utmp; |
| struct object obj; |
struct object obj = OINIT; |
| POLY f; |
POLY f; |
| extern struct context *CurrentContextp; |
extern struct context *CurrentContextp; |
| if (Symbol == 'x' || Symbol == 'd') { |
if (Symbol == 'x' || Symbol == 'd') { |
| Line 560 static void errorParser(s) char s[]; { |
|
| Line 569 static void errorParser(s) char s[]; { |
|
| extern char *GotoLabel; |
extern char *GotoLabel; |
| extern int GotoP; |
extern int GotoP; |
| extern int ErrorMessageMode; |
extern int ErrorMessageMode; |
| |
extern int RestrictedMode, RestrictedMode_saved; |
| int j; |
int j; |
| char tmpc[1024]; |
char tmpc[1024]; |
| |
RestrictedMode = RestrictedMode_saved; |
| |
cancelAlarm(); |
| if (ErrorMessageMode == 1 || ErrorMessageMode == 2) { |
if (ErrorMessageMode == 1 || ErrorMessageMode == 2) { |
| sprintf(tmpc,"\nError(parser.c): "); |
sprintf(tmpc,"\nError(parser.c): "); |
| if (strlen(s) < 1000-strlen(tmpc)) { |
if (strlen(s) < 1000-strlen(tmpc)) { |
| Line 589 static void errorParser(s) char s[]; { |
|
| Line 601 static void errorParser(s) char s[]; { |
|
| fprintf(Fstack,"The interpreter was looking for the label <<%s>>. It is also aborted.\n",GotoLabel); |
fprintf(Fstack,"The interpreter was looking for the label <<%s>>. It is also aborted.\n",GotoLabel); |
| GotoP = 0; |
GotoP = 0; |
| } |
} |
| longjmp(EnvOfParser,1); |
#if defined(__CYGWIN__) |
| |
MYSIGLONGJMP(EnvOfParser,1); |
| |
#else |
| |
MYLONGJMP(EnvOfParser,1); |
| |
#endif |
| } |
} |
| |
|