Question: 7. Given the following grammar for an expression language E: [0] S : expr '$' j expr term '@' term : [1] [2] [3] [4]
![7. Given the following grammar for an expression language E: [0]](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f30e82ee780_99466f30e8267652.jpg)
7. Given the following grammar for an expression language E: [0] S : expr '$' j expr term '@' term : [1] [2] [3] [4] term : factor '%' term | factor ; factor : '&' factor : DIGIT | '('expr ')' ; [5] [6] [7] where $ stands for the EOF marker and the terminal DIGIT stands for a token representing the digits o... 9. a. Can the operand of the unary suffix operator @ be another unary @-expression without needing the operand to be surrounded by parentheses? 2-points b. Can the operand of the unary prefix operator & be another unary &-expression without needing the operand to be surrounded by parentheses? 2-points c. What is the associativity of the binary % operator? 2-points d. Describe the relative precedence of the operators @,% and &. 2-points e. Show a leftmost derivation and corresponding parse tree for the sentence ( 1 @ ) % & 2 $. For each step in your derivation, show the number of the grammar rule being used. 10-points f. In some sense, does the E-language seem "awkward" compared to the language of arithmetic expressions? 2-points 7. Given the following grammar for an expression language E: [0] S : expr '$' j expr term '@' term : [1] [2] [3] [4] term : factor '%' term | factor ; factor : '&' factor : DIGIT | '('expr ')' ; [5] [6] [7] where $ stands for the EOF marker and the terminal DIGIT stands for a token representing the digits o... 9. a. Can the operand of the unary suffix operator @ be another unary @-expression without needing the operand to be surrounded by parentheses? 2-points b. Can the operand of the unary prefix operator & be another unary &-expression without needing the operand to be surrounded by parentheses? 2-points c. What is the associativity of the binary % operator? 2-points d. Describe the relative precedence of the operators @,% and &. 2-points e. Show a leftmost derivation and corresponding parse tree for the sentence ( 1 @ ) % & 2 $. For each step in your derivation, show the number of the grammar rule being used. 10-points f. In some sense, does the E-language seem "awkward" compared to the language of arithmetic expressions? 2-points
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
