version 1.3, 1999/11/02 18:58:25 |
version 1.4, 1999/11/02 19:51:18 |
|
|
/* -*- mode: C; coding: euc-japan -*- */ |
/* -*- mode: C; coding: euc-japan -*- */ |
/* $OpenXM: OpenXM/src/ox_math/parse.c,v 1.2 1999/11/02 06:11:58 ohara Exp $ */ |
/* $OpenXM: OpenXM/src/ox_math/parse.c,v 1.3 1999/11/02 18:58:25 ohara Exp $ */ |
/* $Id$ */ |
/* $Id$ */ |
/* OX expression, CMO expression パーサ */ |
/* OX expression, CMO expression パーサ */ |
|
|
Line 73 static int is_token_cmo(int token) |
|
Line 73 static int is_token_cmo(int token) |
|
|
|
static int is_token_sm(int token) |
static int is_token_sm(int token) |
{ |
{ |
return token >= MIN_T_SM && token < MAX_T_SM; |
return token == TOKEN(SM); |
} |
} |
|
|
static int is_token_ox(int token) |
static int is_token_ox(int token) |
Line 158 static ox* parse_ox_data() |
|
Line 158 static ox* parse_ox_data() |
|
return m; |
return m; |
} |
} |
|
|
static int parse_sm() |
|
{ |
|
int sm_code; |
|
if (!is_token_sm(token)) { |
|
parse_error("invalid SM opecode."); |
|
} |
|
sm_code = token - T_MAGIC; |
|
token = lex(); |
|
return sm_code; |
|
} |
|
|
|
|
|
static ox* parse_ox_command() |
static ox* parse_ox_command() |
{ |
{ |
ox* m; |
ox* m; |
|
|
parse_comma(); |
parse_comma(); |
|
parse_left_parenthesis(); |
m = (ox *)new_ox_command(parse_sm()); |
m = (ox *)new_ox_command(parse_sm()); |
parse_right_parenthesis(); |
parse_right_parenthesis(); |
return m; |
return m; |
} |
} |
|
|
|
static int parse_sm() |
|
{ |
|
int sm_code; |
|
if (token != TOKEN(SM)) { |
|
parse_error("no opecode."); |
|
} |
|
sm_code = yylval.d; |
|
token = lex(); |
|
parse_right_parenthesis(); |
|
return sm_code; |
|
} |
|
|
|
|
/* 正しい入力ならば, parse_cmo を呼ぶ時点で, token には |
/* 正しい入力ならば, parse_cmo を呼ぶ時点で, token には |
TOKEN(CMO_xxx), TOKEN(OX_xxx) のいずれかがセットされている. */ |
TOKEN(CMO_xxx), TOKEN(OX_xxx) のいずれかがセットされている. */ |
static cmo *parse_cmo() |
static cmo *parse_cmo() |
Line 576 static char *lex_quoted_string() |
|
Line 578 static char *lex_quoted_string() |
|
typedef struct { |
typedef struct { |
char *key; |
char *key; |
int token; |
int token; |
|
int op; |
} symbol; |
} symbol; |
|
|
#define MK_KEY_CMO(x) { #x , TOKEN(x) } |
#define MK_KEY_CMO(x) { #x , TOKEN(x) , 0} |
#define MK_KEY(x) { #x , TOKEN(x) } |
#define MK_KEY_SM(x) { #x , TOKEN(SM) , x} |
|
#define MK_KEY(x) { #x , TOKEN(x) , 0} |
|
|
static symbol symbol_list[] = { |
static symbol symbol_list[] = { |
MK_KEY_CMO(CMO_NULL), |
MK_KEY_CMO(CMO_NULL), |
Line 596 static symbol symbol_list[] = { |
|
Line 600 static symbol symbol_list[] = { |
|
MK_KEY_CMO(CMO_INDETERMINATE), |
MK_KEY_CMO(CMO_INDETERMINATE), |
MK_KEY_CMO(CMO_DISTRIBUTED_POLYNOMIAL), |
MK_KEY_CMO(CMO_DISTRIBUTED_POLYNOMIAL), |
MK_KEY_CMO(CMO_ERROR2), |
MK_KEY_CMO(CMO_ERROR2), |
MK_KEY(SM_popCMO), |
MK_KEY_SM(SM_popCMO), |
MK_KEY(SM_popString), |
MK_KEY_SM(SM_popString), |
MK_KEY(SM_mathcap), |
MK_KEY_SM(SM_mathcap), |
MK_KEY(SM_pops), |
MK_KEY_SM(SM_pops), |
MK_KEY(SM_executeStringByLocalParser), |
MK_KEY_SM(SM_executeStringByLocalParser), |
MK_KEY(SM_executeFunction), |
MK_KEY_SM(SM_executeFunction), |
MK_KEY(SM_setMathCap), |
MK_KEY_SM(SM_setMathCap), |
MK_KEY(SM_control_kill), |
MK_KEY_SM(SM_control_kill), |
MK_KEY(SM_control_reset_connection), |
MK_KEY_SM(SM_control_reset_connection), |
MK_KEY(OX_COMMAND), MK_KEY(OX_DATA), |
MK_KEY(OX_COMMAND), |
|
MK_KEY(OX_DATA), |
{NULL, 0} /* a gate keeper */ |
{NULL, 0} /* a gate keeper */ |
}; |
}; |
|
|
Line 614 static int token_of_symbol(char *key) |
|
Line 619 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; |
return kp->token; |
return kp->token; |
} |
} |
} |
} |