0% found this document useful (0 votes)
20 views1 page

Cs 32 SW 3

The document contains homework assignments on writing EBNF descriptions for Java and C code constructs, drawing parse trees and doing leftmost derivations for arithmetic expressions, and proving a grammar is ambiguous.

Uploaded by

louie gonoz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Cs 32 SW 3

The document contains homework assignments on writing EBNF descriptions for Java and C code constructs, drawing parse trees and doing leftmost derivations for arithmetic expressions, and proving a grammar is ambiguous.

Uploaded by

louie gonoz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CompSci 32 - Seatwork 3

1. Write EBNF descriptions for the following:


a. A Java class definition header statement
b. A Java method call statement
c. A C ​switch​ statement
d. C​ float​ literals

2. Using the grammar below,

<assign> ⟶<id> = <expr>


<id>⟶ A | B | C
<expr>⟶ <expr> + <term> | <term>
<term>⟶ <term> * <factor>
<factor>⟶ ( <expr> ) | <id>

Show a parse tree and a leftmost derivation for each of the following statements:
a. A = ( A + B ) * C
b. A = B + C + A
c. A = A * (B + C)
d. A = B * (C * (A + B))

3. Prove that the following grammar is ambiguous:

<S>⟶<A>
<A>⟶<A> + <A> | <id>
<id>⟶ a | b | c

You might also like