tokenize: Fixed the 'typedef' simplifications. Added token '#' upon preprocessor instructions.

This commit is contained in:
Daniel Marjamäki 2007-06-02 16:32:07 +00:00
parent 13657ab127
commit 7b85324a0b
1 changed files with 20 additions and 6 deletions

View File

@ -21,8 +21,6 @@ static void addtoken(const char str[], const unsigned int lineno, const unsigned
static void combine_2tokens(TOKEN *tok, const char str1[], const char str2[]); static void combine_2tokens(TOKEN *tok, const char str1[], const char str2[]);
static int SizeOfType(const char type[]);
static void DeleteNextToken(TOKEN *tok); static void DeleteNextToken(TOKEN *tok);
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -332,6 +330,12 @@ void Tokenize(const char FileName[])
free(strId); free(strId);
} }
else
{
addtoken("#", lineno, CurrentFile);
addtoken(";", lineno, CurrentFile);
}
lineno++; lineno++;
continue; continue;
} }
@ -529,7 +533,6 @@ void SimplifyTokenList()
// typedefs.. // typedefs..
/*
TOKEN *prev = NULL; TOKEN *prev = NULL;
for (TOKEN *tok = tokens; tok; tok = tok->next) for (TOKEN *tok = tokens; tok; tok = tok->next)
{ {
@ -539,9 +542,17 @@ void SimplifyTokenList()
if ( strcmp(tok->str, "typedef") == 0 ) if ( strcmp(tok->str, "typedef") == 0 )
{ {
TOKEN *type0 = tok->next; TOKEN *type0 = tok->next;
int len = 1; int len = 0, parlevel = 0;
while ( strcmp(getstr(type0, len+1), ";") != 0) for ( TOKEN *tok2 = gettok(type0,1); tok2; tok2 = tok2->next)
{
if (strchr("{(", tok2->str[0]))
parlevel++;
else if (strchr("})", tok2->str[0]))
parlevel--;
else if (parlevel==0 && tok2->str[0]==';')
break;
len++; len++;
}
const char *typestr = getstr(type0, len); const char *typestr = getstr(type0, len);
if (typestr[0] != ')') // Function pointer if (typestr[0] != ')') // Function pointer
@ -589,7 +600,6 @@ void SimplifyTokenList()
} }
prev = tok; prev = tok;
} }
*/
// Fill the map TypeSize.. // Fill the map TypeSize..
@ -786,6 +796,10 @@ void SimplifyTokenList()
continue; continue;
TOKEN *type0 = tok->next; TOKEN *type0 = tok->next;
if (!type0)
break;
if (strcmp(type0->str, "else") == 0)
continue;
TOKEN *tok2 = NULL; TOKEN *tok2 = NULL;
unsigned int typelen = 0; unsigned int typelen = 0;