What is a compiler

Assignment Help Theory of Computation
Reference no: EM132313953

Assignment -

1. What is a compiler?

2. Why we need study compiler design?

3. List steps or phases of compiler and identify which type of errors identified by each phase.

4. What are the differences between Analysis (front end) and Synthesis (back end)?

5. What are the differences between top down and bottom up parser (explain your answer by using appropriate example)?

6. Clearly define Token, pattern, lexeme and give examples for each term.

7. Convert the following NFA of identifier into the corresponding DFA. letter(letter|digit)*

89_figure.png

8. Draw DFAs for the string matched by the following definition:

digit =[0-9]

nat=digit+

signednat=(+|-)?nat

number=signednat("."nat)?(E signedNat)?

9. Construct NFA for the following regular repression and convert it to DFA: (a|b|c)*abc

10. Using the grammar below, draw a parse tree for the following string:

"( ( id . id ) id ( id ) ( ( ) ) )"

S → E

E → id

|( E . E )

|( L )

|( )

L → L E

|E

11. Give a rightmost derivation for the string given in (10).

12. Give a leftmost derivation for the string given in (10).

13. Consider the following grammar and Draw the parse tree for the input "y+++y++" using RDP (show all necessary stapes)

S → A

A→ A + A |B++

B → y

14. Using the grammar below, draw a parse tree for the following string using RDP algorithm: ( ( id . id ) id ( id ) ( ( ) ) )

S → E

E → id

| ( E . E )

|( L )

|( )

L → L E

|E

15. Consider the following grammar over the alphabet {g,h,i,b}

A→ BCD

B → bB|ε

C→Cg |g |Ch |i

D→ AB |ε

Fill in the table below with the FIRST and FOLLOW sets for the terminals and non-terminals in this grammar:

 

FIRST

FOLLOW

A

 

 

B

 

 

C

 

 

D

 

 

BCD

 

 

bB

 

 

16. Let G be the following grammar:

S → [ SX ]|a

X→ε |+SY |Yb

Y→ε | -SXc

A. Find FIRST and FOLLOW sets for the non-terminals in this grammar.

B. Construct predictive parsing table for the grammar above.

C .Show a top down predictive parse of the string [a+a-ac]

17. Consider the following grammar G:

A'→ A

A→ xA|yA|y

a. Find FIRST and FOLLOW sets for G:

b. Construct the LL(1) parse table for this grammar.

c. Explain why this grammar is not LL(1).

d. Transform the grammar into a grammar that is LL(1).

e. Give the parse table for the grammar created in (d).

18. Given the following grammar:

S →WAB|ABCS

A→B|WB

B →ε|yB

C→z

W →x

a. Find FIRST and FOLLOW sets of the grammar.

b. Construct the LL(1) parse table.

c. Is the grammar LL(1)? Justify your answer.

19. Given the following grammar:

PROGRAM→ procedure STMT-LIST

STMT-LIST →STMT STMT-LIST | STMT

STMT →do VAR = CONST to CONST begin STMT-LIST end | ASSN-STMT

ASSN-STMT → VAR = CONST | VAR = VAR

CONST →0 | 1 | ...|100

VAR → i | j | x | y

a. Check whether the following fragment of code is correct or not.

b. Show the parse tree for the following code fragment:

procedure

do i=1 to 100 begin

x=10

y=x

end

x=2

20. Given the following grammar

E → TR

R→ +TR

R→ -TR

R→ε

T →0|1|...|9

a. Using panic mode error recovery how to the following inputs are accepted (show all necessary steps)

i. 0+1-2-+3

ii. +2-3+4

iii. 3+2+5-

iv. +2-44++6-7

21. Given the following Grammar:

S → A

S → B

A→ a A b

A→ 0

B → a B b b

B → 1

a. Construct the SLR parsing table.

b. Write the action of an LR parse for the following string "aa1bbbb"

22. Given the following Grammar:

S → S + A

S → A

A → A * B

A → B

B → ( S )

B → a

a. Construct the SLR parsing table.

b. Write the action of an LR parse for the following string

"a * a + a * ( a + a)"

23. Check the given grammar is SLR or not and justify your answer.

a. E→A

E→B

A→+B

A→id

R→A

b. E→DaDbDc

E→FcFbFa

D→ε

F→ε

Reference no: EM132313953

Questions Cloud

What is the heckscher-ohlin model : What is the Heckscher-Ohlin model and some of its applications and real life examples?
Transportation systems and critical infrastructure : Is it possible for the U.S. Government to employ dual-use, all-hazards systems to protect U.S. transportation systems and critical infrastructure?
What is motivation : What is motivation? Explain and what are the theories of motivation and how can those theories motivate people? Why explain
Calculate the effect size using eta squared : Provide an interpretation of the analysis to management and suggest a possible approach to improve satisfaction for the least satisfied group.
What is a compiler : What is a compiler? What are the differences between top down and bottom up parser (explain your answer by using appropriate example)
Contrast role of military in two latin american countries : Compare and contrast the role of the military in two Latin American countries. Include historical background and analysis of current roles.
Monopolistic competitive market structure : What is an example for monopolistic competitive market structure?
Largest social-networking website in the world : Facebook is by far the largest social-networking website in the world. Explain how network externalities help Facebook maintain its position as market leader.
The united states adopt the idea of federalism : How is federalism defined in the text and from which nation did the United States adopt the idea of federalism?

Reviews

Write a Review

Theory of Computation Questions & Answers

  Finite-state machine design

Create a finite-state machine design to turn your FPGA development board into a simple programmable music box.

  Redundant sequence identi cation

Redundant sequence identi cation

  Compute a shortest superstring

Dynamic programming algorithm to compute a shortest superstring.

  Propositional and predicate logic

Write down a structural induction principle for the PlayTree free type

  Design a syntactic analyzer

Design a syntactic analyzer for the language specified by the grammar

  Design unambiguous grammar to parse expressions

Write a program would read two numbers and then print all numbers between the first and the second, inclusive. Design unambiguous grammar to parse expressions

  Consider a logic function with three outputs

Consider a logic function with three outputs,  A ,  B , and  C , and three inputs,  D ,  E , and  F . The function is defined as follows:  A  is true if at least one input is true,  B  is true

  Considering a single programmed operating system

Considering a single programmed operating system, what is the minimal total time required to complete executions of the two processes? You should explain your answer with a diagram.

  How to construct an nfa

Give a construction that assumes you are given a DFA for L and show how to construct an NFA (with or without ε-moves) to recognize sort(L).

  Equivalence classes to construct minimal dfa for language

How many equivalence classes does this relation have and what are they? Use these equivalence classes to construct the minimal DFA for the language.

  Impact of moore-s law on data center costs

Discuss the impact of Moore's law on data center costs on such things as servers and communications equipment. List at least 3 steps or recommendations your data center can take to offset some or all of the effect of Moore's law.

  Problem encountered in statements in predicate logic

How the problem would be encountered in attempting to represent the following statements in Predicate logic. it should be possible to: John only likes to see French movies.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd