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:10
This program reads a file called 'test.txt'. you are required to write two functions that build a wordlist out of all of the words found in the file and print all of the unique words found in the file. remove punctuations using 'string.punctuation' and 'strip()' before adding words to the wordlist. write a function build_wordlist() that takes a 'file pointer' as an argument and reads the contents, builds the wordlist after removing punctuations, and then returns the wordlist. another function find_unique() will take this wordlist as a parameter and return another wordlist comprising of all unique words found in the wordlist. example: contents of 'test.txt': test file another line in the test file output: ['another', 'file', 'in', 'line', 'test', 'the']
Answers: 1
question
Computers and Technology, 23.06.2019 03:30
Hashtags serve to identify the topic of a given tweet true false
Answers: 2
question
Computers and Technology, 24.06.2019 13:30
Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. the program should output the average high, average low, and the highest and lowest temper- atures for the year. your program must consist of the following functions: a. function getdata: this function reads and stores data in the two- dimensional array. b. function averagehigh: this function calculates and returns the average high temperature for the year. c. function averagelow: this function calculates and returns the aver- age low temperature for the year. d. function indexhightemp: this function returns the index of the highest high temperature in the array. e. function indexlowtemp: this function retur
Answers: 3
question
Computers and Technology, 24.06.2019 14:30
Alison is having a hard time at work because hee inbox is flooded with emails every day. some of these emails are unsolicited. some of other she don’t need. which action should she take to better manager her emails?
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.02.2020 06:55
question
Mathematics, 13.02.2020 06:55
question
History, 13.02.2020 06:55
Questions on the website: 13722360