Not logged in. Login

Assignment 1

Consider the following grammar.

<stmt> ::= <if-stmt> | <stmt> ; <stmt> | <action>
<if-stmt> ::= if <expr> then <stmt> [else <stmt>]
<expr> ::= A | B | C
<action> ::= S | T | U

Assume that <expr>s represent values and that <action>s make changes to the current state.

  1. Identify all the terminal, nonterminal and metasymbols in this grammar.
  2. What EBNF extension is used in this grammar beyond pure BNF?
  3. Show a string that is grammatically ambiguous, but not semantically ambiguous according to this grammar. Explain, showing at least two derivation trees for the string.
  4. Show a string that is both grammatically ambiguous and semantically ambiguous according to this grammar. Explain, showing at least two derivation trees for the string.

This assignment is not to be handed in, but there will be a quiz on this assignment on Tuesday, September 22, 2015.

The quiz will count 5% toward the overall course grade.

Updated Tue Sept. 15 2015, 12:16 by cameron.