First, you need to know what is a Terminator and a non-Terminator.
Terminator: In general, the terminator cannot appear on the left of the derivation, that is, the terminator cannot be deduced.
Non-Terminator: Non-Terminator. (Not male or female, haha)
For example, if a --> B, A is a non-Terminator.
(Generally, the Terminator is in lower case, and the non-Terminator is in upper case .)
Ii. Basic Idea of generating a language sentence in grammar: replace the non-terminator in the currently generated symbol string with the symbol string on the right of the corresponding rule starting with the recognition symbol (start character, until all are composed of Terminators.
3. First Set Method
The first set is ultimately for the right string of the form, but the key is to find the first set of non-Terminator, because the first set of Terminator is its own, therefore, after finding the first set of non-Terminator, you can obtain the first set of each string intuitively.
1. directly collect: The pair is like U->... Generate (where a is the terminator), and send a's revenue to first (u)
2. Repeated transmission: U-> P... (P is not a terminator), and all content in first (p) should be transmitted to first (u) medium [meaning to pass the first set of the first non-terminator ~ This place is important and difficult ].
4. Method of follow set
The follow set is for non-Terminator. Follow (u) expresses the set of all possible terminologies with non-terminator U in a sentence. In particular, "#" is the suffix of the identifier. Note that the follow set is derived from the starting symbol S.
1. directly collect: Pay attention to each of the right parts of the generative formula, such as "... UA ..." To directly generate a to follow (u. Because a is the terminator followed by U.
2. direct charge: The pair is like "... Up ..." (P) is a combination of non-terminologies, and first (P) is directly included in follow (U). [here, if first (p) contains null characters, then, the follow (s) of the left (assuming S) is sent to follow (u. In addition, the follow set has no null characters ].
3. charge directly: If S->... U, that is, end with U, then # ε follow (u)
4. * repeated transmission: the opposite is like U->... P (where p is not a terminator), all content in follow (u) should be transmitted to follow (P.
PS: The follow set is a little more complex than the first one, but it is a small case to remember to do more exercises with algorithms.