Machine-translated by Google. Questions are authored in English.
Top

Discussion

State whether the following is true or false.
A missing semicolon is normally detected by the lexical analyser.

  • A.False only at small scales
  • B.True
  • C.False
  • D.True only at large scales

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.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.