G

G Programming Language
git clone http://git.omkov.net/G
Log | Tree | Refs | README | Download

AuthorJakob Wakeling <[email protected]>
Date2022-05-03 06:56:28
Commit1248335294f943f0ef91b8ce334e9a17b1a94cc1
Parent5325b94abafd5aa1a7d6295103ac9359195e11d4

Replace --debug-lex flag with -E

Diffstat

M src/compile.c | 5 +++--
M src/compile.h | 3 ++-
M src/main.c | 10 ++++++----

3 files changed, 11 insertions, 7 deletions

diff --git a/src/compile.c b/src/compile.c
index 4f31c03..2beb0eb 100644
--- a/src/compile.c
+++ b/src/compile.c
@@ -14,13 +14,14 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-bool dlflag = false, dpflag = false, daflag = false;
+bool bflag = false, Bflag = false, cflag = false, Eflag = false;
+bool dpflag = false, daflag = false;
 
 void compile(const char * file, char *src, UINT len) {
 	initialise();
 
 	lex l = lex_init(file, src, len);
-	if (dlflag) { lex_debug(&l); goto end; }
+	if (Eflag) { lex_debug(&l); goto end; }
 
 	ast *a = parse(&l);
 	if (dpflag) { ast_print(a, 0); goto end; }
diff --git a/src/compile.h b/src/compile.h
index b029b58..97acc73 100644
--- a/src/compile.h
+++ b/src/compile.h
@@ -8,7 +8,8 @@
 
 #include "util/util.h"
 
-extern bool dlflag, dpflag, daflag;
+extern bool bflag, Bflag, cflag, Eflag;
+extern bool dpflag, daflag;
 
 extern void compile(const char *file, char *src, UINT len);
 extern void compile_file(const char *file);
diff --git a/src/main.c b/src/main.c
index b0286cd..5d5ea95 100644
--- a/src/main.c
+++ b/src/main.c
@@ -16,7 +16,6 @@
 static struct lop lops[] = {
 	{ "help",          ARG_NUL, 256 },
 	{ "version",       ARG_NUL, 257 },
-	{ "debug-lex",     ARG_NUL, 258 },
 	{ "debug-parse",   ARG_NUL, 259 },
 	{ "debug-analyse", ARG_NUL, 260 },
 	{ NULL, 0, 0 }
@@ -33,11 +32,14 @@ int main(int ac, char *av[]) { A0 = av[0];
 	/* DEBUG */
 	if (ac == 1) { ac = (sizeof (aw) / sizeof (*aw)) - 1; av = aw; }
 
-	struct opt opt = OPTGET_INIT; opt.str = ""; opt.lops = lops;
+	struct opt opt = OPTGET_INIT; opt.str = "bcE"; opt.lops = lops;
 	for (int o; (o = optget(&opt, av, 1)) != -1;) switch (o) {
+	case 'b': { bflag = true; } break; /* Output LLVM IR files */
+	case 'B': { Bflag = true; } break; /* Output LLVM bitcode files */
+	case 'c': { cflag = true; } break; /* Output object files */
+	case 'E': { Eflag = true; } break; /* Output the lexer tokens */
 	case 256: { hlp(); } return 0;
 	case 257: { ver(); } return 0;
-	case 258: { dlflag = true; } break;
 	case 259: { dpflag = true; } break;
 	case 260: { daflag = true; } break;
 	default: {} return 1;