Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Why am i getting these compiler issues. Can somebody fix this sml code so that it compiles correctly and i can use the parse function?
Why am i getting these compiler issues. Can somebody fix this sml code so that it compiles correctly and i can use the parse function?
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