Lex compiler on Linux
I have part of this project built just need help finishing it up quickly.
The first project involves writing the lexical analyzer with lexical error checking, and the compilation listing generator for the compiler. The specification for the lexical structure of the language is the following:
Comments begin with -- and end with the end of the line.
White space between tokens is permitted but not required.
Identifiers must begin with a letter, followed by letters or digits.
Integer literals consist of a sequence of digits.
Real literals consist of a sequence of digits containing a decimal point. At least one digit must be before the decimal point.
Boolean literals are true and false
The logical operators are not, and and or. Each logical operator should be a separate token.
The relational operators are =, /=, >, >=, <, and <=. All six lexemes should be represented by a single token.
The adding operators are the binary + and -. Both lexemes should be represented by a single token.
The multiplying operators are * and /. Both lexemes should be represented by a single token.
The following punctuation symbols should be accepted: commas, colons, semicolons, and parentheses.
The following are reserved words:
begin, boolean, else, end, endif, function, if, is, integer, real, returns, then
The lexical analyzer should be created using flex. The compiler should produce a listing of the program with lexical error messages included after the line in which they occur. Any character than cannot start any token should be considered a lexical error.
It should also generate a file containing the lexeme-token pairs as a means to verify that the lexical analyzer is working correctly. Only token numbers are required, not token names. The token numbers for the punctuation symbols should be the ASCII value of the character. The remaining tokens should be numbered sequentially beginning at 256.
The 40 points for functionality will be allocated as follows:
Compilation listing generated with line numbers 10 points
Detects and reports lexical errors correctly 15 points
Generates file with correct lexeme-token pairs 15 points