How I Went From A 2 To Straight A S

5 mistakes to write a summary

Enter the FIRST (x) function - returning the first k of symbols. Usually attribute as indexes k and G - quantity of symbols and grammar respectively, but it is possible to lower them if it does not cause misunderstanding.

OPR: KC-grammar of G = (N, E, P, S) is called as LL (k) - grammar for some fixed k if from existence of two left conclusions (Syuwaa'yuwb'a'yuwx ((Syuwaa'yuwc'a'yuwy for which FIRST(x) = FIRST(y), follows that b of' =c'.

The theorem can be expressed to the following: on the first symbol after not terminal it is necessary to choose the applicable rule - therefore, these symbols are various and crossing is empty. This theorem can be applied to LL (k) - grammars, but not always to be carried out. Grammars for which the theorem is carried out are called strong, thus, all LL (-grammars - strong. It is also necessary to notice that every LL (k) - grammar is unambiguous therefore if there is an ambiguous grammar - that it not LL (k). There is an unsoluble problem of recognition, whether exists for this KS-grammar of G which is not the LL (k) equivalent it LL (k) - grammar. However in some cases such transformation is possible. Two ways are applied: The first way - elimination of the left recursion.

DKV: Need. Let's say that w, A, a', b' and with' meet conditions of the theorem, and FIRST (b'a') ZFIRST (c'a') contains x. Then by definition of FIRST for some y and z there will be conclusions of Syuwaa'yuwb'a'yuwxy and Syuwaa'yuwc'a'yuwxz. (We will notice that here we used that fact that N does not contain useless terminals as it is supposed for all considered grammars.) If |x |

PRM: Let's consider LL (-grammar of G with two rules S®aS|a. In these two rules "let's put outside brackets to the left" a symbol a, having written down them in the form of S®a(S|e). In other words, we consider that a concatenation of a distributivn concerning operation of a choice of the alternative (designated by vertical line). Let's replace these rules on: Thereby we will receive S®aA A®S|e equivalent to LL (-grammar.

Method: The essence of algorithm is as follows: For each not terminal having two or more rules of promotion crossing of the first k-symbols of all possible chains of promotion is calculated. If this set is empty, pass to the following terminal, differently finish with No value. If all crossings are empty - finish with Yes value. For receiving crossing of two rules it is possible to use record: (FIRSTk (b') EKL) Z (FIRSTk (with') EKL), where L=FIRSTk (a') and an' - a chain of symbols after the terminal.

Otherwise this definition expresses that for the available chain and knowing the following k of symbols it is possible to apply no more than one rule of a conclusion. The grammar is called as LL grammar, if it as LL (k) - grammar for some k.

PRM: Let G consist of the rules S®aAS|b, A®a|bSA. Intuitively G is LL (-no more than one rule applicable to With and leading to the terminal chain beginning a page symbol exists grammar because, so far as the most left not terminal C in the left removed chain and the following entrance symbol is given with. Passing to definition of LL (-grammars, we see that if Syuwsa'yuwb'a'yuwx and Syuwsa'yuwc'a'yuwy and chains x and y begin the same symbol, there has to be b of' =c'. In this case if x and y begin a symbol a, the rule S®aAS and b of' =c' of =aAS participated in a conclusion. The alternative of S®b is impossible here. On the other hand, if x and y begin with b, the rule S®b and b of' =c' of =b has to be applied. Let's notice that x=y=e case is impossible here as e is not brought out of S in grammar of G.

In definition of LL (k) - grammars it is claimed that for this removed wAa chain the chain of w and directly the following of k of entrance symbols behind it unambiguously define what to apply the rule for development of not terminal A. Therefore at first sight can seem that for definition of the necessary rule it is necessary to remember all chain of w. However it not so. Let's prove the theorem very important for understanding of LL (k) - grammars: TRM: KS-grammar of G = (N, E, P, S) is LL (k) - grammar in only case when when for two various rules A®b' and A®c' from P crossing of FIRST (b'a') ZFIRST (c'a') is empty for all such wAa' that SYuWAA'.

Sufficiency. Let's say that G not the LL (k) grammar. Then there will be such two conclusions of Syuwaa'yuwb'a'yuwx and Syuwaa'yuwc'a'yuwy that chains x and y coincide in the first k positions, but b`¹c`. Therefore A®b' and A®c' - various rules from P and each of sets of FIRST (b'a') and FIRST (c'a') contains the chain of FIRST (x) coinciding with FIRST(y). ChTD.