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

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

correct code? Can you show proof of compilation??! because the last three

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

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 Databases Questions!