How lookaheads are propagated in “channel” method of building LALR parser?

The method is described in Dragon Book, however I read about it in “”Parsing Techniques” by D.Grune and C.J.H.Jacobs”.

I start from my understanding of building channels for NFA:

  1. channels are built once, they are like water channels with current
  2. you “drop” lookahead symbols in right places (sources) of the channel, and they propagate with “current”
  3. when symbol propagates, there are no barriers (the only sufficient things for propagation are presence of channel and direction/current); i.e. lookahead cannot just die out of the blue

Is that right?

If I am correct, then eof lookahead should be present in all states, because the source of it is the start production, and all other production states are reachable from start state.

How the DFA is made out of this NFA is not perfectly clear for me — the authors of the mentioned book write about preserving channels, but I see no purpose, if you propagated lookaheads. If the channels have to be preserved, are they cut off from the source if the DFA state does not include source NFA state? I assume no — the channels still runs between DFA states, not only within given DFA state.

In the effect eof should still be present in all items in all states. But when you take a look at DFA presented in book (pdf is from errata):

DFA for LALR (fig. 9.34 in the book, p.301)

you will see there are items without eof in lookahead.

The grammar for this DFA is:

S -> E
E -> E - T
E -> T
T -> ( E )
T -> n

So how it was computed, when eof was dropped, and on what condition?

Update

It is textual pdf, so two interesting states (in DFA; # is eof):

State 1:

S--- >•E[#]
E--- >•E-T[#-]
E--- >•T[#-]
T--- >•n[#-]
T--- >•(E)[#-]

State 6:

T--- >(•E)[#-)]
E--- >•E-T[-)]
E--- >•T[-)]
T--- >•n[-)]
T--- >•(E)[-)]

Arc from 1 to 6 is labeled (.

3

I think I got it.

There are barriers. When you think about NFA (and DFA, but then think about items, not states), there closure transitions and shift transitions, right?

For example — when you have T -> . ( E ) (state 1, last item in the pdf file) to T -> ( . E ) (state 6, first item) this is shift transition, and all lookahead symbols (# and -) are flowing happily.

However, initial closure transition kills all lookaheads (x) — you have to compute them from scratch. Continuing closure transition does not kill lookaheads.

Take a look at state 6 — all except the first item, are effects of closure transitions. The second gets ) from the top one, and - from itself. The third no matter which transition you consider gets ) and -. And for the last 2 ones, continuing closure transition gives also ) and -.

(x) There is an exception — if the pointer sits next to last symbol in production, you copy the lookaheads. Example A -> B . C, when you create closure for C you copy the lookaheads from A, because C in such case has to end with the same stuff as A.

To sum up — you have shift transition, copy all lookaheads.

You have closure:

  • as from X -> A B C D . E, in such case copy lookaheads as for shift transition

  • as from X -> A . B C D E, compute FIRST for C D E (mind you, not just C) and use it (copy) as lookaheads for B closure, if entire chain can be empty (C D E) copy lookaheads as for shift too

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật