What is postfix SDT?
Official theoretical question paper for Compiler Design (PCC-CS501) conducted by Maulana Abul Kalam Azad University of Technology. All questions from Groups A, B, and C are reproduced below with marks weightings.
What is postfix SDT?
What is equivalence of type expression?
The actual parameters are not used by the calling procedure. (true/false)
'goto L' is an unconditional jump(to L) three address Instruction.(true/false)
A basic block is a sequence of consecutive statements with single entry/single exit. (true/false)
Flex is a lexical analyzer generator tool. (True/False)
Write the name of translator that translates assembly code to relocatable machine code.
12_Name is a lexeme of pattern identifier in C language. (True/false)
Write the rule for converting left recursive grammar to right recursive grammar.
What is Annotated -parse tree?
Reduce/Reduce conflict happens during bottom up parsing. (True/False)
How lexical analyzer recognize a token?
Write the difference between synthesized and inherited attributes with examples.
Describe the purpose of two pointers of Buffer Pairs in Lexical Analyzer.
Convert the DAG into Three address code.
Consider the postfix SDT: Here expr, expr1 both are same, and for differentiate between left expr and right expr, we use expr1 in right. expr → expr1 + term { print('+') } expr → expr1 - term { print('-') } expr → term term → 0 { print('0') } term → 1 { print('1') } ................. term → 9 { print('9') } Draw the parse tree with action embedded for the expression 9 + 4 - 3.
Convert the C code into three address Instruction. while( A[i] >= v ) { i = i + 1; } where array elements are integers of 4 bytes in sized.
Suppose ε-closure(q) is a set of states which are reachable from q with zero or more ε-moves, where q is a state in NFA. You are given a Regular Expression R = (b|a)*baa and the set of input symbols is {a,b}U{ε}. Convert this Regular Expression R to NFA N.
Convert this NFA N to DFA D using the definition of ε-closure(q).
Convert this DFA D to Minimal DFA.
Suppose you have given a grammar of certain kind of statements and first & follow sets: A→B A'; A'→+ B A' | ε; B→C B'; B'→* C B' | ε; C→(A) | id | Non-terminals | First sets | Follow sets | |---|---|---| | A | (, id | ), # | | A' | +, ε | +, ), # | | B | (, id | +, ), # | | B' | *, ε | +, *, ), # | | C | (, id | +, *, ), # | Where # is an end marker representing the end of input string. Build the predicting parsing table for the above grammar.
Consider a new set for error recovery of predicting parsing, called synchronizing set of non-terminal A, is a set where each symbol of synchronizing set of non-terminal A is taken from follow(A) set. i.e. synchronizing(C) = follow(C) = {+, *, #}. Instead of wrt 'error' in M[A, a] in parsing table, you use 'syn' in that cell if a belongs to follow(A). Example: If M[A, ] = 'error' in table M, then you use 'syn' in M[A, ] cell of M, since ')' belongs to follow(A). The solution of (b) can be obtained from the following rules given below: (i) If the parser looks up entry M[A, a] and finds that 'error', then the input symbol a is skipped. (ii) If the entry is 'sync', then it skip symbols from input until a terminal symbol is seen which belongs to first(A) to continue parsing, if A is the top of the STACK. (iii) If a token on top of the STACK does not match the input symbol, then you pop the token and resume parsing. Build an error correcting non-recursive version of predicting parsing table for the above grammar.
From the solution of (b), show the behavior of your parser on the following input: | Sl no | STACK | INPUT | Behavior/Action | |---|---|---|---| | 1. | #A | )id * + id# | ........... | | 2. | ####### | | ........... |
Consider the grammar with productions: S → A a | b A c | d c | b d a; A → d Prove that the above grammar is CLR(1) but not SLR(1) by building the parsing table.
Suppose you have been given the three address code of Quick Sort Algorithm | Three address code for Quick Sort | |---|---| | 1: t = m-1 | 11: t5 := a[t4] | 21: a[t10]:= x | | 2: i := n | 12: if t5 > v goto (9) | 22: goto (5) | | 3: i1 := 4*n | 13: if i >= v goto (23) | 23: t11 := 4* i | | 4: v := a[t1] | 14: t6 := 4*i | 24: x := a[t11] | | 5: i := i+1 | 15: x := a[t6] | 25: t12 := 4*i | | 6: i2 := 4*i | 16: t7 := 4*i | 26: t13 := 4*n | | 7: t3 := a[t2] | 17: t8 := 4*j | 27: t14 := a[t13] | | 8: if t3 < v goto (5) | 18: t9 := a[t8] | 28: a[t12] := t14 | | 9: j := j-1 | 19: a[t7] := t9 | 29: t15 := 4*n | | 10: i4 := 4*i | 20: t10 := 4*i | 30: a[t15]:= x | Find the leader codes and basic blocks including three address code of the above code.
Build the flow graph for above code.
Describe in brief about the cousin of Compiler.
Describe the operation of different phases of Compiler with suitable example.