Recent questions tagged parsing

1 vote
1
Find First and Follow of the given grammar $S \rightarrow aSa | bSb|A$ $A \rightarrow aBb$ $B \rightarrow aB|bB|\epsilon$
2
Consider the grammar given $S\rightarrow AA$ $A\rightarrow aA / b$ How many entries will be blank in the GOTO table for SR(0) items?
3
Given answer is (D), how?
1 vote
4
The power of parsers is as follows: CLR(1) > LALR(1) > SLR(1) > LR(0) > LL(1) Can we say that if a language is not parsed by powerful parser then less powerful parsers can't parse that language? Likewise, if a language can be parsed by less powerful ... it be parsed by all powerful parsers than that? Is there a formal proof for the above two questions? How to compare SLR and LALR parser formally?
1 vote
5
Consider the grammar given S->AA A->aA / b How many entries will be blank in the GOTO table for SR(0) items? What is the meaning of SR(0) items?
1 vote
6
Consider the following grammar G: The grammar G is A. LL (1) grammar and not LR (0) B. LL (1) and LR (0) C. Not LL (1) but LR (0) D. Neither LL (1) nor LR (0) Here B should be correct option?
1 vote
7
Since it is a Bottom Up Parser do we need to evaluate expressions following Right Hand Derivations or Left Hand Derivations,i.e. should we evaluate D -> d first or B -> B first?
1 vote
8
Options given A. LL (1) grammar and not LR (0) B. LL (1) and LR (0) C. Not LL (1) but LR (0) D. Neither LL (1) nor LR (0) Answer given is option D. I believe answer should be option (B). Please help.
9
Consider the grammar : $S\rightarrow SS+ | SS* | a$ Which of the following is true: A) SLR(1) but not LL(1) B) LALR(1) but not SLR(1) C) LR(1) but not LALR(1) D) Neither LL(1) nor LR(1) I feel the grammar is unambiguous as I couldn't get more ... any inputs I tried. (Their key is suggesting the answer D saying it's ambiguous) Shouldn't A be the answer? Please guide me and correct me if I'm wrong
10
Which of the following statements is correct? (A) For any context free grammar there is a parser that takes at most O(n2) to parse a string for n terminals. (B) Recursive descent method can't be used to both parse and implement syntax-directed translation. (C) Software tools for generating parsers directly from grammars often use top-down methods. (D) None of the above.
11
S $\rightarrow A$ A $\rightarrow AB/$\epsilon$B$\rightarrow aB/b$is this grammar LALR(1) ? 2 votes 2 answers 12 3 votes 1 answer 13 If a grammar is LL(1) then it would be definitely CLR(1) i.e. LR(1) or LALR(1) 1 vote 0 answers 14 2 votes 1 answer 15 What is Abstract Syntax Tree(AST)? Difference between AST and parse tree?At which phase of compiler such trees are created? Who is the condensed form of whom? 1 vote 1 answer 16 According to my understanding, we LALR is constructed by reducing LR(1) automaton states. So I think it should be LR(1) However, we construct SLR(1) items from the LR(0) automaton, and we say with surety that number of states in SLR(...) is equal to number of states in LALR(...), how can this be? 2 votes 1 answer 17 Code optimization is in syllabus or not . like dead code elimination ..... loop inveriant 1 vote 1 answer 18 Consider the below given grammar: A→AA+ A→a Consider the below given statements: S1: The grammar is not LL(1). S2: The grammar is CLR(1) but not LALR(1). S3: The grammar is ambiguous. S4: The grammar is LALR(1) as well as CLR(1). Choose the correct option:( Marks: ... mber of states in LALR(1) is 5. Only S1 and S2 are correct. Answer given is option (3). But I cant understand why S3 is incorrect. 1 vote 0 answers 19 Consider the following grammar:$S \rightarrow AS \rightarrow xbA \rightarrow aAbA \rightarrow BB \rightarrow x$The average length of the stack used while parsing the string "axb$" using LR(1) parser is _________. I am getting 5, but answer is 2.5.
20
If operator precedence parser can parse ambiguous grammar so why don't we use this parser all the time, Why should we care about all the parsers just use this.
21
Check whether this grammar is LL(1) or not?
1 vote
22
I just want to confirm here that do we count state I1 in reduced state count or not?
23
Consider the grammar with the following productions. S→aaB/aaC B→b C→c Which of the following option is true ? (A) The grammar is LL(3) (B) The grammar is LL(1) (C) The grammar is LL(2) (D) It can’t be LL(k) grammar for any k, as it contains left factoring.
1 vote
$S \rightarrow aBA$ $A \rightarrow \epsilon$ $B \rightarrow a$ Here in the given grammar, what will be the look ahead of B's production:- $S \rightarrow a.BA , \$ B \rightarrow .a \text{ , X}$What will come at the place of X, I think it should be "\$", As $A \rightarrow \epsilon$, So, B's lookahead should be \$. right? 0 votes 0 answers 27 A)LL(k) grammar has one to one correspondence to DCFL B)LR(k) grammar has one to one correspondence to CFL Which one is true? 0 votes 1 answer 28 The grammar$A\rightarrow AA|\left ( A \right )|\epsilon$is not suitable for predictive parsing because the grammar is (A) Ambiguous (B) Left Recursive (C) Right Recursive (D) an operator grammar 0 votes 1 answer 29 S-> Aa A-> Ab A-> c Which of the following item is present in LR(1) item with S'->. S,$ a) A->. Ab,\$ b) A->. Ab,a c) A->. Ab,a/b d) None