Question: Consider the grammar below, which generates arithmetic expressions involving operator + and integer or floating - point operands. Floating - point numbers are distinguished by

Consider the grammar below, which generates arithmetic expressions involving operator + and integer or floating-point operands. Floating-point numbers are distinguished by having a decimal point.
E -> E+T|T
T-> num. num | num
Focus on the data type of the arithmetic expression, generated by B. The data type of an arithmetic expression, involving addition (+ operator) of two integer operands becomes an integer expression, whereas data type of an arithmetic expression involving one integer and one floating point operand becomes a floating point expression. For instance, the data type of expression 7+4 is integer, whereas 8+3.4,5.6+3,7.5+2.9 are floating point expressions.
Consider a SDD, which determines the data type of the expression E. In this SDD, type is the only (synthesized) attribute, defined for the non-terminals E and T, where E.type stores the data type of the expression E. Write the complete SDD which computes E.type to determine the data type of the expression E.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!