Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
77 views5 pages

CS1601 Important Model III

Uploaded by

jayasurya.lj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views5 pages

CS1601 Important Model III

Uploaded by

jayasurya.lj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

Part A Unit I Question

1 Write the purpose of symbol table


2 Difference Between Assembler, Compiler and Interpreter
3 What is Front-end and Back-end of the compiler?
4 Illustrate diagrammatically how a language is processed.
5 State the two main parts of compilation and its function.
6 Describe the possible error recovery actions in lexical analyser.
7 Mention the issues in a lexical analyzer.
8 Define Tokens, Patterns and Lexemes
9 Draw a transition diagram to represent relational operators.
10 Why is compiler optimization essential?
Part B
1 Describe the various phases of a compiler and tract it with the program segment
(position=initial + rate * 60)
2 Construct the NFA from the (a/b)*a(a/b) using Thompson’s construction algorithm.
3 Prove that the following two regular expressions are equivalent by showing that the
minimum state DFA‟s are same.
(i)(a/b)* (ii)(a*/b*)
4 Explain the following
(i) Recognition of tokens
(ii) Specification of tokens
5 Write the subset construction algorithm. Using the above algorithm, convert the
regular expression (a|b)*abb to DFA.
6 (i)Explain language processing system with neat diagram. (5)
(ii)Explain the need for grouping of phases.(3)
(iii)Explain various errors encountered in different phases of compiler.(5)
7 (i)Analyze the role of lexical analyser with suitable examples. (7)
(ii)Draw and explain the transition diagram that recognizes the lexemes matching the
token relop (relational operator) (6)
8 Write LEX specifications and necessary C code that reads English words from a text
file and response every occurrence of the sub string ‘abc’ with ‘ABC’. The program
should also compute number of characters, words and lines read. It should not
consider and count any lines(s) that begin with a symbol ‘#’.
Part A UNIT II
1 Define a Context Free Grammar.
2 Eliminate Left Recursion for the grammar. EE+T/T, TT*F/F,F(E)/id.
3 What is meant by Left Factoring?
4 Write the algorithm for the construction of a predictive parsing table?
5 What is Bottom up parsing and shift reduce parsing?
6 Summarize the merits and demerits of LALR parser.
7 Mention the purpose of YACC.
8 State the various error recovery strategies used in a parser to correct the errors.
9 How will you change the given grammar to an augmented grammar?
10 Write the algorithm for FIRST and FOLLOW?
Part B
1 (i) Prove the grammar is ambiguous. E→E+E | E*E | (E) | id (4)
(ii) Specify the demerits of ambiguous grammar. (3)
(iii) What are the rules to convert an unambiguous grammar from ambiguous
grammar . Write necessary steps for the above ambiguous grammar. (3)
(iv) Using unambiguous grammar, write Leftmost derivation, draw parse tree for
the string id*id*id+id*id. (3)
2 Consider the following grammar and construct SLR parser.
E → E + T/T, T → T * F|F, F → (E) |id.
3 Check whether the following grammar is a LL(1) grammar
S iEtS | iEtSeS | a
Eb
Also define the FIRST and FOLLOW procedures.
4 Construct predictive parsing table and parse the string NOT(true OR false)
bexpr→bexpr OR bterm | bterm
bterm→bterm AND bfactor | bfactor
bfactor→NOT bfactor | (bexpr) | true | false
5 (i) Construct stack implementation of shift reduce parsing for the grammar
E-> E+E
E -> E*E
E -> (E)
E -> id and the input string id1+id2*id3.
(ii) Explain LL(1) grammar for the sentence S ->iEts | iEtSes | a E->b
6 Parse the string (a,a) using SLR parsing table.
S→ (L) | a
L→L , S | S
7 (i) Find the language from (3)
S → 0S1 | 0A1 A→1A0 | 10
(ii) Define Parse tree , Regular Expression , Left most derivation , Right most
derivation, and write example for each. (3)
(iii) Write algorithm to convert NFA from Regular expression. (4)
iv) Find the language from (3)
S→0S1 | 0A | 0 |1B | 1
A→0A | 0
B→1B|1
8 Write in detail about
(i)Recursive descent parsing with algorithm.(6)
(ii)Top down parsing with algorithm.(7)
Part A UNIT III
1 Define syntax directed definition.
2 What are the functions of construction of syntax tree for expression? Explain.
3 What is L-attributed definition?
4 What are static and dynamic errors?
5 Write Static vs. Dynamic Type Checking.
6 What are Inherited and Synthesized attributes?
7 Construct the DAG and identify the value numbers for the sub expressions of the
following expressions, assuming + associates from the left.
(i) a*b + (a*b)
(ii) a*b*a*b
8 What are the advantages of SDT?
9 What the advantages of compile time checking?
A 10 What are the advantages of the dynamic checking?
Part B …………
1 Give a Syntax directed Definitions to differentiate expressions formed by applying
the arithmetic operators + and * to the variable X and constants ; expression :
X*(3*X+X*X)
2 Write Syntax Directed Definition and evaluate 9*3+2 with parser stack using LR
parsing method.
3 Describe in detail about types and declaration with suitable examples.
4 (i)Construct a syntax directed definition for constructing a syntax tree for
assignment statements (8)
S  id: = E
E E1+E2
E E1*E2
E- E1
E( E1)
E id
(ii) Discuss specification of a simple type checker. (5)
5 (i) Given the Syntax-Directed Definition below construct the annotated parse tree for
the input expression: “int a, b, c”. (6)
D→TL L.inh = T.type
T → int T.type = integer
T → float T.type = float
L → L1, id L1.inh = L.inhaddType(id.entry,L.inh)
L → id addType(id.entry,L.inh)
(ii) Given the Syntax-Directed Definition below with the synthesized attribute val,
draw the annotated parse tree for the expression (3+4) * (5+6). (7)
L→E L.val = E.val
E→T E.val = T.val
E → E1 + T E.val = E1.val + T.val
T→F T.val = F.val
T → T1 * F T.val = T1.val * F.val
F→(E) F.val = E.val
F → digit F.val = digit.lexval
6 Construct parse tree, syntax tree and annotated parse tree for the input string is
5*6+7.
7 Explain type checking and type conversion. Explain with an example of converting
the operands the same type.
8 Describe how SDD can be evaluated at the nodes of a parse tree using dependency
graphs.
Part A UNIT 4
1 Define activation trees.
2 What is the use of run time storage?
3 State the tasks of a code generator.
4 List the fields in activation record.
5 Name different storage allocation strategies used in run-time environment.
6 Construct a decorated parse tree according to the syntax directed definition, for the
following input statement ( 4+7.5*3)/2.
7 How do you identify predictive parser and non-recursive predictive parser.
8 Write the grammar for flow control statement while=do.
9 Define address descriptor.
10 Differentiate between static and dynamic storage allocation.
Part B
1 Explain the organization of runtime storage in detail.
2 Explain about various ways to pass a parameters in a function with example.
3 Illustrate the algorithm that generates code for a single basic block with three address
instructions.
4 Explain the issues in the design of a code generator in detail.
5 Explain in detail about Access to Nonlocal Data on the Stack.
6 Describe about the content of activation record.
7 Explain the memory management, using the heap.
8 Explain about stack in storage allocation strategies.
Part A UNIT 5
1 Define optimizing compilers.
2 Mention some of the major optimization techniques.
3 What are the step takes place in peephole optimization?
4 What do you mean by induction variable elimination?
5 List the function –preserving transformation.
6 What is meant by loop optimization?
7 How would you represent the dummy blocks with no statements indicated in global
data flow analysis?
8 Define Target machine.
9 What is a basic block? Give an example?
10 How liveness variable calculated.
Part B
1 Explain the principle sources of optimization in detail.
2 (i)Explain optimization of basic blocks.(6) (ii)Explain redundant common
subexpression elimination.(7)
3 Generate DAG representation of the following code and list out the applications of
DAG representation
i=1
while (i<=10) do
sum+=a[i]
4 What are the optimization technique applied on procedure calls? Explain with
example.
5 Discuss about the following:
i) Copy Propagation
ii) Dead-code Elimination
iii) Code motion.
6 Explain in detail about peephole optimization.
7 Write about data flow analysis of structural programs.
8 Optimize the following code using various optimization techniques:
i=1,s=0;
for(i=1;i<=3;i++)
for(j=1;j<=3;j++) c[i][j]=c[i][j]+a[i][j]+b[i][j];
Part C
1 Consider the Context-Free Grammar(CFG) depicted below where “begin”,”end”and
“x” are all terminal symbols of the grammar and stat is considered the starting
2symbol for this grammar. Productions are numbered in parenthesis and you can
abbreviate “begin” to “b” and “end” to “e” respectively. StatBlock
Blockbegin Block end
BlockBody
Bodyx
(i) Compute the set of LR(1) items for this grammar and draw the
corresponding DFA. Do not forget to augment the grammar with the
initial production SStart$ as the production(0).(7)
(ii) Construct the corresponding LR parsing table.(8)
2 Write the algorithm for construction of LALR parsing table for a given grammar.
Using the algorithm for construction of LALR parsing table construct the LALR
parsing table for the following grammar.
S’  S
S  aAd | bBd | aBe | bAe
Ac
Bc
3 Write and explain the algorithm for construction of basic blocks. (7)
Construct the DAG for the following basic block. (8)
x = a[i]
a[j] =y
z=a[i]

You might also like