i need help writing a program for a lexical analyzer. Topic of assignment: Lexic
ID: 670968 • Letter: I
Question
i need help writing a program for a lexical analyzer.
Topic of assignment: Lexical analyzer
Write Java programs for a lexical analyzer which can identify the following tokens:
1 INT_LIT: consists of digits
2 ID_CODE: starts with a letter followed by letters and digits, and has a limited length of 10
3 ASSIGN_CODE: =
4 PLUS_CODE: +
5 MINUS_CODE: -
6 DIVISON_CODE: /
7 MULTIP_CODE: *
Programs
You will design two classes: TestLexAnalyzer: contains main method which performs input/output operations.
LexAnalyzer: contains all the methods related to lexical analysis. Refer to the C programs in the text book for algorithm design.
Input: a string of assignment statement
Output: tokens of each lexeme.
A running example:
Input string:
num = num + x;
Output:
num ID_CODE
= ASSIGN_CODE
num ID_CODE
+ PLUS_CODE
x ID_CODE
Explanation / Answer
i am not sure i tried:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.