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

Discussion

Backtracking in a top-down parser is undesirable chiefly because

  • A.it stops the parser from ever announcing a fault in the input
  • B.the grammar has to be ambiguous before backtracking becomes possible
  • C.it can take exponential time and undoes semantic actions already run
  • D.it requires more memory than any machine is able to provide

Answer: C

Correct answer: it can take exponential time and undoes semantic actions already run

Backtracking may explore many alternatives before finding the right one, and the cost can grow exponentially with the input. Worse for a practical compiler, any semantic action already executed - a symbol table entry, a line of output - must be undone, which is difficult to do correctly and is why predictive parsing is preferred.

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

Post your comment

Please log in or register to post a comment.