Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Compiler Construction Think about a basic sentence structure for number-crunching articulations: E ::= n | x | E | E + E | ( E

Compiler Construction
Think about a basic sentence structure for number-crunching articulations:
E ::= n | x | −E | E + E | ( E )
with n going over whole number constants and x running over factors. We need to
aggregate articulations to code for a straightforward stack-based machine with the accompanying
guidance set.
guidance meaning
pushvar k push the worth of the k-th variable on top of stack
push n push n on top of stack
add supplant the best two stack things with their total
neg supplant the top stack thing with its refutation
For this issue, we won't stress over how factors will undoubtedly esteems nor
how conceptual linguistic structure trees are delivered.
(a) How will your compiler produce code from articulations of the structure −E?
[4 marks]
(b) How will your compiler create code from articulations of the structure E1 + E2?
[4 marks]
(c) What code will your compiler create for the articulation - (- x + (17 + y))?
[4 marks]
(d) Suppose we currently need to expand the language of number articulations with
duplication
E ::= · · · | E ∗ E
be that as it may, we can't expand the machine with a guidance for increase.
Would you be able to carry out this lengthy language straightforwardly with the machine
guidance set introduced previously? In the event that not, propose an insignificant expansion to the
guidance set that takes into consideration the execution of augmentation utilizing the
expansion from the guidance set. Make sense of the semantics of your expansions
also, how you would utilize them to execute augmentation. [8 marks]
5 (TURN OVER)
CST.2011.3.6
6 Concepts in Programming Languages
(a) Give one contrast and one closeness between the programming dialects:
(I) Algol and SIMULA [2 marks]
(ii) LISP and Smalltalk [2 marks]
(b) What is the sort of the articulation fn f => fn x => f(f(x)) induced by
the SML mediator? Make sense of your response. [6 marks]
(c) Give a model in the SML Modules language of two unmistakable marks, say
IN and OUT, and of a functor that takes structures matching IN to create
structures matching OUT. [6 marks]
(d) Comment on the instrument for boundary passing in the programming
language Scala. [4 marks]
You might wish to consider the accompanying two code tests.
def whileLoop( cond: => Boolean )( comm: => Unit )
{ if( cond ) comm; whileLoop( cond )( comm ) }
def qsort[T]( xs: Array[T] )( certain o: Ord[T] ): Array[T]
= if( xs.length <= 1 ) xs else
{ val turn = xs( xs.length/2 )
Array.concat
( qsort( xs channel (x => x.lt(x,pivot)) ) ,
xs channel (x => x == turn ) ,
qsort( xs channel (x => x.lt(pivot,x)) ) ) }

imageimage

Once again, it is PEMaCS Day in the Division of Physics Engineering Mathematics and Computational Sciences. As part of PEMaCS Day, lunch will be provided. Professor was able to receive a discount on burritos at Chipotle. Consumption of beef is three times that of the consumption of chicken. A chicken burrito costs Professor $3.00, while a beef burrito costs $4.00. Professor is planning to purchase either a chicken or beef burrito for each student in the department. As he does not know the preference of each student, he must ask. There are a total of 100 students in the division and he asks each student to fill in a web form to submit his or her burrito choice, namely chicken or beef. Help Professor figure out how much it will cost to buy lunch for all the students in the department. 1. What distribution best models this problem and why? (10 points) 2. On average, how many students will order a chicken burrito? A beef burrito? Show your work. (10 points) 3. On average, how much money will Professor spend? Show your work (10 points) Baseball legend David "Big Papi" Ortiz of the Boston Red Sox had a .315 batting average in his final season. As a veteran of the game, key to keeping his performance at a high level, Mr. Ortiz spent hours in practice receiving pitches. Always the competitive sort he decided to wager with his pitcher on the practice squad. The pitcher would throw pitches until Mr. Ortiz hit the ball. For each pitch he missed, Mr. Ortiz paid the pitcher $50. When Mr. Ortiz hit the ball, the pitcher would pay Mr. Ortiz $200. 4. What distribution best models this problem and why? (10 points) On average, how many pitches will Mr. Ortiz take for a hit? (10 points) How much money on average will Mr. Ortiz win/lose? (10 points) 5. 6.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Elements Of Chemical Reaction Engineering

Authors: H. Fogler

6th Edition

013548622X, 978-0135486221

More Books

Students also viewed these Computer Network questions

Question

Summarize the findings of psychotherapy effectiveness studies.

Answered: 1 week ago

Question

Calculate the missing values

Answered: 1 week ago