version 1.5, 2004/09/10 13:20:23 |
version 1.8, 2005/07/03 11:08:54 |
|
|
/*$OpenXM: OpenXM/src/kan96xx/Kan/scanner.c,v 1.4 2001/05/04 01:06:25 takayama Exp $*/ |
/*$OpenXM: OpenXM/src/kan96xx/Kan/scanner.c,v 1.7 2004/09/12 00:26:21 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. |
files: none |
files: none |
*/ |
*/ |
#include <stdio.h> |
#include <stdio.h> |
|
#include <stdlib.h> |
|
#include <string.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "stackm.h" |
#include "stackm.h" |
struct tokens lookupTokens(struct tokens t); |
struct tokens lookupTokens(struct tokens t); |
Line 105 static int getSM() |
|
Line 107 static int getSM() |
|
/* get a letter from StringSM */ |
/* get a letter from StringSM */ |
{ |
{ |
int c; |
int c; |
|
|
|
if ((StrpSM > 0) && (StringSM[StrpSM] == ',') && (StringSM[StrpSM-1] == ',')) { int i; |
|
fprintf(stderr,"Warning: ,, is found."); |
|
for (i=(StrpSM-30>0?StrpSM-30:0); i<=StrpSM; i++) { |
|
fprintf(stderr,"%c",StringSM[i]); |
|
} |
|
fprintf(stderr,"\n"); |
|
} |
|
|
c = StringSM[StrpSM++]; |
c = StringSM[StrpSM++]; |
if (c == '\0') { |
if (c == '\0') { |
StrpSM--;return(EOF); |
StrpSM--;return(EOF); |
Line 146 static struct tokens flushSM() |
|
Line 157 static struct tokens flushSM() |
|
strcpy(token,BufSM); |
strcpy(token,BufSM); |
r.token = token; |
r.token = token; |
r.kind = TypeSM; |
r.kind = TypeSM; |
|
r.tflag = 0; |
if (r.kind == ID) { |
if (r.kind == ID) { |
if (isLiteral(r.token)) { |
if (isLiteral(r.token)) { |
r.object = lookupLiteralString(r.token); |
r.object = lookupLiteralString(r.token); |
Line 159 static struct tokens flushSM() |
|
Line 171 static struct tokens flushSM() |
|
static isSpaceSM(c) |
static isSpaceSM(c) |
int c; |
int c; |
{ |
{ |
static int prev=0; |
|
if ((c == ',') && (prev == ',')) fprintf(stderr,"Warning! ,, is found.\n"); |
|
prev = c; |
|
|
|
if (((c <= ' ') || c == ',') && (c!= EOF)) return(1); |
if (((c <= ' ') || c == ',') && (c!= EOF)) return(1); |
else return(0); |
else return(0); |
} |
} |
|
|
char *getLOAD_SM1_PATH() { |
char *getLOAD_SM1_PATH() { |
char *p; |
char *p; |
char *p2; |
char *p2; |
char *getenv(char *s); |
char *getenv(const char *s); |
p = getenv("LOAD_SM1_PATH"); |
p = getenv("LOAD_SM1_PATH"); |
if (p == NULL) { |
if (p == NULL) { |
p = getenv("OpenXM_HOME"); |
p = getenv("OpenXM_HOME"); |