quiz2-ans1 - cs.colostate.eduhowe/cs200/quizzes/quiz2-ans.pdfquiz2-ans1 Author: Adele Howe Created...

1

Click here to load reader

Transcript of quiz2-ans1 - cs.colostate.eduhowe/cs200/quizzes/quiz2-ans.pdfquiz2-ans1 Author: Adele Howe Created...

Page 1: quiz2-ans1 - cs.colostate.eduhowe/cs200/quizzes/quiz2-ans.pdfquiz2-ans1 Author: Adele Howe Created Date: 9/7/2010 11:04:17 PM ...

CS200 Quiz 2: Grammars (9/7/10)

1. Given the grammar G=(V,T,S,P) where V={0,1,S,A}, T={0,1} and P is:

S→0AA→λ | 0A

fill in the blank to produce

0+ .

2. Circle all that are true: In a grammar, a. “x y” means “x followed by y”. b. Non-terminals cannot appear in the left

hand side of productions. c. Terminals are part of the vocabulary. d. The same non-terminal cannot appear in

both the left and right sides.

3. Circle all that are legal strings in the language specified by the grammar with productions: S->0A, S->S11, S->A1, A->0 a. 00 b. 01 c. 10 d. 11

4. Circle all that are legal prefix expressions

from the grammar in class: a. + - a b b. + a – b c c. * / a – c d b d. * / - a c d b

5. Circle all that are true:

a. A derivation shows how a string could be produced from a grammar.

b. Top-down parsing matches the terminals to the right hand size of rules and continues to replace them with non-terminals until it can replace the set with the starting non-terminal.

c. Regular expressions are defined over sets. d. Ambiguous grammars produce more than

one derivation for some legal string.