It is hard for a lexical analyzer to tell, without the aid of other components, that there is a source-code error. For instance, if the string
fi is encountered for the first time in a C program in the context:
fi ( a == f(x) ) ...
a lexical analyzer cannot tell whether
fi is a misspelling of the keyword
if or an undeclared function identifier. Since
fi is a valid lexeme for the token id, the lexical analyzer must return the token
id to the parser and let some other phase of the compiler - probably the parser in this case - handle an error due to transposition of the letters.