CSE 413

Quiz #2

4/11/97

1 point per part except as noted

(2 pts.) Given the expression grammar below (same as Fig. 4-1), write a strict (one step at a time) derivation for

(2+34)

<exp> ::= <exp> + <exp> | <exp> * <exp> | (<exp>) | <number>

<number> ::= <number> <digit> | <digit>

<digit> ::= 0|1|2|3|4|5|6|7|8|9

 

 

Given the following EBNF rules:

<A> ::= <B> {',' <B>}

<B> ::= x | y | z

1. List all of the TERMINALS in those rules

2. List all of the NON-TERMINALS in those rules

3. (2 pts.) Which of the following could NOT be derived (may be more than one or none):

x

w

xy

x,y

x,

y,x,x

[The original version of this question was flawed: had the first rule as <A> ::= <B> | {',' <B>}]

 

 

What is the result of the following?

(car '(a (b c) d))

 

True or false: if L is the list (1 2 3), then (cons 4 L) has the value (4 1 2 3).