Ask Question, Ask an Expert

+1-415-315-9853

info@mywordsolution.com

Ask Computer Engineering Expert

problem 1: Given the productions.

S-> Sa | aaA | AbS
A-> acA

a) List the parse table. Is the grammar LL(1) in this form? If no, why not?

b) If not, reprepare the grammar until it is LL(1), proven. If you cannot accomplish this, why? Either way, show the appropriate sets leading to your decision.

problem 2: Given the LL(1) grammar

S-> aS | B
B-> bBa | Cb
C-> c |d
Assume scanner ( ) and error ( ) functions return the next token and abort processing, respectively. prepare a complete LL(1) recursive-descent parser in C- like pseudo code without rewriting the grammar.

problem 3: In your grammar there is no function call. Suppose we want to change function calls so that they evaluate to some returned data, and this data could be used the same way as variables are used in expressions (not left of assignment). For ex, you could prepare x = 2 + F1(5) * 3 which, assuming that F1(5) returns 10, should put 32 into x.

Show changes needed in syntax and describe semantics of function call.

problem 4: prepare a program would read two numbers and then print all numbers between the first and the second, inclusive. For ex, on input 2 and 5 the program would print 2 3 4 5 (output one per line from the virtual machine).

problem 5: Given the production:

S-> aSAc | Acb
A-> bbb| empty
Implement a complete pseudo code for a recursive descent parser. Assume scanner ( ) function returns the next token and error ( ) aborts processing with an error message. Do not forget the main program. This grammar is LL(1) so no don’t modify.

problem 6: Given:

S -> SabC | abC | aCa
C -> ccC | c | empty | D
D -> dd

Reprepare the grammar as LL(1) if possible or otherwise argue why it is not possible. Prove that it is indeed LL(1), after the modifications, showing only the sets that are needed and using them for your proof.

problem 7: Suppose you have a language where a valid program is a sequence of assignments, with each ending with a semicolon. An assignment has syntax and semantics as in our language. Expressions can use variables and integers. Variables are not defined just used. There are two predefined variables READ and prepare. READ evaluates to the standard input value, prepare doesn’t evaluate to anything but it prints to the output the value being assigned to it. Expressions are as follow: binary -,+,*,/,^, and unary!. Expression can be parenthesized, which overrides any precedence.

Precedence is set as: weakest are + and -, then *, then /, then ^, then the unary. Associativity is right to left for + and -, and left to right for all others. prepare the unambiguous CFG grammar.

ex statements
x:=READ+5;
prepare:=x;
x=y+x/(x*5);

problem 8
: Suppose you have a language where a valid program is a sequence of statements and nothing else. Every statement ends with semicolon. A statement is either input READ(variable) or assignment

variable = expression, where expression is C-like expression involving ( ) and +,-,*,/ all arithmetical binary operators except - which is both unary and binary, and no other operators. Associativity is set so that all operators are left to right except * which is right to left, Precedence is set so that ( ) overrides anything, the rest, from the strongest to the weakest are:

unary minus
+ and -, the same
* and /, the same.

There are no numbers nor anything else. Variables are not defined.

ex program:
READ(x);
READ(y);
x=y+x/(x*y);

Design unambiguous CFG. Make sure to state what the tokens are.

problem 9: Our project grammar uses input statement which reads input into a variable before it can be used. For ex, to read a value and multiply by 10 we must do the following:

READ,x;
y = = x*10;
Suppose that we also want to allow the following:
y = = READ*10;
to do exactly the same semantics except the value is not stored in x. This change should apply to other cases as well, for ex we want to be able to say:
IF (READ > 0) THEN ... #meaning if the input is greater than 0
y= =10+READ*READ ... # multiply two inputs, add 10, put result in y
Again, the original syntax/semantics should be preserved and this should be an additional way to accomplish something. Show the grammar to allow that. Prove that it is LL(1).

problem 10: prepare a valid C-program that would read an input and then compute and output its factorial. Are there limitations of this program? Be very specific.

Computer Engineering, Engineering

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

Have any Question? 


Related Questions in Computer Engineering

Think about a specific healthcare organization are there

Think about a specific healthcare organization: Are there any differences for creating an effective delivery system? Who are the important stakeholders in a healthcare delivery system? This Journal has no entries.

1 http version 11 defines the persistent connection as the

1. HTTP version 1.1 defines the persistent connection as the default connection. Using RFC 2616, find out how a client or server can change this default situation\ to nonpersistent. 2. In SMTP, a sender sends unformatted ...

Read the summary of business rules published by the guide

Read the summary of business rules published by the GUIDE Business Rules Project (1997) and the article by Gottesdiener (1997). Search the Web for additional information on business rules. Then write a three-page executi ...

1 what is a hybrid firewall2 list the five generations of

1. What is a hybrid firewall? 2. List the five generations of firewall technology. Which generations are still in common use? 3. How does a commercial-grade firewall appliance differ from a commercial-grade firewall syst ...

Develop a flash share movieoverviewyour final project in

Develop a Flash share movie OVERVIEW Your final project in this class is required to be more extensive than the weekly lab projects. Your project should demonstrate a significant application of technical elements and als ...

Tchnical paper object-oriented programming oop

Technical Paper: Object-oriented Programming (OOP) / Event-Driven Programming (EDP) versus Procedural Programming (PP) Use the Internet or Strayer databases to research the advantages, features, and common examples of OO ...

Assignment ms project familiarizationprior to completing

Assignment: MS Project Familiarization Prior to completing the assignment, be sure to review the selected MS Project tutorial videos located in Week 2 of the Blackboard online course. Write a two to three page paper in w ...

Given an example of broadcast usage in the network and data

Given an example of broadcast usage in the network and data link layers. For each case, (1) name the protocol that utilizing the broadcast, (2) the reason why the broadcast rather that unicast is used, and (3) how the fa ...

1 when the ivc for the ah protocol is computed why are

1. When the IVC for the AH protocol is computed, why are mutable fields set to 0 rather than omitted? 2. Section 11.4.4 discusses the use of SSL to provide confidentiality, authentication, and integrity security services ...

For hash functions it is crucial to have a sufficiently

For hash functions it is crucial to have a sufficiently large number of output bits, with, e.g., 160 bits, in order to thwart attacks based on the birthday paradox. Why are much shorter output lengths of, e.g., 80 bits, ...

  • 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

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

Describe what you learned about the impact of economic

Describe what you learned about the impact of economic, social, and demographic trends affecting the US labor environmen