title: Creating a infix/postfix/prefix parser in SML Alice
body: <p>So I am trying to create a parser program in SML that prompts the user for an expression. It then tells whether the expression entered is in postfix, prefix, or infix and then it displays the results. Here is an example of what i want it to do:</p>
  
  <pre><code>Enter Expression: "* + 2 3 4"
  
  Postfix: 2 3 + 4 *
  Prefix: * + 2 3 4
  Infix: (2 + 3) * 4
  
  *
  \-- +
      \-- 2
      \-- 3
  \-- 4
  </code></pre>
  
  <p>I am having trouble with creating the function so that it outputs results to the screen and i'm not really sure if i am even doing the method correctly. I'm not even focusing on outputting the tree until I figure out the conversion first.</p>
  
  <pre><code>fun infix_postfix(PostfixString,operatorStack,expList) = 
    if null expList then operatorStack
      else    
        if(hd expList = #"^" orelse
          hd expList = #"*" orelse
          hd expList = #"/" orelse
          hd expList = #"+" orelse
          hd expList = #"-" =  true)
          then 
            hd expList:: operatorStack
         else
            infix_postfix(hd expList :: PostfixString, operatorStack, tl expList);
  
  val x = "+12";
  val expList = (explode x);
  val PostfixString = [];
  val operatorStack = [#"a"];
  infix_postfix(PostfixString, operatorStack, expList);
  </code></pre>
  
  <p>I feel like I should put a recursive method in the second if statement(that checks for equality with the operators)  but due to the limitations in Alice SML's syntax it doesn't let me. Any help would be appreciated, am I even heading in the right direction?</p>
  
  <h2>Here is the result in the console:</h2>
  
  <pre><code>val infix_postfix : char list * char list * char list -&gt; char list = _fn
  val x : string = "+12"
  val expList : char list = [#"+", #"1", #"2"]
  val PostfixString : 'a list = []
  val operatorStack : char list = [#"a"]
  val it : char list = [#"+", #"a"]
  </code></pre>
  
  <p>FYI: I am doing this from the Alice Interpreter Environment</p>