Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due
Assignment 1 - Modify the Lexer
Overview
You are provided with the Lexer code, written together in class, which will be automatically cloned into your GitHub repository when you begin the assignment via this assignment link (https://classroom.github.com/a/S3tv7dx_) . After cloning your assignment, PLEASE UPDATE THE README with your name!
Submission
Your assignment will be submitted using github. Only the “main” branch of your repository will be graded.
Your program will be tested using unit tests, manual compilation, and execution on the command line. I will test with many valid x programs (not just simple.x). To compile and execute, I will use the following steps (these work for a *nix shell and will not work in
Windows, though you should still be able to compile your application from the Windows command line):
Requirements
Requirement 1
The current implementation of Lexer reads a hardcoded file. Lexer must be updated to take a path to a file as a command line argument:
java lexer.Lexer sample_files/simple.x
If a filename is not supplied, a usage instruction should be displayed (in this snippet, the > character indicates the shell prompt and execution command; it is not a part of the required output):
Requirement 2
Requirement 3
Requirement 4
In our grammar definition file, replace the productions below:
Production Name |
Previous Right Hand Rule |
Updated Right Hand Rule |
TYPE |
'int' | 'bool' |
'int' | 'bool' | 'char' | 'hex' |
FACTOR |
'(' REL_OP ')' | IDENTIFIER | CALL | <int> |
'(' REL_OP ')' | IDENTIFIER | CALL | <int> | <char> | <hex> |
REL_OP |
ADD_OP | ADD_OP '==' ADD_OP | ADD_OP
'!=' ADD_OP | ADD_OP '<' ADD_OP |
ADD_OP '<=' ADD_OP
|
ADD_OP | ADD_OP '==' ADD_OP | ADD_OP '!='
ADD_OP | ADD_OP '<' ADD_OP | ADD_OP '<='
ADD_OP | ADD_OP '>' ADD_OP | ADD_OP '>='
ADD_OP
|
STATEMENT |
IF | WHILE | RETURN | BLOCK |
ASSIGNMENT
|
IF | WHILE | RETURN | BLOCK | ASSIGNMENT |
FROM
|
This introduces a "from" statement into the x language that will iterate from the first value to the next, either with an explicitly defined step or a step that defaults to 1.
Since we have added new separators and operators into the language, our grammar file must also be updated with their symbolic constants (To should be placed in the separators section of the file, and the Greater and GreaterEqual should be placed in the operators section of the file):
A char is a double quote, followed by only one character, followed by a double quote:
A hex is the character zero, followed by the character x, followed by one or more digits 0-9 and a-f. The characters may be either upper case or lower case.
Requirement 5
Appendix A
View Rubric
1-Lexer-Rubric
Criteria |
Ratings |
Pts |
|||||
[CODE QUALITY] The code is clean and wellformatted view longer description
|
7 pts
Excellent
|
5 pts
Good
|
4 pts
Fair
|
2 pts
Poor
|
1 pts
Very Poor
|
0 pts
No Marks
Not enoughcode waswritten to beable to evaluate
|
/ 7 pts |
[CODE QUALITY[ Naming (and only necessary comments!)
|
3 pts
Excellent
|
2 pts
Good
|
|
|
1 pts
Poor
Variables or method names do not adequately describe their purpose
|
0 pts
No Marks
Not enough code was written to be able to evaluate
|
/ 3 pts |
[CODE QUALITY] Single responsibility principle
|
3 pts
Excellent
|
2 pts
Good
|
|
|
1 pts
Poor
|
0 pts
No Marks
Not enough code was written to be able to evaluate
|
/ 3 pts |
[MANUAL TESTING] Lexer executed from the command line
|
24 pts
Full Marks
|
|
|
|
|
0 pts
No Marks
|
/ 24 pts |
[UNIT TESTS] Unit tests executed against your lexer
|
60 pts
Full Marks
|
|
|
|
|
0 pts
No Marks
|
/ 60 pts |
INCLUDE YOUR NAME |
3 pts
Full Marks
|
|
|
|
|
0 pts
No Marks
|
/ 3 pts |
|
|
|
|
|
|
|
Total Points: 0 |