Introduction to Compilers

Spring 2002

**due: **Friday, February 1, in class

- A floating point number contains a numeric part followed by an optional exponent. The numeric part may be a positive or negative integer, or a number containing a decimal point and at least one digit on the left- or right-hand side. The numeric part may not start with leading zeros unless the zero is the only digit to the left of the decimal point. The exponent starts with either the character "e" or "E", followed by either a positive or negative integer. Write a concise regular expression that captures this definition.
- A comment in the C language begins with the two-character sequence "/*", followed by the body of the comment, and then the sequence "*/". The body of
the comment may not contain the sequence "*/", although it may contain the "*"
and "/" characters. Write regular expressions for each of the following, or explain why there is no regular expression defining it.
- exactly C comments.
- C comments, permitting intervening "*/" which appears inside quotes.
- C comments, permitting nested comments.

- Appel, problem 2.3 (a,c)
- Appel, problem 2.5 (a)
- Appel, problem 2.6
- Appel, problem 2.7
- Appel, problem 2.9