diff options
Diffstat (limited to 'semantics.c')
-rw-r--r-- | semantics.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/semantics.c b/semantics.c index d507e6a..da2a42b 100644 --- a/semantics.c +++ b/semantics.c @@ -1643,9 +1643,8 @@ void semantics_check(CNode *p) { static CScope_t typedef_scope; static enum { NONE, - TYPEDEF_DECLR, - OTHER_DECLR, - STRUCT_TAG + FORCE_ID, + IN_TYPEDEF } typedef_state; void cibic_init() { @@ -1656,11 +1655,10 @@ void cibic_init() { int is_identifier(const char *name) { CSymbol_t lu; /* struct tag */ - if (typedef_state == STRUCT_TAG) return 1; /* the parser is reading declarators */ - if (typedef_state == OTHER_DECLR) return 1; + if (typedef_state == FORCE_ID) return 1; /* the parser is reading typedef */ - if (typedef_state == TYPEDEF_DECLR) return 1; + if (typedef_state == IN_TYPEDEF) return 1; /* no info about name, assume it to be an id by default */ lu = cscope_lookup(typedef_scope, name, NS_ID); if (!lu) return 1; @@ -1668,7 +1666,7 @@ int is_identifier(const char *name) { } void push(const char *name) { - if (typedef_state == TYPEDEF_DECLR) + if (typedef_state == IN_TYPEDEF) cscope_push_type(typedef_scope, ctype_create(name, 0, NULL), NS_ID); else cscope_push_var(typedef_scope, cvar_create(name, NULL, NULL), NS_ID); @@ -1684,7 +1682,6 @@ CDef_t cdef_create(const char *name, CType_t type, CNode *ast) { void enter_block() { cscope_enter(typedef_scope); } void exit_block() { cscope_exit(typedef_scope); } -void enter_typedef() { typedef_state = TYPEDEF_DECLR; } -void enter_declr() { typedef_state = OTHER_DECLR; } -void enter_struct() { typedef_state = STRUCT_TAG; } -void exit_declr() { typedef_state = NONE; } +void force_id() { typedef_state = FORCE_ID; } +void enter_typedef() { typedef_state = IN_TYPEDEF; } +void clear_state() { typedef_state = NONE; } |