search
Log In
0 votes
125 views

 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$
  1. Give an SDD to determine the type of each term $T$ and expression $E$.
  2. Extend your SDD of $(a)$ to translate expressions into postfix notation.Use the unary operator intToFloat to turn an integer into an equivalent float. 
in Compiler Design 125 views

Please log in or register to answer this question.

Related questions

0 votes
0 answers
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$.
asked Sep 6, 2019 in Compiler Design Lakshman Patel RJIT 47 views
0 votes
0 answers
2
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$.
asked Sep 6, 2019 in Compiler Design Lakshman Patel RJIT 52 views
1 vote
1 answer
3
112 views
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.
asked Sep 6, 2019 in Compiler Design Lakshman Patel RJIT 112 views
0 votes
0 answers
4
...