Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
như nhà nước 10 trong hình. 3.14. Có lẽ nhà nước được nhập vào sau khi nhìn thấy thứ chữ cái, mà là một tiền tố của từ khóa sau đó cũng như có khả năng là tiền tố của một số lexeme cho một định danh. E ký tự nhập vào, chúng tôi phải đi từ nhà nước của một nhà nước đặc biệt nhớ lại chúng tôi | Simpo PDF Merge and Split Unregistered Version - http www.simpopdf.com head body i I body 2 Ị body n semantic action 1 semantic action 2 semantic action n In a Yacc production unquoted strings of letters and digits not declared to be tokens are taken to be nonterminals. A quoted single charâcter e.g. c is taken to be the terminal symbol c as wéll as the integer code for the token represented by that character i.e. Lex would return the character code for c to the parser as an integer . Alternative bodies can be separated by a vertical bar and a semicolon follows each head with its alternatives and their semantic actions. The first head is taken to be the start symbol. A Yacc semantic action is a sequence of c statements. In a semantic action the symbol refers to the attribute value associated with the nonterminal of the head while z refers to the value associated with the zth grammar symbol terminal or nonterminal of the body. The semantic action is performed whenever we reduce by the associated production so normally the semantic action computes a value for in terms of the i s. In the Yacồ specification we have written the two E-productions E-ÌÉ T I T and their associated semantic actions as expr expr term 1 3 I term Note that the nonterminal term in the first production is the third grammar symbol of the body while is the second. The semantic action associated with the first production adds the value of the expr and the term of the body and assigns the result as the value for the nonterminal expr of the head. We have omitted the semantic action for the second production altogether since copying the value is the default action for productions with a single grammar symbol in the body. In general 1 is the default semantic action. Notice that we have added a new starting production line expr n printf 7.d n 1 to the Yacc specification. This production says that an input to the desk calculator ỈS to be an expression followed by a newline character. The semantic action .