Reading dragon Book compiling Principles of Grammar Analysis (9) ...

Source: Internet
Author: User

The previous section is finished. ll (1) The main framework of the analysis algorithm, now let's look at the conflict processing ... There are many ways of dealing with conflicts, and this is called eliminating left recursion ...

The upper right grammar is left recursive grammar, you will find that any left recursive grammar is not ll (1), why? For example, if you look at the No. 0 and 1th of the grammar, they can be written in the following way:

E = t + t + t + ...

E = T

It is not difficult to find that their first collection must be coincident, so the left recursive grammar is obviously not ll (1) ... The way to eliminate left recursion is right recursion, as shown in the lower right:

Another commonly used technique called extracting the left male factor ... This is also very simple ...

So wrap it up. LL (1) The analysis algorithm is this:

In other words, some of the grammar is beyond the LL (1) Analysis algorithm analysis, and secondly, even the grammar can be analyzed, may also need to rewrite to resolve the conflict, but often resolved after the grammar will become difficult to understand.

Like this one.

E-E + T

| T


After rewriting:

E-T + E '

E-> E ' ....

Obviously it is easy to understand before rewriting ...

The summary is pretty much the case.

Reading dragon Book compiling Principles of Grammar Analysis (9) ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.