int main()
{
int a,b,c;
5abc=20;
}
Is 5abc
recognized as token?
If yes then in which category would you place it?
If No, then who is recognizing this error Lexical or Syntax analyser? Please explain.
Your question is not clear, but it seems like you are writing your own compiler/lexical analyser and are asking what it the best way of handling this error. You might have been asking how existing compilers handle this case, but that is easy to find out. Just compile it:
$ gcc SO.c
SO.c:4:5: error: invalid suffix "abc" on integer constant
There is no correct answer; you can make it a lexical error, but then you would have to add a lexical rule to match this specific situation and then return an error token to the parser, which would then cause a syntax error. Alternately you could just return a digit/integer followed by an identifier, which would also generate a syntax error. Usually it is just easier to return the tokens seen and let the parser deal with it as a syntax error. You can see that is what gcc and other common compiler do, which confirms it as the pragmatic choice.