Computer
Science 332
both due Monday, November 26, 2001 by 9 a.m.
This assignment actually consists of two programs. Each is to be written in lex. The first is quite small and is designed more to test your facility with the system than your "programming" skills. The second requires a bit more work.
Your first program is to be named nine.l. It should read a series of words from the keyboard, and for each word, print a message stating whether or not that word contains "nine" as a substring. (This should be very familiar.) You may have the program run until the user types control-D (the end of text marker.)
Your second program is a "token counter". It should take a C++ program as input and count the number of tokens in that program. It should simply read the file and print the number of tokens. For a first draft, get the program to work assuming that there are no quoted strings or comments of any form in the C++ program. After this draft is working, add appropriate lex-code to include each extension (one at a time.) This file should be named token.l.
You are also to create a small C++ file upon which you test your second lex program. Call it test.cpp.
You are to send an email to me at dlevine@cs.sbu.edu containing the three files described above (as attachments) and the number of tokens in your test.cpp (as part of the body of the message.) For this assignment to be considered "on time", I must receive it by 9 a.m. on November 26.