diff lwasm/pseudo.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 b0c9df865b25
children 3864d96ee8c7
line wrap: on
line diff
--- a/lwasm/pseudo.c	Sun Jun 10 14:55:27 2012 -0600
+++ b/lwasm/pseudo.c	Sun Jun 10 18:24:31 2012 -0600
@@ -1017,6 +1017,7 @@
 PARSEFUNC(pseudo_parse_ifp1)
 {
 	l -> len = 0;
+	l -> hideline = 1;
 	
 	if (as -> skipcond && !(as -> skipmacro))
 	{
@@ -1032,6 +1033,7 @@
 PARSEFUNC(pseudo_parse_ifp2)
 {
 	l -> len = 0;
+	l -> hideline = 1;
 	
 	if (as -> skipcond && !(as -> skipmacro))
 	{
@@ -1048,6 +1050,7 @@
 	lw_expr_t e;
 	
 	l -> len = 0;
+	l -> hideline = 1;
 	
 	if (as -> skipcond && !(as -> skipmacro))
 	{
@@ -1071,6 +1074,7 @@
 	lw_expr_t e;
 	
 	l -> len = 0;
+	l -> hideline = 1;
 	
 	if (as -> skipcond && !(as -> skipmacro))
 	{
@@ -1095,6 +1099,7 @@
 	lw_expr_t e;
 	
 	l -> len = 0;
+	l -> hideline = 1;
 	
 	if (as -> skipcond && !(as -> skipmacro))
 	{
@@ -1118,6 +1123,7 @@
 	lw_expr_t e;
 	
 	l -> len = 0;
+	l -> hideline = 1;
 	
 	if (as -> skipcond && !(as -> skipmacro))
 	{
@@ -1141,6 +1147,7 @@
 	lw_expr_t e;
 	
 	l -> len = 0;
+	l -> hideline = 1;
 	
 	if (as -> skipcond && !(as -> skipmacro))
 	{
@@ -1163,6 +1170,7 @@
 {
 	lw_expr_t e;
 
+	l -> hideline = 1;
 	l -> len = 0;
 	
 	if (as -> skipcond && !(as -> skipmacro))
@@ -1184,6 +1192,7 @@
 
 PARSEFUNC(pseudo_parse_endc)
 {
+	l -> hideline = 1;
 	l -> len = 0;
 	skip_operand(p);
 	if (as -> skipcond && !(as -> skipmacro))
@@ -1197,6 +1206,7 @@
 PARSEFUNC(pseudo_parse_else)
 {
 	l -> len = 0;
+	l -> hideline = 1;
 	skip_operand(p);
 	
 	if (as -> skipmacro)
@@ -1222,6 +1232,7 @@
 	struct symtabe *s;
 	
 	l -> len = 0;
+	l -> hideline = 1;
 	
 	if (as -> skipcond && !(as -> skipmacro))
 	{
@@ -1261,6 +1272,7 @@
 	struct symtabe *s;
 	
 	l -> len = 0;
+	l -> hideline = 1;
 	
 	if (as -> skipcond && !(as -> skipmacro))
 	{
@@ -1409,9 +1421,12 @@
 	len = strlen(fn) + 8;
 	p3 = lw_alloc(len + 1);
 	sprintf(p3, "include:%s", fn);
+	as -> fileerr = 0;
 	input_open(as, p3);
 	lw_free(p3);
 
+	if (as -> fileerr == 0)
+		l -> hideline = 1;
 	l -> len = 0;
 	lw_free(fn);
 }