Question: Lexical Analyzer For this assignment, you will create your own lexical analyzer program. The analyzer should ask the user for the name of a source
Lexical Analyzer
For this assignment, you will create your own lexical analyzer program.
The analyzer should ask the user for the name of a source file and then report the types of tokens found and how many of each type of token were identified.
Here is the BNF of the language your program will analyze:
< program> -> beginend -> | ;
Here is a description of the tokens your program will count:
Token Examples ID Dog, kittykat, Rat, a combination of letters, a-z and A-Z. START begin END end ADD_OP + MUL_OP * ASS_OP = INT A combination of digits such as 125 or 5 or 8675 SEMI_OP ;
Write your solution using C++ and submit it in a single, plain text source code file so we can download, compile, and test it.
If the file had Dog kittykat and Rat in it, then it would report something like:
ID 3
It's gonna have begin and end in it, so it would report something like:
START 1 END 1
If there is no + in the file then:
ADD_OP 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
