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
Get step-by-step solutions from verified subject matter experts
