Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Let L be the language generated by the following context-free grammar, G. The DPDA, which we call P, shown is actually a parser for G.

image text in transcribed

Let L be the language generated by the following context-free grammar, G. The DPDA, which we call P, shown is actually a parser for G. Its output is a derivation of its input string. Each arc has four labels "read/pop/push/output." The input alphabet is {a,b,c +, s}, where " is basically an end-of-file symbol, so that the parser can tell that it's reached the end of the input string. a/z/z/3 a/z/z/3 b/z/z/4 0. S b/z/z/4 ES c/z/z/5 1. EE+E c/z/z/5 2. EEE +/z/z/1 3. Ea 4. Eb a/z/z/32 $/2/2/0 5. E b/z/z/42 b/z/z/42 c/z/z/52 c/z/z/52 (a) Show that G is ambiguous. ~0_+/7/7/7 $/7/2/10 a/2/7/32 (c) Despite the ambiguity of G, P is deterministic and will build a unique parse tree for any w EL. Draw the parse tree for the input a+abc+bc8. (b) Walk through the computation of P with input b+abc+bcs. Here is what your answer should look like. I've filled in the first few lines. The output stream grows while the input stream shrinks. read pop push output input b + abc + bcs +abe + bcs abc + bc$ be + bc$ 43 T1111+ Let L be the language generated by the following context-free grammar, G. The DPDA, which we call P, shown is actually a parser for G. Its output is a derivation of its input string. Each arc has four labels "read/pop/push/output." The input alphabet is {a,b,c +, s}, where " is basically an end-of-file symbol, so that the parser can tell that it's reached the end of the input string. a/z/z/3 a/z/z/3 b/z/z/4 0. S b/z/z/4 ES c/z/z/5 1. EE+E c/z/z/5 2. EEE +/z/z/1 3. Ea 4. Eb a/z/z/32 $/2/2/0 5. E b/z/z/42 b/z/z/42 c/z/z/52 c/z/z/52 (a) Show that G is ambiguous. ~0_+/7/7/7 $/7/2/10 a/2/7/32 (c) Despite the ambiguity of G, P is deterministic and will build a unique parse tree for any w EL. Draw the parse tree for the input a+abc+bc8. (b) Walk through the computation of P with input b+abc+bcs. Here is what your answer should look like. I've filled in the first few lines. The output stream grows while the input stream shrinks. read pop push output input b + abc + bcs +abe + bcs abc + bc$ be + bc$ 43 T1111+

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions