token: refactoring the 'isStandardType' a little
This commit is contained in:
parent
c95fee7266
commit
b179083788
15
token.cpp
15
token.cpp
|
@ -51,7 +51,7 @@ void TOKEN::setstr( const char s[] )
|
|||
_cstr = _strdup(s);
|
||||
#endif
|
||||
_isName = bool(_str[0]=='_' || isalpha(_str[0]));
|
||||
_isNumber = bool(isdigit(_str[0]) != 0);
|
||||
_isNumber = bool(isdigit(_str[0]) != 0);
|
||||
}
|
||||
|
||||
void TOKEN::combineWithNext(const char str1[], const char str2[])
|
||||
|
@ -193,16 +193,13 @@ bool TOKEN::isNumber() const
|
|||
return _isNumber;
|
||||
}
|
||||
|
||||
|
||||
bool TOKEN::IsStandardType(const char str[])
|
||||
{
|
||||
if (!str)
|
||||
return false;
|
||||
bool Ret = false;
|
||||
bool TOKEN::isStandardType() const
|
||||
{
|
||||
bool ret = false;
|
||||
const char *type[] = {"bool","char","short","int","long","float","double",0};
|
||||
for (int i = 0; type[i]; i++)
|
||||
Ret |= (strcmp(str,type[i])==0);
|
||||
return Ret;
|
||||
ret |= (_str == type[i]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
2
token.h
2
token.h
|
@ -64,7 +64,7 @@ public:
|
|||
static bool Match(const TOKEN *tok, const char pattern[], const char *varname1[]=0, const char *varname2[]=0);
|
||||
bool isName() const;
|
||||
bool isNumber() const;
|
||||
static bool IsStandardType(const char str[]);
|
||||
bool isStandardType() const;
|
||||
static const TOKEN *findmatch(const TOKEN *tok, const char pattern[], const char *varname1[]=0, const char *varname2[]=0);
|
||||
static const TOKEN *findtoken(const TOKEN *tok1, const char *tokenstr[]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue