Com Sci 221 --- Programming Languages
Assignment #3 --- Winter 1995
Due Monday, 23 January

Last modified: Wed Jan 18 11:20:25 1995

Other versions:


  1. Redo the discussion part of problem 2 in assignment 2. That is, describe briefly (1 sentence should suffice for each) but precisely what classes of arithmetic expressions are derivable from each of the nonterminals Expression, Term, Factor in the grammar for arithemetic expressions in 1.4 and 1.5 on pages 18 and 19 of the text. Your descriptions should make it possible to explain how the grammar imposes precedence on the arithmetic operations, but you should not refer explicitly to precedence in your descriptions. Rather, you should refer to the configurations of binary operators that are and are not allowed.
  2. Pascal and C have almost the same set of integer and boolean operators, although they use different symbols for some of them. List the integer and boolean operators that are in both Pascal and C, showing the symbol used in each language. Look up the precedence and associativity rules for the infix integer and boolean operators that are common to Pascal and C, as well as the unary minus. Compare the two. Find examples of textual expressions that denote different abstract syntax trees in the two languages (ignoring any differences between symbols used for the same operation). Discuss very briefly the relative advantages and disadvantages of each interpretation.

Comments