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

Discussion

String literals containing escape sequences are usually handled by

  • A.rejecting any literal that contains a backslash character
  • B.recognising the whole literal and translating the escapes in the action
  • C.emitting a separate token for each escape sequence encountered
  • D.leaving the escapes untranslated for the code generator to deal with

Answer: B

The pattern matches the literal including its escapes, and the semantic action builds the actual string value. Doing the translation in the scanner means later phases see a plain value. The original spelling is usually retained as well so diagnostics can quote the source.

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

Post your comment

Please log in or register to post a comment.