/**
 * Gets (and returns) a token from the token file.
 *
 * @param input_file the token file
 * @return the token_type scanned from the file
 */
token_type get_token(FILE *input_file) {
  int tmp;
  if(fscanf(input_file, "%d", &tmp) == 1) {
    if(tmp >= 1 && tmp <= 34) {
      if(DEBUG) printf("DEBUG: get_token: %d %s\n", (token_type)tmp, get_token_symbol((token_type)tmp));
      return (token_type)tmp;
    }
  }
  return nulsym;
}
/**
 * Prints out the symbolic internal list of lexemes to a file.
 *
 * If the token_type is either 2 or 3, need to print the symbol hash or else
 * the lexeme (separated by a space).
 *
 * Example: 
 * intsym identsym.20 commasym identsym.26 semicolonsym beginsym identsym.26
 * becomessym numbersym.3 semicolonsym identsym.20 becomessym identsym.26
 * plussym numbersym.56 semicolonsym endsym periodsym
 */
void print_symbolic_internal_lexeme_list(FILE *output_file, lexeme_list *lexemes) {
	if(!output_file) output_file = stdout;
	lexeme_list *pos = lexemes;

	while(pos) {
		fprintf(output_file, "%s", get_token_symbol(pos->t));

		if(pos->t == identsym) {
			//fprintf(output_file, ".%d", symbol_hash(pos->lex));
			fprintf(output_file, ".%s", pos->lex);
		} else if(pos->t == numbersym) {
			fprintf(output_file, ".%s", pos->lex);
		}
		if(pos->next) fprintf(output_file, " ");

		pos = pos->next;
	}
	fprintf(output_file, "\n");
}