Difference between Top down parsing and Bottom up parsing

There are 2 types of Parsing Technique present in parsing, first one is Top-down parsing and second one is Bottom-up parsing.

Top-down Parsing is a parsing technique that first looks at the highest level of the parse tree and works down the parse tree by using the rules of grammar while Bottom-up Parsing is a parsing technique that first looks at the lowest level of the parse tree and works up the parse tree by using the rules of grammar.

There are some differences present to differentiate these two parsing techniques, which are given below:



S.No Top Down Parsing Bottom Up Parsing
1. It is a parsing strategy that first looks at the highest level of the parse tree and works down the parse tree by using the rules of grammar. It is a parsing strategy that first looks at the lowest level of the parse tree and works up the parse tree by using the rules of grammar.
2. Top-down parsing attempts to find the left most derivations for an input string. Bottom-up parsing can be defined as an attempts to reduce the input string to start symbol of a grammar.
3. In this parsing technique we start parsing from top (start symbol of parse tree) to down (the leaf node of parse tree) in top-down manner. In this parsing technique we start parsing from bottom (leaf node of parse tree) to up (the start symbol of parse tree) in bottom-up manner.
4. This parsing technique uses Left Most Derivation. This parsing technique uses Right Most Derivation.
5. It’s main decision is to select what production rule to use in order to construct the string. It’s main decision is to select when to use a production rule to reduce the string to get the starting symbol.



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.