Due: On paper, handed in Friday, January 16 at at the beginning of class. We suggest you show your work to help us award partial credit if appropriate, and for TA sanity.
For questions that ask for regular expressions, you should restrict yourself
to the basic operations and abbreviations outlined in the slides: concatenation,
|
, *
, +
, ?
, and character classes [...]
or character classes containing
all characters except for specific characters, e.g., [^abc]
.
You can also use abbreviations and be somewhat informal when the meaning is
clear,
e.g., notx
= a | b | c | ... | w | y | z
. You should not use additional regular
expression operators found in languages like perl or ruby, or unix tools like
grep and
sed. In particular, you cannot use not(
re)
as
a a regular expression that matches all other regular expressions except for re.
You should do this homework individually.
(Note that there are four questions - the last one may be on the back of the page if you use double-sided printing.)
(a) Write a set of regular expressions that generate C integer constants as described above.An integer constant consisting of a sequence of digits is taken to be octal if it begins with 0 (digit zero), decimal otherwise. Octal constants do not contain the digits 8 or 9. A sequence of digits preceded by 0x or 0X (digit zero) is taken to be a hexadecimal integer. The hexadecimal digits include a or A through f or F with values 10 through 15.
An integer constant may be suffixed with the letter u or U, to specify that it is unsigned. It may also be suffixed by the letter l or L to specify that it is long.
*/
marks the end of a comment
no matter how many times /*
appears before it.)