Introduction to Syntax/Exercise 1

From Wiki**3

< Introduction to Syntax
Revision as of 21:03, 2 April 2010 by Root (talk | contribs) (Introduction to Syntax: Exercise 1 moved to Introduction to Syntax/Exercise 1)

The Problem

Consider the following grammar:

 bexpr   -> bexpr or bexpr | bterm
 bterm   -> bterm and bterm | bfactor
 bfactor -> not bfactor | ( bexpr ) | true | false
  1. Identify the terminal and non-terminal symbols of the grammar.
  2. Show that the grammar is ambiguous by deriving two different trees for the same input sequence.
  3. Write a non-ambiguous grammar for the same language.
  4. Build the tree corresponding to the analysis of the following input sequence: not ( true or false and true )

Solution

The terminal symbols are all the symbols not defined by a rule: or, and, not, (, ), true, false.