TAILIEUCHUNG - Thuật toán Algorithms (Phần 29)

Tham khảo tài liệu 'thuật toán algorithms (phần 29)', khoa học tự nhiên, toán học phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | PARSING 273 procedure expression begin term if p j then begin j j 1 expression end end An array p contains the regular expression being parsed with an index j pointing to the character currently begin examined. To parse a given regular expression we put it in p with a sentinel character in p M l which is not used in the grammar setjto 1 and call expression. If this results in j being set to then the regular ex is in the language described by the grammar. Otherwise we ll see below how various error conditions are handled. The first thing that expression does is call term which has a slightly more complicated implementation procedure term begin fact if or then term end A direct translation from the grammar would simply have term call factor and then term. This obviously won t work because it leaves no way to exit from term this program would into an infinite recursive loop if called. Such loops have particularly unpleasant effects in many systems. The implementation above gets around this by first checking the input to decide whether term should be called. first thing that term does is call factor which is the only one of the that could detect a mismatch in the input. From the grammar we know that when factor is called the current input character must be either or an input letter represented by This process of checking the t character without incrementing j to decide what to do is called lookahead. For some grammars this is not necessary for others even more lookahead is required. Now the implementation of factor fallows directly from the grammar. If the input character being scanned is not a or an input letter a procedure error is called to handle the error on 274 CHAPTER 21 procedure factor begin if pL then begin expression if p j then j j 1 else error end else if letter p j then j - j l else error if end Another error condition occurs when a is missing. These procedures are obviously recursive in fact they are so intertwined that they can t be compiled in .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.