Mercurial > hg-old > index.cgi
diff lwasm/main.c @ 325:619fd6ad4ab9
Completed command line parsing
author | lost |
---|---|
date | Sat, 13 Feb 2010 05:20:55 +0000 |
parents | 473ed9b353eb |
children | 591d01b343b9 |
line wrap: on
line diff
--- a/lwasm/main.c Tue Feb 09 05:59:56 2010 +0000 +++ b/lwasm/main.c Sat Feb 13 05:20:55 2010 +0000 @@ -25,8 +25,13 @@ #include <stdio.h> #include <stdlib.h> +#include <lw_string.h> +#include <lw_stringlist.h> + #include "lwasm.h" +extern int parse_pragma_string(asmstate_t *as, char *str); + /* command line option handling */ const char *argp_program_version = "lwasm from " PACKAGE_STRING; const char *argp_program_bug_address = PACKAGE_BUGREPORT; @@ -57,13 +62,29 @@ switch (key) { case 'I': + lw_stringlist_addstring(as -> include_list, arg); + break; + case 'o': + if (as -> output_file) + lw_free(as -> output_file); + as -> output_file = lw_strdup(arg); + break; + case 'd': as -> debug_level++; break; case 'l': - + if (as -> list_file) + lw_free(as -> list_file); + if (!arg) + as -> list_file = NULL; + else + as -> list_file = lw_strdup(arg); + as -> flags |= FLAG_LIST; + break; + case 'b': as -> output_format = OUTPUT_DECB; break; @@ -77,6 +98,9 @@ break; case 0x101: + as -> flags |= FLAG_DEPEND; + break; + case 'f': if (!strcasecmp(arg, "decb")) as -> output_format = OUTPUT_DECB; @@ -86,7 +110,7 @@ as -> output_format = OUTPUT_OBJ; else if (!strcasecmp(arg, "os9")) { - //as -> pragmas |= PRAGMA_DOLLARNOTLOCAL; + as -> pragmas |= PRAGMA_DOLLARNOTLOCAL; as -> output_format = OUTPUT_OS9; } else @@ -97,6 +121,13 @@ break; case 'p': + if (parse_pragma_string(as, arg) == 0) + { + fprintf(stderr, "Unrecognized pragma string: %s\n", arg); + exit(1); + } + break; + case '9': as -> target = TARGET_6809; break; @@ -109,6 +140,7 @@ break; case ARGP_KEY_ARG: + lw_stringlist_addstring(as -> input_files, arg); break; default: @@ -133,9 +165,13 @@ { /* assembler state */ asmstate_t asmstate = { 0 }; + program_name = argv[0]; - program_name = argv[0]; - + /* initialize assembler state */ + asmstate.input_files = lw_stringlist_create(); + asmstate.include_list = lw_stringlist_create(); + + /* parse command line arguments */ argp_parse(&argp, argc, argv, 0, 0, &asmstate); exit(0);