Question: C++ write a lexical analyzer that reads a string from a file and goes through each character and deciphers the lexical value. he token that
C++
write a lexical analyzer that reads a string from a file and goes through each character and deciphers the lexical value.
he 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
the table is then written to another file
somwthing to look for are keywords, identifiers, operators, separators, digitts, real numbers (with a decimal)
the program also identifies comments and ignores them such as !comment! or //comment
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
