- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 is Top-Down Parsing Without Backtracking in Compiler Design?
There are two types of Top-Down Parsing without Backtracking, which are as follows −
Recursive Descent Parser
Recursive Descent Parser
A top-down parser that implements 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. The recursive procedures can be accessible to write and adequately effective if written in a language that performs the procedure call effectively.
There is a procedure for each non-terminal in the grammar. It can consider a global variable lookahead, influencing the current input token and a procedure match (Expected Token) is the action of recognizing the next token in the parsing process and advancing the input stream pointer, such that lookahead points to the next token to be parsed. Match () is effectively a call to the lexical analyzer to get the next token.
Predictive Parser is also known as Non-Recursive Predictive Parsing. A predictive parser is an effective approach of implementing recursive-descent parsing by handling 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.
The stack includes a sequence of grammar symbols, preceded by $, the bottom-ofstack marker. Initially, the stack includes the start symbol of the grammar preceded by $. The parsing table is a two-dimensional array M[A, a] where ‘A’ is a nonterminal, and ‘a’ is a terminal or the symbol $.
The parser is controlled by a program that performs as follows − The program decides X the symbol on top of the stack and ‘a’ the current input symbol. These two symbols decide the action of the parser.
There are three possibilities such as
- If X = a = $, the parser terminate and declares successful integration of parsing.
- If X =a ≠ $, the parser pops X off the stack and advances the input pointer to the next input symbol.
- If X is a non-terminal, the program consults entry M[X, a] of the parsing table M. This entry will be either an X-production of the grammar or an error entry. If M[X, a] = [X→ UVW], the parser replaces X on top of the stack by UVW (with U on top). As output, the grammar does the semantic action associated with this production, which for the time being, it can assume is just printing the production used. If M[X, a] = error, the parser calls an error recovery routine.
- What is Top-Down Parsing with Backtracking in compiler design?
- What is Top-Down Parsing?
- What are Parsing Techniques in Compiler Design?
- What is Operator Precedence Parsing Algorithm in compiler design?
- What is Stack Implementation of Shift Reduce Parsing in compiler design?
- Difference between Top down parsing and Bottom up parsing
- What is Compiler Design?
- What is Design of Lexical Analysis in Compiler Design?
- What is Chomsky Hierarchy in compiler design?
- What is error handling in compiler design?
- What is Input Buffering in Compiler Design?
- What is Finite Automata in Compiler Design?
- Difference Between Top-down and Bottom-up Parsing
- What is Language Processing Systems in Compiler Design?
- What is minimizing of DFA in compiler design?