aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-03-23 16:14:51 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2023-03-23 16:14:51 +0200
commit5b038666c3e911ffeb78a4d656044e5bd076705b (patch)
tree9b09b4f27c39ef6a0139a5eb9bfa5e98a250086c /src/main.c
parent70615379062cdd2e016f5095dfafd23a6dca148c (diff)
downloadek-5b038666c3e911ffeb78a4d656044e5bd076705b.tar.gz
ek-5b038666c3e911ffeb78a4d656044e5bd076705b.zip
integrate parser work
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c31
1 files changed, 19 insertions, 12 deletions
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 <stdio.h>
#include <unistd.h>
-#include <ct/ctpp.h>
-#include <ct/debug.h>
-#include <ct/imports.h>
-#include <ct/compiler.h>
+#include <cu/debug.h>
+#include <cu/imports.h>
+#include <cu/compiler.h>
static const char *cmdline_usage =
-"C with traits compiler usage:\n"
-" ct [-I <dir>...] [-D <var>...] infile...\n"
+"Copper compiler usage:\n"
+" cu [-I <dir>...] [-D <var>...] infile...\n"
" -h Show usage (this)\n"
" -I <dir> Add directory to import path\n"
" -D <var> 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;