Ask Question, Ask an Expert

+61-413 786 465

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

Question write 1 page that respond to the following

Question: Write 1 Page that respond to the following questions with your thoughts, ideas, and comments. This will be the foundation for future discussions by your classmates. Be substantive and clear, and use examples to ...

Use the management studio to create a new database called

Use the Management Studio to create a new database called the default settings(If the database already exists, use the Management Studio to delete it and than create it.

In a software design meeting in your company your manager

In a software design meeting in your company, your manager says that one of the most important engines of the Record Keeping System you are developing is the Index Sorting Engine. Your coworker quickly jumps in and says ...

Koh aq cuno32 aq precipitatekbr aq srno32 aq no

KOH (aq)+ Cu(NO3)2 (aq) = precipitate KBr (aq) + Sr(NO3)2 (aq) = no precipitate a) What are the possible products when solutions of KOH and Cu(NO3)2 are mixed? b) What are the possible products when solutions of KBr and ...

An exam has 5 multiple choice questions with 2 possible

An exam has 5 multiple choice questions with 2 possible answers each, and 5 true and false questions. Assume each question on the test counts 10 points, and that each question has a unique answer. If a student guesses ea ...

What is the various security architectures which provides

What is the various security architectures. Which provides the best balance between simplicity and security? Justify your answer.

Explain the differences between working in the web based

Explain the differences between working in the web based version of Outlook in Office 365 to the desktop application version of Outlook.

In 2005 team dad used a toyota truck with a system of

In 2005, Team DAD used a Toyota truck with a system of spinning lasers as its "visual" system. What advantages and or disadvantage does such a system have compared to camera-based systems?

What is the lithium by mass in a sample of pure lithium

What is the % lithium by mass in a sample of pure lithium carbonate that has a sample size of 10.0g?

Semantic html5an ongoing belief in the web design industry

Semantic HTML5: An ongoing belief in the Web design industry is that HTML5 is critical to Web design for four reasons: Accessibility. Search engine optimization. Faster download speeds. More efficient styling and coding. ...

  • 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

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As