Get some experience using Flex



next up previous
Next: Lexical Structure of Up: Assignment 1: ``Cadaver'' Compiler Previous: Evaluate the Lexical

Get some experience using Flex

A lexical language is described subsequently. It is designed solely as a scanner exercise - it is not a thing of beauty. Two characters of lookahead are necessary to recognize the tokens described below.

Write a scanner that translates a source program consistent with the syntax described below into a sequence of lexical units (tokens) and associated lexical values (if appropriate). Write the scanner using the flex scanner generator. The textbook contains a pretty good description of the predecessor tool LEX. The flex manual is available on-line.

The scanner should emit a token ERROR with a lexical value which is the sequence of characters in error. Minimal error recovery is to find the nearest character at which to continue scanning. You may add more if you wish. Evaluate the correctness and robustness of your scanner by providing as input pseudo-programs constructed using the lexical structure we have described. You may share test programs with other class members by posting them to the news group. (Be sure the comments explain the intended outcome). Also run some real program text (e.g. from C) through your scanner to test robustness.

Keep track of how much time you spend writing and debugging your scanner. Your write-up should discuss your experience (what the difficulties were and how you solved them, how long it took, whether you had used Flex before), as well as your solution and testing. I would also like some input/output examples of your scanner in action. In other words, convince me that you did the assignment and maybe that you learned something.



Susan Graham
Fri Sep 1 09:45:06 PDT 1995