version 1.9, 2005/07/18 10:55:16 |
version 1.11, 2020/10/06 11:33:47 |
|
|
/*$OpenXM: OpenXM/src/kan96xx/Kan/scanner.c,v 1.8 2005/07/03 11:08:54 ohara Exp $*/ |
/*$OpenXM: OpenXM/src/kan96xx/Kan/scanner.c,v 1.10 2018/09/07 00:15:44 takayama Exp $*/ |
/* scanner.c (SM StackMachine) */ |
/* scanner.c (SM StackMachine) */ |
/* export: struct tokens getokenSM(actionType kind,char *str); |
/* export: struct tokens getokenSM(actionType kind,char *str); |
scanner.c is used to get tokens from streams. |
scanner.c is used to get tokens from streams. |
Line 62 static int FileStackP = 0; |
|
Line 62 static int FileStackP = 0; |
|
/**************** end of declaration part of lexical analizer ******/ |
/**************** end of declaration part of lexical analizer ******/ |
|
|
static int getSM(); |
static int getSM(); |
static putSM(); |
static void putSM(); |
static struct tokens flushSM(); |
static struct tokens flushSM(); |
static isSpaceSM(); |
static int isSpaceSM(); |
static isDollarSM(); |
static int isDollarSM(); |
static isBraceSM(); |
static int isBraceSM(); |
static isKakkoSM(); |
static int isKakkoSM(); |
static isSymbolSM(); |
static int isSymbolSM(); |
static mygetchar(); |
static int mygetchar(); |
static myungetchar(); |
static int myungetchar(); |
|
|
int ScannerWhich = 0; |
int ScannerWhich = 0; |
unsigned char ScannerBuf[SCANNERBUF_SIZE]; |
unsigned char ScannerBuf[SCANNERBUF_SIZE]; |
Line 84 static mygetchar() |
|
Line 84 static mygetchar() |
|
} |
} |
*/ |
*/ |
|
|
static mygetchar() |
static int mygetchar() |
{ int c; |
{ int c; |
c = getc(Cfp); |
c = getc(Cfp); |
if (c > 0) { /* ungetchar is ignored */ |
if (c > 0) { /* ungetchar is ignored */ |
Line 93 static mygetchar() |
|
Line 93 static mygetchar() |
|
} |
} |
if (EchoInScanner) { |
if (EchoInScanner) { |
if (c==EOF) { |
if (c==EOF) { |
printf("\n%% EOF of file %x\n",(int) Cfp); |
printf("\n%% EOF of file %p\n",Cfp); |
}else{ |
}else{ |
printf("%c",c); |
printf("%c",c); |
} |
} |
Line 104 static mygetchar() |
|
Line 104 static mygetchar() |
|
} |
} |
|
|
|
|
static myungetchar(c) |
static int myungetchar(c) |
int c; |
int c; |
{ |
{ |
return( ungetc(c,Cfp) ); |
return( ungetc(c,Cfp) ); |
Line 130 static int getSM() |
|
Line 130 static int getSM() |
|
} else return(c); |
} else return(c); |
} |
} |
|
|
static putSM(c) |
static void putSM(c) |
int c; |
int c; |
/* put a letter on BufSM */ |
/* put a letter on BufSM */ |
{ |
{ |
Line 176 static struct tokens flushSM() |
|
Line 176 static struct tokens flushSM() |
|
return(r); |
return(r); |
} |
} |
|
|
static isSpaceSM(c) |
static int isSpaceSM(c) |
int c; |
int c; |
{ |
{ |
if (((c <= ' ') || c == ',') && (c!= EOF)) return(1); |
if (((c <= ' ') || c == ',') && (c!= EOF)) return(1); |
else return(0); |
else return(0); |
} |
} |
|
|
static isDollarSM(c) |
static int isDollarSM(c) |
int c; |
int c; |
{ |
{ |
if (c == '$') return(1); |
if (c == '$') return(1); |
else return(0); |
else return(0); |
} |
} |
|
|
static isBraceSM(c) |
static int isBraceSM(c) |
int c; |
int c; |
{ |
{ |
if (c == '{') return(1); |
if (c == '{') return(1); |
else return(0); |
else return(0); |
} |
} |
|
|
static isKakkoSM(c) |
static int isKakkoSM(c) |
int c; |
int c; |
{ |
{ |
if (c == '(') return(1); |
if (c == '(') return(1); |
else return(0); |
else return(0); |
} |
} |
|
|
static isSymbolSM(c) |
static int isSymbolSM(c) |
int c; |
int c; |
{ |
{ |
if ((c == '{') || |
if ((c == '{') || |