#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "handle_init_file.h" void handle_init_file( struct environment** environment, struct booleans* booleans, const char* init_file_path) { ENTER; dpvs(init_file_path); assert(init_file_path); struct istream* stream = new_file_istream( /* path: */ init_file_path); struct wcistream* wcstream = new_istream_wcistream( /* binary stream: */ stream); struct string* filename = new_string_from_ascii( /* data: */ init_file_path, /* len: */ (size_t) -1); struct position* position = new_position( /* filename: */ filename, /* line number: */ 1, /* column: */ 1); struct tokenizer* tokenizer = new_tokenizer( /* wide-character stream: */ wcstream, /* inital position (mutated): */ position); istream_read(stream); wcistream_read(wcstream); tokenizer_next(tokenizer); while (tokenizer->token->kind == tk_newline) { tokenizer_next(tokenizer); } if (tokenizer->token->kind == tk_EOF) { // error: empty file TODO; } while (tokenizer->token->kind != tk_EOF) { struct statement* statement = parse( /* tokenizer: */ tokenizer); struct stringtree* error_messages = statement_prettyprint_errors(statement); if (error_messages) { // print one (or more) error expressions TODO; // exit(1); TODO; } statement_execute( /* instance: */ statement, /* environment: */ environment, /* booleans: */ booleans, /* color factory: */ NULL, /* wide-character stdout: */ NULL, /* print value: */ false, /* print with color?: */ false); while (tokenizer->token->kind == tk_newline) { tokenizer_next(tokenizer); } free_stringtree(error_messages); free_statement(statement); } free_tokenizer(tokenizer); free_position(position); free_string(filename); free_wcistream(wcstream); free_istream(stream); EXIT; }