CS412/413
Introduction to Compilers and Translators
Spring 1999

Homework 1: Lexical Analysis

Due: February 5, 1999 at the beginning of class


[#1] The wording of the problem makes me think that we are allowed to match integer constants (like 42, or 42e2) with this regexp. Is that right?

This is correct. (You may match "42" and "42e2".)

[#1] Is our regular expression supposed to accept "0"? (It doesn't look like it is supposed to.)

"0" is not allowed. (However, "0.0" is allowed.)

[#1] Your given solution must be a "simple" regular expression; that is, there must be no non-terminals. For example, the following solution is not allowed:

Numeric -> ...
Exponent -> ...
FloatingPoint -> Numeric Exponent?

We expect you to expand your solution to read something like (this example is wrong!):

FloatingPoint -> [0-9]+ [Ee] [0-9]+

However, feel free to use and show your "intermediate" regular expressions in your work. But your final answer must be a "simple" regular expression.

[#2] Also, in homework 1, problem 2, it says "other escape sequences are allowed but we will ignore them here", so do you mean something like "foo\tbar\t\baz" (ie, C string with tab escapes) should also be recognized or that the only escape sequences with which this excersize is concerned are ones that escape quote, backslash and newline?

The only escape sequences to be concerned with are those that escape quote, backslash, and newline. For example, the following sequences should not be matched: "\b", "\v".