Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the following code to perform the following tasks: (8 pts) Show all variables that are visible at POSITION #1 only. Provide their nesting level

  1. Use the following code to perform the following tasks:

    1. (8 pts) Show all variables that are visible at POSITION #1 only. Provide their nesting level and offset, using the activation record layout discussed in class.

    2. (12 pts) Show the contents of the call stack at the time when control reaches POSITION #1. Use the layout defined in chapter 10 and used in class for statically scoped languages that allow nested functions. Show values and links.

function main() { int w = 1, x = 2;

function a(bool flag) { int x = 3;

function b() {

c(4);

}

function c(int x) { // POSITION #1

}

b();

}

a(true);

}

  1. (10 points) Provide a leftmost derivation for the string aaabb using the following grammar:

a | a

b | b

  1. (10 points) Identify the shortest possible legal program:

program ( { , } )

A | B begin end

= |

  1. (10 points) Show the following grammar is ambiguous:

xx |

x | x

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

Step: 3

blur-text-image

Students also viewed these Databases questions