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 03:30
Jessie has received a contract to build a real-time application for a baker. however, the baker doesn't want to invest too much money. his only requirement is that he wants the customers to know which cupcakes are available at what time and in what quantity. so his core requirement is that the details of product should be in real time. what platform can jessie use to develop this application?
Answers: 1
question
Computers and Technology, 22.06.2019 05:00
Lisa has a section of her document that she would like to include in the index. which option should lisa choose? mark index mark entry insert endnote add text
Answers: 3
question
Computers and Technology, 22.06.2019 16:00
You have inserted new slides based on a word outline. how do you format these new slides to match the powerpoint presentation formatting? a. select all slides in the presentation and click format on the home tab. b. select the new slides and click reset on the home tab. c. select all slides in the presentation and click reset on the home tab. d. select the new slides and click format on the home tab.
Answers: 3
question
Computers and Technology, 22.06.2019 17:00
Your company has 1,500 desktop computers running windows 7. you want to upgrade them to windows 10. which type of microsoft license would be best suited in this situation?
Answers: 3
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, 01.12.2020 20:20
question
Mathematics, 01.12.2020 20:20
question
Mathematics, 01.12.2020 20:20
question
Mathematics, 01.12.2020 20:20
question
Mathematics, 01.12.2020 20:20
question
English, 01.12.2020 20:20
question
English, 01.12.2020 20:20
Questions on the website: 13722363