   
   def parse_statement([{:keyword, "while"},
                        {:symbol, "("}| rest]) do
-    {exp, rest1} = parse_expression(rest)
+    {exp, rest1} = parse_e(rest)
     [{:symbol, ")"},
      {:symbol, "{"}| rest2] = rest1
     {statements, rest3} = parse_statements(rest2)
     {more, rest4} = parse_statement(rest3)
     {["        <whileStatement>",
       "          <keyword> while </keyword>",
-      "          <symbol> ( </symbol>"]
+      "          <symbol> ( </symbol>",
+      "          <expression>"]
      ++ exp
      ++
-     ["          <symbol> ) </symbol>",
+     ["          </expression>",
+      "          <symbol> ) </symbol>",
       "          <symbol> { </symbol>"]
      ++ statements
      ++


  def parse_statement([{:keyword, "return"}
                       | rest]) do
    {expression, rest1} = parse_expression(rest)
    [{:symbol, ";"} | rest2] = rest1
    {statement, rest3} = parse_statement(rest2)
    {["        <returnStatement>",
      "          <keyword> return </keyword>"]
     ++ expression
     ++
     ["          <symbol> ; </symbol>",
      "        </returnStatement>"]
     ++ statement, rest3}
  end

  def parse_expression([{:identifier, x} | rest]) do
    {more, rest1} = parse_expression(rest)
    {["          <expression>",
      "            <term>",
      "              <identifier> #{x} </identifier>",
      "            </term>",
      "          </expression>"] ++ more, rest1}
  end

  def parse_expression([{:symbol, ","} | rest]) do
    {exp, rest1} = parse_expression(rest)
    {["          <symbol> , </symbol>"] ++ exp, rest1}
  end

  def parse_expression(all), do: {[], all}
  
  def parse_subroutine_call([{:identifier, subroutine_name},
                             {:symbol, "("}

      "        </letStatement>"] ++ statement, rest1}
  end

  def parse_statement([{:keyword, "let"},
                       {:identifier, var_lhs},
                       {:symbol, "="}
                      | rest]) do
    {rh_exp, rest1} = parse_e(rest)
    [{:symbol, ";"} | rest2] = rest1
    {statement, rest3} = parse_statement(rest2)
    {["        <letStatement>",
      "          <keyword> let </keyword>",
      "          <identifier> #{var_lhs} </identifier>",
      "          <symbol> = </symbol>",
      "          <expression>"]
     ++ rh_exp
     ++
     ["          </expression>",
      "          <symbol> ; </symbol>",
      "        </letStatement>"]
     ++ statement, rest3}
  end
  
  def parse_statement([{:keyword, "if"},
                       {:symbol, "("} | rest]) do
    {exp, rest1} = parse_e(rest)
    [{:symbol, ")"},
     {:symbol, "{"}| rest2] = rest1
    {statements, rest3} = parse_statements(rest2)
