TAILIEUCHUNG - compilers principles techniques and tools phần 2

để sử dụng trong tương lai, họ sẽ được sử dụng để minh họa cho điều trị dự phòng trường trong Tag lớp công, vì vậy họ có thể được sử dụng bên ngoài gói. Họ là tĩnh, do đó chỉ là một ví dụ hoặc bản sao của các lĩnh vực này. Các lĩnh vực cuối cùng, | Simpo PDF Merge and Split Unregistered Version - http Where the pseudocode had terminals like num and id the Java code uses integer constants. Class Tag implements such constants 1 package lexer File 2 public class Tag 3 public final static int 4 NUM 256 ID 257 TRUE 258 FALSE 259 5 In addition to the integer-valued fields NUM and ID this class defines two additional fields TRUE and FALSE for future use they will be used to illustrate the treatment of reserved The fields in class Tag are public so they can be used outside the package. They are static so there is just one instance or copy of these fields. The fields are final so they can be set just once. In effect these fields represent constants. A similar effect is achieved in c by using define-statements to allow names such as NUM to be used as symbolic constants . define NUM 256 The Java code refers to Tag. NUM and Tag. ID in places where the pseudocode referred to terminals num and id. The only requirement is that and Tag. ID must be initialized with distinct values that differ from each other and from the constants representing single-character tokens such as or . 1 package lexer File 2 public class Num extends Token 3 public final int value 4 public Num int v super value v 5 1 package lexer File 2 public class Word extends Token 3 public final String lexeme 4 public Worddnt t String s 5 super t lexeme new String s 6 7 Figure Subclasses Num and Word of Token Classes Num and Word appear in Fig. . Class Num extends Token by declaring an integer field value on line 3. The constructor Num on line 4 calls super Tag. NUM which sets field tag in the superclass Token to Tag. NUM. 7ASCII characters are typically converted into integers between 0 and 255. We therefore use integers greater than 255 for terminals. Simpo PDF Merge and Split Unregistered Version - http 1 package lexer File 2 import . import

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.