interpret/src/driver.c

56 lines
1.2 KiB
C
Raw Normal View History

2023-04-22 03:11:57 +00:00
/** @license 2023 Neil Edelman, distributed under the terms of the
[MIT License](https://opensource.org/licenses/MIT).
Scan source files for meanings.
@std C99 */
#include "journal.h"
2023-04-23 07:20:50 +00:00
#include "scan.h"
2023-04-22 03:11:57 +00:00
#include <stdio.h>
#include <errno.h>
#include <assert.h>
int main(void) {
2023-04-22 03:49:36 +00:00
const char *intent = "start";
2023-04-22 03:11:57 +00:00
struct journal jrnl = {0};
2023-04-23 07:20:50 +00:00
struct scan scn = {0};
2023-04-22 03:11:57 +00:00
errno = 0;
2023-04-22 07:37:44 +00:00
intent = "../journal";
jrnl = journal(intent);
2023-04-22 03:11:57 +00:00
fprintf(stderr, "Journal: %s.\n", journal_to_string(&jrnl));
if(errno) goto catch;
intent = "parse";
2023-04-23 07:20:50 +00:00
scn = scan(&jrnl);
2023-04-26 07:59:14 +00:00
//fprintf(stderr, "Scan: %s.\n", scan_to_string(&scrs));
// <- Not sure what that would do.
2023-04-23 07:20:50 +00:00
if(errno) goto catch;
2023-04-26 07:59:14 +00:00
intent = "derived/score.gnu";
if(!freopen(intent, "w", stdout)) goto catch;
scan_score_graph(&scn);
intent = "derived/glider.gnu";
if(!freopen(intent, "w", stdout)) goto catch;
scan_glider_graph(&scn);
2023-04-28 20:40:11 +00:00
intent = "derived/flight.gnu";
if(!freopen(intent, "w", stdout)) goto catch;
scan_flight_graph(&scn);
2023-04-28 23:18:58 +00:00
intent = "derived/kjv.gnu";
if(!freopen(intent, "w", stdout)) goto catch;
scan_kjv_graph(&scn);
intent = 0;
2023-04-22 03:11:57 +00:00
goto finally;
catch:
2023-04-22 03:49:36 +00:00
perror(intent);
2023-04-22 03:11:57 +00:00
finally:
2023-04-23 07:20:50 +00:00
scan_(&scn);
2023-04-22 03:11:57 +00:00
journal_(&jrnl);
2023-04-22 03:49:36 +00:00
return intent ? EXIT_FAILURE : EXIT_SUCCESS;
2023-04-22 03:11:57 +00:00
}