CSCI 3675
Fall 2001
Homework assignment 1

Due: Tuesday, August 28

  1. (Exercise 3, page 39) Explain why interpreters tend to be more portable than compilers.

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

  3. (Exercise 1, page 59) C++ was developed by augmenting C. When C++ was developed, it was deemed necessary to add a different kind of comment from the C comment. A C++ comment begins with // and ends at the end of a line. A C comment begins with /* and ends with */. Explain why the C style of comments was considered so bad that it needed to be replaced. Also explain how a compiler can warn a programmer about mistakes using the C comment.

  4. (Exercise 4, page 59) What is the difference between a lexeme and a token? Why is it useful to make this distinction?

  5. (Exercise 6, page 59) Using grammar (3.8.1-3.8.8) Draw a parse tree for expression (4)+5*(6+2).

  6. (Exercise 7, page 59) Show that grammar (3.5.1) is ambiguous. Assume that there is a simple kind of statement s and a simple kind of expression e and do not worry about the details of those.

  7. (Exercise 9, page 59) Lexical rules need to specified collections of lexemes, and sometimes grammars are used for that purpose. A Pascal identifier consists of a letter followed by zero or more letters and digits. Assume that nonterminals <letter> (generating a single letter) and <digit> (generating a single digit) are available. Give a BNF grammar for <identifier> describing Pascal identifiers. (Do not use extended BNF.)