Ask Question, Ask an Expert


Ask Computer Engineering Expert

problem 1: Given the production:

S-> aSAb | Ab
A-> bbb
implement a complete pseudo code for a recursive descent parser. Assume scanner ( ) returns the next token.

problem 2: Give all needed first and follow sets needed to check if the grammar is LL(1). Is it?:

S -> aA | BB
A -> aaA | empty
B -> bB | Cd
C -> cA | dC

problem 3: A function returns a number, takes no arguments, and its body is a block. Functions are defined exactly like variables in the grammar except that function name is follow by a block. Show the grammar. Is the resulting grammar LL(1)?

problem 4: A function definition must be before the program token, and functions cannot be nested (exactly like in C). Every function has a return type (no void) and one argument. Function call is like in C, with an expression for the argument and the function call itself is an expression. Show the grammar. exs:

int fun1(long x)
/* same as in any block*/
long fun2(int x)
/** ... */
program xxx(void)
int x;

problem 5: Design unambiguous grammar to parse expressions involving +, -, *, / and unary -. Unary minus is strongest, followed by * and /(same precedence, right associative), then +, left associative, then finally -, left associative. Do not use any other operators, and use only number tokens.

problem 6: Assume function f ( ) has local variables a, b, and function g is nested inside of f ( ) and has local variable a. There is also a global variable c.

a) show the complete memory space for the program when it begins execution
b) show the stack after f ( ) is called, which subsequently calls g ( ), which calls itself once.
c) assume we have three statements in g ( )

stat1: c=10;
stat2: a=20;
stat3: b=30;
how would they be translated by the compiler: describe in words.

problem 7: Show the grammar for:

a) Allow global variables placed just before the first begin – these variables are optional and are listed separated by commas. For ex:

int x,y,z;
begin {etc.}

b) Also allow functions. Each function takes any number of arguments and always returns an integer. Parameter list is C-like, and the return statement (followed by an expression) is mandatory. Functions can be called in place of any expression. Functions are defined with a block, which is the same as the begin-end block in our grammar. Functions are defined separately, as in C but before the main program. Assume we have a multi-pass compiler so that prototypes is not an issue. The following is an ex program

int sum(int a, b) {paramater list is same as for globals}
int c;
return a+b;
int x,y;

problem 8: Given the program (like Pascal, with nested functions)

int x, y; {global}
function A
int z; {z is in A}
function B {B is defined inside A}
int x; {x is in B}
function C {C is inside B}
int x; {x is in C}
C(); {recursive call on C}
end; {end of C}
end; {end of B}
B(); { A calls B}
end; {end of A}

a) show ARs (activation Records) for A, B, C (show only local data, static and dynamic link}
b) What is in the persistent data space?
c) assume call to A() is done somewhere. Then, show that contents of the stack during the 3rd recursive call to C(). Make sure to fill out all info on the stack.
d) How would the left-hand-side variables in C()be translated by the compiler (describe in words, separately for each variable).

problem 9: Given the grammar, with lower case terminals and upper case nonterminals, and S the initial nonterminal

S -> aS | aA | bA
A -> Aa | ABb | cA
B -> bB | bdB | c

a) remove left recursion as needed, showing the modified grammar

b) left-factorize as needed what you get in a), showing the new grammar

c) Is the resulting grammar LL(1)? Argue piece by piece why it is or why it is not, showing all (and only the necessary) First and Follow sets.

problem 10: Assume the following static program structure, show the static chains and display when exactly five ARs are on the stack, assuming procedure A is called first.

proc A
begin /* proc A */
proc B
begin /* proc B */
proc C
begin /* proc C */
call A
end /* proc C */
call C
end /* proc B */
proc D
begin /* proc D */
call B
end /* proc D */
call D
end /* proc A */

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93892

Have any Question? 

Related Questions in Computer Engineering

Grant artistic company sells artistic boutique works and

Grant Artistic Company sells artistic boutique works and related "arty" products to Joanne's Africa Arts Shop. Over the phone, representatives of the two companies negotiate of sale of seven African tribal masks as well ...

Computer security system security assignment objectivesthe

COMPUTER SECURITY (SYSTEM SECURITY) ASSIGNMENT Objectives: The main objective of this assignment is for the students to understand the security mechanisms in Unix-like operating systems and their interplay with software ...

1 what is the difference between a threat agent and a

1. What is the difference between a threat agent and a threat? 2. What is the difference between vulnerability and exposure? 3. How is infrastructure protection (assuring the security of utility services) related to info ...

1 what is the standard for encryption currently recommended

1. What is the standard for encryption currently recommended by NIST? 2. What is the most popular symmetric encryption system used over the Web? The most popular asymmetric system? Hybrid system?

Create a simple model that includes some agents a rule for

Create a simple model that includes some agents, a rule for birth of agents (see hatch primitive) and a rule for death of agents (see die primitive). It is often useful to include a rule for agent movement. The agents ca ...

Assignment computer forensic toolsyou have been recently

Assignment: Computer Forensic Tools You have been recently hired to assist with purchasing computer forensics tools and resources for a major corporation. Using the concepts that you learned in chapters nine through twel ...

1 why is information security a management problem what can

1. Why is information security a management problem? What can management do that technology cannot? 2. Why is data the most important asset an organization possesses? What other assets in the organization require protect ...

1 why is it important to explore divisional and group

1. Why is it important to explore divisional and group structures of an organization when starting a network design project? 2. The "Networks Offer a Service" section mentioned ITSM and ITIL. Research these topics in mor ...

1 a network consists of n hosts assuming that cryptographic

1. A network consists of n hosts. Assuming that cryptographic keys are distributed on a per-hostpair basis, compute how many different keys are required. 2. One cryptographic checksum is computed by applying the DES in C ...

1 why is antivirus software always developed after the

1. Why is antivirus software always developed after the virus has stricken? 2. Describe the similarities between biological viruses and computer viruses. 3. What are the difficulties faced by a community that wants to fi ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

WalMart Identification of theory and critical discussion

Drawing on the prescribed text and/or relevant academic literature, produce a paper which discusses the nature of group

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro