parsing - Difference between an LL and Recursive Descent parser? -


I've been trying to teach myself recently how to work for parsers (for languages ​​/ context-free grammar) , And most of this is understandable, except one thing, I am specifically focusing on ll (k) grammar , for which two main algorithms (piles / pars Using the table) and (using just recursion) appears.

As far as I can see, recursive descent algorithms all work in LL.K. and possibly more, while an LL Parser works on all L.L. (K) grammar. A recurring descent parser is very easy to implement clearly, although it is much simpler than an LL parser (as an LL is compared to an LR one).

So my question is, what are the advantages / problems that encounter when using algorithms? Why can it ever take an LLL on an iterative line, provided it works on a single set of grammar and it is intriguing to be implemented?

LLL is usually more efficient parsing technique than recurring descent, in fact, a deceptive recursive-lineage parser In the worst case scenario, O (k ^ n) (where n is the input size) will be. Some techniques such as memoanization (which generate parsons) can improve this and increase grammar classes accepted by the parser, but always have a space deal. The LL Parser (for my knowledge) is always the linear time.

On the flip side, you are right in your intuition that parsons of recurrent descent can handle the grammatical class over LLL. The recurring descendant can control any grammar, which is also a small group of lll (*) (which is, unlimited lookahhead), as well as unclear grammar. The reason for this is that the recurring descendants are not actually computious of PEG's direct-encoded implementation, or in particular, the unrelated operator ( a | b ), which means that a | B is not equal to b | A . A recursive-line parser will try every option in order. So if matches a input, then it can also be that if the b happens match the input. It allows ambiguity like the classic "longest match", such as the dangling else problem is arranged properly by ordering respectively.

With all of them, it is possible to possible apply a lal (k) parser to use recursive clan so that it runs in linear time. This is essentially done to inline the preset set so that each parse routine determines the appropriate output for a certain input in a constant time. Unfortunately, this kind of technique is being handled with grammar of the whole class. Once we get into parsing the future, problems like hanging up the problem are not easily accessible.

Why LLL will be chosen on the recursive clan, this is mainly the question, efficiency and maintenance is clearly easy to implement the parser of the iterative line, but they are usually difficult to maintain Because they do not exist in any declarative form. Most non-trivial parser employs-case parser generators like ANTLR or Bison. With such devices, it really does not matter if the algorithm is directly-encoded with recursive-lineage or table-operated LL (K).

As a matter of interest, it is also worth considering, which is a parsing algorithm directly encoded after the recurring descendant fashion, but the LLRR is capable of handling grammar. I would also like to dig, which is a functional way of composing simultaneous parsing of recurring descent.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -