CST 8152 Compilers - Assignment #4 Demonstration required in Labs March 12-13
This assignment builds on Assignment #3. It asks you to enhance your lexical analyser to handle new tokens and lexical errors in preparation for using your scanner in a recursive-descent parser (Assignment #5).
1. Enhance the DFA you used in Assignment #3. Have it recognize (accept) any of the following six new single-character lexemes: = + - * / ;
(Those of you handling /*
*/ comments will have to be very careful here.)
2. Enhance your lexical analyser to use your new DFA to classify and return the six lexemes to your main program as six new token types. You may find your DFA is simpler if you separate the recognition of the six lexemes from their classification.
3. Enhance your main program to also display the new token types, following the output pattern specified in previous assignments.
4. Further enhance your DFA to allow for the detection of invalid lexical input found leading up to the beginning of a lexeme. Instead of silently skipping over all unrecognized characters, your scanner may only silently skip over leading white space. Other unrecognized characters will be collected for later output in an error message.
5. Have your scanner report in an error message any leading invalid lexical input that was collected, before your scanner returns. Your scanner must collect as much of the invalid input as it can before issuing the error message. Dont issue a separate message for every single invalid character if you can avoid it! Dont forget to report invalid input appearing just before end-of-file.
The deliverables for this assignment are as follows:
1. Have available clear hard copy of your enhanced DFA diagram and your C source code.
2. Demonstrate briefly (2-3 minutes) but convincingly that your scanner works.
Nothing has to be handed in for this assignment. You have about 2-3 minutes of my time in the Lab to demonstrate your program and convince me that it works and that you know how it works. Your mark for this assignment is determined by the clarity and efficiency of your in-Lab demonstration. (You might want to have examples of test input and output readily available to substantiate your quick demonstration.) Organize your Lab presentation -- three minutes is not very much time.