diff lwasm/main.c @ 219:afd50d6b4113

Add --preprocess option Add --preprocess option which expands macros, resolves conditions, and resolves include files if possible. If an include file is not available, it the include directive is retained.
author William Astle <lost@l-w.ca>
date Sun, 10 Jun 2012 18:24:31 -0600
parents b0d53e2f3f53
children 03f7192fcd20
line wrap: on
line diff
--- a/lwasm/main.c	Sun Jun 10 14:55:27 2012 -0600
+++ b/lwasm/main.c	Sun Jun 10 18:24:31 2012 -0600
@@ -55,6 +55,7 @@
 	{ "6309",		'3',	0,			0,							"Set assembler to 6309 mode (default)" },
 	{ "includedir",	'I',	"PATH",		0,							"Add entry to include path" },
 	{ "define", 'D', "SYM[=VAL]", 0, "Automatically define SYM to be VAL (or 1)"},
+	{ "preprocess",	'P',	0,			0,							"Preprocess macros and conditionals and output revised source to stdout" },
 	{ 0 }
 };
 
@@ -172,6 +173,10 @@
 		as -> target = TARGET_6309;
 		break;
 
+	case 'P':
+		as -> preprocess = 1;
+		break;
+		
 	case lw_cmdline_key_end:
 		break;
 	
@@ -265,7 +270,12 @@
 		(passlist[passnum].fn)(&asmstate);
 		debug_message(&asmstate, 50, "After pass %d (%s)\n", passnum, passlist[passnum].passname);
 		dump_state(&asmstate);
-		
+
+		if (asmstate.preprocess)
+		{
+			/* we're done if we were preprocessing */
+			exit(0);
+		}
 		if (asmstate.errorcount > 0)
 		{
 			if (asmstate.flags & FLAG_DEPEND)