Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Consider the following grammar for the for statements : for - stmt - - > for ( var = exp,exp, exp ) do stmt var

Consider the following grammar for the for statements :
for-stmt --> for ( var =exp,exp, exp) do stmt
var id
The informal semantic of the "for" statement is to:
Use the code generated for the three expressions between parentheses,
Initialize the loop control variable ("var") by the first expression appearing in the list,
Use the code generated for the statement
Loop by incrementing the control variable by the second expression in the list, until the control variable
value is greater than the value of the third expression in the list
a. Write an attribute grammar for generating three-address code for the above grammar.
b. Write the three-address code generated for the statement:
for (i=e1,e2,e3)dos1
Assuming that the code evaluating e1, e2, e3 are e1.code, e2.cod, and e3.code respectively and their values
are to be stored in t1,t2, and t3.
image text in transcribed

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

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students explore these related Databases questions

Question

What is Accounting?

Answered: 3 weeks ago

Question

Define organisation chart

Answered: 3 weeks ago

Question

What are the advantages of planning ?

Answered: 3 weeks ago