subject

Lexical Analyzer Implementation

Use Java to write a simple Lexical Analyzer.

Input: a source code file, (.txt file). Ask user to input the file name.

Output: printing all recognized tokens

The source code accepted tokens include

Keywords: int double String (case sensitive)

operators: = ( ) + - * / , ;

identifier: letter(letter|digit)*

int constant

double constant

string constant: string constant is enclosed in a pair of "", such as "abc"

anything not recognized is detected as errors

If the input file has the following content:

int a, b=10;

a =bc*10-&(3.2+"abc";

The output should be

Line1:1 keyword: int

Line1: 5 identifier: a

Line1:6 operator: ,

Line1: 7 identifier: b

Line1: 8 operator: =

Line1: 9 int constant: 10

Line1: 11 operator: ;

Line2: 1 identifier: a

Line2: 3 operator: =

Line2: 4 identifier: bc

Line2: 6 operator: *

Line2: 7 int constant: 10

Line2: 9 operator: -

Line2: 10 error: & not recognized

Line2: 11 operator: (

Line2: 12 double constant: 3.2

Line2: 15 operator: +

Line2: 16 string constant: "abc"

Line2: 21 operator: ;

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 20:40
On nba 2k 19, every time i try to join a my park game, it leads ro a website telling my dad that he needs ps plus. i already have ps plus though. how do i fix this?
Answers: 2
question
Computers and Technology, 24.06.2019 14:30
In a home that has 120 v service, there is an electric appliance that has a resistance of 12 ohms. how much power will this appliance consume? a. 10 w b. 120 w c 1200 w d. 1440 w
Answers: 1
question
Computers and Technology, 24.06.2019 16:00
"gps interaction and cognitive process" respond to the following: imagine that you have been asked to design a gps product that will have voice recognition and bluetooth capability. discuss and conceptualize a user interaction model. predict two (2) problems that may arise in gps products with voice recognition and bluetooth capability. recommend solutions for each of these issues. attention is one of the six cognition processes. when attention is applied to a design, the goal is to make it easier for the end user to quickly locate where he / she should type information on the computer or mobile device screen. compare and contrast how the google search engine and the microsoft bing search engine employ the attention cognition process. provide your opinion as to which search engine better employs the attention cognition process and explain why.
Answers: 3
question
Computers and Technology, 24.06.2019 23:30
True or false when a host gets an ip address from a dhcp server it is said to be configured manually
Answers: 1
You know the right answer?
Lexical Analyzer Implementation

Use Java to write a simple Lexical Analyzer.

...
Questions
question
Mathematics, 05.06.2020 04:57
question
English, 05.06.2020 04:57