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

Discussion

An unterminated string literal is normally reported by

  • A.the parser once it attempts to reduce the expression
  • B.the semantic analyser during type checking of the operands
  • C.the linker when it resolves the external references
  • D.the lexical analyser

Answer: D

Correct answer: the lexical analyser

A string literal is a single token, and the scanner is the phase that assembles it from characters. Reaching the end of the line or the file with the closing quote still missing means the token cannot be completed, which the scanner discovers immediately.

The parser never sees a token at all in this case, so it cannot be the reporter. The contrast with the missing semicolon is instructive: one is a malformed token, the other a malformed sequence of good tokens.

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

Post your comment

Please log in or register to post a comment.