Solution
Abhishek Ranjan answered on
Mar 25 2023
CMSC 430 Project 1
CMSC 430 Project 1
Project Description:
- The project involves modifying the existing lexical analyzer and compilation listing
generator code. The modifications include adding new tokens for operators and reserved
words, allowing underscores in identifiers, adding a second type of comment, and
counting and displaying e
ors.
Token Modifications:
- Added a new token ARROW for the two-character punctuation symbol =>.
- Added reserved words: case, else, endcase, endif, if, others, real, then, and when. Each
eserved word is a separate token with the same name as the lexeme but in all uppe
case.
- Added two logical operators. The lexeme for the first is or, and its token is OROP. The
second logical operator added is not, and its token is NOTOP.
- Added five relational operators. The lexemes for =, /=, >, >=, and <= are represented by
the single token RELOP.
- Added the binary operator - for the ADDOP token. Added the lexeme / for the MULOP
token.
- Added a new token REMOP for the remainder operator with the lexeme rem. Added a
new token EXPOP for the exponentiation operator with the lexeme **.
- Added a second type of comment that begins with
and ends with the end of the line.
No token is returned. Modified the definition for identifiers to allow underscores but not
consecutive underscores, leading, or trailing underscores.
- Added a real literal token with the name REAL_LITERAL. It begins with a sequence of
one or more digits followed by a decimal point and zero or more additional digits. It may
optionally end with an exponent. If present, the exponent begins with an e or E, followed
y an optional plus or minus sign, and one or more digits.
- Added a Boolean literal token with two lexemes, true and false, and named
BOOL_LITERAL.
Compilation Listing...