COMPILER DESIGN

SYNTAX ANALYSIS

ROLE OF THE PARSER

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
predictive parser
A
needs backtracking
B
does not need backtracking
C
may not terminate
D
none
Explanation: 

Detailed explanation-1: -A predictive parser is a recursive descent parser that doesn’t need backtracking or backup. It is a top-down parser with no need for backtracking. At each stage, the rule to be extended is chosen based on the next terminal symbol. Hence the correct answer is recursive.

Detailed explanation-2: -Which parsing technique avoids backtracking? Explanation: Both predictive parsing and recursive descent parsing avoid backtracking.

Detailed explanation-3: -Backtracking is still useful, but if you need backtracking you can use a dedicated parser for it: OneOf . It’s a parser that tries multiple parsers on the same input. If one fails, it backtracks the input to its original state, and if one succeeds, then that output is returned and no other parsers are tried.

There is 1 question to complete.