State whether the following is true or false.
A missing semicolon is normally detected by the lexical analyser.
Answer: C
Correct answer: False
The lexical analyser recognises tokens individually and has no view of how they should be arranged. A semicolon is simply a token that is absent; the scanner has nothing to compare its absence against.
The parser detects it, when the token stream fails to match any grammar production at the point where a statement should have ended. The distinction is the general one: lexical analysis catches malformed tokens, syntax analysis catches malformed sequences of well-formed tokens.
Please log in or register to report this question.