# ps2 - not(g Add one more production for C(i.e of the form C...

This preview shows pages 1–2. Sign up to view the full content.

Problem Set 2: Context-free Grammars, Parsers 1. For the following sub-problems, consider the following context-free grammar: S A (1) A xAC (2) A B (3) B yBC (4) B λ (5) C z (6) (a) What are the terminals and non-terminals of this language? (b) Describe the strings are generated by this language. Is this a regular language ( i.e. , could you write a regular expression that generates this language)? (c) Show the derivation of the string xxyzzz starting from S (specify which produc- tion you used at each step), and give the parse tree according to that derivation. (d) Give the ﬁrst and follow sets for each of the non-terminals of the grammar. (e) What are the predict sets for each production? (f) Give the parse table for the grammar. Is this an LL(1) grammar? Why or why

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: not? (g) Add one more production for C (i.e., of the form C → α ) that makes this grammar not LL(1). 2. for the following sub-problems, consider the following grammar: S → AB \$ (7) A → xB (8) A → xyB (9) B → zA (10) B → w (11) (12) (a) Describe the strings generated by this language. (b) Is this language LL(1)? Why or why not? (c) Build the CFSM for this grammar. (d) Build the goto and action tables for this grammar. Is it an LR(0) grammar? Why or why not? 1 (e) If we add the production B → yz to the grammar, is it an LR(0) grammar? Why or why not? (f) (ECE 573 only): Build the LR(1) machine for the grammar extended with the rule from (e). 2...
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

ps2 - not(g Add one more production for C(i.e of the form C...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online