CpS 450 Language Translation Systems

Chapter 3 Homework

Instructions

Do the following problems from Exercises 3.0.6 on pp. 84-86 in your textbook:

  • #5 part d (5 pts)

  • #6 part d (5 pts)

  • #7 parts a and c (8 pts)

(12 pts) Write a grammar for Boolean expressions that includes the constants true and false, the operators and, or, and not, and parentheses. For example, your grammar should be able to derive the following strings:

false or true and false
not false or true and not false
not (true and false) 
not not true

Be sure to give or a lower precedence than and and and a lower precedence than not. Also, and and or should be left-associative. Finally, be sure your grammar is not ambiguous.

After designing your grammar, test it by building parse trees for the sample strings above (show these trees). Verify that the parse tree structure shows correct precedence.

I recommend that you design your grammar by following the example of mathematical expression grammars in the book (such as G5).

Submission

You may turn in a neatly handwritten or word processed paper. See the syllabus for additional information about homework exercises.