# Recent questions tagged compiler-design

0 answers 9 views
Is following grammar has language which is inherently ambiguous? $S \rightarrow aaAb | aab | A$ $A \rightarrow aaAb | aAb | \epsilon$ I think that this grammar has unambiguous grammar as follow. Let's first rewrite the grammar as below such that this grammar has same ... have to perform $S \rightarrow A$. Please help me with this. I want to know whether this language is inherenly ambigous or not?
0 answers 9 views
How to solve this?
This is what I got: First(S)={b} First(A)={b} First(B)={b,e} First(C)={b,e,epsilon} Follow(S)={$,d} Follow(A)={a,b,e} Follow(B)={a,b,d,e,$} Follow(C)={a,b,e,$} 0 votes 1 answer 17 views Hello all, I have been trying to understand how to add look aheads in cannonical collection of LR(1) items: This is my approach: It asked for the items in closure of S'→.S, ...$ I am unable to figure out how to get a, b in lookaheads, I am only getting $. Any help is appreciated. Thank you 0 votes 0 answers 14 views Is there any lexical error in this program? According to me there is NONE, but according to MADE EASY there is a lexical error and the reason they provided is→ Shouldn’t it should be a semantic error ? 0 votes 1 answer 13 views A grammar that has not any epsilon productions and also free from unit productions. The maximum number of reduce moves that can be taken during bottom up evaluation of 25 token string by bottom up parsers is ________. My ans is 24, but they have given ans as 49..which is right? 0 votes 1 answer 20 views My ans is 30, but they have given ans as 29...which is correct? 0 votes 0 answers 10 views 0 votes 0 answers 5 views Consider the following 'C' code main() { int i = 0 , n = 10; int a[n]; while (i < = (n - 1)) { a [i] = i * i ; i = i + 1 ; } return ; } The number of leaded statements in the above ' C ' code are _________ 0 votes 0 answers 17 views Ans given is D, but according to me it should be A.. Which is correct? 0 votes 0 answers 6 views Consider the grammar shown below S → aBCd|dCBe B → bB|ϵ C → Ca|ac|ϵ In the predictive parsing table M of this grammar ,the entries M[B,c] and m[C,d] respectively 0 votes 0 answers 3 views S→ pSqS / qSpS / ε Is the given grammar ambiguous? If so draw the 2 distinct parse tree. 0 votes 0 answers 9 views Sometimes I want to ask questions which have diagramatic representation. I don’t like psoting pics as I don’t receive answers on them. Do anyone know some online resources where I can do the tasks such as drawing DAGs, Syntax Tree, parse tree and state diagrams quickly without wasting much of time. 0 votes 1 answer 6 views Consider the following block of three address statements a = c + d e = a + d d = c + d Then the number o nodes in the DAG constructed for the above block of statement is ______________. 0 votes 0 answers 2 views I know the option is (b). I wanted to see the full triple table. Can someone please help in drawing that. 0 votes 0 answers 3 views I know the option is (b). I wanted to see the full triple table. Can someone please help in drawing that. 0 votes 0 answers 4 views Page no. 363 2nd edition Ulman In three-address code, there is at most one operator on the irght side ofan instruction; that is, no built-up arithmetic expressions are permitted. Can someone please explain the meaning of the highlighted line? 0 votes 0 answers 4 views I read the following statements→ LR(1) parsers efficiently handles DCFL in guaranteed linear time. So every regular grammar is LR(1) grammar. Is this statement true? 1 vote 0 answers 19 views 0 votes 1 answer 17 views I know the answer is D. Looking for some more clarification. My explanation is that “1y” won’t have any pattern matching by the lexical analyser. So, it will throw an error? Is this reasoning and logic correct??? 0 votes 2 answers 15 views Consider the following statements. S1: If G is a LL(k) grammar then G may or maynot be LL(k + 1) grammar (for k>=1) . S2: If G is a LL(1) grammar then G cannot be parse by LR(0)parser. Select the correct option. 1. Both S1 and S2 are true. 2. Both S1 and S2 are false. 3. S1 is true and S2 is false. 4. S1 is false and S2 is true. 0 votes 1 answer 7 views Consider the following grammar. S-> SaSaS | ϵ For string “aaaaaa” , total number of possible parse tree are_____ 0 votes 0 answers 6 views Which of the following intermediate code helps in generating the efficient target code Three address code DAG Postfix Quadruples 0 votes 0 answers 10 views 0 votes 4 answers 7 views Please clarify this doubt: suppose we have an SDT. In the syntax analysis phase the top-down parser generates the annotated parse tree. for the grammar. and in the semantic analysis phase this tree is parsed and the corresponding actions are performed. In ... phase and then in the semantic analysis phase we perform the actions corresponding to the reductions. Is this the way things are performed 0 votes 0 answers 11 views I want to know if there is some method for calculating first and follow directly for a left recursive grammar. I know how to remove left recursion and then calculate the first and follow but I want to know if there is some quick trick from speed point of view. 0 votes 1 answer 24 views In the grammar S$\rightarrow$TA A$\rightarrow$+TA/$\epsilon$T$\rightarrow$a/$epsilon$Follow(T)$\cap$First(S) is Answer given is +. Please help me understand the steps. Getting answer is not the only objective. 1 vote 1 answer 9 views S$ \rightarrow $[SX] | a X$ \rightarrow \epsilon$| + SY | Y b Y$ \rightarrow \epsilon$| -SXc Then FOLLOW (S) is PS: The answr is {dollar, +, -, ], c, b} I just want to clarify each step. Getting just answre is not the objective. Please do mention the every step. 0 votes 0 answers 5 views Que 1) When follow will not have dollar? Que 2) Why follow has to have dollar? 0 votes 1 answer 8 views Find FOLLOW(B) In the following grammar A -> BCD B -> w | Bx C -> yCz | m D -> DB | a 0 votes 1 answer 31 views The least number of total variables needed to create a three address code in static single assignment form for the following code segment is: q=3 r=10 s=q+r t=2*r+s t=q u=q+r v=q+t t=3+x 0 votes 1 answer 19 views Consider the following grammar, where S and T are non-terminals and +, * and a are terminals. S→S∗S|S+S|T|a T→a The total number of possible parse trees for the string a∗a+a is? 0 votes 1 answer 18 views “Any DCFL has an equivalent grammar that can be parsed by a SLR(1) parser with end string delimiter” True or False? What about LR(0) for the same? 0 votes 0 answers 6 views For which of the following languages a LL(1) grammar does not exist? {$a^{n}ob^{n}$∣n≥1}∪{$a^{n}b^{n}$∣n≥1} {$a^{n}b^{m}$∣m,n≥0} {$a^{i}b^{j}$∣i≥j} {$a^{i}b^{j}$∣i=j} Why C is the answer here? Can anyone explain? 0 votes 1 answer 26 views Consider the following two grammars G1: A → A1 | 0A1 | 01 G2: A → 0A | 1 Which of the following is True regarding above grammars? (a) L1 is LR(k) (b) L2 is LR(k) (c) Both L1 and L2 is LR(k) (d) None is LR(k) 0 votes 0 answers 8 views a ( ) ,$ a > > > ( < < = < ) > > > , < < > > \$ < < How to construct the operator function graph for this operation relation table? I know the general procedure but here the “=” is causing troubles.