ps2-sol

# ps2-sol - ECE 468& 573 Problem Set 2 Context-free...

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

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: ECE 468 & 573 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? Answer: Terminals: { x,y,z } . Non-terminals: { S,A,B,C } . (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)? Answer: This string is some number of x s, some number of y s, and then as many z s as x s and y s combined. In other words: x n y m z ( n + m ) (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. Answer: In each step, I have highlighted which non-terminal gets replaced. S Rule 1 A Rule 2 x A C Rule 2 xx A CC Rule 3 xx B CC Rule 4 xxy B CCC Rule 5 xxy C CC Rule 6 xxyz C C Rule 6 xxyzz C Rule 6 xxyzzz Done!...
View Full Document

{[ snackBarMessage ]}

### Page1 / 5

ps2-sol - ECE 468& 573 Problem Set 2 Context-free...

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

View Full Document
Ask a homework question - tutors are online