- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are Parsing Techniques in Compiler Design?
Parsing is known as Syntax Analysis. It contains arranging the tokens as source code into grammatical phases that are used by the compiler to synthesis output generally grammatical phases of the source code are defined by parse tree. There are various types of parsing techniques which are as follows −
- Top-Down Parser
It generates the Parse Tree from root to leaves. In top-down parsing, the parsin begins from the start symbol and changes it into the input symbol.
An example of a Top-Down Parser is Predictive Parsers, Recursive Descent Parser.
Predictive Parser − Predictive Parser is also known as Non-Recursive Predictive Parsing. A predictive parser is an effective approach of implementing recursivedescent parsing by manipulating the stack of activation records explicitly. The predictive parser has an input, a stack, a parsing table, and an output. The input includes the string to be parsed, followed by $, the right-end marker.
Recursive Descent Parser − A top-down parser that executes a set of recursive procedures to process the input without backtracking is known as recursive-descent parser, and parsing is known as recursive-descent parsing.
- Bottom-Up Parser
It generates the Parse Tree from leaves to root for a given input string. In Grammar, the input string will be reduced to the starting symbol.
Example of Bottom-Up Parser is Shift Reduce Parser, Operator Precedence Parser, and LR Parsers.
Shift Reduce Parser − Shift reduce parser is a type of bottom-up parser. It uses a stack to influence the grammar symbols. A parser goes on changing the input symbols onto the stack until a handle comes on the top of the stack. When a handle occurs on the top of the stack, it implements reduction.
Operator Precedence Parser − The shift-reduce parsers can be generated by hand for a small class of grammars. These grammars have the property that no production on the right side is ϵ or has two adjacent non-terminals. Grammar with the latter property is known as operator grammar.
LR Parsers − The LR Parser is a shift-reduce parser that creates use of deterministic finite automata, identifying the set of all viable prefixes by reading the stack from bottom to top. It decides what handle, if any, is available.
A viable prefix of a right sequential form is that prefix that includes a handle, but no symbol to the right of the handle. Thus, if a finite state machine that identifies viable prefixes of the right sentential form is generated, it can guide the handle selection in the shift-reduce parser.
There are three types of LR Parsers which are as follows −
Simple LR Parser (SLR) − It is very easy to implement but it fails to produce a table for some classes of grammars.
Canonical LR Parser (CLR) − It is the most powerful and works on large classes of grammars.
Look Ahead LR Parser (LALR) − It is intermediate in power between SLR and CLR.
- Related Articles
- What is Operator Precedence Parsing Algorithm in compiler design?
- What is techniques of storage allocation in compiler design?
- What is Top-Down Parsing with Backtracking in compiler design?
- What is Top-Down Parsing Without Backtracking in Compiler Design?
- What is Stack Implementation of Shift Reduce Parsing in compiler design?
- What are Precedence Functions in compiler design?
- What is Compiler Design?
- What is Design of Lexical Analysis in Compiler Design?
- What are the attributes of programming languages in compiler design?
- What are the types of the translator in compiler design?
- What are the operations on sequential files in compiler design?
- What are the Rules of Regular Expressions in Compiler Design?
- What are Lists and Self-Organizing lists in compiler design?
- What is Chomsky Hierarchy in compiler design?
- What is error handling in compiler design?
