Question: Please provide a complete code for this. Each and every code file with full execution! Requirement specifications Implement a scanner for the provided lexical definitions,

Please provide a complete code for this. Each and every code file with full execution!
Requirement specifications
Implement a scanner for the provided lexical definitions, a part of the front-end of the compiler project. The scanner will extract tokens from the input source and pass them along, one token at a time.
The scanner is embedded and thus it will return one token every time it is called by the parser. Since the parser is not available yet, we will use a tester to visualize and test the produced tokens. Avoid generating a file with all tokens, or even a container with all tokens, just produce one token at a time upon a call.
- Tokens dont have to be separated by white spaces except when needed to prevent incorrect tokes (this will need FSA implementation or something similar). For example, assuming ID starts with a letter
"1+x" doesnt need white spaces to figure this is integer followed by operator followed by ID
(In option 1 above this would be an error because a token "1+x" doesnt match any token definitions)"x y" which is ID followed by ID must have the white space or otherwise it would be just one ID "xy"
You must have the README.txt file with your submission (in the submission directory, spelled exactly as stated) stating on the first line which option you are using: 1 or 2. If the information is missing, the project will be graded under option 1.
Implement a token as a triplet {tokenID, tokenInstance, line#}(or pair if not processing line numbers).
Dont forget EOFtk (end of file token) token to be generated at the end of processing
Implement the scanner in a separate file with basename "scanner"
For testing purposes, the scanner will be tested using a testing driver implemented in the the same scanner file or in a file with basename "testScanner". You need to implement your own tester and include as a part of the project. This tester is a simple function:
call the scanner, once for each single token, until it gets the EOFtk
for each received token, display the token to the screen, one per line, including information (descriptive) on what token class, what token instance (if the token class includes more token instances) and what line (if processed).
Here is a pseudocode for the tester
token=scanner(); // get first token after any necessary prep steps if any
while (true){
//print line number (if processing, space, descriptive token, space, token instance (string),
if (token == EOFTk)
break;
token=scanner();
}
Invocation
scanner [file]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!