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

What are the phases in the software development life cycle

What are the phases in the software development life cycle? What statistical process control method scan be employed on software development projects? What is concurrent engineering? How can concurrent engineering be use ...

Inez reports that an extra banana would increase her

Inez reports that an extra banana would increase her utility by two units and an extra pear would increase her utility by six units. What is her MRS of bananas for pears-that is, how many bananas would she voluntarily gi ...

Write a program will simulate and display the process of

Write a program will simulate and display the process of looping. The program will accept input for name of a variable; initialize value, conditional operator, conditional value, alternating value such as increment (++) ...

In 300 to 500 words answer these questionsno plagiarismin

In 300 to 500 words. Answer these questions. No Plagiarism In Clear English Cash Flow and Taxes 1. How does net cash flow differ from net income and why is that difference relevant to financial decision making? 2. With r ...

Sketch out a class diagram uml for the candidate classes

Sketch out a class diagram (UML) for the candidate classes you list from the description provided. You should have AT LEAST ONE generalization relationship and AT LEAST ONE composition relationship: The library system ne ...

Assignment applications of graph theoryin 1736 a famous

Assignment: Applications of Graph Theory In 1736, a famous Swiss mathematician Leonhard Euler (1707 - 1783) started the work in the area of Graph Theory through his successful attempt in solving the problem of "Seven Bri ...

A fenced enclosure consists of a rectangle of length l and

A fenced enclosure consists of a rectangle of length L and width 2R, and a semicircle of radius R, as shown in Figure P20. The enclosure is to be built to have an area A of 1600 ft2. The cost of the fence is $40/ft for t ...

Health insurance portability and accountability actthe case

Health Insurance Portability and Accountability Act The case described in the Introduction is not atypical, even with as much emphasis as there is on information security; it is a good example of where an organization ha ...

Next generation software for a word-processing system is to

Next generation software for a word-processing system is to be developed. Do a few hours of research on the application area and conduct a FAST meeting (Chapter 11) with your fellow students to develop requirements (your ...

Createnbspan 8- to 10-slide presentation that should be 5

Create  an 8- to 10-slide presentation that should be 5 to 10 minutes in length.  Please include detailed speaker notes , based on the Week 4 Persuasive Messages Part I & Part II assignment.   Apply  the four aspects of ...

  • 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

A cola-dispensing machine is set to dispense 9 ounces of

A cola-dispensing machine is set to dispense 9 ounces of cola per cup, with a standard deviation of 1.0 ounce. The manuf

What is marketingbullwhat is marketing think back to your

What is Marketing? • "What is marketing"? Think back to your impressions before you started this class versus how you

Question -your client david smith runs a small it

QUESTION - Your client, David Smith runs a small IT consulting business specialising in computer software and techno

Inspection of a random sample of 22 aircraft showed that 15

Inspection of a random sample of 22 aircraft showed that 15 needed repairs to fix a wiring problem that might compromise

Effective hrmquestionhow can an effective hrm system help

Effective HRM Question How can an effective HRM system help facilitate the achievement of an organization's strate