Open In App

Working of top down parser

In this article, we are going to cover working of top down parser and will see how we can take input and parse it and also cover some basics of top down. 

Pre-requisite – Parsing  



Top Down Parser : 
 

Working of Top Down Parser : 
Let’s consider an example where grammar is given and you need to construct a parse tree by using top down parser technique. 



Example – 
 

S -> aABe
A -> Abc | b
B -> d

Now, let’s consider the input to read and to construct a parse tree with top down approach. 

 

Input – 
 

abbcde$

Now, you will see that how top down approach works. Here, you will see how you can generate a input string from the grammar for top down approach. 
 

Given below is the Diagram explanation for constructing top down parse tree. You can see clearly in the diagram how you can generate the input string using grammar with top down approach. 

 

 

Article Tags :