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

Discussion

Packrat parsing achieves linear time by

  • A.removing all backtracking from the parser before it runs
  • B.turning the rules into a deterministic machine before parsing starts
  • C.restricting the grammar to a class that is no larger than LL(1)
  • D.memoising the result of each parsing function at each input position

Answer: D

Caching results means no position is ever parsed twice for the same rule. The linear time comes at the cost of memory proportional to input length times the number of rules. For large inputs that memory cost can be the deciding practical consideration.

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

Post your comment

Please log in or register to post a comment.