#include #include #include #include "precedent.h" #include "hashtable.h" #include "parse.h" #include "eval.h" int main(int argc, char** argv) { if (argc > 1) { if (strcmp("--version", argv[1]) == 0) { printf("precedent, version 0.1\n"); printf("Copyright 2023 Kai Stevenson\n"); printf("This software was licensed under the MIT license;\n"); printf("for more information, see the license file.\n"); return 0; } else if (strcmp("--help", argv[1]) == 0) { printf("usage: precedent [--version] [--help] \n"); return 0; } } sym_t* finalSymbol = parse_symbol_final(read_file(argv[1])); printf("drawing program:\n"); write_symbol_visual(finalSymbol, 0); printf("\nexecuting program:\n"); init_eval(); eval(finalSymbol); return 0; } char* read_file(char* path) { FILE* file = fopen(path, "r"); fseek(file, 0, SEEK_END); unsigned long int length = ftell(file); fseek(file, 0, SEEK_SET); char* out = malloc((length + 1) * sizeof(char)); fread(out, length, 1, file); fclose(file); out[length] = '\0'; return out; }