Question

Let G be the following grammar: 1. S T 2. T O 3. T T 4. O V = E i [ E ] 5. V i 6. V i 7. E ( E) 8. E Construct the LR(0) DFA

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a)

b)

LR(0) parsing table:

( ) ; = [ ] i $ E O S T V
0 s5 1 2 3 4
1 r2 r2 r2 r2 r2 r2 r2 r2
2 acc
3 r1 r1 s6/r1 r1 r1 r1 r1 r1
4 s7
5 r6 r6 r6 r6 s8/r6 r6 r6 r6
6 s5 9 4
7 s10 s12 11
8 s10 s12 13
9 r3 r3 r3 r3 r3 r3 r3 r3
10 s10 s12 14
11 r4 r4 r4 r4 r4 r4 r4 r4
12 r7 r7 r7 r7 r7 r7 r7 r7
13 s15
14 s16
15 r5 r5 r5 r5 r5 r5 r5 r5
16 r8 r8 r8 r8 r8 r8 r8 r8

Row(5,[) - has shift reduce conflict

Row(3,;) - has shift reduce conflict

LR(0) parsing table has shift reduce conflicts, so we need to make SLR(1) parsing table.

Computing FIRST and FOLLOW

FOLLOW FIRST { $. ), i. ]} S.:) =

SLR(1) parsing table is as follows:

$ i E S T s5 r2 r2 s7 s8 s5 s10 s12 1 s10 $12 13 r3 r3 14 10 s10 $12 11 r4 r4 12 r7 r7 13 s15 s16 14 r5 16 r8 rf r8

Add a comment
Know the answer?
Add Answer to:
Let G be the following grammar: 1. S T 2. T O 3. T T 4. O V = E i [ E ] 5. V i 6. V i 7. E ( E) 8. E Construct the LR(0...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 7- Show a complete LR(0) and SLR(1) parsers, including the canonical collection of LR(0) and parsing table, using the following grammar E-→ E + T / T T-, T F / F l a l b Is this grammar LR(0) or...

    7- Show a complete LR(0) and SLR(1) parsers, including the canonical collection of LR(0) and parsing table, using the following grammar E-→ E + T / T T-, T F / F l a l b Is this grammar LR(0) or SLR(1)? Why? 7- Show a complete LR(0) and SLR(1) parsers, including the canonical collection of LR(0) and parsing table, using the following grammar E-→ E + T / T T-, T F / F l a l b Is...

  • Consider the following grammar. Construct the canonical collection of LR(0) items. E -> E + T...

    Consider the following grammar. Construct the canonical collection of LR(0) items. E -> E + T (1) E -> T (2) T -> TF (3) T -> F (4) F -> F* (5) F -> a (6) F -> b (7)

  • Consider the following grammar G: S'S SA xb AaAb B 3. do ed bisbon s LR...

    Consider the following grammar G: S'S SA xb AaAb B 3. do ed bisbon s LR Bx where S, A, and B are nonterminals, and a, b and x are terminals (a) [10] Is G SLR(1)? If yes, give the parsing table. Otherwise, explain why (b) [15] Is G LR(1)? If yes, give the parsing table. Otherwise, explain why. (c) [15] Is G LALR(1)? If yes, give the parsing table. Otherwise, explain why. umi Consider the following grammar G: S'S...

  • (10] Eliminate left recursion from the grammar A Ba |Aa c B Bb | Ab 1...

    (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...

  • busi 101 2021 1 4. Consider the following grammar G: S' S SiEtS iEtSeS E b...

    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....

  • 1) Create an LR(0) parse table for the following grammar. Show all steps (creating closures, the...

    1) Create an LR(0) parse table for the following grammar. Show all steps (creating closures, the DFA, the transition table, and finally the parse table): E -> E + T | E * T | T T -> ( E ) | id 2) Show a complete bottom-up parse, including the parse stack contents, input string, and action for the string below using the parse table you created in step 6. Think about how I went through this in class....

  • busi 101 2021 1 4. Consider the following grammar G: S' S SiEtS iEtSeS E b...

    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

  • Construct a regular grammar G = {V,T,S,P} such that L(G)= L(r) where r is a regular...

    Construct a regular grammar G = {V,T,S,P} such that L(G)= L(r) where r is a regular expression (a+b)a(a+b)*. Question 10 Construct a Regular grammar G = (V, T, S, P) such that L(G) = L(r) wherer is the regular expression (a+b)a(a+b). B I VA A IX E 12 XX, SEE 2 x G 14pt Paragraph

  • 6. (20) Let G = (V, ∑, R, S) be a grammar with V = {Q,...

    6. (20) Let G = (V, ∑, R, S) be a grammar with V = {Q, R, T}; ∑ = {q, r,ts}; and the set of rules: S→Q Q→q | RqT R→r | rT | QQr T→t | S| tT a. (5) Convert G to a PDA using the method we described. b. (15) Convert G to Chomsky normal form. 6. (20) Let G = (V, , R, S) be a grammar with V = {Q, R, T}; { =...

  • 6.(20) Let G=(V, S, R, S) be a grammar with V = {Q, R, T}; {...

    6.(20) Let G=(V, S, R, S) be a grammar with V = {Q, R, T}; { = {q, r,ts}; and the set of rules: SQ Qq RqT R~rrt Qor T>t | ST a. (5) Convert G to a PDA using the method we described. b. (15) Convert G to Chomsky normal form.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT