Computer Science 3675
Fall 2002
Homework set 1

Due: Tues, Sep 3, at the beginning of class. (Tuesday is a Monday this week.)

  1. (Exercise 5, page 30) Give an example of an expression or statement that you consider misleading in a programming language with which you are familiar.

  2. (Exercise 4, page 40) What is the difference between a library function and a run-time support function?

  3. (Exercise 8, page 40) Where are programming language features typically put more to the test, in libraries or in application programs?

  4. (Exercise 4, page 61) The syntax of C allows an expression to be just a semicolon. Such a statement performs no action. Give an example where an extraneouse semicolon (easily overlooked by a programmer) vastly changes the meaning of a C program. The program must compile both with and without the semicolon. (Hint: consider a while loop.)

  5. (Exercise 6, page 61) Using grammar (3.8.1-3.8.8), draw a parse tree for expression 3+4+8. Does addition associate to the left or to the right according to this grammar?

  6. (Exercise 7, page 61) Using grammar (3.8.1-3.8.8), draw a parse tree for expresion (4)+5*(6+2).

 

Grammar (3.8.1-3.3.8) is as follows.

 
  <expression>      ::= <sum-expression>
                    |   <expression> = <sum-expression>

  <sum-expression>  ::= <prod-expression>
                    |   <sum-expression> + <prod-expression>

  <prod-expression> ::= <factor>
                    |   <prod-expression> * <factor>

  <factor>          ::= number
                    |   ( <expression> )