comparison mc-parse.c @ 360:d8190f815254

*** empty log message ***
author kono
date Mon, 05 Jul 2004 11:26:03 +0900
parents 7ab4434ad869
children 5cf12c7a3274
comparison
equal deleted inserted replaced
359:7ab4434ad869 360:d8190f815254
1032 char *p = cheap->ptr; 1032 char *p = cheap->ptr;
1033 char *q = name; 1033 char *q = name;
1034 unsigned int hash = 0; 1034 unsigned int hash = 0;
1035 struct cheap scheap; 1035 struct cheap scheap;
1036 NMTBL *n; 1036 NMTBL *n;
1037 #if 1
1038 NMTBL *nlist;
1039 #endif
1037 1040
1038 while((ch = *name++)) { 1041 while((ch = *name++)) {
1039 hash_value(hash,*cheap->ptr = ch); 1042 hash_value(hash,*cheap->ptr = ch);
1040 increment_cheap(cheap,&p);len++; 1043 increment_cheap(cheap,&p);len++;
1041 } 1044 }
1052 ndsp /= 10; 1055 ndsp /= 10;
1053 } 1056 }
1054 *cheap->ptr = 0; 1057 *cheap->ptr = 0;
1055 increment_cheap(cheap,&p); 1058 increment_cheap(cheap,&p);
1056 save_cheap(&scheap,cheap); 1059 save_cheap(&scheap,cheap);
1057 n = name_space_search( 1060 n = name_space_search(nlist=hash_search(delimit=='_'?p:q,&scheap,len,hash,DEF),0);
1058 name_space_search(hash_search(delimit=='_'?p:q,&scheap,len,hash,DEF),LDECL),0);
1059 n->nm = p; 1061 n->nm = p;
1060 return n; 1062 return n;
1061 } 1063 }
1062 1064
1063 1065
3231 } 3233 }
3232 3234
3233 extern int 3235 extern int
3234 getsym(int sc) 3236 getsym(int sc)
3235 { 3237 {
3236 NMTBL *nlist,*nptr0,*nptr1,*nptrm; 3238 NMTBL *nlist,*nptr0,*nptrm;
3237 char c; 3239 char c;
3238 3240
3239 if (alpha(skipspc())) { 3241 if (alpha(skipspc())) {
3240 nptrm=name_space_search(nlist = get_name_from_chptr(),MACRO); 3242 nptrm=name_space_search(nlist = get_name_from_chptr(),MACRO);
3241 if (mode==MDECL) { 3243 if (mode==MDECL) {
3264 if (mode==ADECL && nptr0->sc ==TYPE) return sym; 3266 if (mode==ADECL && nptr0->sc ==TYPE) return sym;
3265 if (mode==GDECL || mode==GSDECL || mode==GUDECL || 3267 if (mode==GDECL || mode==GSDECL || mode==GUDECL ||
3266 mode==GTDECL || mode==TOP || mode==GEDECL) { 3268 mode==GTDECL || mode==TOP || mode==GEDECL) {
3267 return sym; 3269 return sym;
3268 } 3270 }
3269 3271 if (nptr->sc == TYPE) return sym;
3270 /* local variable name table */ 3272 if (nptr->sc == TAG) return sym;
3271 nptr1 = name_space_search(nlist=name_space_search(nlist,LDECL),sc);
3272 if (mode==STAT) { 3273 if (mode==STAT) {
3273 /* can be undeclared global variable */ 3274 /* can be undeclared global variable */
3274 if (nptr1->sc == EMPTY) return sym; 3275 return sym;
3275 else {
3276 nptr=nptr1;
3277 return sym;
3278 }
3279 } 3276 }
3280 /* define case */ 3277 /* define case */
3281 nptr = make_local_scope(nlist,nptr1,sc); 3278 nptr = make_local_scope(nlist,nptr,sc);
3282 return sym; 3279 return sym;
3283 3280
3284 } else if (digit(ch)||ch=='.') { 3281 } else if (digit(ch)||ch=='.') {
3285 return get_numerical(); 3282 return get_numerical();
3286 } else if(ch=='\'') { 3283 } else if(ch=='\'') {
3482 // search local nptr by name and storage class 3479 // search local nptr by name and storage class
3483 extern NMTBL * 3480 extern NMTBL *
3484 lsearch(char *name,int sc) 3481 lsearch(char *name,int sc)
3485 { 3482 {
3486 NMTBL *nlist,*nptr1; 3483 NMTBL *nlist,*nptr1;
3487 nptr1 = name_space_search( 3484 nptr1 = name_space_search(nlist=get_name(name,0,DEF),sc);
3488 nlist = name_space_search(get_name(name,0,DEF),LDECL),sc);
3489 return make_local_scope(nlist,nptr1,sc); 3485 return make_local_scope(nlist,nptr1,sc);
3490 } 3486 }
3491 3487
3492 // search top level local name (for label) 3488 // search top level local name (for label)
3493 static NMTBL * 3489 static NMTBL *
3494 l_top_search(char *name,int sc) 3490 l_top_search(char *name,int sc)
3495 { 3491 {
3496 NMTBL *nlist,*nptr1; 3492 NMTBL *nlist,*nptr1;
3497 nptr1 = name_space_search( 3493 nptr1 = name_space_search(nlist=get_name(name,0,DEF),sc);
3498 nlist = name_space_search(get_name(name,0,DEF),LDECL),sc);
3499 return make_top_scope(nlist,nptr1,sc); 3494 return make_top_scope(nlist,nptr1,sc);
3500 } 3495 }
3501 3496
3502 extern NMTBL * 3497 extern NMTBL *
3503 make_local_scope(NMTBL *nlist,NMTBL *nptr1,int sc) 3498 make_local_scope(NMTBL *nlist,NMTBL *nptr1,int sc)