Browse Source

Shorten remaining debug flags

master
Jake Wakeling 5 months ago
parent
commit
58115a4af3
  1. 31
      src/main.c

31
src/main.c

@ -19,8 +19,6 @@
static struct lop lops[] = {
{ "help", ARG_NUL, 256 },
{ "version", ARG_NUL, 257 },
{ "debug-parse", ARG_NUL, 259 },
{ "debug-analyse", ARG_NUL, 260 },
{ NULL, 0, 0 }
};
@ -28,8 +26,8 @@ static char *aw[] = {
"g", "/home/deus/Workspace/G/examples/main.g", NULL
};
static bool bflag = false, Bflag = false, cflag = false, Eflag = false;
static bool dpflag = false, daflag = false;
static bool bflag = false, Bflag = false, cflag = false;
static bool Eflag = false, pflag = false, Pflag = false;
static void compile(const char *file, char *src, UINT len);
static void compile_file(const char *file);
@ -41,16 +39,16 @@ 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 = "bcE"; opt.lops = lops;
struct opt opt = OPTGET_INIT; opt.str = "bBcEpP"; 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 'E': { Eflag = true; } break; /* Output lexer tokens */
case 'p': { pflag = true; } break; /* Output parser AST */
case 'P': { Pflag = true; } break; /* Output analyser AST */
case 256: { hlp(); } return 0;
case 257: { ver(); } return 0;
case 259: { dpflag = true; } break;
case 260: { daflag = true; } break;
default: {} return 1;
}
@ -67,10 +65,10 @@ static void compile(const char * file, char *src, UINT len) {
if (Eflag) { lex_debug(&l); goto end; }
ast *a = parse(&l);
if (dpflag) { ast_print(a, 0); goto end; }
if (pflag) { ast_print(a, 0); goto end; }
analyse(a);
if (daflag) { ast_print(a, 0); goto end; }
if (Pflag) { ast_print(a, 0); goto end; }
llvm(a);
@ -94,11 +92,14 @@ static void hlp(void) {
puts("G - G Programming Language\n");
puts("Usage: g\n");
puts("Options:");
puts(" --help Display help information");
puts(" --version Display version information");
puts(" --debug-lex Print lexer debug output and exit");
puts(" --debug-parse Print parser debug output and exit");
puts(" --debug-analyse Print analysis debug output and exit");
puts(" -b, Output LLVM IR files");
puts(" -B, Output LLVM bitcode files");
puts(" -c, Output object files");
puts(" -E, Output lexer tokens");
puts(" -p, Output parser AST");
puts(" -P, Output analyser AST");
puts(" --help Display help information");
puts(" --version Display version information");
}
/* Print version information. */

Loading…
Cancel
Save