Microsoft Visual C++ Windows Applications by Example phần 7

tái sử dụng một phần lớn các chức năng. Người dùng có thể tái định hình ellipse bằng cách nắm bắt ellipse ở trên cùng bên trái của nó, ngoài cùng bên phải, hoặc điểm thấp nhứt. Lớp reuses m_ptTopLeft các lĩnh vực và | Chapter 8 Formula Interpretation The core of a spreadsheet program is its ability to interpret formulas. When the user inputs a formula in a cell it has to be interpreted and its value has to be evaluated. The process is called formula interpretation and is divided into three separate steps. First given the input string the scanner generates a list of tokens then the parser generates a syntax tree and finally the evaluator determines the value of the formula. A token is the smallest significant part of the formula. For instance the text a1 is interpreted as a token representing a reference the text is interpreted as the value . Assume that the cells have values according the sheet below the formula interpretation process will be as follows. a1 b1 Scanner T_VALUE T_MUL T_LEFT_PAREN T_REFERENCE row 0 col 0 T_PLUS T_REFERENCE row 0 col 1 EOL 243 The Calc Application Parser 1 1 1 al bl Evaluator The Tokens The scanner takes a string as input traverses it and finds its least significant parts its tokens. Blanks are ignored and the scanner sees no difference between capital and small letters. The token T_VALUE needs an extra piece of information to keep track of the actual value it is called an attribute. T_REFERENCE also needs an attribute to keep track of its row and column. In this application there are ten different tokens 244 Chapter 8 T_ADD T_SUB The four arithmetic operators - and . T_MUL T_DIV T_LEFT_PAREN Left and right parenthesis and . T_RIGHT_PAREN T_VALUE A numerical value for instance 123 or . It does not matter whether the value is integral or decimal. Nor does it matter if the decimal point if present is preceded or succeeded by digits. However the value must contain at least one digit. Attribute a value of type double. T_REFERENCE Reference for instance a12 b22. Attribute an object of the Reference class. T_EOL The end of the line there is no more characters in the string. As stated above the string 2 al bl

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
97    97    2    21-06-2024
Đã 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.