2018-01-21 03:56:50 +00:00
|
|
|
/* Copyright (C) 2016 Jeremiah Orians
|
|
|
|
* This file is part of stage0.
|
|
|
|
*
|
|
|
|
* stage0 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* stage0 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with stage0. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "cc.h"
|
|
|
|
/* The core functions */
|
|
|
|
void initialize_types();
|
|
|
|
struct token_list* read_all_tokens(FILE* a, struct token_list* current);
|
|
|
|
struct token_list* reverse_list(struct token_list* head);
|
|
|
|
struct token_list* program(struct token_list* out);
|
2018-01-25 01:00:22 +00:00
|
|
|
void recursive_output(struct token_list* i, FILE* out);
|
2018-01-21 03:56:50 +00:00
|
|
|
|
|
|
|
/* Our essential organizer */
|
2018-01-25 01:00:22 +00:00
|
|
|
int main()
|
2018-01-21 03:56:50 +00:00
|
|
|
{
|
|
|
|
initialize_types();
|
2018-01-25 01:00:22 +00:00
|
|
|
FILE* input = fopen("input.c", "r");
|
2018-01-21 03:56:50 +00:00
|
|
|
global_token = reverse_list(read_all_tokens(input, NULL));
|
|
|
|
struct token_list* output_list = program(NULL);
|
2018-01-25 01:00:22 +00:00
|
|
|
FILE* output = fopen("input.M1", "w");
|
|
|
|
file_print("\n# Core program\n\n", output);
|
|
|
|
recursive_output(output_list, output);
|
|
|
|
file_print("\n# Program global variables\n\n", output);
|
|
|
|
recursive_output(globals_list, output);
|
|
|
|
file_print("\n# Program strings\n\n", output);
|
|
|
|
recursive_output(strings_list, output);
|
2018-01-21 03:56:50 +00:00
|
|
|
fclose(output);
|
|
|
|
return 0;
|
|
|
|
}
|