diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-09-05 17:14:53 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-09-26 03:41:55 +0200 |
| commit | 3c0819236e4f07c8f57aaf1ca46d0d68aa761558 (patch) | |
| tree | bd8b57cf5420cabc4ec29815052df545b55026f9 /main.c | |
| parent | a3f56c76444fee090e62a59f257ed5f60b4e552b (diff) | |
| download | prc-3c0819236e4f07c8f57aaf1ca46d0d68aa761558.tar.gz | |
Move source to src/prc1
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 53 |
1 files changed, 0 insertions, 53 deletions
@@ -1,53 +0,0 @@ -#include "cgen.h" -#include "lex.h" -#include "parse.h" -#include <errno.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -int main(int argc, char *argv[]) -{ - struct lex l = {0}; - struct ast a = {0}; - struct cgen c = {0}; - FILE *f = stdin; - int opened = 0, ret = EXIT_FAILURE; - - if (argc != 2) - { - fprintf(stderr, "%s: error: missing input file\n", *argv); - goto end; - } - else if (strcmp(argv[1], "-")) - { - if (!(f = fopen(argv[1], "rb"))) - { - fprintf(stderr, "failed to open %s: %s\n", argv[1], - strerror(errno)); - goto end; - } - - opened = 1; - l.loc.f = argv[1]; - } - else - l.loc.f = "stdin"; - - if (lex(&l, f) || parse(&l, &a) || cgen(&a, &c)) - goto end; - - ret = EXIT_SUCCESS; - -end: - if (opened && fclose(f)) - { - perror("fclose(3)"); - ret = EXIT_FAILURE; - } - - cgen_free(&c); - ast_free(&a); - lex_free(&l); - return ret; -} |
