ICS 142
Homework 1
Due 4/19
- (40 points) Hand-implement a lexical analyzer for Tiny-Ada in C++ or Java. Recognize each reserved word explicitly in your state machine. (Hint: use your transition diagram from homework 0 as a guide.)
- (40 points) Use Flex to generate a lexical analyzer for Tiny-Ada. Use a separate pattern to handle each reserved word. (Hint: see section 3.5 of the text.)
- (20 points) Find out how much space is required for each scanner. Use the timer class supplied to compare the speed of your two scanners on several test input programs. Which one is faster? Which one requires less space?
- Submit the listings of your two lexical analyzers and sample runs of both on one correct and one incorrect program. Output should be a list of lexeme/token pairs. Errors must be reported. For the single character lexemes, such as "*" and "(", use the character as the token but make up token names, such as Begin, for multiple character lexemes, such as "begin". Include a title page with your name, student ID number and ICS 142.