title: Creating a parser for a simple pseudocode language?
body: <p>I wanted to make a simple parser, for a "pseudo code" like language(kept rigid), in Java.
  A sample pseudo code would be -  </p>
  
  <pre><code>//This is a comment
  $x1 = readint
  $x2 = readint
  
  $dx = $x2 - $x1
  #f = $dx / 2
  
  if ($dx &gt; 0)
  {
    loop while(#f &gt; 1)
    {
       print(#f)
       #f = #f / 2
    }
  }
  </code></pre>
  
  <p>Note that above code is rigid in that, there can not be more than one statement on a line, integers start with $, floats start with # etc.</p>
  
  <p>To parse such code, first I can use <code>StringTokenizer</code>, and then regular expression, to match integer-variables, float-variables, or Keywords.</p>
  
  <p>Is this approach good? For statements in loop, how can i store expressions, so that i don't have to tokenize in each iteration?</p>
  
  <p>I could think of converting expressions (like #f = #f / 2) to polish notation, and then to store in stack. And in each iteration, while popping operands I could replace value for each variable. But is this efficient enough?</p>
  
  <p>Thanks in advance, for any suggestion.</p>