From 5b038666c3e911ffeb78a4d656044e5bd076705b Mon Sep 17 00:00:00 2001 From: Kimplul Date: Thu, 23 Mar 2023 16:14:51 +0200 Subject: integrate parser work --- src/main.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 93b9dfa..c63c042 100644 --- a/src/main.c +++ b/src/main.c @@ -2,18 +2,18 @@ #include #include -#include -#include -#include -#include +#include +#include +#include static const char *cmdline_usage = -"C with traits compiler usage:\n" -" ct [-I ...] [-D ...] infile...\n" +"Copper compiler usage:\n" +" cu [-I ...] [-D ...] infile...\n" " -h Show usage (this)\n" " -I Add directory to import path\n" " -D Add predefined variable\n" -" infile Top file to compile\n" +" -o Name of output\n" +" infile Top file(s) to compile\n" ; static void usage() @@ -24,14 +24,19 @@ static void usage() int main(int argc, char *argv[]) { int opt; - while ((opt = getopt(argc, argv, "hI:D:")) != -1) { + while ((opt = getopt(argc, argv, "hI:D:o:")) != -1) { switch (opt) { + case 'o': + error("not yet implemented"); + break; + case 'I': add_import_path(optarg); break; case 'D': - add_predefined_variable(optarg); + /* TODO */ + error("not yet implemented"); break; case 'h': @@ -44,13 +49,15 @@ int main(int argc, char *argv[]) } if (optind >= argc) { - error("no input files\n"); + error("no input files"); + usage(); exit(EXIT_FAILURE); } for (int i = optind; i < argc; ++i) { - debug("starting compilation of '%s'\n", argv[i]); - compile(argv[i]); + debug("starting compilation of '%s'", argv[i]); + if (compile(argv[i])) + return -1; } return 0; -- cgit v1.3