Question
C++ write a lexical analyzer that reads information from a file and reads each character in the lines and states the token that it is.
C++
write a lexical analyzer that reads information from a file and reads each character in the lines and states the token that it is.
for example
while (fahr < upper) a = 23.00 whileend
Output:
token lexeme
--------------------------------
keyword while
separator (
identifier fahr
operator <
identifier upper
separator )
identifier a
operator =
real 23.00
keyword whileend
some things to look for are operators, seperators, keywords, identifiers, etc.
the program also notes what are considered comments and ignores those comments
! this is a comment ! or // this is a comment
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