Need boolean algebra specialist
CMSC 430 Project 1
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:
1. Comments begin with -- and end with the end of the line. 2. White space between tokens is permitted but not required. 3. Identifiers must begin with a letter, followed by letters, digits or underscores.
Consecutive underscores and trailing underscores are not permitted 4. Integer literals consist of a sequence of digits preceded by an optional sign. 5. Real literals consist of a sequence of digits containing a decimal point. At least one digit
must be before the decimal point. 6. Boolean literals are true and false. 7. The logical operators are not, and and or. Each logical operator should be a separate
token. 8. The relational operators are =, /=, >, >=, <, and <=. All six lexemes should be represented
by a single token. 9. The adding operators are the binary + and -. Both lexemes should be represented by a
single token. 10. The multiplying operators are *, / and rem. The first two lexemes should be represented
by a single token. 11. The exponentiation operator is **. 12. The following punctuation symbols should be accepted: commas, colons, semicolons,
and parentheses. In addition the two character arrow symbol => should be a punctuation token.
13. The following are reserved words:
begin, boolean, case, else, end, endcase, endif, function, if, is, integer, real, returns, then, when
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 that cannot start any token should be considered a lexical error. An example of compilation listing output is shown below:
1 -- Program with two lexical errors 2 3 function main a: integer returns integer; 4 b: integer is a * 2; 5 begin 6 if a <= 0 then 7 b + b; 8 else 9 b ^ b $ Lexical Error, Invalid Character ^ Lexical Error, Invalid Character $
10 endif; 11 end; Lexical Errors 2
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.
You are to submit two files.
1. The first is a .zip file that contains all the source code for the project. The .zip file should contain the flex input file, which should be a .l file, all .cc and .h files and a makefile that builds the project.
2. The second is a Word document (PDF or RTF is also acceptable) that contains the documentation for the project, which should include the following:
a. A discussion of how you approached the project b. A test plan that includes test cases that you have created indicating what aspects
of the program each one is testing c. A discussion of lessons learned from the project and any improvements that could
be made
Grading Rubric:
Attribute Meets Does not Meet Functionality (15 points)
Detects comment lexeme but does not return token (1)
Recognizes valid identifiers and rejects invalid ones (1)
Recognizes valid literals and rejects invalid ones (1)
Recognizes logical operators and returns distinct tokens (1)
Recognizes relational operators and returns single tokens(1)
Recognizes arithmetic operators and returns appropriate token(1)
(0 points)
Does not detect comment lexeme or returns token
Does not recognize valid identifiers ot accepts invalid ones
Does not recognize valid literals or accepts invalid ones
Does not recognizes logical operators or returns single token
Does not recognize relational operators or returns distinct tokens
Recognizes reserved words and returns distinct tokens (1)
Detects and reports lexical errors correctly (2)
Generates compilation listing with line numbers (3)
Produces lexeme-token file (3)
Does not recognize arithmetic operators and return appropriate token
Does not recognizes reserved words or returns single token
Does not detect and report lexical errors correctly
Does not generate compilation listing with line numbers
Does not produce lexeme- token file
Test Cases (5 points)
Includes test case containing all lexemes(2)
Includes test case with multiple errors on one line (2)
Includes test case with no errors (1)
(0 points)
Does not include test case containing all lexemes
Does not include test case with multiple errors on one line
Does not include test case with no errors
Documentation (5 points)
Discussion of approach included (2)
Lessons learned included (2)
Comment blocks with class description included with each class (1)
(0 points)
Discussion of approach not included
Lessons learned not included
Comment blocks with class description not included with each class