# Recent questions and answers in Compiler Design 1 vote
1
Synthesized attribute can easily be simulated by an LL grammar ambiguous grammar LR grammar none of the above
2
Bottom up parser uses right hand derivation or left hand derivation????
3
What is actual difference between in LALR(1) and CLR(1). please explain this by taking one example.
4
What is the best resources to study Handles in compiler Design ? I can not understand this.
5
what is the usage of symbol table in code optimization phase please explain???
6
Consider the following code fragment void foo(int x, int y) { x+=y; y+=x; } main() { int x=5.5; foo(x,x); } What is the final value of x in both call by value and call by reference, respectively? 5 and 16 5 and 12 5 and 20 12 and 20
7
Construct the DAG and identify the value numbers for the subexpressions of the following expressions, assuming $+$ associates from the left. $a+b+(a+b)$ $a+b+a+b$ $a+a+((a+a+a+(a+a+a+a))$
8
S -> S is a context free grammer or not?
9
The grammar $A \rightarrow AA \mid (A) \mid \epsilon$ is not suitable for predictive-parsing because the grammar is: ambiguous left-recursive right-recursive an operator-grammar
10
What is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon and unit production (i.e.,of type $A\to\epsilon$ and $A \to a)$ to parse a string with $n$ tokens? $n/2$ $n-1$ $2n-1$ $2^n$
11
i got 5 and 4 but given ans is 6 and 6. How??
12
13
Given the 3-address code for a basic block: The number of registers that are needed to allocate this basic block with no spills are ________.? My doubt here is : Is there any difference in question asking for minimum numbers of registers and minimum number ... If the question ask for minimum number of variables required in three address code, Only then should we optimize the code before counting?
14
A system program that combines the separately complied modules of a program into a form suitable for execution assembler linking loader cross compiler load and go
15
A symbol is a compile time data structure. In which of the following phase/s a symbol is modified ? Only semantic analysis None of these Only lexical analysis Lexical analysis and syntax analysis
16
The application of finite automata include:- a)Lexical Analyzer b)Text Editor c)Operating System d)All of the above
17
1 vote
18
What it the number of tokens in the following line? printf("%d numbers.", &x);
19
In the Lexical Analysis, regular expression can be used to model A) the structures of lexemes with fixed length identifier excluded B) the structure of tokens C) the structure of tokens but not lexemes D) the structure of lexemes with variable length identifier included
20
Consider the following statements related to compiler construction: Lexical Analysis is specified by context-free grammars and implemented by pushdown automata. Syntax Analysis is specified by regular expressions and implemented by finite-state machine. Which of the above statement(s) is/are correct? Only I Only II Both I and II Neither I nor II
21
In a compiler, keywords of a language are recognized during parsing of the program the code generation the lexical analysis of the program dataflow analysis
22
The output of lexical analyzer is: A set of regular expressions Strings of character Syntax tree Set of tokens
1 vote
23
$A→ b.a , \left \{ b \right \}$ $B→ b.,\left \{ a \right \}$ It is a SR conflict in LALR(1). Now how reduce state operated on $a$ for non terminal $B$(and not $b$) ?
24
Which of the following is the most general phase-structured grammar ? Regular Context-sensitive Context free Syntax tree
25
Consider an $\varepsilon$-tree CFG. If for every pair of productions $A\rightarrow u$ and $A\rightarrow v$ If $\text{FIRST(u)} \cap \text{FIRST(v)}$ is empty then the CFG has to be $LL(1).$ If the CFG is $LL(1)$ then $\text{FIRST(u)} \cap \text{FIRST(v)}$ has to be empty. Both $(A)$ and $(B)$ None of the above
26
Consider the following statements: S1 : Three-address code is a linearized representation of syntax tree. S2 : The syntax tree not depicts the natural hierarchical structure of source programm. Which of the following is true? plz explain s1 statement
27
Identify the total number of tokens in the given statement printf("A%B="&i); $7$ $8$ $9$ $13$
28
A shift reduce parser carries out the actions specified within braces immediately after reducing with the corresponding rule of grammar $S \rightarrow xxW \;\text{{print“1"}}$ $S \rightarrow y \;\text{{print“2"}}$ $W \rightarrow Sz\; \text{{print“3"}}$ What is the translation of $xxxxyzz$ using the syntax directed translation scheme described by the above rules? $23131$ $11233$ $11231$ $33211$
29
A lexical analyzer uses the following patterns to recognize three tokens $T_1$, $T_2$, and $T_3$ over the alphabet $\{a, b, c\}$. $T_1$: $a?(b \mid c)^*a$ $T_2$: $b?(a \mid c)^*b$ $T_3$: $c?(b \mid a)^*c$ Note that ... possible prefix. If the string bbaacabc is processes by the analyzer, which one of the following is the sequence of tokens it outputs? $T_1T_2T_3$ $T_1T_1T_3$ $T_2T_1T_3$ $T_3T_3$
30
Consider the following two sets of LR(1) items of an LR(1) grammar.$\begin{array}{l|l} X \rightarrow c.X, c/d &X → c.X, \$\\ X \rightarrow .cX, c/d& X → .cX, \$\\ X \rightarrow .d, c/d & X → .d, \$ ... . Cannot be merged since goto on c will lead to two different sets. $1$ only $2$ only $1$ and $4$ only $\text{1, 2, 3}$ and $4$
31
What is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon and unit-production (i.e., of type $A \rightarrow \epsilon$ and $A \rightarrow a$) to parse a string with $n$ tokens? $n/2$ $n-1$ $2n-1$ $2^{n}$
32
A canonical set of items is given below $S \to L .> R$ $Q \to R.$ On input symbol $<$ the set has a shift-reduce conflict and a reduce-reduce conflict. a shift-reduce conflict but not a reduce-reduce conflict. a reduce-reduce conflict but not a shift-reduce conflict. neither a shift-reduce nor a reduce-reduce conflict.
33
34
Consider the following grammar G $S \rightarrow F \mid H$ $F \rightarrow p \mid c$ $H \rightarrow d \mid c$ Where $S$, $F$, and $H$ are non-terminal symbols, $p, d$, and $c$ are terminal symbols. Which of the following statement(s) is/are correct? S1 ... are generated using grammar G S2: LR(1) can parse all strings that are generated using grammar G Only S1 Only S2 Both S1 and S2 Neither S1 and S2
The attribute of three arithmetic operators in some programming language are given below. $\begin{array}{|c|l|}\hline \textbf{OPERATOR} & \textbf{PRECEDENCE} & \textbf{ASSOCIATIVITY} & \textbf{ARITY} \\\hline \text{$ ... $2-5+1-7*3$ in this language is ________.
Consider the following grammar: $P\rightarrow xQRS$ $Q\rightarrow yz\mid z$ $R\rightarrow w\mid \varepsilon$ $S\rightarrow y$ What is FOLLOW($Q$)? $\left \{ R \right \}$ $\left \{ w \right \}$ $\left \{ w,y \right \}$ $\left \{ w,\$ \right \}$12 votes 3 answers 38 Merging states with a common core may produce __________ conflicts and does not produce ___________ conflicts in an LALR purser. 1 vote 3 answers 39 A grammar is defined as$A \rightarrow BCB \rightarrow x \mid BxC \rightarrow B \mid DD \rightarrow y \mid EyE \rightarrow z$The non terminal alphabet of the grammar is$\{A,B,C,D,E\}\{B,C,D,E\}\{A,B,C,D,E,x,y,z\}\{x,y,z\}$2 votes 3 answers 40 Given the grammar$s \rightarrow T ^{\ast} S\ \mid TT \rightarrow U+T\ \mid UU \rightarrow a \mid b$Which of the following statements is wrong? Grammar is not ambiguous Priority of$+$over$^{\ast}$is ensured Right to left evaluation of$^{\ast}$and$+\$ happens None of these