# Ullman (Compiler Design) Edition 2 Exercise 5.3 Question 2 (Page No. 323)

52 views
Give an SDD to translate infix expressions with $+$ and $\ast$ into equivalent expressions without redundant parentheses. For example, since both operators associate from the left, and $\ast$ takes precedence over  $+, ((a\ast(b+c))\ast(d))$ translates into $a\ast(b + c)\ast d$.

## Related questions

1
47 views
Give an SDD to differentiate expressions such as $x\ast(3\ast x + x\ast x)$ involving the operators $+$ and $\ast,$ the variable $x$, and constants. Assume that no simplification occurs, so that, for example, $3\ast x$ will be translated into $3\ast 1+0\ast x$.
Below is a grammar for expressions involving operator $+$ and integer or floating-point operands. Floating-point numbers are distinguished by having a decimal point. $E\rightarrow E+T\mid T$ $T\rightarrow num.num\mid num$ Give an SDD to determine the type ... SDD of $(a)$ to translate expressions into postfix notation.Use the unary operator intToFloat to turn an integer into an equivalent float.
The following SDT computes the value of a string of $0's$ and $1's$ interpreted as a positive, binary integer. $B\rightarrow B_{1}0\:\{B.val=2\times B_{1}.val\}\mid B_{1}1\:\{B.val=2\times B_{1}.val+1\}\mid 1 \:\{B.val=1\}$ Rewrite this SDT so the underlying grammar is not left recursive, and yet the same value of $B.val$ is computed for the entire input string.
Suppose that we have a production $A\rightarrow BCD$. Each of the four nonterminals $A, B, C,$ and $D$ have two attributes: $s$ is a synthesized attribute, and $i$ is an inherited attribute. For each of the sets of rules below, tell whether the rules are consistent with an S-attributed definition the rules are consistent with ... $A.s=B.s+D.s$ $A.s=D.i,B.i=A.s+C.s,C.i=B.s,$ and $D.i=B.i+C.i.$