I'm concerned about the very important difference between the therms: "LL(k)
parser" and "parser for LL(k)
grammars". When a LL(1)
backtracking parser is in question, it IS a parser for LL(k)
grammars, because it can parse them, but its NOT LL(k)
parser, because it does not use k
tokens to look ahead from a single position in the grammar, but its exploring with backtracking the possible cases, regardless that it still uses k
tokens to explore.
Am I right?
The question may break down to the way the look-ahead is performed. If the look-ahead is actually still processing the grammar with backtracking, that does not make it LL(k)
parser. To be LL(k)
parser the parser must not use the grammar with backtracking mechanism, because then it would be "LL(1)
parser with backtracking that can parser LL(k)
grammars".
Am I right again?
I think the difference is related to the expectation that LL(1)
parser is using a constant
time per token, and LL(k)
parser is using at most k * constant
(linear to the look-ahead) time per token, not an exponential time
as it would be in the case of a backtracking parser.
Update 1: to simplify - per token, is the parsing LL(k)
expected to run exponentially in respect to k
or in a linear time in respect to k
?
Update 2: I have changed it to LL(k)
because the question is irrelevant to the range of which k
is (integer or infinity).
I suggest you to read the chapter 5.1 of Aho Ullman Volume 1.
https://dl.acm.org/doi/book/10.5555/578789