Question
Your lexical analyzer should be implemented in a class called Lexer.java class Lexer.java should have a static method called Tokenize(String fileName) . The method takes
Your lexical analyzer should be implemented in a class called Lexer.java class Lexer.java should have a static method called Tokenize(String fileName). The method takes the source code file name as input and generates (prints on the screen) the equivalent sequence of tokens. Each token is on a new line. Your code must produce the correct output for the testcase.txt as shown in testcase_tokenized.txt.
textcase.txt procedure calculateTax(int bracket)
for(int i = 0; i if(bracket >= 1000) break; } return bracket; end calculateTax int 9user = 5; textcase_tokenized.txt PROC IDENT LP INT IDENT RP FOR LP INT IDENT ASSIGN INT_CONST SEMI IDENT LT IDENT SEMI IDENT ASSIGN IDENT INC RP LB IDENT ASSIGN IDENT MUL_OP LP IDENT DIV_OP INT_CONST RP SEMI IF LP IDENT GE INT_CONST RP BREAK SEMI RB RETURN IDENT SEMI END IDENT INT SYNTAX ERROR: INVALID IDENTIFIER NAME
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started