Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Why do I keep getting this error in my terminal after running this SML code? I need the parse function to work correctly fun parse
Why do I keep getting this error in my terminal after running this SML code? I need the parse function to work correctly
fun parse (fileName: string) : token list = let val file = TextIo. openIn(fileName) in createlist(TextIo. input1(file), file, []) end; fun createlist (c:char, file:TextIo.instream, acc:token list) : token list = if Char, isAlpha(c) then getword(Textio.input1(file), file, acc, [c]) case c of #"= createlist(Textio.input1(file), file, acc) #"= createlist(TextIO. input1(file), file, acc @ [EQ]) #"+ createlist(TextIo.input1(file), file, acc [ [PL]) | \#"-" createlist(TextIo.input1(file), file, acc @ [MI]) | "*" createlist(TextIo.input1(file), file, acc @ [TI]) "/" createlist(TextIo.input1(file), file, acc [ [DI]) else if c=nil then acc else print("Compilation error"); fun getword (c:char, file:TextIo.instream, acc:token list, tmp:char list) = if Char. isAlpha(c) then getword(TextIO.input1(file), file, acc, temp \& c) let val word = implode (tmp) In createlist(TextI0.input1(file), file, acc [ID word]) else if c=nil then acc else print("Compilation error") endStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started