First set and follow set

Source: Internet
Author: User

ellipsisRepresents the final symbol of the other related production, at the beginning, the ellipsis is not in the   first set case one   if a is only on the right side of the →, then ={a}, Example M→α,first (alpha) ={α} situation Daini   For a→bcdefg,                One if no b→ε, then first (A) ={...} ∪first (b), then ask first (b)                 Two if there is b→ε, then first (A) ={...} ∪ (First (b)-{ε}) ∪first (CDEFG), then respectively first (b)-{ε}, first (CDEFG) case if g→ε, then first (G) ={...} ∪{ε}  Follow set case if S is the start symbol (generally the first production), then follow (S) ={......,$}  Case II     If there is a production A→ΑBCD, and ε does not belong to primary (CD) So follow (B) ={...} ∪ (First (CD))               Two if there is a production A→ΓBCD and ε belongs to first (CD) then follow (B) ={...} ∪ (First (CD)-{ε}) ∪follow (a) case B   if there is a production m→cdb, then follow (B) ={...} ∪follow (M)     example for grammar g[a]a→bcc|gdb   b→bcde|εc→dab|cad→dd|εe→gaf|c first set First look → Left (A) =first (BCc) ∪fisrt (GDB)                = (First (B)-{ε}) ∪first (Cc) ∪{g}  & nbsp           ={b}∪first (DABC) ∪first (CAC) ∪{g}               ={b}∪first (DDABC) ∪first (aBc) ∪{c}∪{g}              ={ B,d,a,c,g}first (B) =first (BCDE) ∪first (ε)               ={b,ε}first (c) =first (DaB) ∪first (CA)                =first (Ddab) ∪first (AB) ∪{c}     equivalent (first (D)-{ ε}) ∪first (AB) ∪{c}              ={d,a,c}first (d) =first (DD) ∪first (ε)                ={d,ε}first (E) =first (gAf) ∪first (c) ={g,c}---------------------------------- ---------------------------------------------------------------------follow set First look → right follow (A) ={$}∪{f}={f,$}follow (B) =first (Cc) ∪follow (A) ∪follow (C)                       ={D,A,C}∪{F , $}∪follow (c) First go to follow (c)                       ={A,C,D,G,F,$}FO Llow (C) ={c}∪first (DE)                       ={c}∪{d}∪first (E)                      ={c,d,g}follow (d) = (First (B)-{ε}) ∪follow (A) ∪first (E) ∪{a}∪follow (d)                      ={b}∪{f,$}∪{g,c}∪{a}                  &NBSP ;  ={a,b,g,c,f,$}follow (E) =follow (b) ={a,c,d,g,f,$}

First set and follow set

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: info-contact@alibabacloud.com 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.