 
   def compile_var_dec(all), do: {[], all}
 
-  def compile_statements([{:statements, statements_parsed} | rest]) do
-    {compile_statement(statements_parsed), rest}
-  end
-  
-  def compile_statement([{:doStatement, do_parsed} | rest]) do
-    compile_do_statement(do_parsed)
-    ++ compile_statement(rest)
-  end
-
-  def compile_statement([{:letStatement, let_parsed} | rest]) do
+  def compile_statements(class_name, [{:statements, statements_parsed} | rest]) do
+    {compile_statement(class_name, statements_parsed), rest}
+  end
+  
+  def compile_statement(class_name, [{:doStatement, do_parsed} | rest]) do
+    compile_do_statement(class_name, do_parsed)
+    ++ compile_statement(class_name, rest)
+  end
+
+  def compile_statement(class_name, [{:letStatement, let_parsed} | rest]) do
     compile_let_statement(let_parsed)
-    ++ compile_statement(rest)
-  end
-
-  def compile_statement([{:whileStatement, while_parsed} | rest]) do
-    compile_while_statement(while_parsed)
-    ++ compile_statement(rest)
-  end
-
-  def compile_statement([{:ifStatement, if_parsed} | rest]) do
-    compile_if_statement(if_parsed)
-    ++ compile_statement(rest)
-  end
-
-  def compile_statement([{:returnStatement, return_parsed} | rest]) do
+    ++ compile_statement(class_name, rest)
+  end
+
+  def compile_statement(class_name, [{:whileStatement, while_parsed} | rest]) do
+    compile_while_statement(class_name, while_parsed)
+    ++ compile_statement(class_name, rest)
+  end
+
+  def compile_statement(class_name, [{:ifStatement, if_parsed} | rest]) do
+    compile_if_statement(class_name, if_parsed)
+    ++ compile_statement(class_name, rest)
+  end
+
+  def compile_statement(class_name, [{:returnStatement, return_parsed} | rest]) do
     compile_return_statement(return_parsed)
-    ++ compile_statement(rest)
-  end
-
-  def compile_statement([]), do: []
+    ++ compile_statement(class_name, rest)
+  end
+
+  def compile_statement(_class_name, []), do: []
 
   def compile_return_statement([{:keyword, "return"},
                                 {:symbol, ";"}]) do

    ++ ["pop #{segment_of(kind)} #{index}"]
  end

  def compile_do_statement([{:keyword, "do"},
                            {:identifier, class_name, :attr, %{category: :class}},
                            {:symbol, "."},
                            {:identifier, fn_name, :attr, _},
                            {:symbol, "("},
                            {:expressionList, exp_list_parsed},
                            {:symbol, ")"},
                            {:symbol, ";"}]) do
    compile_exp_list(exp_list_parsed)
    ++ ["call #{class_name}.#{fn_name} #{number_of_expressions(exp_list_parsed)}"]
  end
    
  def compile_do_statement([{:keyword, "do"},
                            {:identifier, _var_name, :attr, %{type: type, category: :var, kind: kind, index: index}},
                            {:symbol, "."},
                            {:identifier, fn_name, :attr, _},
                            {:symbol, "("},
                            {:expressionList, exp_list_parsed},
                            {:symbol, ")"},
                            {:symbol, ";"}]) do
    compile_exp_list(exp_list_parsed)
    ++ ["push #{segment_of(kind)} #{index}",
        "call #{type}.#{fn_name} #{number_of_expressions(exp_list_parsed)}"]
  end

  def compile_while_statement([{:keyword, "while"},
                               {:symbol, "("},
                               {:expression, exp_parsed},
                               {:symbol, ")"},
                               {:symbol, "{"} | rest]) do
    label1 = "whileL1$#{JackUuid.generate()}"
    label2 = "whileL2$#{JackUuid.generate()}"
    exp = compile_exp(exp_parsed)
    {statements, rest1} = compile_statements(rest)
    [{:symbol, "}"}] = rest1
    ["label #{label1}"]
    ++ exp


  def compile_exp([]), do: []

  def compile_term([{:keyword, "this"}]), do: ["push argument 0"]
  def compile_term([{:keyword, "true"}]), do: ["push constant 1", "neg"]
  def compile_term([{:keyword, "false"}]), do: ["push constant 0"]
  
