4)
Calculate Nullable, FIRST and FOLLOW for nonterminals A and B for the following grammar.
A → BAa
A → ε
B → bBc
B → AA
please help ASAP
Non-terminal N is nullable if N Æ+ ε • Example: S Æ AB$ A Æ a | ε B Æ b • When should you use the A Æ ε production? • One solution: – Ignore ε productions and compute FIRST – Table[A,a] = AÆa – all other entries for A: A Æ ε • This is bad practice – errors should be caught as soon as possible – what if next input token was $? • Solution: – if we use A Æ ε production to derive a legal string, next token in input must be b – if next token is b, use A Æ ε production; otherwise report error • How do we describe this formall
FOLLOW: Non-terminal Æ subset of terminals • b ε FOLLOW(A) if S Æ* …Ab… • To compute FOLLOW(A), we must look at RHS of productions that contain A • Example: S Æ AB$ A Æ a | ε B Æ b • FOLLOW(B) = {$} • FOLLOW(A) = FIRST(B) • But ε rules change FIRST computation as well! – FIRST(S) needs to take into account the fact that A is nullable • How do we get all this straight?
4) Calculate Nullable, FIRST and FOLLOW for nonterminals A and B for the following grammar. A...
Using the CYK algorithm, determine whether the word “abbaa” can be generated by the following grammar: S ⟶ XY X ⟶ SY Y ⟶ SS X ⟶ a | bb Y ⟶ aa What are all the producing nonterminals for the substring "bb"? What are all the producing nonterminals for the substring "baa"? What are all the producing nonterminals for the substring "abb"? What are all the producing nonterminals for the substring "bbaa"?
Given the following grammar: A -> A ; B A -> B B -> B , C B -> C C -> ( A ) C -> a rewrite the grammar to avoid left recursion For the rewritten grammar of question , Compute First, Follow, and nullable.
Given the following grammar, FIRST and FOLLOW sets and LL Parser table, trace the parse of the string “fd xcor + ycor rt ycor” and draw the parse tree. FIRST(S) = FIRST(B) = FIRST(D) = { fd, rt } FIRST(A) = { fd, rt, ε } FIRST(E) = { xcor, ycor } FIRST(F) = { +, -, ε } FOLLOW(S) = { $ } S --> BA FOLLOW(A) = { $ } A --> BA | ε FOLLOW(B) = {...
Calculate First set, Follow set and LL(1) parsing table. Then judge whether the syntax is or is not LL(1) grammar.Calculate First set, Follow set and LL(1) parsing table. Then judge whether the syntax is or is not LL(1) grammar. for the given grammar G[S] S→XY X→Ya|ε Y→Zb|Z Z→d|ε
(10] Eliminate left recursion from the grammar A Ba |Aa c B Bb | Ab 1 d A Ad IB A BA ASJAE Consider the following grammar G: S'S S (S)S|e fa) (10] Construct the collection of the sets of LR(0) items (b) [5] When constructing the action table of SLR parser of G what are the rules to determine the parsing actions? That is, what is the rule for a shift action at state /? What is the rule...
Consider the following LL(1) grammar with terminals (, ), +, id,
num, and starting symbol S.
Compute the first and follow set of all the nonterminals.
S → (ST) F→id
busi 101 2021 1 4. Consider the following grammar G: S' S SiEtS iEtSeS E b where S and E are nonterminals and i, t, e, a, and b are terminals (a) [5] Please identify the conflicts in the parsing table of G (b) [5] Build the parse tree of the word iEtiEtSeS if shift action is chosen (c) [5] Build the parse tree of the word iEtiEtSeS if reduce action is chosen mulo a
busi 101 2021 1 4....
Given the following grammar with start symbol : ?: ? → b? | a? ? → a? | ε a) Give two strings derived from this grammar and their corresponding derivations. (Please mention the derivation as well).
This question concerns the following grammar. program -> { stmts } EOF stmts -> stmt stmts | ε stmt -> ID = exp ; | IF ( exp ) stmt exp -> ID tail tail -> + exp | - exp | ε Compute the FIRST and FOLLOW sets for the non-terminals of this grammar.
busi 101 2021 1 4. Consider the following grammar G: S' S SiEtS iEtSeS E b where S and E are nonterminals and i, t, e, a, and b are terminals (a) [5] Please identify the conflicts in the parsing table of G (b) [5] Build the parse tree of the word iEtiEtSeS if shift action is chosen (c) [5] Build the parse tree of the word iEtiEtSeS if reduce action is chosen mulo a