load "Real"; open TextIO Char String Real exception StackUnderflow exception BadOperator of string val _ = while not (endOfStream stdIn) do case foldl (fn (w, s) => let fun f opr = case s of h1 :: h2 :: t => opr (h2, h1) :: t | _ => raise StackUnderflow in case w of "+" => f (op +) | "-" => f (op -) | "*" => f (op * ) | "/" => f (op /) | _ => case fromString w of NONE => raise BadOperator w | SOME(value) => value :: s end) nil (tokens isSpace (inputLine stdIn)) of h :: _ => print ((toString h) ^ "\n") | _ => ()