I've watched this course by Alex Aiken and read through many other resources. But I'm struggling to find clear classification of top-down parsers.
This document doesn't provide a clear classification either but at least gives some definitions I'll use in the post. So here is the classification I've come up so far:
Backtracking VS Predictive
Backtracking
One solution to parsing would be to implement backtracking. Based on the information the parser currently has about the input, a decision is made to go with one particular production. If this choice leads to a dead end, the parser would have to backtrack to that decision point, moving backwards through the input, and start again making a different choice and so on until it either found the production that was the appropriate one or ran out of choices.
Predictive
A predictive parser is characterized by its ability to choose the production to apply solely on the basis of the next input symbol and the current nonterminal being processed.
Recursive descent VS table-driven
Recursive descent
A recursive-descent parser consists of several small functions, one for each nonterminal in the grammar. As we parse a sentence, we call the functions that correspond to the left side nonterminal of the productions we are applying. If these productions are recursive, we end up calling the functions recursively.
Table driven
There is another method for implementing a predictive parser that uses a table to store that production along with an explicit stack to keep track of where we are in the parse
As I understand now I have four different types of parsers:
- Recursive descent + backtracking
- Recursive descent + prediction
- Table-driven + backtracking
- Table-driven + prediction
If I'm correct, can some also tell me where in the following 4 types of parsers the LL(k)
parser falls?
table driven
but then saw some implementions with stack. Are you saying there's a contradiction heretable/stack implementation
? Why? Also, where doLL
,LL(1)
,LL(k)
parsers go in this classification? – Cathar