Parsing is classified into two categories, i.e. Top Down Parsing and Bottom-Up Parsing. Top-Down Parsing is based on Left Most Derivation whereas Bottom Up Parsing is dependent on Reverse Right Most Derivation.
The process of constructing the parse tree which starts from the root and goes down to the leaf is Top-Down Parsing.
- Top-Down Parsers constructs from the Grammar which is free from ambiguity and left recursion.
- Top Down Parsers uses leftmost derivation to construct a parse tree.
- It allows a grammar which is free from Left Factoring.
Classification of Top-Down Parsing –
- With Backtracking: Brute Force Technique
- Without Backtracking:1. Recursive Descent Parsing
2. Predictive Parsing or Non-Recursive Parsing or LL(1) Parsing or Table Driver Parsing
Brute Force Technique or Recursive Descent Parsing –
- Whenever a Non-terminal spend first time then go with the first alternative and compare with the given I/P String
- If matching doesn’t occur then go with the second alternative and compare with the given I/P String.
- If matching again not found then go with the alternative and so on.
- Moreover, If matching occurs for at least one alternative, then the I/P string is parsed successfully.
LL(1) or Table Driver or Predictive Parser –
- In LL1, first L stands for Left to Right and second L stands for Left-most Derivation. 1 stands for number of Look Aheads token used by parser while parsing a sentence.
- LL(1) parsing is constructed from the grammar which is free from left recursion, common prefix, and ambiguity.
- LL(1) parser depends on 1 look ahead symbol to predict the production to expand the parse tree.
- This parser is Non-Recursive.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Parsing | Set 1 (Introduction, Ambiguity and Parsers)
- Bottom Up or Shift Reduce Parsers | Set 2
- SLR, CLR and LALR Parsers | Set 3
- Types of Parsers in Compiler Design
- Difference between Top down parsing and Bottom up parsing
- Working of top down parser
- Classification of Context Free Grammars
- Classification and Programming of Read-Only Memory (ROM)
- Classification of Number System
- Classification of Routing Algorithms
- Top 5 Topics for Each Section of GATE CS Syllabus
- Top 5 PSUs for Computer Science Engineers in India
- Difference between Batch Processing and Stream Processing
- Difference between Multitasking and Multiprocessing
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.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.