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

Still using the graph from exercise 1 write a windows

Still using the graph from Exercise 1, write a Windows application that allows the user to search for a vertex in the graph using either a depth-first search or a breadth-first search. Exercise 1 Build a weighted graph t ...

In el farol extension 1 we modify the color based on reward

In El Farol Extension 1, we modify the color based on reward with the agents starting as white and becoming darker as they accumulate rewards. Can you modify this code to use a different color? Or can you modify it so th ...

Modify exercise 1 so that the class can keep track of

Modify Exercise 1 so that the class can keep track of multiple courses. Write a program to test your implementation. Exercise 1 Design and implement a class that allows a teacher to track the grades in a single course. I ...

1 explain the advantages of ipv6 when compared to ipv42

1. Explain the advantages of IPv6 when compared to IPv4. 2. Explain the use of the flow field in IPv6. What is the potential application of this field? 3. Distinguish between compatible and mapped addresses and explain t ...

1 you want to write a program in which you need to refer to

1. You want to write a program in which you need to refer to the InetAddress of the computer you are working with. Write a statement in Java to create the corresponding object. 2. You want to create all InetAddress objec ...

1 why are vulnerabilities difficult to predict2 discuss the

1. Why are vulnerabilities difficult to predict? 2. Discuss the sources of system vulnerabilities. 3. Is it possible to locate all vulnerabilities in a network? In other words, can one make an authoritative list of those ...

1 assume a 64 kib direct-mapped cache with a 32-byte block

1. Assume a 64 KiB direct-mapped cache with a 32-byte block. What is the miss rate for the address stream above? How is this miss rate sensitive to the size of the cache or the working set? How would you categorize the m ...

This exercise asks you to consider sources of errors in

This exercise asks you to consider sources of errors in thumbprints (see Section 25.6.2.3). Recall that a thumbprint is computed from the contents of a connection over some interval of time. Consider clocks on two differ ...

Write an apa formatted paper to address the assignment

Write an APA formatted paper to address the assignment below. This paper should be approximately 4-5 pages long, not including cover, abstract, references, etc. Be sure the paper thoroughly answers the topics to be addre ...

Why do you suppose so much planning needs to occur before

Why do you suppose so much planning needs to occur before installation of the Linux OS?

  • 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