CSCI 3675
Summer 2001
Homework assignment 1

Due: Wed, June 27

  1. Explain why interpreters tend to be more portable than compilers.

  2. 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.

  3. Give an umambiguous grammar for C++ while-statements. Assume that you can use nonterminals <expression> and <statement>.

  4. 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 grammar for <identifier> describing Pascal identifiers.

  5. Using grammar (3.7.4-3.7.7) in the text, draw a parse tree for expression 4+5*6+2.