subject

(a) Write a context-free grammar for polynomials in x. Add semantic func- tions to produce an attribute grammar that will accumulate the polynomials derivative (as a string) in a synthesized attribute of the root of the parse tree. The following assumes that exponents in the input are all positive integers. PT more-Ts more. Ts. st :=T. d P. d:= more. Ts. d T num T tail > Ttail. c := num. v T. d: T. tail. d T tail x exp exp. c:- T. tail. c ► T. tail. d = exp. d T tail DT-tail. d:="" exp ** num exp. d := float_to_string(exp. cx num. v) + "* **" + int_to_string(num. - 1) expe exp. d := float_to_string(exp. c) more. Ts + + T more. Ts2 ► more. Ts2.st := more. TS. st + "+" +Td more. TS. d:= more. Ts2.d more. Ts € more-Ts. d:= more. Ts. st (b) Replace your semantic functions with action routines that can be evaluated during parsing. P + T {more. Ts. st := T. d} more_Ts {P. d := more-Ts. d} T + num {T-tail. c := num. v} T_tail {T. d := T-tail. d} T tail + x {exp. c := T-tail. c} exp {T-tail. d = exp. d} €{T-tail. d := ""} exp ** num {exp. d := float_to_string(exp. c x num. v) + "x **" + int. to. string(num. v - 1)} € {exp. d := float-to-string(exp. c)} more-Ts → + T {more-Ts2.st := more. Tsi. st + + T. d} more-T2 {more. Ts .d = more. Ts2.d} e{more. Ts. d := more. Ts. st} E Consider provided solutions of PLP Exercise 4.17 (1) Explain essential differences between solutions (a) and (b). (ii) Modify solutions (a), (b) so that the second derivative (not the first derivative) is accumulated in a synthetized attribute of the root of the parse tree.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:40
In this lab, you complete a python program that calculates an employee's annual bonus. input is an employee's first name, last name, salary, and numeric performance rating. if the rating is 1, 2, or 3, the bonus rate used is .25, .15, or .1 respectively. if the rating is 4 or higher, the rate is 0. the employee bonus is calculated by multiplying the bonus rate by the annual salary.
Answers: 1
question
Computers and Technology, 23.06.2019 00:40
Consider the following statements: struct nametype{string first; string last; }; struct coursetype{string name; int callnum; int credits; char grade; }; struct studenttype{nametype name; double gpa; coursetype course; }; studenttype student; studenttype classlist[100]; coursetype course; nametype name; mark the following statements as valid or invalid. if a statement is invalid, explain why.a.) student.course.callnum = "csc230"; b.) cin > > student.name; c.) classlist[0] = name; d.) classlist[1].gpa = 3.45; e.) name = classlist[15].name; f.) student.name = name; g.) cout < < classlist[10] < < endl; h.) for (int j = 0; j < 100; j++)classlist[j].name = name; i.) classlist.course.credits = 3; j.) course = studenttype.course;
Answers: 1
question
Computers and Technology, 23.06.2019 11:30
The most accurate readings that you can take on an analog vom are when the meter's pointer is at the a. center scale. b. extreme right. c. near right. d. extreme left.
Answers: 1
question
Computers and Technology, 23.06.2019 14:00
How are stop motion special effects in animated films created
Answers: 1
You know the right answer?
(a) Write a context-free grammar for polynomials in x. Add semantic func- tions to produce an attrib...
Questions
question
Mathematics, 24.03.2020 00:35
question
Mathematics, 24.03.2020 00:46
Questions on the website: 13722360