CMSC 430 Project 1
The first project involves modifying the attached lexical analyzer and the compilation listing generator code. You need to make the following modifications to the lexical analyzer, scanner.l:
- A second type of comment should be added that begins with // and ends with the end of line. As with the existing comment, no token should be returned.
- The definition for the identifiers should be modified so that underscores can be included, however, consecutive underscores, leading and trailing underscores should not be permitted.
- A real literal token should be added. It should begin with a sequence of one or more digits following by a decimal point followed by zero or more additional digits. It may optionally end with an exponent. If present, the exponent should begin with an e or E, followed by an optional plus or minus sign followed by one or more digits. The token should be named REAL_LITERAL.
- A Boolean literal token should be added. It should have two lexemes, which are true and false. The token should be named BOOL_LITERAL.
- Two additional logical operators should be added. The lexeme for the first should be or and its token should be OROP. The second logical operator added should be not and its token should be NOTOP.
- Five relational operators should be added. They are =, /=, >, >= and
- One additional lexeme should be added for the ADDOP token. It is binary -.
- One additional lexeme should be added for the MULOP token. It is/.
- A new token REMOP should be added for the remainder operator. Its lexeme should be rem.
- A new token EXPOP should be added for the exponentiation operator. Its lexeme should be **.
- A new token ARROW should be added for the two character punctuation symbol =>.
- The following reserved words should be added:
case, else, endcase, endif, if, others, real, then, when
Each reserved words should be a separate token. The token name should be the same as the lexeme, but in all upper case.
You must also modify the header file tokens.h to include each the new tokens mentioned above.