| version 1.5, 1999/11/03 10:56:40 |
version 1.6, 1999/11/04 18:15:20 |
|
|
| /* -*- mode: C; coding: euc-japan -*- */ |
/* -*- mode: C; coding: euc-japan -*- */ |
| /* $OpenXM: OpenXM/src/ox_math/parse.c,v 1.4 1999/11/02 19:51:18 ohara Exp $ */ |
/* $OpenXM: OpenXM/src/ox_math/parse.c,v 1.5 1999/11/03 10:56:40 ohara Exp $ */ |
| |
|
| /* OX expression, CMO expression パーサ */ |
/* OX expression, CMO expression パーサ */ |
| |
|
| Line 60 static cmo *parse_cmo_zero(); |
|
| Line 60 static cmo *parse_cmo_zero(); |
|
| static cmo *parse_cmo_dms_generic(); |
static cmo *parse_cmo_dms_generic(); |
| static cmo *parse_cmo_ring_by_name(); |
static cmo *parse_cmo_ring_by_name(); |
| static cmo *parse_cmo_distributed_polynomial(); |
static cmo *parse_cmo_distributed_polynomial(); |
| |
static cmo *parse_cmo_indeterminate(); |
| static cmo *parse_cmo_error2(); |
static cmo *parse_cmo_error2(); |
| static cmo *parse_cmo(); |
static cmo *parse_cmo(); |
| static int parse_sm(); |
static int parse_sm(); |
| Line 234 static cmo *parse_cmo() |
|
| Line 235 static cmo *parse_cmo() |
|
| token = lex(); |
token = lex(); |
| m = parse_cmo_distributed_polynomial(); |
m = parse_cmo_distributed_polynomial(); |
| break; |
break; |
| |
case TOKEN(CMO_INDETERMINATE): |
| |
token = lex(); |
| |
m = parse_cmo_indeterminate(); |
| |
break; |
| case TOKEN(CMO_ERROR2): |
case TOKEN(CMO_ERROR2): |
| token = lex(); |
token = lex(); |
| m = parse_cmo_error2(); |
m = parse_cmo_error2(); |
| Line 490 static cmo *parse_cmo_distributed_polynomial() |
|
| Line 495 static cmo *parse_cmo_distributed_polynomial() |
|
| if (ob->tag != CMO_MONOMIAL32 && ob->tag != CMO_ZERO) { |
if (ob->tag != CMO_MONOMIAL32 && ob->tag != CMO_ZERO) { |
| parse_error("invalid cmo."); |
parse_error("invalid cmo."); |
| } |
} |
| append_cmo_list(m, ob); |
append_cmo_list((cmo_list *)m, ob); |
| if (token != ',') { |
if (token != ',') { |
| break; |
break; |
| } |
} |
| Line 503 static cmo *parse_cmo_distributed_polynomial() |
|
| Line 508 static cmo *parse_cmo_distributed_polynomial() |
|
| return (cmo *)m; |
return (cmo *)m; |
| } |
} |
| |
|
| |
static cmo *parse_cmo_indeterminate() |
| |
{ |
| |
cmo *ob; |
| |
|
| |
parse_comma(); |
| |
parse_left_parenthesis(); |
| |
ob = parse_cmo(); |
| |
parse_right_parenthesis(); |
| |
return (cmo *)new_cmo_indeterminate(ob); |
| |
} |
| |
|
| static cmo *parse_cmo_error2() |
static cmo *parse_cmo_error2() |
| { |
{ |
| cmo *ob; |
cmo *ob; |
| Line 578 static char *lex_quoted_string() |
|
| Line 593 static char *lex_quoted_string() |
|
| |
|
| typedef struct { |
typedef struct { |
| char *key; |
char *key; |
| |
int tag; |
| int token; |
int token; |
| int op; |
|
| } symbol; |
} symbol; |
| |
|
| #define MK_KEY_CMO(x) { #x , TOKEN(x) , 0} |
#define MK_KEY_CMO(x) { #x , x , TOKEN(x) } |
| #define MK_KEY_SM(x) { #x , TOKEN(SM) , x} |
#define MK_KEY_SM(x) { #x , x , TOKEN(SM) } |
| #define MK_KEY(x) { #x , TOKEN(x) , 0} |
#define MK_KEY(x) { #x , x , TOKEN(x) } |
| |
|
| static symbol symbol_list[] = { |
static symbol symbol_list[] = { |
| MK_KEY_CMO(CMO_NULL), |
MK_KEY_CMO(CMO_NULL), |
| Line 612 static symbol symbol_list[] = { |
|
| Line 627 static symbol symbol_list[] = { |
|
| MK_KEY_SM(SM_control_reset_connection), |
MK_KEY_SM(SM_control_reset_connection), |
| MK_KEY(OX_COMMAND), |
MK_KEY(OX_COMMAND), |
| MK_KEY(OX_DATA), |
MK_KEY(OX_DATA), |
| {NULL, 0} /* a gate keeper */ |
{NULL, 0, 0} /* a gate keeper */ |
| }; |
}; |
| |
|
| static int token_of_symbol(char *key) |
static int token_of_symbol(char *key) |
| Line 620 static int token_of_symbol(char *key) |
|
| Line 635 static int token_of_symbol(char *key) |
|
| symbol *kp; |
symbol *kp; |
| for(kp = symbol_list; kp->key != NULL; kp++) { |
for(kp = symbol_list; kp->key != NULL; kp++) { |
| if (strcmp(key, kp->key)==0) { |
if (strcmp(key, kp->key)==0) { |
| yylval.d = kp->op; |
yylval.d = kp->tag; |
| return kp->token; |
return kp->token; |
| } |
} |
| } |
} |
|
|
| return 0; |
return 0; |
| } |
} |
| |
|
| |
/* 一文字読み込む関数 */ |
| static char *mygetc_line; |
static char *mygetc_line; |
| static int mygetc_counter; |
static int mygetc_counter; |
| static int mygetc_counter_max; |
static int mygetc_counter_max; |
| |
static int mygetc_nonlf_flag; |
| |
|
| int mygetc() |
int mygetc() |
| { |
{ |
| if (mygetc_counter <= mygetc_counter_max) { |
int c = '\0'; |
| return mygetc_line[mygetc_counter++]; |
|
| |
if (mygetc_nonlf_flag && mygetc_counter <= mygetc_counter_max) { |
| |
c = mygetc_line[mygetc_counter++]; |
| |
if (c == '\0') { |
| |
c = '\n'; |
| |
mygetc_nonlf_flag = 0; |
| |
} |
| } |
} |
| return 0; |
return c; |
| } |
} |
| |
|
| int setmode_mygetc(char *s, int len) |
int setmode_mygetc(char *s, int len) |
| { |
{ |
| |
mygetc_nonlf_flag=1; |
| mygetc_counter=0; |
mygetc_counter=0; |
| mygetc_counter_max=len; |
mygetc_counter_max=len; |
| mygetc_line=s; |
mygetc_line=s; |