In this assignment you will implement a lexical analyzer for the Decaf language.
Your lexical analyzer should output
The output should be formatted as follows:
line column token value xxxx xxxx xxxx xxxx
If a token has no value (for example, a reserved word will have no value), then the value column will be empty Comments and whitespace should not be printed out as tokens.
If an error is detected, then the token should be the character or word that is recognized, and the value should be the error message. The quit error message should be printed starting in the first column. For example, given the following input:
class foo { int x; foo village?market; ? == 5^;
your lexical analyzer might produce:
line column token value 1 1 CLASS 1 7 IDENTIFIER foo 1 11 LCURLY 2 4 INT 2 8 IDENTIFIER x 2 9 SEMICOLON 3 4 IDENTIFIER foo 3 8 IDENTIFIER village 3 14 ?market error: unrecognized word 3 21 SEMICOLON 4 4 ? error: unrecognized character 4 6 EQ 4 9 NUMBER 5 4 10 ^ error: unrecognized character 4 11 SEMICOLON
Your output will be graded manually, so things such as spacing between columns and the names of your tokens are up to you.
You should do all your developement within a single directory. When you are ready to submit the assignment, create a directory named lexer_submission in your home directory. copy all your files from your developement directory into this submission directory. Be sure to include a make file and check to ensure that builds your project successfully. To check your code I should need only run make to build your executable and execute it.
Your lexical analyzer will be tested against a number of test files.
You source code should use comment blocks to explain any non-obvious operations (for example, how you handle comments).
The possible number of points for this assignment is 10.