Recent questions tagged compiler

1 1 vote
0 0 answers
162
162 views
We know that the class of languages of LR(0), SLR(1), LALR(1), CLR(1) is the class of DCFLs, with the only exception being that...An LR(0) language is a DCFL that has the...
0 0 votes
1 1 answer
144
144 views
A phase of a compiler which produce the symbol table isSyntax analysisSemantic analysisTarget code generationCode optimization
0 0 votes
1 1 answer
146
146 views
Arrange the following tasks of Lexical Analyzer in correct sequence:Token Generation.Removal of comments/White sphere.Buffering and reading source characters.Return token...
1 1 vote
1 1 answer
119
119 views
Match the LIST-I with LIST-IILIST-IInputLIST-IICompiler PhaseA.Syntax TreeI.Code GeneratorB.Character StreamII.Syntax AnalyzerC.Intermediate RepresentationIII.Semantic An...
0 0 votes
0 0 answers
165
165 views
Isnt this answer wrongI4 stateC - d., a | d there shouldnt be any $https://gateoverflow.in/?qa=blob&qa_blobid=5254677790122576834
2 2 votes
3 3 answers
559
559 views
A lexical analyzer is designed for a new language with the following rules for token generation:$\mathrm{KEYWORD1}: \verb|if|$ $\mathrm{KEYWORD2}: \verb|iff|$ $\mathrm{ID...
2 2 votes
5 5 answers
566
566 views
Consider the following arammar $G$ :$$\begin{aligned}& S \rightarrow(L) \mid a \\& L \rightarrow L, S \mid S\end{aligned}$$Which of the following statement(s) is/are TRUE...
5 5 votes
2 2 answers
306
306 views
Consider a Bottom-Up parser for a grammar $G$. During the parsing of an input string $w$, the parser reaches a configuration where the stack contains the prefix $\alpha$ ...
2 2 votes
2 2 answers
317
317 views
Which of the following statement(s) is/are TRUE regarding Lexical Analysis and Regular Expressions?The number of states in a minimal Deterministic Finite Automaton (DFA) ...
1 1 vote
2 2 answers
307
307 views
Consider the following Syntax Directed Translation (SDT) scheme where $S$ is the start symbol and $id.\mathrm{val}$ represents the numerical value of an identifier:$$\beg...
1 1 vote
2 2 answers
375
375 views
A lexical analyzer for a specific language identifies tokens using the following regular expressions:$$\begin{aligned}& L_1: a(a \mid b)^* \\& L_2: a b(a \mid b)^* \\& L_...
1 1 vote
1 1 answer
296
296 views
Consider the following basic block of intermediate code:1. a = 10 2. b = a + 5 3. c = b * 2 4. a = c - b 5. d = a + bAssuming that only the variable $\verb|d|$ is "live" ...
2 2 votes
2 2 answers
292
292 views
Consider the following L-attributed Syntax Directed Definition (SDD). $S$ is the start symbol, and S.val is a synthesized attribute. A.inh is an inherited attribute.$S \r...
1 1 vote
1 1 answer
272
272 views
In the context of Code Optimization, consider the following code segment inside a loop:for (i = 0; i < n; i++) { x = y + z; a[i] = 2 * i + x; }Moving the statemen...
2 2 votes
3 3 answers
345
345 views
Consider the following syntax-directed translation scheme (SDTS) where $S$ is the start symbol:$$\begin{aligned}& S \rightarrow E\{\text { print }(\text { E.val })\} \\& ...
2 2 votes
1 1 answer
301
301 views
Consider the following grammar $g$ :$$\begin{gathered}s \rightarrow l=r \mid r \\l \rightarrow * r \mid i d \\r \rightarrow l\end{gathered}$$Which of the following statem...
1 1 vote
1 1 answer
264
264 views
Consider the following basic block of three-address code:$\mathrm{t 1=a+b}$ $\mathrm{t 2=c* d}$ $\mathrm{t} 3=\mathrm{t} 1+\mathrm{t} 2$ $\mathrm{a=t 3}$ $\mathrm{t 4=c*d...
2 2 votes
1 1 answer
287
287 views
Consider the following regular expression over the alphabet $\{a, b\}$ used for a lexical analyzer token definition:$$R=(a+b)^*(a a+b b)(a+b)^*$$Which of the following de...
1 1 vote
2 2 answers
292
292 views
Consider the following SDT scheme used to evaluate an expression. The synthesized attribute $\mathrm{val}$ stores the numerical value.\[\begin{aligned}E &\rightarrow E_1 ...
2 2 votes
1 1 answer
276
276 views
Consider the following grammar $G$ with terminal set $\Sigma=\{a, b, c, d\}$ and non-terminal set $V=\{S, A, B\}$ :$$\begin{gathered}S \rightarrow a A b \mid b B a \\A \r...
0 0 votes
1 1 answer
335
335 views
Consider the following sequence of three-address code (TAC) instructions:1. i = 1 2. j = 1 3. t1 = 5 * i 4. t2 = t1 + j 5. a[t2] = 0 6. j = j + 1 7. if j <= 5 goto (3) 8....
2 2 votes
2 2 answers
332
332 views
Consider the following grammar $G$ with start symbol $S$ :$$\begin{aligned}& S \rightarrow L=R \\& S \rightarrow R \\& L \rightarrow * R \\& L \rightarrow i d . \\& R \ri...
0 0 votes
1 1 answer
302
302 views
Consider the following basic block of Three-Address Code:1. a = 1 2. b = a + 1 3. c = a + b 4. a = c + b 5. return aA variable is live at a point if its current value wil...
1 1 vote
2 2 answers
290
290 views
Consider the following Syntax-Directed Translation (SDT) scheme with the grammar rules and actions provided below:$$\begin{aligned}& S \rightarrow S_1 \# T\left\{S . \mat...
2 2 votes
3 3 answers
368
368 views
Consider the following lexical specification for a scanner:$\mathrm{KEYWORD\_IF: \verb|if|}$ $\mathrm{ID: [a-z][0-9]*}$ $\mathrm{NUM: [0-9]+}$ The scanner follows the Lon...
1 1 vote
1 1 answer
258
258 views
Consider the following three-address code sequence used for a loop:i = 0 L1: t1 = i * 4 t2 = base + t1 val = load t2 i = i + 1 if i < 100 goto L1Which optimization techni...
1 1 vote
1 1 answer
255
255 views
An $\mathrm{LR(1)}$ parser is being constructed for a grammar. If a particular state in the corresponding $\mathrm{LR}(1)$ canonical collection contains the item $[A \rig...
1 1 vote
2 2 answers
252
252 views
In a compiler's optimization phase, a Directed Acyclic Graph (DAG) is often used instead of a standard syntax tree to represent expressions. Consider the expression: $a=(...
0 0 votes
1 1 answer
279
279 views
Consider a syntax tree for the expression $a+b * c-d / e$. If the expression is evaluated using a post-order traversal of this tree, and the values at the leaves are $a=2...
1 1 vote
1 1 answer
235
235 views
Consider the expression tree shown below. Each leaf represents a numerical value, which can be chosen from the set $\{-1,1\}$. Over all possible choices of the values at ...