Michelle
Michelle

Reputation: 107

How to determine if a grammar is suitable for top down parsing?

I have been reading top down parsing from dragon book recently and one of questions asks to check if the given grammar is suitable for top down parsing or not. How to determine this? Are the following conditions for the grammar sufficient to be a valid one?

1) Left factored.
2) No Left Recursion.
3) Unambiguous.

Upvotes: 1

Views: 1815

Answers (1)

Jeff Straney
Jeff Straney

Reputation: 41

A grammar that uses the leftmost derivation, is unambiguous, and has no left recursion is known as an LL(k) language. k is the amount of look-ahead used by the parser. Top down parsing uses LL(k) languages, so if the language is LL it should be top-down parsable.

sources: http://www.csd.uwo.ca/~moreno/CS447/Lectures/Syntax.html/node14.html https://en.wikipedia.org/wiki/Top-down_parsing

Upvotes: 1

Related Questions