version 1.1, 1999/12/09 22:44:56 |
version 1.2, 1999/12/22 11:26:37 |
|
|
/* -*- mode: C; coding: euc-japan -*- */ |
/* -*- mode: C; coding: euc-japan -*- */ |
/* $OpenXM$ */ |
/* $OpenXM: OpenXM/src/ox_toolkit/parse.c,v 1.1 1999/12/09 22:44:56 ohara Exp $ */ |
|
|
/* OX expression, CMO expression パーサ */ |
/* OX expression, CMO expression パーサ */ |
|
|
Line 92 static int parse_error(char *s) |
|
Line 92 static int parse_error(char *s) |
|
longjmp(env_parse, 1); |
longjmp(env_parse, 1); |
} |
} |
|
|
|
int setflag_parse(int flag) |
|
{ |
|
pflag_cmo_addrev = flag; |
|
} |
|
|
|
int init_parser(char *s) |
|
{ |
|
setflag_parse(PFLAG_ADDREV); |
|
setmode_mygetc(s); |
|
} |
|
|
/* この部分は書き換え予定. */ |
/* この部分は書き換え予定. */ |
cmo *parse() |
cmo *parse() |
{ |
{ |
|
|
}else { |
}else { |
parse_error("invalid symbol."); |
parse_error("invalid symbol."); |
} |
} |
parse_lf(); |
/* parse_lf(); */ |
return m; |
return m; |
} |
} |
return NULL; |
return NULL; |
Line 536 static cmo *parse_cmo_error2() |
|
Line 547 static cmo *parse_cmo_error2() |
|
static int c = ' '; |
static int c = ' '; |
|
|
/* 一文字読み込む関数 */ |
/* 一文字読み込む関数 */ |
static int (*GETC)() = getchar; |
static char *mygetc_ptr; |
|
static int mygetc() |
|
{ |
|
return *mygetc_ptr++; |
|
} |
|
|
int setgetc(int (*foo)()) |
int setmode_mygetc(char *s) |
{ |
{ |
GETC = foo; |
mygetc_ptr=s; |
} |
} |
|
|
int resetgetc() |
static int (*GETC)() = mygetc; |
|
|
|
/* 一文字読み込む関数の選択 (ex. setgetc(getchar); ) */ |
|
int setgetc(int (*foo)()) |
{ |
{ |
GETC = getchar; |
if (foo == NULL) { |
|
GETC = mygetc; |
|
}else { |
|
GETC = foo; |
|
} |
} |
} |
|
|
#define SIZE_BUFFER 8192 |
#define SIZE_BUFFER 8192 |
|
|
|
|
c = GETC(); |
c = GETC(); |
return 0; |
return 0; |
} |
|
|
|
/* 一文字読み込む関数 */ |
|
static char *mygetc_line; |
|
static int mygetc_counter; |
|
static int mygetc_counter_max; |
|
static int mygetc_nonlf_flag; |
|
|
|
int mygetc() |
|
{ |
|
int c = '\0'; |
|
|
|
if (mygetc_nonlf_flag && mygetc_counter <= mygetc_counter_max) { |
|
c = mygetc_line[mygetc_counter++]; |
|
if (c == '\0') { |
|
c = '\n'; |
|
mygetc_nonlf_flag = 0; |
|
} |
|
} |
|
return c; |
|
} |
|
|
|
int setmode_mygetc(char *s, int len) |
|
{ |
|
mygetc_nonlf_flag=1; |
|
mygetc_counter=0; |
|
mygetc_counter_max=len; |
|
mygetc_line=s; |
|
} |
|
|
|
int setflag_parse(int flag) |
|
{ |
|
pflag_cmo_addrev = flag; |
|
} |
} |