Question: Why Does this SML code not work? and what is the correct code? Can you show proof of compilation??! because the last three attempts have

Why Does this SML code not work? and what is the correct code?

Can you show proof of compilation??! because the last three attempts have not worked.
Declare the following datatype: datatype token = ID of string | EQ | PL | MI | TI | DI; Write an ML function named parse : string token list that inputs the name of a text file. The file will contain a sequence of characters representing a (not necessarily proper) assignment statement. Your function will parse the text file character by character. The output will be a list of tokens that classify each type of word that was read in the file. The following tables shows all the possible words and their tokens. For example, if the text file is named input.txt and contains: profit=Revenuecost Then your function should work as follows: -parse("input.txt");valit=[ID"profit",EQ,ID"Revenue",MI,ID"cost"]:tokenlist As another example, if the text file is named input2.txt and contains: Hello world + Then your function should work as follows: - parse ("input2.txt"); val it = [ID "Hello", ID "world",PL] : token list If your function reads any other invalid characters such as in the example: Hello 3 world + Then your function should return an empty list and print the message "Compilation error" to the terminal
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
