Due: Monday, January 25
Face-to-face students: Submit in class.
Online students: Submit a scanned or typed homework by email, as an attachment.
Please type the answers to these exercises.
Write a Flex regular expression for each of the following sets of strings.
(Dragon book, Exercise 3.5.2, page 146) Write a Flex program that reads a file, and writes a modified version of the file to the standard output, replacing each nonempty sequence of blanks and tabs by a single blank.
For this program, your actions will not return results. They will print something, and then continue looking for another regular expression.
Write a main function in the last part of the Flex program (after the second %%). The name of the file to read is argv[1] on the command line.
(Dragon book, Exercise 3.5.4, page 146) Write a Flex program that converts to Pig-latin. It should read from the standard input and write to the standard output.
Each sequence of letters that begins with a consonant has the consonant moved to the end of the string and followed by ay.
Each sequence of letters that begins with a vowel just has ay added to the end.
Each nonletter is copied to the output unchanged.
For example, if the input is
The quick (brown) fox jumped over the lazy dogs.then the output is
heTay uickqay (rownbay) oxfay umpedjay overay heay azylay ogsday.