Difference Between Recursive Predictive Descent Parser and Non-Recursive Predictive Descent Parser
Last Updated :
23 Sep, 2024
Syntax analysis is an important task of compilers. Parsing techniques can be used for the analysis of the structure of programming languages. Out of these techniques, Recursive Predictive Descent Parsing and Non-Recursive Predictive Descent Parsing are two well-known top-down methods. Although both intend to analyze strings according to grammar rules and regulations, they employ entirely different strategies, especially in the utilization of backtracking and parsing tables.
What is a Recursive Predictive Descent Parser?
Recursive Predictive Descent Parser is one of the top-down parsing techniques, which comprises a set of recursive procedures for the evaluation of input strings. Every operation corresponds to a non-terminal within the grammar, and it is the job of an operation to expand on this non-terminal. The parser tries to find the best match according to the syntax rules, and if this match fails, there is backing into other possible productions. This approach is also famous for getting a parse tree defined by some input since it recurs in nature.
Key Characteristics
- Backtracking: In case of the failure of one derivation, the parser resets it to another derivation.
- Procedural Implementation: Generally, a recursive function is determined for each non-terminal in its grammar.
- Parse Tree Generation: The way that a parser builds procedure calls is that a parse tree is in effect self-defined as the sequence of the procedure calls.
What is Backtracking?
It means, that if one derivation of production fails, the syntax analyzer restarts the process using different rules of the same production. This technique may process input string more than once to determine right production. Top- down parser start from root node (start symbol) and match input string against production rules to replace them (if matched).
Example of CFG
S -> aAb | aBb
A -> cx | dx
B -> xe
For an input string – read, a top-down parser, will behave like this.
It will start with S from production rules and will match its yield to left-most letter of input, i.e. ‘a’. The very production of S (S -> aAb) matches with it. So top-down parser advances to next input letter (i.e., ‘d’). The parser tries to expand non-terminal ‘A’ and checks its production from left (A -> cx). It does not match with next input symbol. So top-down parser backtracks to obtain next production rule of A, (A -> dx).
Now parser matches all input letters in an ordered manner. The string is accepted.

What is Non-Recursive Predictive Descent Parser?
A non-recursive predictive descent Parser, commonly referred to as the predictive parser, does not require backtracking, thanks to a parsing table. This parser employs the use of a ‘look-ahead’ pointer to decide which among the various production rules to implement depending on an input symbol that is to follow. To make sure that no backtracking is needed, this method puts some restrictions on the grammar, which is of a class called LL(k) grammar.
Key Characteristics
- No Backtracking: This principle is regularly used in the construction of the predictive parser in opposition with the backtracking with the help of a parsing table and look-ahead symbols.
- LL(k) Grammar: It only recognizes a limited subset of grammars known as the LL(k) grammars so as to achieve deterministic parse.
- Parsing Table: A table is formed so as to assist the parser in determining which production is the best to apply in relation to the current input and the element on top of the stack.

Predictive parsing uses a stack and a parsing table to parse input and generate a parse tree. Both stack and input contains an end symbol $ to denote that stack is empty and input is consumed. The parser refers to parsing table to take any decision on input and stack element combination. There might be instances where there is no production matching input string, making parsing procedure to fail.
Difference between Recursive Predictive Descent Parser and Non-Recursive Predictive Descent Parser
Recursive Predictive Descent Parser
|
Non-Recursive Predictive Descent Parser
|
It is a technique which may or may not require backtracking process. |
It is a technique that does not require any kind of backtracking. |
It uses procedures for every non-terminal entity to parse strings. |
It finds out productions to use by replacing input string. |
It is a type of top-down parsing built from a set of mutually recursive procedures where each procedure implements one of non-terminal s of grammar. |
It is a type of top-down approach, which is also a type of recursive parsing that does not uses technique of backtracking. |
It contains several small functions one for each non- terminals in grammar. |
The predictive parser uses a look ahead pointer which points to next input symbols to make it parser back tracking free, predictive parser puts some constraints on grammar. |
It accepts all kinds of grammars. |
It accepts only a class of grammar known as LL(k) grammar. |
Conclusion
Recursive and Non-recursive predictive descent parsers are two very vital methods in syntactical analysis. The recursive variant is more general in that it can accept many grammars, but it may include backtracking, thus it is slower. On the other hand, the non-recursive predictive parser that is based on a parsing table is characterized by better efficiency. Since there is no need for a backtracking though, it is suitable only for LL(k) grammars.
Similar Reads
Difference Between Top Down Parsing and Bottom Up Parsing
Parsing is a process in which the syntax of a program is checked by a parser and a parse tree is constructed for the same. There are two main approaches to parsing in compilers: based on them, I have come across two parsing methods namely the top-down parsing and the bottom-up parsing. Both techniqu
5 min read
Difference between Context Free Grammar and Regular Grammar
Noam Chomsky has divided grammar into four types : Type Name 0 Unrestricted Grammar1 Context Sensitive Grammar2 Context Free Grammar3 Regular Grammar 1. Context Free Grammar : Language generated by Context Free Grammar is accepted by Pushdown AutomataIt is a subset of Type 0 and Type 1 grammar and a
2 min read
Difference between structured and unstructured programming
Structured Programming Structured Programming is a type of programming that generally converts large or complex programs into more manageable and small pieces of code.These small pieces of codes are usually known as functions or modules or sub-programs of large complex programs.It is known as modula
3 min read
Difference between Compile Time Errors and Runtime Errors
Compile-Time Errors: Errors that occur when you violate the rules of writing syntax are known as Compile-Time errors. This compiler error indicates something that must be fixed before the code can be compiled. All these errors are detected by the compiler and thus are known as compile-time errors. M
3 min read
What is the difference between pipeline and make_pipeline in scikit?
Generally, a machine learning pipeline is a series of steps, executed in an order wise to automate the machine learning workflows. A series of steps include training, splitting, and deploying the model. Pipeline It is used to execute the process sequentially and execute the steps, transformers, or e
2 min read
Difference between Machine Learning and Predictive Modelling
1. Machine Learning : It is a branch of computer science which makes use of cognitive mastering strategies to program their structures besides the need of being explicitly programmed. In different words, those machines are properly recognized to develop better with experience. 2. Predictive Modellin
2 min read
Difference between Procedural and Non-Procedural language
Procedural Language: In procedural languages, the program code is written as a sequence of instructions. User has to specify "what to do" and also "how to do" (step by step procedure). These instructions are executed in the sequential order. These instructions are written to solve specific problems.
2 min read
Difference Between Recursion and Induction
Recursion and induction are fundamental ideas in computer science and mathematics that might be regularly used to solve problems regarding repetitive structures. Recursion is a programming technique in which a function calls itself to solve the problem, whilst induction is a mathematical proof techn
4 min read
Total Recursive Functions and Partial Recursive Functions in Automata
Total Recursive Functions: A recursive function is called total recursive function if it is defined for its all arguments.Let f(a1, a2, ...an) be a function defined on function g(b1, b2, ...bn).Then f is a total function if every element of f is assigned to some unique element of function g. A total
2 min read
Algorithm for non recursive Predictive Parsing
Prerequisite - Classification of Top Down Parsers Predictive parsing is a special form of recursive descent parsing, where no backtracking is required, so this can predict which products to use to replace the input string. Non-recursive predictive parsing or table-driven is also known as LL(1) parse
4 min read