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 19:00
The fourth generation of computers emerged between 1970s and 1980s. which technological advancement brought about this generation of computers? which computer architecture was used most in this generation?
Answers: 3
question
Computers and Technology, 23.06.2019 14:30
Choose the answers that best complete each sentence. on average,are more expensive than other kinds of postsecondary schools. the cost of room and board includes. to save money, some students attend auniversity in their home state.
Answers: 2
question
Computers and Technology, 24.06.2019 13:50
Write a program that performs a simple n-body simulation, called "jumping leprechauns." this simulation involves n leprechauns, numberd 1 to n. it maintains a gold value g_i for each leprechaun i, which begins with each leprechaun starting out with a million dollars worth of gold, that is, g_i = 1000000 for each i = 1,. in addition, the simulation also maintains, for each leprachaun,i, a place on the horizon, which is represented as a double-precision floating point number, x_i. in each iteration of the simulation, the simulation processes the leprachauns in order. processing a leprachaun i during its iteration begins by computing a new place on the horizon for i, which is determined by the assignment:
Answers: 3
question
Computers and Technology, 24.06.2019 18:00
Why is a multiview sketch drawinf different from other sketches like isometric, two point, and oblique
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, 13.04.2020 22:53
question
Spanish, 13.04.2020 22:53
question
Social Studies, 13.04.2020 22:53
question
Mathematics, 13.04.2020 22:53
question
Mathematics, 13.04.2020 22:53
Questions on the website: 13722361