       List.keymember?([tup], :expression, 0)
     end) |> length()
   end
-  
-  # def number_of_parameters(param_list) do
-  #   Enum.filter(param_list, fn (tup) ->
-  #     List.keymember?([tup], :identifier, 0)
-  #   end) |> length()
-  # end
 
   def number_of_locals(subroutine_body) do
     Enum.filter(subroutine_body, fn(tup) ->

    ["return"]
  end

  def segment_of(:static), do: "static"
  def segment_of(:field),  do: "this"
  def segment_of(:arg),    do: "argument"
  def segment_of(:var),    do: "local"
  
  def compile_let_statement([{:keyword, "let"},
                             {:identifier, var_name, :attr, %{kind: kind, index: index}},
                             {:symbol, "="},
                             {:expression, exp_parsed},
                             {:symbol, ";"}]) do

  def compile_term([{:keyword, "true"}]), do: ["push constant -1"]
  def compile_term([{:keyword, "false"}]), do: ["push constant 0"]
  
  def compile_term([{:identifier, _var_name, :attr, %{kind: kind, index: index}}]) do
    ["push #{segment_of(kind)} #{index}"]
  end
  
