LL Parser | LR Parser |
---|---|
It is also known as top-down parsing. | It is also known as bottom-up parsing. |
First L of LL is for left to right (i.e, input is processed in the order it is read) and second L for leftmost derivation. | L-Left to right (i.e, input is processed in the order it is read) and R - Rightmost derivation |
LL starts with only the root non-terminal on the stack. | LR ends with only the root non-terminal on stack. |
LL ends when the stack is empty. | LR starts with an empty stack. |
LL expands non-terminal. | LR reduces non-terminal. |
LL reads terminal when its pop one of the stack. | LR reads terminal when it pushes them on the stack. |
LL uses pre-order traversal of the parse tree. | LR uses post-order traversal of the parse tree. |
During LL parser the parser continuosly chooses between two action. Predict: Based on the leftmost non-terminal and some number of lookahead tokens. Match: Match the leftmost guessed terminal symbol with the leftmost unconsumed symbol of input. |
During an LR parser the parser continuosly chooses between two action. Shift: Add the next token of input to a buffer for consideration. Reduce: Reduce a collection of terminals and non-terminals. |
LL parser are easier to write but less powerful and comes in many flavours like LL(1), etc. | LR parsers are much powerful and they come in many flavours like LR(0), SLR(1), LALR(1), LR(1), etc. |
Difference between LL Parser vs LR Parser. LL Parser vs LR Parser
About Vipul Singh
Editor-in-Chief and Owner of TechBlogMU. Computer Engineer, Data Science Enthusiast and Tech Blogger. Catch him on Facebook and Twitter
Become a Patron: https://www.patreon.com/techblogmu
Subjects
- Artificial Intelligence (AI)
- ASP.NET with C#
- Big Data Analytics
- Computer Networks
- Cryptography and System Security
- Data Structures
- Data Warehouse and Mining
- Database Management System
- Digital Signal Processing
- Human Machine Interaction
- Machine Learning
- Microprocessor
- Object Oriented Programming Methodolgy (OOPM)
- Operating System
- Parallel and Distributed Database
- Software Architecture (SA)
- Statistics
- Structured and Object Oriented Analysis and Design (SOOAD)
- System Programming and Compiler Construction (SPCC)
- Theory of Computation