HW – Regular Expressions CMSC 208 Spring 2015 1) Problem 5 on page 75 of the book. 2) Problems 13 and 14 on page 76 of the book. 3) Problem 16 parts a, b, and c on page 76 of the book. 4) Problem 17 parts a-e on page 76 of the book. 5) Alphabet = {A .. Z} a. Give a regular expression for all words that have two vowels in them. b. Give an automaton picture for the same language. 6) Consider the rules for valid identifiers in the C++ language. remember.) Give a regular expression for identifiers in C++. (Look them up if you do not 7) Define a “simple HW inequality” to be an expression that compares two integers, with either side of the operator being an integer. Assume all identifiers are integers For example: VALID: varname < 15 15 >= varname 17 < 19 x2 < y3 INVALID var < 15.0 --- not an integer var >> 19 --- not a valid operator x == 4 + 5 --- the arithmetic expression considered not valid for this exercise. a. What is the alphabet? b. Give a regular expression to describe the language of “simple HW inequalities”. c. Give an automaton picture for “simple HW inequalities”. CMSC 208 HW – Regular Expressions Spring 2015 EXTRA CREDIT) Consider “compound HW inequalities” that allow for the Boolean connectors (and, or, not) as well as parentheses involving “simple HW inequalities”. EG: VALID: varname < 15 (varname < 15) (15 < varname) and (varname <= 20) not (x < y) or (z == w) not ((x < y) or (z == w)) INVALID: (varname < 15 --- mismatched parentheses (varname << 15) --- not a valid operator not and (x < y) or (z == w) --- invalid combination a. Give a regular expression for “compound HW inequalities”. Use [ ] rather than parentheses in the expression so that the () can be part of the alphabet. b. Give an automaton picture for “compound HW inequalities”. HINT: Try adding the parens first. Then try adding the binary operators (and, or). Then try adding the unary operator (not). Partial credit available for each stage.