i have a code to check lexeme is keyword or not:
void Is_Keyword_Or_Not()
{
char *keywords[]={"INCLUDE","VOID","MAIN","i","var","cin","cout","if",
"then","else","and","or","not","loop","exit","when",
"while","until"};
int j=0;
flag=0;
for (j=0;j<18;j++) //search for keyword & # of keywords = 18.
{
if (strcmpi(lexeme,keywords[j])==0)
{
temp.assign(lexeme,INCLUDE);
flag=1;
break;
}
}
}
i have defined macros like:
INCLUDE 1
INT 2
etc
just like INCLUDE in temp.assign,i want specific value defined in macro to be returned as compared to lexeme
it could be done by using lots of "if" but is there another short way to do that?