
void init_builtin_procedures() {
  // TODO why do we start at procedure index 3 not 1?
  vector_set(procedure_name, 3, exit_tok);
  vector_set(procedure_value, 3, 1);
  vector_set(sorted_procedure, 3, 3);
  vector_set(procedure_name, 4, putchar_tok);
  vector_set(procedure_value, 4, 1);
  vector_set(sorted_procedure, 4, 4);
  return;
}

// main

int main() {
  int i;

  // dont allow hash table to get more than 0.75 full
  hash_count_threshold = (HASH_TABLE_SIZE * 3) >> 2;
  hash_count = 0;

  function_name = make_vector(512);
  function_value = make_vector(512);
  sorted_function = make_vector(512);

  procedure_name = make_vector(512);
  procedure_value = make_vector(512);
  sorted_procedure = make_vector(512);

  constant_name = make_vector(512);
  constant_value = make_vector(512);
  sorted_constant = make_vector(512);

  top_level_variable_name = make_vector(512);
  top_level_variable_position = make_vector(512);
  top_level_variable_size = make_vector(512);
  sorted_top_level_variable = make_vector(512);

  variable_name = make_vector(512);
  variable_position = make_vector(512);
  variable_size = make_vector(512);
  variable_is_reference = make_vector(512);

  make_data_stream();

  pool_idx = 1;

  comment_arr_idx = 0;

  is_data_stream = 1;
  first_char = my_getchar();
  lookahead_ch = first_char;
  ch = ' ';
  line_count = 1;

  init_keywords();

  set_unary_minus();

  is_data_stream = 0;
  init_args();

  line_count = 1;
  token_ring_idx = 0;
  dummy = get_token();
  dummy = get_token();
  dummy = get_token();

  label_count = 1;

  error_idx = 0;

  constant_idx = 1;

  top_level_variable_idx = 0;
  function_idx = 1;
  procedure_idx = 1;

  case_label = make_vector(512);
  case_label_idx = 0;

  // built in functions

  vector_set(function_name, 1, abs_tok);
  vector_set(function_value, 1, 1);
  vector_set(function_name, 2, getchar_tok);
  vector_set(function_value, 2, 0);

  function_idx = 3;

  // manually sort the functions
  // abs
  vector_set(sorted_function, 1, 1);
  // getchar
  vector_set(sorted_function, 2, 2);

  // built in procedures

  init_builtin_procedures();

  procedure_idx = 5;

  // now sort the procedures

  // 5 and 4 - magic
  for (i = 5; i <= procedure_idx; i++)
    log_sorted_vector(4, i, procedure_name, sorted_procedure);

//printf("%d", vector_pool_idx);
//printf("\n");
//exit(0);

  parse_program();

  cleanup();

  return 0;
}
