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

Discussion

Input buffering with two halves is used in a scanner to

  • A.hold the symbol table entries created during the scan
  • B.reduce the cost of reading characters one at a time from the file
  • C.allow the scanner to modify the source program while it is reading it
  • D.store the tokens produced until the parser is ready for them

Answer: B

Correct answer: reduce the cost of reading characters one at a time from the file

Reading is done a block at a time into one half of the buffer while the scanner works through the other, so a system call is made once per block rather than once per character. The two-half arrangement also allows a lexeme to straddle the boundary, since the beginning of it survives in the half that has not yet been refilled.

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

Post your comment

Please log in or register to post a comment.